.main {
    margin-left: var(--sidebar-width);
    height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column; align-items: stretch;
    transition: margin-left .25s ease;
}
body.compact .main { margin-left: var(--sidebar-compact); }

.page-header {
    height: 85px; padding: 0 40px;
    display: flex; align-items: center; flex-shrink: 0;
}
.full-divider {
    position: fixed; top: 85px; left: 0; right: 0;
    height: 1px; background: var(--border); z-index: 150;
}
.page-home-link {
    font-size: 16px; font-weight: 700; color: var(--text);
    text-decoration: none; letter-spacing: .3px;
}
.page-home-link:hover { opacity: .75; }
.page-home-link .ath { color: var(--accent); }

.page-content {
    flex: 1; padding: 48px 40px 64px;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
}

.game-card {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 10px; padding: 32px;
    display: flex; gap: 32px;
    box-shadow: 0 4px 32px rgba(0,0,0,.35);
}

.board-wrap {
    position: relative;
}

#board {
    background: #000;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: block;
}

#hud {
    min-width: 10rem;
    display: flex; flex-direction: column; gap: 4px;
}
.hud-label {
    font-size: 11px; font-weight: 700; letter-spacing: 1.2px;
    text-transform: uppercase; color: var(--text-muted);
    margin-top: 20px;
}
.hud-label:first-child { margin-top: 0; }
.hud-value {
    font-size: 28px; font-weight: 800; color: var(--accent);
}

body.grey-mode #board { background: #000; }

/* ── Game Over overlay ── */
.game-over-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.82);
    border-radius: var(--radius);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; padding: 24px; text-align: center;
}
.game-over-overlay[hidden] {
    display: none;
}
.game-over-title {
    font-size: 22px; font-weight: 800; color: var(--accent);
    text-transform: uppercase; letter-spacing: 1.5px;
}
.game-over-score {
    font-size: 40px; font-weight: 900; color: var(--text);
}
#scoreForm {
    display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 220px;
}
#playerNameInput {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 14px;
    padding: 9px 12px; outline: none; text-align: center;
    font-family: inherit;
}
#playerNameInput:focus { border-color: var(--accent); }
.btn {
    background: var(--accent); border: none; border-radius: var(--radius);
    color: #111; font-size: 13px; font-weight: 700; padding: 9px 16px;
    cursor: pointer; white-space: nowrap; transition: opacity .15s, transform .1s;
    font-family: inherit;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-ghost {
    background: none; border: 1px solid var(--border);
    color: var(--text-muted);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); transform: none; }
.score-feedback {
    font-size: 12px; min-height: 14px;
}
.score-feedback.success { color: #55c878; }
.score-feedback.error { color: #e06060; }

/* ── Highscore list ── */
.highscore-list {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column; gap: 6px;
    font-size: 13px;
}
.highscore-list li {
    display: flex; justify-content: space-between; gap: 8px;
    color: var(--text-muted);
}
.highscore-list li .hs-name {
    color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.highscore-list li .hs-score {
    color: var(--accent); font-weight: 700; flex-shrink: 0;
}
.highscore-list .empty {
    color: var(--text-muted); font-style: italic;
}

button.nav-item {
    border: none; background: none; width: 100%; text-align: left;
    font-family: inherit;
}
body.compact button.nav-item { width: auto; }

/* ── Help overlay ── */
.help-overlay {
    position: fixed; inset: 0; z-index: 400;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.help-overlay[hidden] {
    display: none;
}
.help-card {
    position: relative;
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 10px; padding: 32px;
    max-width: 420px; width: 100%;
    box-shadow: 0 4px 32px rgba(0,0,0,.35);
}
.help-card h2 {
    font-size: 18px; font-weight: 800; color: var(--text);
    margin: 0 0 20px;
}
.help-section + .help-section {
    margin-top: 24px;
}
.help-section h3 {
    font-size: 11px; font-weight: 700; letter-spacing: 1.2px;
    text-transform: uppercase; color: var(--accent);
    margin: 0 0 10px;
}
.help-section ul {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column; gap: 8px;
}
.help-section li {
    display: flex; align-items: center; gap: 10px;
    font-size: 14px; color: var(--text);
}
.help-section kbd {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text);
    font-family: inherit; font-size: 12px;
    padding: 2px 8px; min-width: 20px; text-align: center;
}
.help-close {
    position: absolute; top: 16px; right: 16px;
    background: none; border: none; color: var(--text-muted);
    font-size: 16px; cursor: pointer; padding: 4px;
}
.help-close:hover { color: var(--text); }

@media (max-width: 768px) {
    .main { margin-left: 0; }
    body.compact .main { margin-left: 0; }
}

@media (max-width: 600px) {
    .page-content { padding: 24px 16px; }
    .game-card { flex-direction: column; align-items: center; padding: 22px; }
}

/* ── Touch controls: swipe/tap directly on the board, only on touch devices ── */
.touch-pause-btn {
    display: none;
}
@media (hover: none) and (pointer: coarse) {
    #board {
        touch-action: none;
    }
    .touch-pause-btn {
        display: flex; align-items: center; justify-content: center;
        position: absolute; top: 8px; right: 8px;
        width: 34px; height: 34px;
        background: rgba(0,0,0,0.5); border: 1px solid var(--border);
        border-radius: var(--radius); color: var(--accent);
        font-size: 14px; z-index: 10;
        touch-action: manipulation; -webkit-tap-highlight-color: transparent;
    }
    .touch-pause-btn:active { background: var(--accent-dim); }
}
