.co-container {
    max-width: 1900px;
    margin: 0 auto;
    padding: 4rem 2rem 3rem;
}

.co-layout {
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(320px, 680px) minmax(360px, 1.3fr);
    gap: 1.5rem;
    align-items: start;
}

/* DOM order is description -> board -> info (so the page's <h1> and "About this
   position" text read before the stats panel's <h2>, and so a stacked mobile layout
   shows the header first) -- but the desktop 3-column layout puts the stats panel on
   the left and the description panel on the right, so `order` reassigns the visual
   column per panel independently of that reading order. Reset in the stacked layout
   below so mobile falls back to plain DOM order. */
.co-description-panel {
    order: 3;
}

.co-board-panel {
    order: 2;
}

.co-info-panel {
    order: 1;
}

.co-panel {
    background: rgba(26, 31, 46, 0.85);
    border: 1px solid rgba(0, 212, 255, 0.15);
    border-radius: 12px;
    padding: 1.25rem;
}

/* --- Description panel --- */
.co-title {
    font-size: 1.7rem;
    margin-bottom: 0.5rem;
}

.co-intro {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(0, 212, 255, 0.15);
}

.co-description-panel h2 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.co-description-text {
    color: var(--text-primary);
    line-height: 1.6;
}

/* --- Board panel --- */
.co-board-panel {
    position: sticky;
    top: 6.5rem;
}

.co-board-wrap {
    display: grid;
    position: relative;
    grid-template-columns: 1.6rem 1fr;
    grid-template-rows: 1fr 1.6rem;
    grid-template-areas:
        "ranks board"
        "corner files";
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.co-board {
    grid-area: board;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    outline: 1px solid rgba(0, 212, 255, 0.4);
    outline-offset: -1px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 0 24px rgba(0, 212, 255, 0.18), 0 12px 30px rgba(0, 0, 0, 0.45);
}

.co-board-ranks,
.co-board-files {
    display: flex;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    user-select: none;
}

.co-board-ranks {
    grid-area: ranks;
    flex-direction: column;
    padding: 2px 0;
}

.co-board-ranks span,
.co-board-files span {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.co-board-files {
    grid-area: files;
    flex-direction: row;
    padding: 0 2px;
}

.co-board-corner {
    grid-area: corner;
}

.co-board-arrows {
    grid-area: board;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.co-move-arrow {
    fill: #ffc93c;
    stroke: rgba(10, 15, 28, 0.35);
    stroke-width: 1.5px;
    stroke-linejoin: round;
    pointer-events: none;
}

.co-move-arrow-hit {
    fill: transparent;
    stroke: none;
    cursor: pointer;
    pointer-events: fill;
}

.co-move-arrow-hit:focus-visible {
    outline: none;
}

/* The board's dark squares are chess.com's green (#769656), not the site's old navy —
   blue and green sit at nearly the same brightness, so this arrow's only real contrast
   comes from its outline; a much stronger stroke than the gold arrow needs is required
   here specifically so it doesn't wash out on dark squares. */
.co-move-arrow.co-depth2 {
    fill: #33c6ff;
    stroke: rgba(10, 15, 28, 0.55);
    pointer-events: none;
}

/* "Beyond the book" continuation moves aren't backed by game-frequency stats like the
   yellow book arrows, so they get their own color to read as Stockfish's own suggestion
   rather than a popularity-weighted move. Purple and the board's green dark squares are
   close to the same luminance (and a red-green colorblind confusion pair on top of
   that), so this leans on a heavier dark outline rather than the fill alone to stay
   readable there. */
.co-move-arrow.co-continuation-arrow {
    fill: #b47bff;
    stroke: rgba(10, 15, 28, 0.7);
    stroke-width: 2px;
}

.co-move-arrow-hit:focus-visible + .co-move-arrow.co-continuation-arrow {
    filter: drop-shadow(0 0 5px rgba(180, 123, 255, 0.9)) drop-shadow(0 0 3px rgba(10, 15, 28, 0.65));
}

/* A shorter arrow drawn on top of a longer collinear one (e.g. a pawn's single-step
   over its own double-step) — same fill as a normal arrow (no separate color in the
   palette), just a crisp light outline so it reads as visually distinct from the arrow
   underneath it, echoing the focus-ring treatment below rather than introducing a new
   color. At depth 1 this is also the actually-clickable one; at depth 2 (hover preview /
   flow mode) all arrows are visual-only, this included — see drawArrow. The dark halo
   alongside the white stroke is what keeps this visible on the board's light (cream)
   squares, where a plain white outline all but disappears — the halo does nothing on
   dark squares (already low-contrast against the fill there) but isn't needed there
   either, since the white stroke alone reads fine against green. */
.co-move-arrow.co-overlap-priority {
    stroke: rgba(255, 255, 255, 0.85);
    stroke-width: 2px;
    filter: drop-shadow(0 0 2px rgba(10, 15, 28, 0.55));
}

/* Already beats co-overlap-priority on specificity (three class-level selectors —
   :focus-visible plus two classes — vs. two), so the focus ring wins regardless of
   source order; kept below it anyway for readability, grouped with the other arrow
   state rules. Same reasoning as co-overlap-priority above for the second, dark
   drop-shadow layer: a keyboard focus indicator has to be visible on every square color,
   and a plain white glow alone reads poorly against the board's cream light squares. */
.co-move-arrow-hit:focus-visible + .co-move-arrow {
    stroke: var(--text-primary);
    stroke-width: 2.5px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 3px rgba(10, 15, 28, 0.65));
}

.co-square {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
}

/* Chess.com's classic green board palette -- much better contrast for the dark
   pieces than the site's navy theme gave the board, particularly the black pawn
   (see co-piece-bP in the template, which has no fill of its own and otherwise
   defaults to pure black). */
.co-square.co-light {
    background: #eeeed2;
}

.co-square.co-dark {
    background: #769656;
}

.co-piece {
    width: 82%;
    height: 82%;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}

.co-move-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.co-move-nav-btn {
    flex: 1;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.25);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.co-move-nav-btn:hover:not(:disabled) {
    background: rgba(0, 212, 255, 0.2);
    border-color: var(--accent-blue);
}

.co-move-nav-btn:disabled {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
    cursor: default;
}

.co-flow-toggle {
    display: block;
    width: 100%;
    margin-bottom: 0.75rem;
}

.co-flow-toggle[aria-pressed="true"] {
    background: rgba(51, 198, 255, 0.22);
    border-color: #33c6ff;
    color: var(--text-primary);
}

.co-move-path {
    font-size: 0.9rem;
    color: var(--text-secondary);
    word-break: break-word;
    line-height: 1.7;
}

.co-board-credit {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.co-board-credit a {
    color: inherit;
}

.co-piece-hint {
    grid-area: board;
    align-self: end;
    justify-self: center;
    margin-bottom: 0.6rem;
    padding: 0.4rem 0.9rem;
    background: rgba(10, 15, 28, 0.92);
    border: 1px solid rgba(255, 201, 60, 0.4);
    border-radius: 999px;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s;
}

.co-piece-hint.co-visible {
    opacity: 1;
    visibility: visible;
}

/* --- Info panel --- */
.co-info-panel h2 {
    font-size: 1.3rem;
    margin-bottom: 0.25rem;
}

.co-eco {
    display: inline-block;
    background: rgba(0, 212, 255, 0.15);
    color: var(--accent-blue);
    border-radius: 6px;
    padding: 0.15rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.co-continuation-badge {
    display: inline-block;
    background: rgba(255, 176, 32, 0.15);
    color: #ffb020;
    border-radius: 6px;
    padding: 0.15rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 0.4rem;
}

.co-continuation-badge[hidden] {
    display: none;
}

.co-stats-section.co-preview-dimmed {
    opacity: 0.35;
    filter: grayscale(60%);
    pointer-events: none;
}

.co-stats-section h3,
.co-eval-section h3,
.co-continuation-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin: 1rem 0 0.5rem;
}

.co-eval-section h3 {
    margin-top: 0;
}

.co-eval-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.co-eval-bar {
    flex: 1;
    height: 14px;
    border-radius: 999px;
    overflow: hidden;
    background: #2a2f3e;
}

.co-eval-bar-white {
    display: block;
    height: 100%;
    background: #e8eaf0;
    transition: width 0.15s;
}

.co-eval-score {
    min-width: 3.5rem;
    text-align: right;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.co-eval-note {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

.co-continuation-section {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.co-continuation-intro {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
}

.co-continuation-moves {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.6rem;
}

.co-continuation-move {
    font-family: inherit;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    background: rgba(0, 212, 255, 0.08);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 5px;
    color: var(--text-secondary);
    cursor: pointer;
}

.co-continuation-move:hover {
    background: rgba(0, 212, 255, 0.18);
    color: var(--text-primary);
}

.co-continuation-move:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 1px;
}

.co-continuation-move.co-active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: var(--primary-dark);
    font-weight: 700;
}

.co-stats-bar {
    display: flex;
    height: 22px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.4rem;
}

.co-stats-bar[hidden] {
    display: none;
}

.co-stats-bar span {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--primary-dark);
    font-weight: 600;
}

.co-stats-white { background: #e8eaf0; }
.co-stats-draw { background: #8890a4; }
.co-stats-black { background: #2a2f3e; color: var(--text-primary) !important; }

.co-stats-total {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.co-moves-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.co-moves-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--tertiary-dark);
}

.co-moves-table td {
    padding: 0.35rem 0.3rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.co-moves-table tr.co-clickable {
    cursor: pointer;
}

.co-moves-table tr.co-clickable:hover td {
    color: var(--accent-blue);
}

.co-empty-note,
.co-loading-note {
    color: var(--text-muted);
    font-size: 0.85rem;
}

@media (max-width: 1150px) {
    .co-layout {
        grid-template-columns: 1fr;
    }

    .co-board-panel {
        position: static;
        max-width: 480px;
        margin: 0 auto;
    }

    /* Stacked layout follows plain DOM order (description -> board -> info) rather
       than the desktop column swap above. */
    .co-description-panel,
    .co-board-panel,
    .co-info-panel {
        order: initial;
    }
}
