:root {
    --bg: #07111f;
    --bg-alt: #0c172a;
    --surface: rgba(10, 20, 38, 0.84);
    --surface-strong: rgba(13, 25, 46, 0.96);
    --text: #edf3ff;
    --muted: #a7b4cb;
    --line: rgba(255, 255, 255, 0.1);
    --accent: #7c5cff;
    --accent-2: #2dd4bf;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --panel-width: min(440px, 100vw);
}

html[data-theme="light"] {
    --bg: #f4f7fb;
    --bg-alt: #ffffff;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-strong: rgba(255, 255, 255, 0.98);
    --text: #101828;
    --muted: #52607a;
    --line: rgba(16, 24, 40, 0.08);
    --accent: #5b5bd6;
    --accent-2: #0ea5a3;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(124, 92, 255, 0.22), transparent 28%),
        radial-gradient(circle at top right, rgba(45, 212, 191, 0.18), transparent 26%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(255,255,255,0.03), transparent 35%, transparent 65%, rgba(255,255,255,0.02));
}

body.menu-open {
    overflow: hidden;
}

button,
select,
input {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

.page-shell {
    width: min(calc(100% - 32px), 1320px);
    margin: 0 auto;
    padding: 20px 0 32px;
}

.game-topbar,
.glass-panel,
.side-panel-inner,
.popup-content {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.game-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 20px;
    border-radius: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    position: sticky;
    top: 16px;
    z-index: 40;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: 0.08em;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
    box-shadow: 0 14px 28px rgba(124, 92, 255, 0.28);
}

.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand-copy small,
.compact-nav a,
.eyebrow,
.mini-stat span,
.panel-card span,
.stat-item h4,
#info-box,
.text-box,
.status-row,
#dynamicText,
.panel-card p {
    color: var(--muted);
}

.compact-nav,
.topbar-actions,
.button-row,
.field-row,
.status-row,
.panel-tabs,
.side-panel-header,
.stage-header {
    display: flex;
    align-items: center;
}

.compact-nav,
.topbar-actions,
.button-row,
.field-row,
.panel-tabs {
    gap: 12px;
}

.compact-nav a {
    padding: 10px 14px;
    border-radius: 999px;
}


.compact-nav a:hover,
.compact-nav a:focus-visible,
.nav-jump-menu > summary:hover,
.nav-jump-menu > summary:focus-visible {
    background: rgba(255,255,255,0.06);
}

.nav-jump-menu {
    position: relative;
}

.nav-jump-menu > summary {
    list-style: none;
    padding: 10px 14px;
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
    color: var(--muted);
}

.nav-jump-menu > summary::-webkit-details-marker {
    display: none;
}

.nav-jump-menu > summary::after {
    content: "▾";
    margin-left: 8px;
    font-size: 0.8em;
}

.nav-jump-menu[open] > summary::after {
    content: "▴";
}

.nav-jump-list {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 180px;
    display: grid;
    gap: 6px;
    padding: 10px;
    border-radius: 18px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    z-index: 45;
}

.nav-jump-list a {
    padding: 10px 12px;
    border-radius: 12px;
}

.primary-button,
.secondary-button,
.ghost-button,
.tab-button {
    border: 0;
    cursor: pointer;
    padding: 12px 18px;
    border-radius: 999px;
    font: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.primary-button {
    color: white;
    background: linear-gradient(135deg, var(--accent), #9d74ff);
    box-shadow: 0 14px 28px rgba(124, 92, 255, 0.28);
}

.secondary-button,
.ghost-button,
.tab-button,
select,
input {
    color: var(--text);
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--line);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.tab-button:hover {
    transform: translateY(-2px);
}

.tab-button.is-active {
    background: rgba(124, 92, 255, 0.16);
    color: #d8ccff;
}

.game-layout {
    padding-top: 24px;
}

.glass-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}

.board-stage {
    padding: 20px;
}

.play-surface {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.compact-setup-card {
    padding: 16px;
    position: sticky;
    top: 108px;
}

.setup-card-header {
    margin-bottom: 14px;
}

.setup-card-header h2 {
    margin: 0 0 6px;
    font-size: 1.35rem;
}

.setup-card-header p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
    font-size: 0.95rem;
}

.visually-hidden-select {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

.compact-options-stack {
    display: grid;
    gap: 12px;
}

.compact-field {
    position: relative;
}

.compact-field label {
    font-size: 0.92rem;
    font-weight: 600;
}

.segmented-control {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 6px;
    border-radius: 18px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--line);
}

.segment-button {
    border: 0;
    cursor: pointer;
    min-height: 44px;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 14px;
    color: var(--muted);
    background: transparent;
    font: inherit;
    font-weight: 600;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.segment-button:hover {
    color: var(--text);
    background: rgba(255,255,255,0.05);
}

.segment-button.is-active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.95), rgba(88, 209, 193, 0.88));
    box-shadow: 0 12px 24px rgba(61, 91, 196, 0.22);
}

.setup-wide-button {
    width: 100%;
    justify-content: center;
}

.compact-action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.compact-action-row .primary-button,
.compact-action-row .ghost-button {
    width: 100%;
}

.compact-status-row {
    display: grid;
    gap: 6px;
    justify-content: start;
}

.stage-header {
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.eyebrow {
    display: inline-flex;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.75rem;
    color: var(--accent-2);
    margin-bottom: 10px;
}

.stage-header h1,
.side-panel-header h2 {
    margin: 0;
}

.mini-stats-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(110px, 1fr));
    gap: 10px;
    min-width: min(420px, 100%);
}

.mini-stat,
.panel-card,
.stat-item,
.controls-shell,
#info-box,
.text-box,
.popup-content {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.mini-stat {
    padding: 14px;
}

.mini-stat strong {
    display: block;
    color: var(--text);
    font-size: 1.3rem;
    margin-top: 4px;
}

.controls-shell {
    padding: 18px;
    margin-bottom: 0;
}

#game-controls {
    display: grid;
    gap: 12px;
}

.field-group {
    display: grid;
    gap: 8px;
}

.grow {
    flex: 1;
}

.field-row {
    flex-wrap: wrap;
}

select,
input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    outline: none;
}

.remote-panel {
    display: grid;
    gap: 14px;
}

.remote-action-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.remote-action-buttons .segment-button {
    width: 100%;
}

.status-row {
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.board-and-info {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 16px;
    align-items: start;
    min-width: 0;
}

.board-column {
    display: grid;
    gap: 8px;
    justify-items: center;
    min-width: 0;
}

#chess-board {
    display: grid;
    grid-template-columns: repeat(8, 12.5%);
    grid-template-rows: repeat(8, 12.5%);
    gap: 0;
    width: min(100%, 640px);
    max-width: 640px;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid var(--line);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}

.text-box {
    width: min(100%, 640px);
    max-width: 640px;
    min-height: 40px;
    padding: 8px 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

#info-box {
    width: 100%;
    min-height: 100%;
    max-height: 736px;
    overflow: auto;
}

.move-history-panel {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--line);
    border-radius: 22px;
    overflow: hidden;
}

.move-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px 6px !important;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
}

.move-history-header h3 {
    margin: 0;
    font-size: 0.9rem !important;
}

.move-history-header .eyebrow {
    margin-bottom: 4px;
}

.move-history-pill {
    padding: 4px 8px !important;
    border-radius: 999px;
    border: 1px solid rgba(124, 92, 255, 0.28);
    background: rgba(124, 92, 255, 0.12);
    color: #d8ccff;
    font-size: 0.65rem !important;
    font-weight: 700;
}

.move-history-body {
    padding: 10px;
    display: grid;
    align-content: start;
    gap: 4px !important;
    font-family: Inter, Arial, sans-serif;
}

.move-history-empty {
    margin: 0;
    padding: 10px !important;
    border-radius: 16px;
    background: rgba(255,255,255,0.03);
    border: 1px dashed var(--line);
    color: var(--muted);
    line-height: 1.6;
}

.move-history-table {
    display: grid;
    gap: 4px !important;
}

.move-history-head,
.move-history-row {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 4px !important;
    align-items: center;
}

.move-history-head {
    padding: 0 2px 2px !important;
    color: var(--muted);
    font-size: 0.65rem !important;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em !important;
}

.move-history-row {
    padding: 4px 5px !important;
    border-radius: 10px !important;
    border: 1px solid var(--line);
    background: rgba(255,255,255,0.035);
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.move-history-row.is-latest {
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.14), rgba(45, 212, 191, 0.08));
    border-color: rgba(124, 92, 255, 0.32);
}

.move-index {
    width: 22px !important;
    height: 22px !important;
    border-radius: 8px !important;
    display: grid;
    place-items: center;
    background: rgba(124, 92, 255, 0.14);
    color: #d8ccff;
    font-weight: 800;
    font-size: 0.68rem !important;
}

.move-cell {
    min-height: 30px !important;
    padding: 2px 4px !important;
    border-radius: 10px !important;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.04);
    display: flex;
    align-items: center;
    color: var(--text);
    font-weight: 600;
    letter-spacing: 0.01em;
}

.move-cell.is-empty {
    color: rgba(167, 180, 203, 0.5);
    justify-content: center;
}

.move-entry {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 3px !important;
}

.move-piece-icon {
    width: 14px !important;
    height: 14px !important;
    object-fit: contain;
    flex: 0 0 14px !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.22));
}

.move-entry-copy {
    min-width: 0;
    display: grid;
    gap: 0 !important;
}

.move-entry-title {
    color: var(--text);
    font-weight: 700;
    line-height: 1 !important;
    font-size: 0.78rem !important;
}

.move-entry-meta {
    color: var(--muted);
    font-size: 0.54rem !important;
    line-height: 1 !important;
}

.move-history-note {
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.1), rgba(124, 92, 255, 0.08));
    color: var(--text);
    line-height: 1.5;
    text-align: center;
    font-weight: 700;
}

.move-history-note.is-success {
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.16), rgba(124, 92, 255, 0.12));
}

.move-history-note.is-draw {
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.16), rgba(124, 92, 255, 0.08));
}

.move-history-note.is-warning {
    background: linear-gradient(135deg, rgba(248, 113, 113, 0.18), rgba(124, 92, 255, 0.1));
}

.move-history-empty hr,
.move-history-empty .history-divider,
.move-history-empty .move-divider {
    width: 72% !important;
    margin: 8px auto 0 !important;
}

.square {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.piece {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: relative;
}

.light {
    background-color: #f0d9b5;
}

.dark {
    background-color: #8f6a4e;
}

.clicked {
    background-color: #a8d5a8 !important;
}

.kingCheck {
    background-color: #960505 !important;
}

.highlighted {
    width: 100%;
    height: 100%;
    background-color: #d9d21a !important;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.moved {
    width: 100%;
    height: 100%;
    background-color: #b7d7c6 !important;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.popup {
    display: none;
    position: fixed;
    inset: 0;
    min-height: 100vh;
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
    padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
    background: rgba(4, 10, 20, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 120;
    overflow: auto;
}

.popup-content {
    position: relative;
    width: min(calc(100% - 24px), 420px);
    padding: 24px;
    background: var(--surface-strong);
    box-shadow: var(--shadow);
}

.result-popup-card {
    width: min(100%, 460px);
    padding: 28px;
    border-radius: 28px;
    border: 1px solid rgba(255,255,255,0.12);
    background:
        radial-gradient(circle at top right, rgba(124, 92, 255, 0.22), transparent 36%),
        radial-gradient(circle at bottom left, rgba(45, 212, 191, 0.14), transparent 34%),
        var(--surface-strong);
    text-align: center;
}

.result-popup-icon {
    width: 58px;
    height: 58px;
    margin: 0 auto 18px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 1.75rem;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 14px 28px rgba(124, 92, 255, 0.28);
}

.result-popup-copy h2 {
    margin: 10px 0 8px;
    font-size: clamp(1.7rem, 2.4vw, 2rem);
}

.result-badge {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 7px 11px;
    border-radius: 999px;
    background: rgba(124, 92, 255, 0.14);
    border: 1px solid rgba(124, 92, 255, 0.24);
    color: #d8ccff;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#dynamicText {
    line-height: 1.7;
    margin: 0;
    color: var(--muted);
    font-size: 1.02rem;
    text-align: center;
}

.result-popup-actions {
    margin-top: 22px;
    display: flex;
    justify-content: center;
}

.result-popup-actions .primary-button {
    min-width: 170px;
}

.flip-board {
    transform: rotate(180deg);
}

.flip-board .square {
    transform: rotate(180deg);
}

.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--panel-width);
    max-width: 100%;
    height: 100vh;
    padding: 16px;
    transform: translateX(100%);
    transition: transform 0.28s ease;
    z-index: 110;
}

.side-panel.is-open {
    transform: translateX(0);
}

.side-panel::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.46);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
    z-index: -1;
}

.side-panel.is-open::before {
    opacity: 1;
    pointer-events: auto;
}

.side-panel-inner {
    height: 100%;
    overflow: auto;
    padding: 22px;
    border-radius: 28px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.side-panel-header {
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-strong);
    padding-bottom: 16px;
    margin-bottom: 8px;
}

.panel-tabs {
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.panel-section {
    display: none;
}

.panel-section.is-active {
    display: block;
}

.panel-card-grid {
    display: grid;
    gap: 14px;
}

.quick-grid,
.statistics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.single-column {
    grid-template-columns: 1fr;
}

.panel-card,
.stat-item {
    padding: 16px;
}

.panel-card strong,
.stat-item .stat-value {
    display: block;
    margin: 8px 0 0;
    color: var(--text);
}

.statistics-panel h3,
.panel-card h3 {
    margin-top: 0;
}

.stat-item h4 {
    margin: 0;
    font-size: 0.95rem;
}

.stat-item .stat-value {
    font-size: 1.9rem;
    font-weight: 700;
}

#statistics {
    display: grid;
    gap: 16px;
}

@media (max-width: 1100px) {
    .board-and-info {
        grid-template-columns: 1fr;
    }

    #info-box {
        min-height: 180px;
    }
}

@media (max-width: 820px) {
    .game-topbar {
        position: static;
        top: auto;
    }

    .compact-setup-card {
        position: static;
        top: auto;
    }

    #play-area {
        scroll-margin-top: 16px;
    }
}

@media (max-width: 900px) {
    .game-topbar,
    .stage-header {
        flex-direction: column;
        align-items: stretch;
    }

    .compact-nav,
    .topbar-actions,
    .mini-stats-strip {
        min-width: 0;
    }

    .mini-stats-strip {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .page-shell {
        width: min(calc(100% - 20px), 1320px);
        padding-top: 10px;
    }
    .game-topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        gap: 12px;
        padding: 14px 16px;
    }

    .brand {
        min-width: 0;
        align-items: flex-start;
    }

    .brand-copy strong,
    .brand-copy small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar-actions {
        width: 100%;
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        align-items: stretch;
    }

    .topbar-actions > * {
        min-width: 0;
    }

    .topbar-actions .auth-controls {
        grid-column: 1 / -1;
        justify-content: stretch;
    }

    .topbar-actions .auth-user-chip,
    .topbar-actions #auth-logged-out,
    .topbar-actions #auth-open-button {
        width: 100%;
    }

    .compact-nav {
        order: 4;
        grid-column: 1 / -1;
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .compact-nav a,
    .topbar-actions .primary-button,
    .topbar-actions .ghost-button {
        width: 100%;
        justify-content: center;
    }

    .board-stage,
    .side-panel-inner {
        padding: 18px;
    }

    .compact-nav,
    .topbar-actions,
    .button-row,
    .field-row,
    .mini-stats-strip,
    .quick-grid,
    .statistics-grid {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .button-row,
    .field-row,
    .compact-nav,
    .topbar-actions {
        display: flex;
    }

    .mini-stats-strip,
    .quick-grid,
    .statistics-grid {
        display: grid;
    }

    #chess-board,
    .text-box {
        max-width: 100%;
    }

    .piece {
        width: 76%;
        height: 76%;
    }
}


@media (max-width: 1100px) {
    .play-surface {
        grid-template-columns: 1fr;
    }

    .compact-setup-card {
        position: static;
    }

    .board-and-info {
        grid-template-columns: 1fr;
    }

    #info-box {
        max-height: 320px;
    }

    .move-history-panel {
        min-height: 320px;
    }
}

@media (max-width: 820px) {
    .stage-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .mini-stats-strip {
        width: 100%;
        min-width: 0;
    }

    .compact-action-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .page-shell {
        width: min(calc(100% - 20px), 1320px);
        padding-top: 14px;
    }

    .game-topbar {
        padding: 14px 16px;
        flex-wrap: wrap;
    }

    .compact-nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .board-stage {
        padding: 14px;
    }

    .mini-stats-strip {
        grid-template-columns: 1fr;
    }

    .segmented-control {
        grid-template-columns: 1fr 1fr;
    }
}

.segment-button.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (max-width: 640px) {
    .move-history-head,
    .move-history-row {
        grid-template-columns: 36px minmax(0, 1fr) minmax(0, 1fr);
        gap: 6px;
    }

    .move-history-row {
        padding: 7px 8px;
    }

    .move-index {
        width: 26px;
        height: 26px;
        font-size: 0.76rem;
    }

    .move-cell {
        min-height: 42px;
        padding: 5px 6px;
    }

    .move-piece-icon {
        width: 18px;
        height: 18px;
        flex-basis: 18px;
    }

    .move-entry {
        gap: 6px;
    }

    .move-entry-title {
        font-size: 0.82rem;
        line-height: 1.05;
    }

    .move-entry-meta {
        font-size: 0.62rem;
        line-height: 1.05;
    }

    .result-popup-card {
        padding: 22px;
    }
}

/* Connect 4 additions */
.connect-copy-box {
    width: min(100%, 640px);
    text-align: center;
}

.connect4-stage {
    position: relative;
    width: min(100%, 640px);
    display: grid;
    gap: 12px;
    justify-items: stretch;
}

.connect4-column-hints {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.connect4-column-button {
    min-height: 48px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,0.05);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.connect4-column-button:hover,
.connect4-column-button:focus-visible {
    transform: translateY(-2px);
    background: rgba(124, 92, 255, 0.12);
    border-color: rgba(124, 92, 255, 0.36);
}

.connect4-column-button.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.connect4-drop-preview {
    position: absolute;
    top: 60px;
    left: 0;
    width: calc((100% - 48px) / 7);
    aspect-ratio: 1;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    z-index: 5;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
    transition: transform 0.16s ease, opacity 0.16s ease;
}

.connect4-drop-preview.is-visible {
    opacity: 0.45;
}

.connect4-drop-preview.is-red,
.connect4-piece.is-red {
    background: radial-gradient(circle at 32% 28%, #ffb3ad 0%, #ff655a 28%, #e62e24 60%, #8d0808 100%);
}

.connect4-drop-preview.is-yellow,
.connect4-piece.is-yellow {
    background: radial-gradient(circle at 32% 28%, #fff7a3 0%, #ffe367 28%, #ffb703 60%, #b36a00 100%);
}

.connect4-board {
    position: relative;
    width: 100%;
    aspect-ratio: 7 / 6;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(0, 1fr));
    gap: 10px;
    padding: 18px;
    border-radius: 28px;
    background: linear-gradient(180deg, #2167ff 0%, #0e42b5 100%);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 30px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.connect4-board::before {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 22px;
    border: 1px solid rgba(255,255,255,0.08);
    pointer-events: none;
}

.connect4-cell {
    position: relative;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(3, 17, 57, 0.94) 0%, rgba(2, 14, 48, 0.97) 65%, rgba(1, 8, 24, 1) 100%);
    box-shadow: inset 0 8px 18px rgba(0, 0, 0, 0.35), inset 0 -4px 12px rgba(255,255,255,0.06);
    overflow: hidden;
}

.connect4-cell.is-winning {
    box-shadow: inset 0 8px 18px rgba(0, 0, 0, 0.35), 0 0 0 3px rgba(255,255,255,0.2), 0 0 22px rgba(255, 227, 103, 0.55);
}

.connect4-piece {
    position: absolute;
    inset: 7%;
    border-radius: 50%;
    transform: translateY(-130%);
    opacity: 0;
}

.connect4-piece.is-settled {
    opacity: 1;
    transform: translateY(0);
}

.connect4-piece.is-dropping {
    transition: transform 360ms cubic-bezier(0.2, 0.9, 0.2, 1), opacity 140ms ease;
}

.connect4-piece.is-winning-piece {
    box-shadow: 0 0 0 3px rgba(255,255,255,0.18), 0 0 20px rgba(255,255,255,0.22);
}

.connect4-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.connect4-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--line);
}

.connect4-chip-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

@media (max-width: 900px) {
    .connect4-stage {
        width: min(100%, 100vw - 48px);
    }

    .connect4-board {
        gap: 8px;
        padding: 14px;
    }
}

@media (max-width: 640px) {
    .connect4-column-hints {
        gap: 6px;
    }

    .connect4-column-button {
        min-height: 42px;
        font-size: 0.92rem;
        padding: 8px 4px;
    }

    .connect4-board {
        gap: 6px;
        padding: 12px;
        border-radius: 22px;
    }
}


.stage-inline-ad {
    flex: 1 1 360px;
    min-width: 220px;
    max-width: 560px;
    padding: 12px 14px;
    border-radius: var(--radius-lg);
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--line);
    overflow: hidden;
}

.adsense-label {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stage-inline-ad .adsbygoogle {
    min-height: 70px;
}

@media (max-width: 980px) {
    .stage-inline-ad {
        order: 3;
        width: 100%;
        max-width: none;
    }
}

.panel-contact {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-contact > span {
    display: block;
    margin-bottom: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.8;
}

.panel-contact p {
    margin: 0;
}

.panel-contact a {
    color: #8ab4ff;
    text-decoration: none;
}

.panel-contact a:hover {
    text-decoration: underline;
}

.mobile-screen-toggle {
    display: none;
}

@media (max-width: 820px) {
    body {
        padding-bottom: 124px;
    }

    .game-topbar {
        position: static;
    }

    .compact-nav {
        display: none !important;
    }

    .stage-header {
        gap: 12px;
        margin-bottom: 14px;
    }

    .stage-header > div:first-child h1 {
        margin-bottom: 0;
    }

    .stage-inline-ad {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 72px;
        z-index: 32;
        max-width: none;
        margin: 0;
        min-width: 0;
        padding: 10px 12px;
        border-radius: 20px;
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
        background: rgba(11, 22, 39, 0.96);
    }

    html[data-theme="light"] .stage-inline-ad {
        background: rgba(255, 255, 255, 0.98);
    }

    .stage-inline-ad .adsbygoogle {
        min-height: 52px;
    }

    .board-stage {
        border-radius: 28px;
    }

    .play-surface {
        gap: 16px;
    }

    .controls-shell,
    .board-column,
    .move-history-panel {
        border-radius: 24px;
    }

    .board-and-info {
        gap: 16px;
    }

    body.mobile-pre-game .board-and-info {
        display: none;
    }

    body.mobile-in-game .controls-shell {
        display: none;
    }

    body.mobile-in-game .stage-header {
        margin-bottom: 10px;
    }

    body.mobile-in-game .mini-stats-strip {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .mobile-screen-toggle {
        position: fixed;
        right: 12px;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 86px);
        z-index: 38;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 12px 16px;
        border-radius: 999px;
        border: 1px solid var(--line);
        background: linear-gradient(135deg, var(--accent), #9d74ff);
        color: #fff;
        box-shadow: 0 14px 28px rgba(124, 92, 255, 0.28);
        font: inherit;
    }
}


@media (max-width: 820px) {
    body {
        padding-bottom: 176px;
    }

    .game-topbar {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 12px;
        padding: 16px 18px;
    }

    .game-topbar .compact-nav,
    .game-topbar #theme-toggle,
    .game-topbar #menu-toggle,
    .game-topbar .auth-user-label,
    .game-topbar .auth-status-badge,
    .game-topbar .auth-rank-badge {
        display: none !important;
    }

    .game-topbar .topbar-actions {
        width: auto;
        gap: 0;
    }

    .game-topbar .auth-controls {
        justify-content: flex-end;
    }

    .game-topbar .auth-user-chip {
        padding: 4px 6px 4px 4px;
        border: 1px solid var(--line);
        background: rgba(255,255,255,0.04);
        gap: 8px;
    }

    .game-topbar .auth-user-copy {
        align-items: flex-end;
    }

    .game-topbar .auth-user-name {
        max-width: 24vw;
    }

    .game-topbar .auth-user-actions .ghost-button,
    .game-topbar .auth-user-actions .auth-link-button {
        height: 30px;
        min-height: 30px;
        padding: 0 10px;
        font-size: 0.82rem;
    }

    .game-topbar #auth-logged-out .ghost-button,
    .game-topbar #auth-logged-out .primary-button {
        height: 34px;
        min-height: 34px;
        padding: 0 12px;
        font-size: 0.86rem;
        white-space: nowrap;
    }

    .stage-inline-ad {
        left: 10px;
        right: 10px;
        bottom: max(6px, env(safe-area-inset-bottom, 0px));
        z-index: 30;
        padding: 6px 12px;
        min-height: 34px;
        max-height: 34px;
        border-radius: 14px;
        overflow: hidden;
    }

    .stage-inline-ad .adsense-label {
        display: none;
    }

    .stage-inline-ad .adsbygoogle {
        min-height: 24px !important;
        max-height: 24px !important;
    }

    .mini-stats-strip {
        display: none !important;
    }

    .mobile-screen-toggle {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 86px);
    }
}


.mobile-page-ad-box {
    display: none;
}

@media (max-width: 820px) {
    .stage-header .stage-inline-ad {
        display: none !important;
    }

    .mobile-page-ad-box {
        display: block;
        margin-top: 16px;
        padding: 12px 14px;
        border-radius: 18px;
        border: 1px solid var(--line);
        background: var(--surface-soft);
        box-shadow: var(--shadow);
    }

    .mobile-page-ad-box .adsbygoogle {
        min-height: 52px !important;
        max-height: 72px;
    }
}


/* Debug board editor */
.debug-editor {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid rgba(120, 140, 255, 0.28);
    background: rgba(16, 22, 48, 0.72);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.debug-editor[hidden] { display: none !important; }
.debug-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.debug-editor-title {
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.82;
}
.debug-editor-toggle {
    border: 1px solid rgba(140, 154, 255, 0.35);
    background: rgba(108, 92, 231, 0.18);
    color: inherit;
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
}
.debug-editor-toggle.is-active {
    background: rgba(108, 92, 231, 0.34);
}
.debug-editor-panel[hidden] { display: none !important; }
.debug-editor-copy {
    margin: 0 0 10px;
    font-size: 0.9rem;
    opacity: 0.82;
}
.debug-editor-pieces,
.debug-editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.debug-editor-piece,
.debug-editor-action {
    min-width: 42px;
    min-height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(140, 154, 255, 0.24);
    background: rgba(255,255,255,0.04);
    color: inherit;
    cursor: pointer;
}
.debug-editor-piece.is-selected,
.debug-editor-action:hover,
.debug-editor-piece:hover {
    border-color: rgba(120, 200, 255, 0.72);
    box-shadow: 0 0 0 1px rgba(120, 200, 255, 0.2);
}
.debug-editor-piece {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    font-size: 1.1rem;
    font-weight: 700;
}
.debug-editor-piece img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    pointer-events: none;
}
.debug-editor-piece.is-eraser {
    font-size: 0.8rem;
    min-width: 58px;
    padding: 6px 10px;
}
.debug-editor-piece-dot {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-block;
}
.debug-editor-piece-dot.is-red { background: #e34f5f; }
.debug-editor-piece-dot.is-black { background: #252a36; border: 2px solid rgba(255,255,255,0.3); }
.debug-editor-piece-dot.is-yellow { background: #f1c94a; }
.debug-editor-piece-dot.is-king::after {
    content: "K";
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    font-size: 0.72rem;
    font-weight: 800;
    color: #fff;
}
.debug-editor-action {
    padding: 8px 12px;
    min-width: auto;
}
.debug-editor-board-active {
    outline: 2px dashed rgba(120, 200, 255, 0.24);
    outline-offset: 6px;
}
@media (max-width: 820px) {
    .debug-editor {
        margin-bottom: 10px;
        padding: 10px;
    }
    .debug-editor-toggle,
    .debug-editor-action {
        min-height: 40px;
    }
}


.result-popup-card {
    overflow: hidden;
}

.result-popup-card::before,
.result-popup-card::after {
    content: "";
    position: absolute;
    inset: -12%;
    pointer-events: none;
    opacity: 0;
}

.result-popup-card.result-variant-win::before {
    background:
        radial-gradient(circle at 16% 18%, rgba(255, 214, 102, 0.95) 0 4px, transparent 5px),
        radial-gradient(circle at 28% 8%, rgba(255, 99, 132, 0.9) 0 3px, transparent 4px),
        radial-gradient(circle at 82% 20%, rgba(45, 212, 191, 0.92) 0 4px, transparent 5px),
        radial-gradient(circle at 72% 10%, rgba(124, 92, 255, 0.9) 0 3px, transparent 4px),
        linear-gradient(135deg, transparent 47%, rgba(255,255,255,0.35) 49%, transparent 51%),
        linear-gradient(225deg, transparent 47%, rgba(255,255,255,0.28) 49%, transparent 51%);
    animation: resultConfettiBurst 1100ms ease-out forwards;
}

.result-popup-card.result-variant-win::after {
    background:
        linear-gradient(115deg, transparent 46%, rgba(255, 214, 102, 0.42) 49%, transparent 52%),
        linear-gradient(245deg, transparent 46%, rgba(45, 212, 191, 0.34) 49%, transparent 52%);
    animation: resultRibbonSweep 1200ms ease-out forwards;
}

.result-popup-card.result-variant-loss::before {
    background:
        radial-gradient(circle at 22% 18%, rgba(148, 163, 184, 0.18) 0 7px, transparent 8px),
        radial-gradient(circle at 38% 10%, rgba(148, 163, 184, 0.14) 0 9px, transparent 10px),
        radial-gradient(circle at 70% 16%, rgba(148, 163, 184, 0.16) 0 7px, transparent 8px),
        radial-gradient(circle at 84% 12%, rgba(148, 163, 184, 0.12) 0 9px, transparent 10px);
    animation: resultSoftRain 1400ms ease-out forwards;
}

.result-popup-card.result-variant-loss::after {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.02), rgba(15, 23, 42, 0.2));
    animation: resultDimPulse 1000ms ease-out forwards;
}

.result-popup-card.result-variant-draw::before {
    background: radial-gradient(circle at 50% 0%, rgba(255,255,255,0.14), transparent 52%);
    animation: resultDrawGlow 900ms ease-out forwards;
}

@keyframes resultConfettiBurst {
    0% { opacity: 0; transform: translateY(12px) scale(0.92); }
    20% { opacity: 1; }
    100% { opacity: 1; transform: translateY(-18px) scale(1.04); }
}

@keyframes resultRibbonSweep {
    0% { opacity: 0; transform: scale(0.92) rotate(0deg); }
    25% { opacity: 0.95; }
    100% { opacity: 0.55; transform: scale(1.04) rotate(6deg); }
}

@keyframes resultSoftRain {
    0% { opacity: 0; transform: translateY(-16px); }
    25% { opacity: 0.8; }
    100% { opacity: 1; transform: translateY(18px); }
}

@keyframes resultDimPulse {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes resultDrawGlow {
    0% { opacity: 0; transform: scale(0.94); }
    100% { opacity: 1; transform: scale(1.02); }
}

/* Keep the mobile status area stable when player names change length. */
.connect-copy-box {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 760px) {
    .connect-copy-box {
        min-height: 56px;
    }
}

/* ── AI Difficulty control ──────────────────────────────────────────────── */
.diff-player-field { margin-top:8px; }
.diff-player-field .diff-segmented { display:flex; gap:4px; }
.diff-opt-wrap { position:relative; flex:1; }
.diff-opt-wrap .segment-button { width:100%; text-align:center; padding:10px 4px; }
.diff-opt-wrap .segment-button.is-locked { opacity:0.38; cursor:not-allowed; }
.diff-tooltip {
    position:absolute; bottom:calc(100% + 8px); left:50%; transform:translateX(-50%);
    background:var(--surface-strong,#1a1a2e); border:1px solid var(--line,rgba(255,255,255,.12));
    border-radius:10px; padding:8px 12px; font-size:0.76rem; line-height:1.45;
    color:var(--text,#e8e6f0); white-space:nowrap; pointer-events:none;
    opacity:0; transition:opacity .15s; z-index:200;
}
.diff-opt-wrap:hover .diff-tooltip { opacity:1; }
.diff-opt-wrap:first-child .diff-tooltip { left:0; transform:none; }
.diff-opt-wrap:last-child .diff-tooltip { left:auto; right:0; transform:none; }

/* ── Quick Setup UI improvements ─────────────────────────────────────── */
/* Game mode buttons with built-in sublabel */
.segment-button.has-sublabel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    height: auto;
    padding: 8px 10px;
    line-height: 1.2;
}
.seg-label {
    font-size: 0.88rem;
    font-weight: 600;
}
.seg-sublabel {
    font-size: 0.65rem;
    font-weight: 400;
    opacity: 0.78;
    line-height: 1.2;
}
.segment-button.has-sublabel.is-active .seg-sublabel { opacity: 0.9; }

/* Game mode contextual hint (active-mode description below toggle) */
.game-mode-hint {
    display: block;
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 5px;
    line-height: 1.3;
}

/* VS divider between player rows */
.player-vs-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin: 2px 0;
    user-select: none;
}
.player-vs-divider::before,
.player-vs-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

/* AI difficulty label above buttons */
.diff-field-header { margin-bottom: 5px; }
.diff-field-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Remote setup: Create | Code | Join layout */
.remote-setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 8px;
    align-items: stretch;
}
.remote-create-btn {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
}
.remote-join-btn {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
}
.code-input-wrapper {
    grid-column: 2;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
}
.code-input-wrapper #join-code {
    width: 100%;
    text-align: center;
    font-size: 1.05rem;
    letter-spacing: 0.12em;
}
.copy-code-btn {
    font-size: 0.75rem;
    padding: 5px 8px;
    min-height: auto;
    height: auto;
    line-height: 1.3;
    width: 100%;
}

/* ── Side panel guide & stats improvements ─────────────────────────── */
/* Collapsible guide sections */
.guide-section { border-bottom: 1px solid var(--line); padding: 0; }
.guide-section:last-child { border-bottom: none; }
.guide-section > summary {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 0; font-size: 0.9rem; font-weight: 600;
    cursor: pointer; list-style: none; color: var(--text);
    user-select: none;
}
.guide-section > summary::-webkit-details-marker { display: none; }
.guide-section > summary::after {
    content: '+'; font-size: 1rem; color: var(--muted);
    transition: transform .2s;
}
.guide-section[open] > summary::after { content: '\2212'; }
.guide-body { padding: 0 0 12px 0; font-size: 0.84rem; color: var(--muted); line-height: 1.6; }
.guide-body p { margin: 0 0 8px 0; }
.guide-body ul { margin: 0 0 8px 0; padding-left: 18px; }
.guide-body li { margin-bottom: 4px; }
.guide-body ol { margin: 0 0 8px 0; padding-left: 18px; }
.game-intro-text { font-size: 0.85rem; color: var(--muted); line-height: 1.6; margin: 0 0 14px 0; }

/* WLD stats blocks */
.stats-section-title {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--muted); margin: 14px 0 8px 0;
}
.wld-row { display: flex; gap: 8px; margin-bottom: 4px; }
.wld-cell {
    flex: 1; background: rgba(255,255,255,0.04); border: 1px solid var(--line);
    border-radius: 10px; padding: 8px 6px; text-align: center;
    display: flex; flex-direction: column; gap: 2px;
}
.wld-cell .wld-label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: 0.06em; }
.wld-cell .wld-value { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.wld-cell.wld-win .wld-value { color: #4ade80; }
.wld-cell.wld-loss .wld-value { color: #f87171; }
.wld-cell.wld-draw .wld-value { color: var(--accent-2); }
.personal-best-row { margin-bottom: 10px; }
.personal-best-row-label { font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; }
.stats-signin-note { font-size: 0.82rem; color: var(--muted); padding: 8px 0; }
.stats-signin-note a { color: var(--accent-2); text-decoration: underline; }

/* Leaderboard preview */
.lb-preview-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 0.82rem;
}
.lb-preview-row:last-child { border-bottom: none; }
.lb-rank { font-weight: 700; width: 20px; color: var(--muted); flex-shrink: 0; }
.lb-rank.gold { color: #f59e0b; }
.lb-rank.silver { color: #94a3b8; }
.lb-rank.bronze { color: #b45309; }
.lb-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-size: 0.75rem; color: var(--muted); }
.lb-preview-more { display: block; text-align: right; font-size: 0.78rem; color: var(--accent-2); margin-top: 8px; text-decoration: none; }
.lb-preview-more:hover { text-decoration: underline; }
.lb-preview-empty { font-size: 0.82rem; color: var(--muted); padding: 8px 0; }

/* Other games list in About */
.other-games-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.other-game-item { display: flex; flex-direction: column; gap: 2px; }
.other-game-item a { font-weight: 600; color: var(--text); }

.legal-footer {
    display: block;
    width: 100%;
    margin-top: 40px;
    padding: 20px 16px 28px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 400;
    text-align: center;
}

.legal-footer__links {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    text-align: center;
}

.legal-footer__links a,
.legal-footer div {
    color: var(--muted);
    font-weight: 400;
    text-align: center;
    text-decoration: none;
}

.legal-footer__links a:hover,
.legal-footer__links a:focus-visible {
    color: var(--accent-2);
    text-decoration: underline;
}
.other-game-item a:hover { color: var(--accent-2); }
.other-game-item span { font-size: 0.8rem; color: var(--muted); }


.email-image-link {
    display: inline-flex;
    align-items: center;
    margin-top: 8px;
    border-radius: 12px;
}

.email-image {
    display: block;
    max-width: min(100%, 365px);
    height: auto;
}

.social-follow {
    margin-top: 14px;
}

.social-follow__title {
    display: block;
    margin-bottom: 10px;
    color: var(--muted, rgba(255, 255, 255, 0.72));
    font-size: 0.86rem;
    line-height: 1.5;
}

.social-follow__links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.social-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 11px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: #eef3ff;
    font-size: 0.84rem;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.social-link svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.social-link:hover,
.social-link:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(138, 180, 255, 0.55);
    background: rgba(138, 180, 255, 0.14);
    text-decoration: none;
}

@media (max-width: 480px) {
    .social-follow__links {
        gap: 8px;
    }

    .social-link {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
}
