/* ==========================================================================
   RTL layout — activates when i18n.load() sets <html dir="rtl">.
   The board itself stays visually LTR (files a–h left-to-right) because
   chess coordinates are direction-neutral, but text, back arrows, and
   panel flows mirror.
   ========================================================================== */
html[dir="rtl"] body { direction: rtl; text-align: right; }
html[dir="rtl"] .back-btn::before { content: ""; }
html[dir="rtl"] .back-btn { direction: rtl; }
html[dir="rtl"] #chess-board { direction: ltr; }

/* Guest identity block on the Profile screen. */
.identity-row {
    display: flex; align-items: baseline; gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.85rem;
}
.identity-label {
    min-width: 3.5rem;
    color: var(--panel-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.identity-value {
    font-family: 'Consolas', 'Menlo', monospace;
    color: var(--panel-fg);
    word-break: break-all;
}

/* ---------- v4.2 friend lobby / v4.3 queue ---------- */
.primary-btn, .secondary-btn {
    padding: 0.75rem 1.5rem; border-radius: 8px; border: none;
    font-size: 1rem; font-weight: 600; cursor: pointer; margin: 0.5rem 0.25rem;
    min-height: 44px; /* v5.3 mobile touch target */
}
.primary-btn   { background: linear-gradient(180deg, #f5d94a, #d4b829); color: #1a1a1a; }
.primary-btn:hover:not(:disabled)   { filter: brightness(1.1); }
.secondary-btn { background: rgba(255,255,255,0.15); color: #fff; }
.secondary-btn:hover:not(:disabled) { background: rgba(255,255,255,0.25); }
.primary-btn:disabled, .secondary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.lobby-code-row {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem; margin-top: 0.5rem;
    background: rgba(0,0,0,0.25); border-radius: 6px;
}
.lobby-code {
    font-family: 'Consolas', monospace; font-size: 1.4rem; letter-spacing: 0.15em;
    color: #f5d94a; font-weight: 700;
}

/* ---------- v5.0 shop / skin browser ---------- */
.skin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
.skin-card {
    background: rgba(0,0,0,0.25); border: 2px solid transparent; border-radius: 8px;
    padding: 0.75rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}
.skin-card.active { border-color: #f5d94a; }
.skin-card.locked { opacity: 0.7; }
.skin-preview {
    width: 100%; aspect-ratio: 1;
    background: linear-gradient(45deg, var(--sq-light, #f0d9b5) 50%, var(--sq-dark, #b58863) 50%);
    border-radius: 4px;
}
.skin-board-classic { background: linear-gradient(45deg, #f0d9b5 50%, #b58863 50%); }
.skin-board-felt    { background: linear-gradient(45deg, #eeeed2 50%, #769656 50%); }
.skin-board-ice     { background: linear-gradient(45deg, #dee3e6 50%, #8ca2ad 50%); }
.skin-board-coral   { background: linear-gradient(45deg, #fbe4d8 50%, #d97757 50%); }
.skin-board-noir    { background: linear-gradient(45deg, #3a3a3a 50%, #1a1a1a 50%); }
.skin-board-candy   { background: linear-gradient(45deg, #ffe4f2 50%, #e685b5 50%); }
.skin-name { font-size: 0.85rem; text-align: center; color: rgba(255,255,255,0.85); }
.skin-action {
    background: rgba(255,255,255,0.15); color: #fff; border: none; border-radius: 6px;
    padding: 0.5rem 0.75rem; font-size: 0.8rem; cursor: pointer; width: 100%;
    min-height: 36px;
}
.skin-action:hover:not(:disabled) { background: rgba(255,255,255,0.25); }

/* Tutor commentary panel — Dr. Wolf-style running feed of coach messages. */
.tutor-commentary { display: none; margin-top: 12px; }
.tutor-commentary.active {
    display: flex; flex-direction: column; gap: 6px;
    background: var(--panel-bg); border-radius: var(--radius-lg);
    padding: 12px; box-shadow: var(--shadow-panel);
    border: 1px solid var(--panel-border);
    max-height: 320px;
}
.tutor-commentary .panel-heading { margin: 0 0 4px 0; color: var(--panel-fg); }
.commentary-list {
    list-style: none; margin: 0; padding: 0; overflow-y: auto;
    display: flex; flex-direction: column; gap: 4px;
}
.commentary-item {
    padding: 6px 10px; border-radius: 6px; font-size: 0.85rem; line-height: 1.4;
    background: rgba(0,0,0,0.05); color: var(--panel-fg);
    border-left: 3px solid transparent;
}
.commentary-praise    { border-left-color: #2c7a2c; background: rgba(44,122,44,0.12); }
.commentary-milestone { border-left-color: #d4b829; background: rgba(212,184,41,0.15); font-weight: 600; }
.commentary-warn      { border-left-color: #d97706; background: rgba(217,119,6,0.10); }
.commentary-danger    { border-left-color: #c53030; background: rgba(197,48,48,0.12); }
.commentary-neutral   { border-left-color: rgba(0,0,0,0.15); }

/* Tutor game controls — hidden unless the current game is tutor mode. */
.tutor-controls { display: none; margin-top: 8px; }
.tutor-controls.active { display: flex; gap: 8px; }
.tutor-controls button {
    flex: 1; background: linear-gradient(180deg, #f5d94a, #d4b829);
    color: #1a1a1a; border: none; border-radius: 6px;
    padding: 8px 12px; cursor: pointer; font-weight: 600;
    min-height: 40px;
}
.tutor-controls button:hover:not(:disabled) { filter: brightness(1.1); }
.tutor-controls button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- v5.2 tutorial ---------- */
.tutorial-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.tutorial-card {
    background: rgba(0,0,0,0.25); border-radius: 8px; padding: 1rem;
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem; text-align: center;
}
.tutorial-glyph { font-size: 3rem; line-height: 1; }
.tutorial-glyph.small { font-size: 2rem; }
.tutorial-card h4 { margin: 0; font-size: 1rem; color: #f5d94a; }
.tutorial-card p  { margin: 0; font-size: 0.85rem; color: rgba(255,255,255,0.8); }
.tutorial-body { color: rgba(255,255,255,0.85); line-height: 1.5; }

/* ---------- v5.3 mobile polish ---------- */
@media (max-width: 640px) {
    .home-menu, .menu-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .menu-tile { min-height: 88px; }             /* 44*2 touch target */
    .form-panel { padding: 0.75rem !important; }
    .screen-title { font-size: 1.4rem; }
    .skin-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
    /* Prevent iOS from zooming when tapping an input */
    input[type="text"], input[type="checkbox"] + label, select { font-size: 16px; }
}
@media (max-width: 640px) and (orientation: portrait) {
    #chess-board { max-width: 100vw; }
}
@media (max-width: 900px) and (orientation: landscape) {
    /* Keep board and panels side-by-side, but shrink panel width. */
    .side-panel { max-width: 40vw; }
}
/* Ensure all buttons meet touch target on mobile */
@media (pointer: coarse) {
    button, .menu-tile, .avatar-cell { min-height: 44px; min-width: 44px; }
}

/* ==========================================================================
   Ruthless Chess — theme
   Palette:
     --bg-*     : app background gradient
     --wood-*   : board frame and square colors (warm walnut set)
     --accent-* : highlights (selection, last-move, check)
     --panel-*  : side panel surfaces
   ========================================================================== */
:root {
    --bg-1: #1a1f2e;
    --bg-2: #2d3548;

    --accent-select:    #f5d94a;
    --accent-lastmove:  rgba(120, 180, 90, 0.55);
    --accent-check:     rgba(220, 60, 60, 0.75);
    --accent-hint:      rgba(20, 20, 20, 0.30);
    --accent-capture:   rgba(200, 60, 60, 0.55);

    --panel-bg:      rgba(255, 255, 255, 0.97);
    --panel-fg:      #1a1a1a;
    --panel-muted:   #667085;
    --panel-border:  rgba(0, 0, 0, 0.08);

    --btn-bg-1: #3e4c7e;
    --btn-bg-2: #2b365c;
    --btn-fg:   #ffffff;
    --btn-danger-1: #c94a4a;
    --btn-danger-2: #8f2f2f;
    --btn-primary-1: #4caf7a;
    --btn-primary-2: #2f7853;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-panel: 0 6px 20px rgba(0, 0, 0, 0.25);
    --shadow-piece: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.45));
}

/* ---------- Board themes ---------- */
html.theme-classic {
    --wood-frame-dark: #3b2416; --wood-frame-mid: #5a3a24; --wood-frame-hi: #7a5230;
    --sq-light: #edd6b0; --sq-dark: #8b6b47;
}
html.theme-felt {
    --wood-frame-dark: #1e3a1f; --wood-frame-mid: #2e5a30; --wood-frame-hi: #4a7c4d;
    --sq-light: #ebecd0; --sq-dark: #779556;
}
html.theme-ice {
    --wood-frame-dark: #1e2a3a; --wood-frame-mid: #2f4560; --wood-frame-hi: #4a6d92;
    --sq-light: #dee9f0; --sq-dark: #547ea1;
}

/* ---------- Screens ---------- */
.screen { display: none; flex-direction: column; gap: 14px; width: 100%; max-width: 1080px; }
.screen.active { display: flex; }

.screen-title {
    color: #fff;
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.4px;
    margin: 4px 0 10px;
}

.back-btn {
    align-self: flex-start;
    padding: 7px 14px;
    background: linear-gradient(180deg, rgba(255,255,255,0.15), rgba(255,255,255,0.05));
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 0.85rem;
    border-radius: var(--radius-md);
    min-height: 36px;
    min-width: 90px;
}
.back-btn:hover { background: linear-gradient(180deg, rgba(255,255,255,0.25), rgba(255,255,255,0.1)); }

.form-panel {
    background: var(--panel-bg);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow-panel);
    border: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.form-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--panel-border);
}
.form-row:last-of-type { border-bottom: none; }
.form-row.column { flex-direction: column; align-items: stretch; }
.form-row label { font-weight: 600; font-size: 0.95rem; color: var(--panel-fg); }
.form-row input[type="text"] {
    padding: 10px 12px;
    border: 1px solid #d0d5dd;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
}
.form-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: #2b365c; cursor: pointer; }
.form-note { font-size: 0.8rem; color: var(--panel-muted); font-style: italic; margin-top: 4px; }

/* ---------- Loading screen (splash on boot) ---------- */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(180deg, rgba(5,7,15,0.55) 0%, rgba(5,7,15,0.80) 100%),
        url('../../assets/images/loading-hero.png') center / cover no-repeat,
        #05070f;
    opacity: 1;
    transition: opacity 0.5s ease-out, visibility 0s linear 0.5s;
}
body.loaded #loading-screen {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.loading-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    animation: loadingIn 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes loadingIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.loading-logo {
    width: clamp(240px, 36vw, 460px);
    height: auto;
    filter: drop-shadow(0 8px 24px rgba(0,0,0,0.55))
            drop-shadow(0 0 30px rgba(245,217,74,0.15));
}
.loading-spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(245, 217, 74, 0.20);
    border-top-color: #f5d94a;
    animation: loadingSpin 0.9s linear infinite;
}
@keyframes loadingSpin { to { transform: rotate(360deg); } }
.loading-caption {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-weight: 500;
}

/* ---------- Home screen ---------- */
/* When the home screen is active, paint the cinematic hero image on <body>
   so it fills the whole viewport (not just the 1080px #app column). Uses
   :has() so no JS toggle is needed. The two-stop gradient on top keeps
   the centered title + menu-grid readable against the bright king. */
body:has(#screen-home.active) {
    background:
        /* Much lighter overlay so the image reads clearly. Just enough tint
           at the bottom to keep the menu-grid tiles legible. */
        linear-gradient(180deg, rgba(5, 7, 15, 0.15) 0%, rgba(5, 7, 15, 0.50) 100%),
        url('../../assets/images/home-hero1.png') center / cover no-repeat fixed,
        #05070f !important;
}
/* LIGHT theme override: original navy gradient — no image, no overlay. */
body.theme-light:has(#screen-home.active) {
    background: radial-gradient(ellipse at top, var(--bg-2), var(--bg-1) 70%) !important;
}
/* LIGHT theme: primary tile returns to solid red (no image to compete with). */
body.theme-light .menu-tile.primary {
    background: linear-gradient(180deg, #c94a4a, #8f2f2f);
    border-color: rgba(255,255,255,0.25);
}
body.theme-light .menu-tile.primary:hover {
    background: linear-gradient(180deg, #d95555, #9f3535);
    border-color: rgba(255,255,255,0.35);
}
/* LIGHT theme: topbar icons don't need the heavy dark backdrop. */
body.theme-light .icon-btn {
    background: rgba(255,255,255,0.15);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    border-color: rgba(255,255,255,0.20);
}
body.theme-light .icon-btn:hover { background: rgba(255,255,255,0.25); }
.home-topbar {
    position: absolute;
    top: 16px;
    right: 20px;
    display: flex;
    gap: 8px;
}
.icon-btn {
    width: 42px; height: 42px;
    min-width: 42px; min-height: 42px;
    padding: 0;
    border-radius: 50%;
    /* Darker backdrop + blur so the icons stay legible against any bright
       part of the home hero image behind them. */
    background: rgba(10, 13, 32, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.22);
    font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.icon-btn:hover { background: rgba(10, 13, 32, 0.75); }
.icon-btn.off { opacity: 0.4; position: relative; }
.icon-btn.off::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 44%, #ff5555 44%, #ff5555 56%, transparent 56%);
    border-radius: 50%;
    pointer-events: none;
}

.home-hero { text-align: center; margin-top: 40px; }
.home-logo {
    display: block;
    width: clamp(280px, 42vw, 520px);
    height: auto;
    margin: 0 auto;
    /* Subtle glow anchors the logo to the dark background image behind it. */
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.55))
            drop-shadow(0 0 30px rgba(245, 217, 74, 0.15));
}
.home-tagline {
    color: rgba(255,255,255,0.7);
    margin-top: 10px;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.resume-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 720px;
    margin: 20px auto 0;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(245,217,74,0.14), rgba(201,74,74,0.14));
    border: 1px solid rgba(245,217,74,0.35);
    border-radius: 12px;
    color: #fff;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    flex-wrap: wrap;
}
.resume-banner .resume-info { min-width: 0; flex: 1 1 auto; }
.resume-banner .resume-title {
    font-weight: 700;
    letter-spacing: 0.4px;
    color: #f5d94a;
    margin-bottom: 2px;
}
.resume-banner .resume-summary {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.78);
}
.resume-banner .resume-actions {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}
.resume-banner .btn {
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}
.resume-banner .btn-primary {
    background: linear-gradient(135deg, #f5d94a, #c94a4a);
    color: #1a1a1a;
}
.resume-banner .btn-ghost {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.85);
}
.resume-banner .btn:hover { filter: brightness(1.08); }

.overwrite-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: overwriteFadeIn 0.15s ease-out;
}
@keyframes overwriteFadeIn { from { opacity: 0; } to { opacity: 1; } }
.overwrite-modal-panel {
    background: #23232a;
    border: 1px solid rgba(245,217,74,0.35);
    border-radius: 14px;
    padding: 24px;
    max-width: 420px;
    width: 100%;
    color: #fff;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.overwrite-modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f5d94a;
    margin-bottom: 8px;
}
.overwrite-modal-body {
    color: rgba(255,255,255,0.8);
    font-size: 0.95rem;
    margin-bottom: 20px;
    line-height: 1.4;
}
.overwrite-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.overwrite-modal-actions .btn {
    padding: 9px 16px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-size: 0.92rem;
}
.overwrite-modal-actions .btn-primary {
    background: linear-gradient(135deg, #f5d94a, #c94a4a);
    color: #1a1a1a;
}
.overwrite-modal-actions .btn-ghost {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.85);
}
.overwrite-modal-actions .btn:hover { filter: brightness(1.08); }

/* ---------- Home v2: primary mode cards ---------- */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    padding: 20px;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}
.menu-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px 12px;
    min-height: 100px;
    background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.04));
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.menu-tile:hover {
    background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.08));
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.3);
    filter: none;
}
.menu-tile.primary {
    /* Translucent RED glass — background image still reads through, but the
       tile keeps its crimson identity as the primary CTA. */
    background: linear-gradient(180deg, rgba(201, 74, 74, 0.35), rgba(143, 47, 47, 0.28));
    border-color: rgba(201, 74, 74, 0.55);
    grid-column: span 2;
}
.menu-tile.primary:hover {
    background: linear-gradient(180deg, rgba(217, 85, 85, 0.48), rgba(159, 53, 53, 0.40));
    border-color: rgba(217, 85, 85, 0.75);
}
.tile-icon { font-size: 1.8rem; line-height: 1; }
.tile-label { font-size: 0.9rem; font-weight: 600; letter-spacing: 0.3px; }
.home-footer {
    text-align: center;
    color: rgba(255,255,255,0.4);
    font-size: 0.75rem;
    margin-top: 20px;
    letter-spacing: 0.5px;
}

/* ---------- Avatar grid ---------- */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 6px;
}
.avatar-cell {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    background: linear-gradient(180deg, #f5eede, #e6d6b8);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: #2b1e14;
    min-height: 56px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    padding: 0;
}
.avatar-cell:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.2); }
.avatar-cell.selected {
    border-color: #2b365c;
    box-shadow: 0 0 0 3px rgba(43,54,92,0.3), 0 2px 4px rgba(0,0,0,0.15);
    background: linear-gradient(180deg, #fff8dc, #ffeaa0);
}

/* ---------- Profile stats ---------- */
.panel-heading {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--panel-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 12px;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.stat-cell {
    background: #f7f9fc;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    padding: 10px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.stat-value {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: #1a2755;
    line-height: 1;
}
.stat-label {
    font-size: 0.72rem;
    color: var(--panel-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.openings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}
.opening-list {
    list-style: none;
    margin-top: 6px;
    padding: 0;
}
.opening-list li {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.85rem;
    border-bottom: 1px dashed var(--panel-border);
}
.opening-list li:last-child { border-bottom: none; }
.opening-list .opening-empty {
    color: var(--panel-muted);
    justify-content: center;
    font-style: italic;
}
.opening-move  { color: #1a2755; font-weight: 600; }
.opening-count { color: var(--panel-muted); }
.form-actions {
    display: flex;
    justify-content: center;
    margin-top: 14px;
}

/* ---------- Placeholder screen ---------- */
.placeholder-content {
    background: var(--panel-bg);
    border-radius: var(--radius-lg);
    padding: 48px 32px;
    text-align: center;
    box-shadow: var(--shadow-panel);
    border: 1px solid var(--panel-border);
}
.placeholder-icon { font-size: 3.5rem; margin-bottom: 16px; }
.placeholder-text { color: var(--panel-muted); font-size: 1rem; max-width: 400px; margin: 0 auto; }

/* ---------- Game screen back button ---------- */
/* Game screen header uses --panel-bg (light), so the default white back-btn
   text vanishes. Override to dark colors on this instance only. */
.game-back {
    margin-right: 12px;
    color: var(--panel-fg);
    background: linear-gradient(180deg, rgba(0,0,0,0.06), rgba(0,0,0,0.02));
    border-color: rgba(0,0,0,0.15);
}
.game-back:hover { background: linear-gradient(180deg, rgba(0,0,0,0.12), rgba(0,0,0,0.05)); }

/* v-clean game header: back arrow (left), live status (center), New Game (right). */
.game-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
}
.game-header .status-bar {
    flex: 1;
    text-align: center;
    background: transparent;
    box-shadow: none;
    border: none;
    padding: 0;
    color: var(--panel-fg);
    font-weight: 600;
    font-size: 1rem;
}
.header-primary {
    background: linear-gradient(180deg, #f5d94a, #d4b829);
    color: #1a1a1a;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
    min-height: 40px;
}
.header-primary:hover { filter: brightness(1.1); }

/* Sidebar play-controls: compact row, equal-flex buttons. */
.play-controls {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}
.play-controls button {
    flex: 1;
    padding: 8px 6px;
    background: linear-gradient(180deg, rgba(255,255,255,0.85), rgba(240,240,240,0.85));
    color: #1a1a1a;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    min-height: 40px;
}
.play-controls button:hover:not(:disabled) { background: rgba(255,255,255,1); }
.play-controls button.danger {
    background: linear-gradient(180deg, #f5cccc, #e8a3a3);
    color: #6b1a1a;
    border-color: #d97706;
}
.play-controls button.danger:hover { background: #e8a3a3; }

/* ---------- AI setup modal (difficulty + color pickers) ---------- */
#ai-setup-modal .modal-content { max-width: 460px; padding: 26px 28px; }
.setup-section { margin-top: 14px; text-align: left; }
.setup-section h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--panel-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 10px;
}
.option-grid {
    display: grid;
    gap: 8px;
}
.difficulty-grid { grid-template-columns: repeat(4, 1fr); }
.color-grid      { grid-template-columns: repeat(3, 1fr); }

.option-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px 6px;
    min-height: 76px;
    background: linear-gradient(180deg, #f5eede, #e6d6b8);
    color: #2b1e14;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.12);
}
.option-btn:hover {
    background: linear-gradient(180deg, #fdf3d9, #f0dfaf);
    filter: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.18);
}
.option-btn.selected {
    border-color: #2b365c;
    box-shadow: 0 0 0 3px rgba(43,54,92,0.35), 0 2px 4px rgba(0,0,0,0.12);
    background: linear-gradient(180deg, #fff8dc, #ffeaa0);
}
.option-btn .opt-icon { font-size: 1.5rem; line-height: 1; }
.option-btn .opt-label { font-size: 0.78rem; letter-spacing: 0.3px; }

@media (max-width: 500px) {
    .difficulty-grid { grid-template-columns: repeat(2, 1fr); }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(ellipse at top, var(--bg-2), var(--bg-1) 70%);
    min-height: 100vh;
    color: var(--panel-fg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px 12px;
    position: relative;
}

#app {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 1080px;
    position: relative;
}

/* ---------- Header ---------- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel-bg);
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-panel);
    border: 1px solid var(--panel-border);
}

.header h1 {
    color: #1a2755;
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #1a2755, #c94a4a);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ---------- Buttons ---------- */
button {
    padding: 9px 16px;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, var(--btn-bg-1), var(--btn-bg-2));
    color: var(--btn-fg);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    min-height: 42px;
    min-width: 44px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
button:hover { filter: brightness(1.1); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15); }
button:active { transform: translateY(1px) scale(0.99); }
button:disabled { background: linear-gradient(180deg, #8a8a8a, #6d6d6d); cursor: not-allowed; filter: none; opacity: 0.7; }

button.primary { background: linear-gradient(180deg, var(--btn-primary-1), var(--btn-primary-2)); }
button.danger  { background: linear-gradient(180deg, var(--btn-danger-1),  var(--btn-danger-2));  }

/* ---------- Settings ---------- */
.settings-panel {
    display: none;
    background: var(--panel-bg);
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-panel);
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
    border: 1px solid var(--panel-border);
}
.settings-panel.active { display: flex; }

.setting-group { display: flex; flex-direction: column; gap: 6px; }
.setting-group label { font-size: 0.82rem; color: var(--panel-fg); font-weight: 600; }
select, input[type="range"] {
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid #d0d5dd;
    min-height: 36px;
    background: white;
    font-size: 0.9rem;
}

/* ---------- Status bar ---------- */
.status-bar {
    background: var(--panel-bg);
    padding: 11px 16px;
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--panel-fg);
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.2px;
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-panel);
}

/* ---------- Main layout ---------- */
/* On desktop, board and sidebar share the same explicit height so there's no
   dead vertical space below either. On mobile the media queries below take
   over — items wrap, board goes full width, sidebar stacks under it. */
.main-content {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
}
@media (min-width: 900px) {
    .main-content {
        flex-wrap: nowrap;
        /* Prefer viewport height so the board grows on tall monitors, capped
           at 720px so ultra-wide screens don't blow the frame proportions. */
        height: min(82vh, 720px);
    }
    #game-container {
        width: auto;
        height: 100%;
        max-width: min(82vh, 720px);
        aspect-ratio: 1;
    }
    .side-panel {
        width: 320px;
        height: 100%;
        overflow-y: auto;
    }
}

/* ---------- Board frame ---------- */
#game-container {
    width: min(80vw, 80vh, 560px);
    height: min(80vw, 80vh, 560px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow:
        0 12px 30px rgba(0, 0, 0, 0.45),
        inset 0 0 0 2px rgba(255, 255, 255, 0.05);
    /* Layered gradient gives the frame a beveled, polished-wood look. */
    background:
        linear-gradient(135deg, var(--wood-frame-hi), var(--wood-frame-dark)) padding-box;
    border: 10px solid transparent;
    background-clip: padding-box;
    position: relative;
}
#game-container::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5), inset 0 2px 8px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    z-index: 2;
}

#chess-board {
    width: 100%;
    height: 100%;
    position: relative;
}

#chess-board-grid {
    width: 100%;
    height: 100%;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Squares ---------- */
.square {
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    cursor: pointer;
    position: relative;
    transition: background-color 0.15s ease;
}
.square.white-square { background-color: var(--sq-light); }
.square.black-square { background-color: var(--sq-dark);  }

/* Coordinate labels (a-h, 1-8) in the corners of edge squares. */
.coord {
    position: absolute;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: clamp(0.55rem, 1.3vw, 0.75rem);
    font-weight: 700;
    pointer-events: none;
    user-select: none;
    line-height: 1;
    opacity: 0.75;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.coord-rank { top: 3px;    left: 4px;   }
.coord-file { bottom: 3px; right: 5px; }
.white-square .coord { color: var(--wood-frame-dark); }
.black-square .coord { color: var(--sq-light); }
/* When board is flipped, counter-rotate labels so they stay upright. */
#chess-board-grid.flipped .coord { transform: rotate(180deg); }

/* ---------- Highlights ---------- */
.square.selected {
    background: radial-gradient(circle, rgba(245, 217, 74, 0.6) 0%, rgba(245, 217, 74, 0.25) 80%) !important;
    box-shadow: inset 0 0 0 3px var(--accent-select);
}
.square.last-move {
    box-shadow: inset 0 0 0 3px var(--accent-lastmove);
}
.square.check {
    background: radial-gradient(circle, var(--accent-check) 0%, rgba(220, 60, 60, 0.1) 75%) !important;
    animation: check-pulse 1.4s ease-in-out infinite;
}
@keyframes check-pulse {
    0%, 100% { box-shadow: inset 0 0 0 0 rgba(220, 60, 60, 0); }
    50%      { box-shadow: inset 0 0 24px 4px rgba(220, 60, 60, 0.45); }
}

/* Move-hint dots and capture rings — use ::after so they don't collide with
   the coordinate labels (which are child elements, not pseudo-elements). */
.square.valid-move::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 28%; height: 28%;
    transform: translate(-50%, -50%);
    background: var(--accent-hint);
    border-radius: 50%;
    pointer-events: none;
    animation: dot-in 0.15s ease-out;
}
.square.valid-capture::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 82%; height: 82%;
    transform: translate(-50%, -50%);
    border: 5px solid var(--accent-capture);
    border-radius: 50%;
    pointer-events: none;
    box-sizing: border-box;
    animation: dot-in 0.15s ease-out;
}
@keyframes dot-in {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1);   }
}

/* ---------- Pieces ---------- */
.piece {
    pointer-events: none;
    width: 92%;
    height: 92%;
    display: flex;
    justify-content: center;
    align-items: center;
    filter: var(--shadow-piece);
    position: relative;
    z-index: 1;
}
.piece svg { width: 100%; height: 100%; display: block; }
/*
 * NOTE: no CSS animation on `.piece`. Because `board.setPosition()` rebuilds
 * every piece element after each move (to keep castling / en passant /
 * promotion in sync), any animation on the base class would replay across
 * all 32 pieces on every move — a full-board flicker. The FLIP slide in
 * board.animateMove() already gives the visual feedback we want.
 */

/* ---------- Side panel ---------- */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(80vw, 320px);
}

.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel-bg);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-panel);
    border: 1px solid var(--panel-border);
    transition: box-shadow 0.2s ease;
    flex: 0 0 auto;
}
.player-info.active {
    background: linear-gradient(180deg, #fff8dc, #ffeaa0);
    box-shadow: 0 0 0 2px #f5d94a, var(--shadow-panel);
}

.player-name { font-weight: 700; color: var(--panel-fg); letter-spacing: 0.3px; font-size: 0.95rem; }
.player-clock {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a2755;
    letter-spacing: 1px;
}
.player-clock.low      { color: #d97706; }
.player-clock.critical { color: #dc2626; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* Compact eval bar — no "Eval" label; the bar itself is the meaning. */
.analysis-panel {
    background: var(--panel-bg);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    box-shadow: var(--shadow-panel);
    border: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.analysis-value {
    align-self: flex-end;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.9rem;
    font-weight: 700;
    color: #1a2755;
    text-align: right;
}
.eval-bar {
    height: 8px;
    background: #2b1e14;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
}
.eval-bar-fill {
    height: 100%;
    width: 50%;
    background: linear-gradient(90deg, #f6ecd6, #edd6b0);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid rgba(0,0,0,0.15);
}
.eval-bar::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: 50%;
    width: 1px;
    background: rgba(255,255,255,0.25);
}

/* Move-list annotation colors — icons themselves come from JS. */
#move-list li.move.move-inaccuracy { color: #b45309; }
#move-list li.move.move-mistake    { color: #c2410c; }
#move-list li.move.move-blunder    { color: #b91c1c; font-weight: 700; }

.move-log {
    background: var(--panel-bg);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    box-shadow: var(--shadow-panel);
    border: 1px solid var(--panel-border);
    flex: 1 1 auto;
    min-height: 120px;
    display: flex;
    flex-direction: column;
}
.move-log h3 {
    margin-bottom: 10px;
    color: #1a2755;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 6px;
}

#move-list {
    list-style: none;
    /* Fill whatever height the move-log gets from flex — no arbitrary cap. */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 36px 1fr 1fr;
    gap: 4px 8px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.88rem;
    padding-right: 4px;
}
#move-list li.move-number { color: var(--panel-muted); font-weight: 700; }
#move-list li.move {
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    cursor: default;
    transition: background 0.12s ease;
}
#move-list li.move:hover { background: #e6efff; }

/* Custom scrollbar for the move list. */
#move-list::-webkit-scrollbar { width: 6px; }
#move-list::-webkit-scrollbar-thumb { background: #c0c8d4; border-radius: 3px; }

/* ---------- Modals ---------- */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(10, 15, 30, 0.72);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fade-in 0.18s ease-out;
}
.modal.active { display: flex; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background: white;
    padding: 28px 32px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modal-in 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modal-in {
    from { transform: translateY(20px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0) scale(1);       opacity: 1; }
}

.modal-content h2 {
    color: #1a2755;
    margin-bottom: 14px;
    font-size: 1.4rem;
    font-weight: 700;
}
.modal-content p { margin-bottom: 20px; color: #4b5563; font-size: 0.95rem; }

.modal-content .setting-group {
    text-align: left;
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: #f7f9fc;
    transition: background 0.15s ease;
}
.modal-content .setting-group:hover { background: #eef2fa; }
.modal-content .setting-group label { cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 0.95rem; }
.modal-content .setting-group input[type="radio"] { width: 16px; height: 16px; accent-color: #2b365c; }

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.modal-actions button { min-width: 96px; padding: 10px 18px; }

.promotion-options {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 22px 0;
    flex-wrap: wrap;
}
.promotion-piece {
    width: 68px;
    height: 68px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg, #f5eede, #e6d6b8);
    border: 2px solid #c9a97a;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    filter: var(--shadow-piece);
}
.promotion-piece:hover { transform: translateY(-3px); box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25); }
.promotion-piece:active { transform: translateY(-1px); }
.promotion-piece svg { width: 100%; height: 100%; }

/* ---------- Result overlay ---------- */
.result-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(10, 15, 30, 0.82);
    backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fade-in 0.25s ease-out;
}
.result-overlay.active { display: flex; }

.result-content {
    background: linear-gradient(180deg, rgba(20, 24, 58, 0.96), rgba(5, 7, 15, 0.96));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(245, 217, 74, 0.35);
    padding: 42px 40px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.75), 0 0 40px rgba(245, 217, 74, 0.08);
    animation: modal-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.result-title {
    font-size: 2.2rem;
    background: linear-gradient(180deg, #ffe37a, #c94a4a);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.result-message { font-size: 1.05rem; color: rgba(255,255,255,0.80); margin-bottom: 26px; }

/* Buttons inside the result modal — dark glass with gold hover.
   Light theme users get the same treatment for consistency. */
.result-actions button {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.92);
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    box-shadow: none;
    min-height: 42px;
}
.result-actions button:hover {
    background: rgba(245, 217, 74, 0.18);
    border-color: rgba(245, 217, 74, 0.55);
    color: #fff;
    filter: none;
}
.result-actions button.primary {
    background: linear-gradient(135deg, rgba(245, 217, 74, 0.90), rgba(201, 74, 74, 0.90));
    color: #05070f;
    border-color: rgba(245, 217, 74, 0.60);
    box-shadow: 0 6px 18px rgba(245, 217, 74, 0.20);
}
.result-actions button.primary:hover {
    background: linear-gradient(135deg, rgba(255, 227, 122, 0.95), rgba(217, 85, 85, 0.95));
    color: #05070f;
}

/* ---------- Phase B: review + pre-move ---------- */
.review-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}
.review-controls button {
    padding: 6px 10px;
    font-size: 0.9rem;
}
.review-position {
    font-family: monospace;
    color: #f5d94a;
    padding: 0 8px;
    min-width: 60px;
    text-align: center;
}
.move.current {
    background: rgba(245, 217, 74, 0.25);
    outline: 1px solid rgba(245, 217, 74, 0.6);
    border-radius: 3px;
}
.square.premove {
    box-shadow: inset 0 0 0 3px rgba(120, 180, 255, 0.75);
}
.result-actions {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
    body { padding: 10px 6px; }
    .main-content { flex-direction: column; align-items: center; }
    .side-panel { width: 100%; max-width: min(95vw, 560px); }
    #game-container { width: min(95vw, 95vw); height: min(95vw, 95vw); border-width: 8px; }
    .header { flex-direction: column; gap: 10px; text-align: center; }
    .game-controls { justify-content: center; }
    .move-log { max-height: 200px; }
    .coord { font-size: clamp(0.5rem, 2vw, 0.7rem); }
}

/* ================================================================
   GAME SCREEN v2 — Template-inspired layout (1920x1080 reference)
   ---------------------------------------------------------------
   Topbar (brand · match badge · icons)
   Arena (left-panel | eval-strip | board | right-panel)
   Bottom pill actions (floating)
   Slide-out drawer for move list + review controls
   Loading-hero.png as background (light overlay — the atmosphere IS
   the background here, no heavy tint like other screens).
   ================================================================ */

body:has(#screen-game.active):not(.theme-light) {
    background:
        linear-gradient(180deg, rgba(5, 7, 15, 0.35) 0%, rgba(5, 7, 15, 0.60) 100%),
        url('../../assets/images/loading-hero.png') center / cover no-repeat fixed,
        #05070f !important;
}

/* Escape the #app 1080px column so the arena can breathe on 1920. */
#screen-game.game-v2.active {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
    max-width: none;
    z-index: 5;
    overflow: hidden;
}

/* ---------- Topbar ---------- */
#screen-game.game-v2 .game-topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 16px 28px 12px;
    background: none;
    border: none;
    height: auto;
    flex: 0 0 auto;
}
#screen-game.game-v2 .topbar-left  { display: flex; align-items: center; gap: 12px; }
#screen-game.game-v2 .topbar-center { justify-self: center; }
#screen-game.game-v2 .topbar-right { display: flex; align-items: center; gap: 10px; justify-self: end; }

#screen-game.game-v2 .brand-crest {
    font-size: 1.5rem;
    line-height: 1;
    background: linear-gradient(180deg, #ffe37a, #c94a4a);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(245,217,74,0.30));
}
#screen-game.game-v2 .brand-name {
    color: rgba(255,255,255,0.92);
    font-family: 'Cormorant Garamond', 'Times New Roman', serif;
    font-weight: 600;
    letter-spacing: 4px;
    font-size: 1.1rem;
    text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
#screen-game.game-v2 .match-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    color: #f5d94a;
    letter-spacing: 4px;
    font-weight: 700;
    font-size: 0.85rem;
    text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
#screen-game.game-v2 .match-badge-icon { font-size: 1rem; }

#screen-game.game-v2 .topbar-icon {
    width: 42px; height: 42px;
    min-width: 42px; min-height: 42px;
    padding: 0;
    border-radius: 50%;
    background: rgba(10, 13, 32, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.90);
    font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
#screen-game.game-v2 .topbar-icon:hover {
    background: rgba(245,217,74,0.20);
    border-color: rgba(245,217,74,0.55);
    color: #fff;
    transform: translateY(-1px);
    filter: none;
}

/* Status bar — subtle strip under the topbar, centered */
#screen-game.game-v2 .status-bar {
    align-self: center;
    color: rgba(255,255,255,0.65);
    font-size: 0.82rem;
    letter-spacing: 1.5px;
    padding: 0 12px 12px;
    text-shadow: 0 2px 6px rgba(0,0,0,0.6);
    flex: 0 0 auto;
    text-transform: uppercase;
    background: none;
    border: none;
    text-align: center;
}

/* ---------- Arena: 3-col layout (left panel · board · right panel), eval strip nested ---------- */
#screen-game.game-v2 .game-arena {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr) minmax(220px, 300px);
    align-items: center;
    justify-items: center;
    gap: clamp(20px, 3vw, 60px);
    padding: 8px clamp(24px, 4vw, 60px) 110px;   /* bottom padding leaves room for floating action row */
    min-height: 0;
    overflow: hidden;
}

/* Player panels (left + right of the board) */
#screen-game.game-v2 .player-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 280px;
    align-self: center;
    justify-self: center;
    /* Override the legacy .player-info flex row from the pre-rework CSS. */
    background: none;
    padding: 0;
    border: none;
    box-shadow: none;
}
#screen-game.game-v2 .player-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: rgba(10, 13, 32, 0.65);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.45);
    transition: border-color 0.25s, box-shadow 0.25s;
}
/* Turn indicator: when it's this player's turn, the whole card lights up gold */
#screen-game.game-v2 .player-panel.active .player-card {
    border-color: rgba(245,217,74,0.60);
    box-shadow: 0 12px 30px rgba(0,0,0,0.45), 0 0 0 1px rgba(245,217,74,0.35);
}

#screen-game.game-v2 .player-avatar {
    position: relative;
    width: 60px; height: 60px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: linear-gradient(180deg, #14183a, #05070f);
    border: 2px solid rgba(245,217,74,0.55);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 12px rgba(245,217,74,0.25), inset 0 2px 6px rgba(0,0,0,0.5);
}
#screen-game.game-v2 .avatar-glyph {
    font-size: 1.8rem;
    color: rgba(255,255,255,0.75);
    line-height: 1;
}
#screen-game.game-v2 .avatar-crown {
    position: absolute;
    top: -14px; left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    color: #f5d94a;
    filter: drop-shadow(0 1px 4px rgba(245,217,74,0.60));
}

#screen-game.game-v2 .player-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#screen-game.game-v2 .player-name {
    font-size: 1.15rem; font-weight: 700; letter-spacing: 0.3px;
    color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
#screen-game.game-v2 .player-elo {
    font-size: 0.78rem; color: rgba(255,255,255,0.60);
    letter-spacing: 1px;
}
#screen-game.game-v2 .player-rank {
    font-size: 0.72rem; color: #f5d94a;
    letter-spacing: 1.5px; font-weight: 700;
    margin-top: 4px;
}

/* Clock panel: separate rectangle below the player card */
#screen-game.game-v2 .player-clock-panel {
    padding: 14px 18px;
    background: rgba(5, 7, 15, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    text-align: center;
    box-shadow: 0 10px 24px rgba(0,0,0,0.45);
}
#screen-game.game-v2 .player-clock {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 2.4rem;
    font-weight: 700;
    color: rgba(255,255,255,0.95);
    letter-spacing: 3px;
    line-height: 1;
    display: block;
    text-shadow: 0 2px 8px rgba(0,0,0,0.55);
}
#screen-game.game-v2 .player-clock.low      { color: #ffb84d; }
#screen-game.game-v2 .player-clock.critical { color: #ff5555; animation: pulse 1s infinite; }
#screen-game.game-v2 .player-clock-bar {
    margin-top: 10px;
    height: 3px;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
    overflow: hidden;
}
#screen-game.game-v2 .player-clock-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ffe37a, #f5d94a);
    transition: width 0.4s ease;
}

/* Eval strip: thin vertical bar between left panel and board */
#screen-game.game-v2 .eval-strip {
    position: absolute;
    /* Positioned relative to the arena, near the board's left edge.
       Kept out of the grid so it doesn't reserve column width. */
    height: min(72vh, 700px);
    width: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;   /* purely decorative */
    left: max(320px, calc(50% - min(36vh, 350px) - 30px));
    top: 50%;
    transform: translateY(-40%);
    z-index: 2;
}
#screen-game.game-v2 .eval-strip-track {
    flex: 1 1 auto;
    width: 100%;
    background: rgba(5, 7, 15, 0.7);
    border: 1px solid rgba(245,217,74,0.20);
    border-radius: 7px;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.6), 0 0 12px rgba(0,0,0,0.5);
}
#screen-game.game-v2 .eval-strip-fill {
    width: 100%;
    height: 50%;
    background: linear-gradient(0deg, #ffe37a, #f5d94a);
    transition: height 0.4s ease;
}
#screen-game.game-v2 .eval-strip-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: #f5d94a;
    text-shadow: 0 2px 4px rgba(0,0,0,0.7);
    letter-spacing: 0.5px;
}

/* Board frame — dark polished stone + gold hairline */
#screen-game.game-v2 #game-container {
    width: min(72vh, 700px);
    height: min(72vh, 700px);
    max-width: none;
    aspect-ratio: 1;
    justify-self: center;
    border-radius: 4px;
    border: none;
    background: transparent;
    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(245, 217, 74, 0.35),
        0 0 0 4px rgba(20, 24, 58, 0.85),
        0 0 40px rgba(245, 217, 74, 0.10);
    position: relative;
    overflow: hidden;
}
#screen-game.game-v2 #game-container::before {
    /* Remove the previous beveled-wood inset shadow */
    box-shadow: none;
}

/* ---------- Bottom action pill row (floating) ---------- */
#screen-game.game-v2 .game-actions {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 3;
}
#screen-game.game-v2 .tutor-controls {
    display: none;
    gap: 10px;
}
#screen-game.game-v2 .tutor-controls.active { display: inline-flex; }

#screen-game.game-v2 .action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(10, 13, 32, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 40px;
    color: rgba(255,255,255,0.92);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    min-height: 44px;
}
#screen-game.game-v2 .action-btn:hover {
    background: rgba(245,217,74,0.18);
    border-color: rgba(245,217,74,0.55);
    color: #fff;
    transform: translateY(-2px);
    filter: none;
}
#screen-game.game-v2 .action-btn.danger { color: #ff6b6b; }
#screen-game.game-v2 .action-btn.danger:hover {
    background: rgba(201,74,74,0.35);
    border-color: rgba(217,85,85,0.75);
    color: #fff;
}
#screen-game.game-v2 .action-icon { font-size: 1.05rem; line-height: 1; }
#screen-game.game-v2 .action-label { line-height: 1; }

/* ---------- Move list drawer (slide-in from right) ---------- */
#screen-game.game-v2 .game-drawer {
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    width: min(90vw, 380px);
    background: rgba(10, 13, 32, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid rgba(245,217,74,0.20);
    box-shadow: -30px 0 60px rgba(0,0,0,0.6);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
    z-index: 10;
}
#screen-game.game-v2 .game-drawer.open { transform: translateX(0); }

#screen-game.game-v2 .drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
#screen-game.game-v2 .drawer-title {
    color: #f5d94a;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
}
#screen-game.game-v2 .drawer-close {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.70);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 8px;
}
#screen-game.game-v2 .drawer-close:hover { color: #fff; background: rgba(255,255,255,0.08); }

#screen-game.game-v2 .game-drawer .move-log {
    background: none;
    border: none;
    padding: 0;
    box-shadow: none;
    flex: 1 1 auto;
    min-height: 0;
}
#screen-game.game-v2 #move-list {
    color: rgba(255,255,255,0.90);
    padding-right: 4px;
}
#screen-game.game-v2 #move-list li.move-number { color: rgba(245,217,74,0.75); }
#screen-game.game-v2 #move-list li.move:hover  { background: rgba(255,255,255,0.08); }
#screen-game.game-v2 #move-list li.move.current {
    background: rgba(245,217,74,0.25);
    outline: 1px solid rgba(245,217,74,0.6);
    border-radius: 3px;
}
#screen-game.game-v2 #move-list li.move.move-inaccuracy { color: #f5b642; }
#screen-game.game-v2 #move-list li.move.move-mistake    { color: #ff9550; }
#screen-game.game-v2 #move-list li.move.move-blunder    { color: #ff6b6b; }
#screen-game.game-v2 #move-list::-webkit-scrollbar { width: 6px; }
#screen-game.game-v2 #move-list::-webkit-scrollbar-thumb { background: rgba(245,217,74,0.35); border-radius: 3px; }

#screen-game.game-v2 .review-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
#screen-game.game-v2 .review-controls button {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.88);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
}
#screen-game.game-v2 .review-controls button:hover {
    background: rgba(245,217,74,0.15);
    border-color: rgba(245,217,74,0.45);
}

/* Tutor commentary — floats bottom-left corner when in tutor mode */
#screen-game.game-v2 .tutor-commentary {
    position: absolute;
    left: 24px;
    bottom: 96px;
    width: 300px;
    max-height: 240px;
    background: rgba(10, 13, 32, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 14px;
    padding: 12px 14px;
    display: none;
    z-index: 4;
    overflow: hidden;
}
#screen-game.game-v2 .tutor-commentary.active { display: block; }
#screen-game.game-v2 .tutor-commentary .panel-heading {
    color: #f5d94a;
    font-size: 0.78rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 8px;
}
#screen-game.game-v2 .tutor-commentary .commentary-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 180px;
    overflow-y: auto;
    color: rgba(255,255,255,0.88);
    font-size: 0.82rem;
}

/* ---------- Responsive: hide side panels below 1200px, keep board central ---------- */
@media (max-width: 1200px) {
    #screen-game.game-v2 .game-arena {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    #screen-game.game-v2 .player-panel {
        max-width: 480px;
        flex-direction: row;
        justify-content: space-between;
    }
    #screen-game.game-v2 .player-clock-panel { flex: 0 0 auto; }
    #screen-game.game-v2 .eval-strip { display: none; }
}
@media (max-width: 700px) {
    #screen-game.game-v2 .brand-name { display: none; }
    #screen-game.game-v2 .match-badge-label { font-size: 0.7rem; letter-spacing: 2px; }
    #screen-game.game-v2 .action-btn { padding: 10px 14px; font-size: 0.8rem; }
    #screen-game.game-v2 .action-label { display: none; }
}

/* =========== Mobile fixes for Android/iOS (Chrome/Safari) =========== */

/* `background-attachment: fixed` breaks on mobile browsers (Chrome address-bar
   resize glitches; Safari sometimes refuses to render). Fall back to `scroll`
   so the image sits behind the viewport cleanly on phones and tablets. */
@media (max-width: 900px), (hover: none) {
    body:has(#screen-home.active),
    body:has(#screen-home.active).theme-light,
    body:has(#screen-game.active):not(.theme-light) {
        background-attachment: scroll !important;
    }
}

/* Phone-first game layout: board fills width, panels shrink to compact
   horizontal bars top+bottom, action pills wrap. */
@media (max-width: 600px) {
    #screen-game.game-v2.active { overflow-y: auto; }
    #screen-game.game-v2 .game-topbar {
        grid-template-columns: auto 1fr auto;
        padding: 10px 12px 6px;
        gap: 8px;
    }
    #screen-game.game-v2 .topbar-icon { width: 36px; height: 36px; min-width: 36px; min-height: 36px; }
    #screen-game.game-v2 .status-bar { font-size: 0.72rem; padding: 0 8px 8px; letter-spacing: 1px; }

    #screen-game.game-v2 .game-arena {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        padding: 4px 8px 88px;
        gap: 8px;
    }
    /* Player panels become compact horizontal strips (avatar + name/elo + clock inline) */
    #screen-game.game-v2 .player-panel {
        flex-direction: row;
        max-width: none;
        gap: 8px;
    }
    #screen-game.game-v2 .player-card {
        flex: 1 1 auto;
        padding: 8px 12px;
        gap: 10px;
    }
    #screen-game.game-v2 .player-avatar { width: 38px; height: 38px; }
    #screen-game.game-v2 .avatar-glyph { font-size: 1.2rem; }
    #screen-game.game-v2 .avatar-crown { font-size: 0.7rem; top: -9px; }
    #screen-game.game-v2 .player-name { font-size: 0.92rem; }
    #screen-game.game-v2 .player-elo, #screen-game.game-v2 .player-rank { font-size: 0.65rem; letter-spacing: 0.8px; }
    #screen-game.game-v2 .player-clock-panel {
        padding: 8px 12px;
        flex: 0 0 auto;
    }
    #screen-game.game-v2 .player-clock { font-size: 1.4rem; letter-spacing: 1.5px; }
    #screen-game.game-v2 .player-clock-bar { margin-top: 4px; }

    /* Board fills the phone width */
    #screen-game.game-v2 #game-container {
        width: min(96vw, 96vw);
        height: min(96vw, 96vw);
        max-width: 96vw;
        max-height: 96vw;
        border-radius: 3px;
    }

    /* Bottom pill row: keep floating but let it wrap if needed */
    #screen-game.game-v2 .game-actions {
        bottom: 12px;
        gap: 6px;
        flex-wrap: wrap;
        justify-content: center;
        left: 6px; right: 6px;
        transform: none;
        max-width: none;
        width: auto;
    }
    #screen-game.game-v2 .action-btn { padding: 8px 12px; min-height: 40px; }
    #screen-game.game-v2 .action-icon { font-size: 0.95rem; }

    /* Drawer takes near-full width on phones */
    #screen-game.game-v2 .game-drawer { width: min(96vw, 380px); padding: 14px; }

    /* Tutor commentary — reposition so it doesn't overlap the action row */
    #screen-game.game-v2 .tutor-commentary {
        left: 8px; right: 8px; bottom: 70px;
        width: auto;
    }
}

/* Home screen mobile — the 10-tile grid handles itself, but on very narrow
   phones the primary tile's `grid-column: span 2` can force overflow.
   Keep it single-column of tiles at ≤420px. */
@media (max-width: 420px) {
    .menu-grid {
        grid-template-columns: 1fr;
        max-width: 100%;
        padding: 12px;
    }
    .menu-tile.primary { grid-column: auto; }
}

/* Bigger board + wider sidebar for 1920x1080 */
@media (min-width: 1400px) {
    #screen-game.active .main-content {
        height: min(88vh, 900px);
        gap: 28px;
    }
    #screen-game.active #game-container {
        max-width: min(88vh, 900px);
    }
    #screen-game.active .side-panel {
        width: 420px;
    }
}

/* Game header — dark & subtle so the board carries the eye */
body:has(#screen-game.active):not(.theme-light) .game-header {
    background: rgba(10, 13, 32, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 16px;
    margin-bottom: 14px;
}
body:has(#screen-game.active):not(.theme-light) .game-header .status-bar {
    color: rgba(255, 255, 255, 0.92);
    font-weight: 600;
    letter-spacing: 0.3px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
body:has(#screen-game.active):not(.theme-light) .back-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
}
body:has(#screen-game.active):not(.theme-light) .back-btn:hover {
    background: rgba(245, 217, 74, 0.15);
    border-color: rgba(245, 217, 74, 0.45);
    color: #fff;
}
body:has(#screen-game.active):not(.theme-light) .header-primary {
    background: linear-gradient(180deg, rgba(201, 74, 74, 0.85), rgba(143, 47, 47, 0.85));
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 6px 18px rgba(201, 74, 74, 0.25);
}

/* Board frame — deep beveled dark, subtle gold rim */
body:has(#screen-game.active):not(.theme-light) #game-container {
    background: linear-gradient(135deg, #1a1f3a, #0a0d20) padding-box;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(245, 217, 74, 0.18),
        inset 0 0 0 2px rgba(255, 255, 255, 0.04);
}

/* Sidebar container — dark glass panel */
body:has(#screen-game.active):not(.theme-light) .side-panel {
    background: rgba(10, 13, 32, 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px;
    gap: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

/* Player info blocks — dark cards, gold ring when it's their turn */
body:has(#screen-game.active):not(.theme-light) .player-info {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 14px;
    box-shadow: none;
    color: rgba(255, 255, 255, 0.92);
}
body:has(#screen-game.active):not(.theme-light) .player-info.active {
    background: linear-gradient(135deg, rgba(245, 217, 74, 0.14), rgba(201, 74, 74, 0.08));
    border-color: rgba(245, 217, 74, 0.60);
    box-shadow: 0 0 0 1px rgba(245, 217, 74, 0.35), 0 6px 18px rgba(245, 217, 74, 0.10);
}
body:has(#screen-game.active):not(.theme-light) .player-name {
    color: rgba(255, 255, 255, 0.92);
    font-weight: 600;
}
body:has(#screen-game.active):not(.theme-light) .player-clock {
    color: #f5d94a;
    font-size: 1.45rem;
    font-weight: 800;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    letter-spacing: 1.5px;
}
body:has(#screen-game.active):not(.theme-light) .player-clock.low      { color: #ffb84d; }
body:has(#screen-game.active):not(.theme-light) .player-clock.critical { color: #ff5555; }

/* Eval bar */
body:has(#screen-game.active):not(.theme-light) .analysis-panel {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: none;
    padding: 10px 12px;
}
body:has(#screen-game.active):not(.theme-light) .eval-bar {
    height: 10px;
    background: rgba(5, 7, 15, 0.6);
    border-radius: 5px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}
body:has(#screen-game.active):not(.theme-light) .eval-bar-fill {
    background: linear-gradient(90deg, #ffe37a, #f5d94a);
}
body:has(#screen-game.active):not(.theme-light) .analysis-value {
    color: #f5d94a;
    font-size: 0.95rem;
}

/* Move log */
body:has(#screen-game.active):not(.theme-light) .move-log {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: none;
    padding: 12px 14px;
}
body:has(#screen-game.active):not(.theme-light) #move-list  { color: rgba(255, 255, 255, 0.88); }
body:has(#screen-game.active):not(.theme-light) #move-list li.move-number { color: rgba(245, 217, 74, 0.70); }
body:has(#screen-game.active):not(.theme-light) #move-list li.move:hover  { background: rgba(255, 255, 255, 0.08); }
body:has(#screen-game.active):not(.theme-light) #move-list li.move.current {
    background: rgba(245, 217, 74, 0.25);
    outline: 1px solid rgba(245, 217, 74, 0.6);
}
body:has(#screen-game.active):not(.theme-light) #move-list::-webkit-scrollbar-thumb {
    background: rgba(245, 217, 74, 0.30);
}

/* Move annotation colors — brighten for dark bg */
body:has(#screen-game.active):not(.theme-light) #move-list li.move.move-inaccuracy { color: #f5b642; }
body:has(#screen-game.active):not(.theme-light) #move-list li.move.move-mistake    { color: #ff9550; }
body:has(#screen-game.active):not(.theme-light) #move-list li.move.move-blunder    { color: #ff6b6b; }

/* Game control buttons — dark glass with gold hover */
body:has(#screen-game.active):not(.theme-light) .game-controls button {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.90);
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    box-shadow: none;
}
body:has(#screen-game.active):not(.theme-light) .game-controls button:hover {
    background: rgba(245, 217, 74, 0.12);
    border-color: rgba(245, 217, 74, 0.45);
    transform: translateY(-1px);
    filter: none;
}
body:has(#screen-game.active):not(.theme-light) .game-controls button.danger {
    background: rgba(201, 74, 74, 0.35);
    border-color: rgba(201, 74, 74, 0.60);
}
body:has(#screen-game.active):not(.theme-light) .game-controls button.danger:hover {
    background: rgba(217, 85, 85, 0.55);
    border-color: rgba(217, 85, 85, 0.80);
}

/* Tutor commentary panel */
body:has(#screen-game.active):not(.theme-light) .tutor-commentary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
body:has(#screen-game.active):not(.theme-light) .tutor-commentary .panel-heading {
    color: #f5d94a;
    border-bottom-color: rgba(255, 255, 255, 0.10);
}
