/* ============================================================================
   N-Back — game-specific styles.
   Loaded in <head>, BEFORE base.css (which ships with bars.html and wins
   specificity ties). Only rules base.css cannot override — or deliberately
   overrides of it — live here. Shared components (.btn, .card, .screen,
   .bottom-dock, .modal-*, .hidden, .help-icon) come from base.css.
   ========================================================================== */

/* --- Page-local variables --- */
/* (The --bg / --text / --accent / --success / --error aliases are owned by
   base.css :root, which loads later and wins — nback's old copies were inert.) */
:root {
    --text-contrast: oklch(0.2 0 0);
    --font-main: var(--global-font-main);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --grid-cols: 3;
    /* Set by the header-sync patch in nback.js. Currently inert: base.css
       .screen { inset: 0 } wins over any top offset. Kept for zero-change. */
    --header-offset: var(--global-header-height, 72px);
    --grid-cell: var(--bg-surface-2);
}

/* Deliberate drift: nback pins its own palette for the dark-ish themes
   instead of inheriting the global theme tokens. These beat the base.css
   :root aliases on specificity, so they are load-bearing. */
body[data-theme="dark"],
body[data-theme="nord"],
body[data-theme="synth"],
body[data-theme="mocha"],
body[data-theme="forest"] {
    --bg-body: oklch(0.22 0.02 280);
    --bg-surface: oklch(0.28 0.02 280 / 0.6);
    --bg-surface-2: oklch(0.35 0.03 280);
    --border: oklch(100.00% 0.000 89.9 / 0.05);
    --text-primary: oklch(0.95 0 0);
    --text-secondary: oklch(0.7 0 0);
    --text-contrast: oklch(0.2 0 0);
    --success: oklch(70% 0.18 145);
    --error: oklch(60% 0.2 25);
}

body[data-theme="amoled"] {
    --bg-body: oklch(0 0 0);
    --bg-surface: oklch(0.1 0 0 / 0.5);
    --bg-surface-2: oklch(0.15 0 0);
    --border: oklch(100.00% 0.000 89.9 / 0.04);
    --text-primary: oklch(0.95 0 0);
    --text-secondary: oklch(0.6 0 0);
    --text-contrast: oklch(0.2 0 0);
    --accent: var(--global-accent);
    --success: oklch(70% 0.18 145);
    --error: oklch(60% 0.2 25);
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    background: linear-gradient(135deg, var(--bg-body), var(--bg-surface-2));
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* --- Screen delta over base.css .screen (position/inset/transition/transform
   come from base.css; nback only adds the opaque background + clipping) --- */
.screen {
    background: var(--bg-body);
    overflow: hidden;
}

/* Screens are position:absolute, so they ignore the body's sidebar
   padding. Offset them by the fixed sidebar width on desktop, and go
   full-width when the nav is hidden (e.g. during a live session).
   !important beats base.css .screen { inset: 0 } — e2e measures this. */
@media (min-width: 769px) {
    .screen { left: var(--sidebar-w-current, 80px) !important; }
    body.global-hide-nav .screen { left: 0 !important; }
}

/* --- Content scroll delta (base.css owns padding/overflow/flex) --- */
.content-scroll {
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Desktop: leave room under the settings so the floating START button never
   permanently covers the last row of cards. */
@media (min-width: 769px) {
    #screen-menu .content-scroll {
        padding-bottom: 120px;
    }
}

.container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* --- Bottom dock delta (base.css owns position/padding/background/border/
   gap/z-index; the mobile safe-area bottom offset must beat it) --- */
.bottom-dock {
    -webkit-backdrop-filter: blur(12px);
}

/* Desktop: keep the dock full-width (base.css's 90%-wide rounded tray left
   stray side gaps). The START dock itself is transparent — just the button,
   anchored bottom-right. */
@media (min-width: 769px) {
    body .bottom-dock {
        width: 100%;
        left: 0;
        transform: none;
        border-radius: 0;
        border-top: 1px solid var(--border);
    }

    #screen-menu .bottom-dock {
        background: transparent;
        border: none;
        box-shadow: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        justify-content: center;
        padding-right: var(--s-4);
    }

    #screen-menu .bottom-dock .btn-primary {
        margin: 0 auto;
        min-width: 400px;
        max-width: 560px;
    }
}

@media (max-width: 768px) {
    /* The menu + report screens keep the global bottom nav visible (z 9998),
       so their docks must sit ABOVE it or START gets clipped. Extend the dock
       background to the viewport edge (padding, not a floating bottom offset)
       so nothing scrolls through the gap. The game screen covers the nav
       (z 10000) and keeps its dock flush to the bottom. */
    #screen-menu .bottom-dock,
    #screen-report .bottom-dock {
        bottom: 0 !important;
        padding-bottom: calc(90px + env(safe-area-inset-bottom)) !important;
    }

    #screen-game .bottom-dock {
        bottom: max(8px, env(safe-area-inset-bottom)) !important;
    }

    #screen-menu .content-scroll,
    #screen-report .content-scroll {
        padding-bottom: 240px;
    }

    #screen-menu .content-scroll {
        padding-top: 68px;
    }
}

/* Start button - centered, prominent CTA */
.bottom-dock .btn-primary {
    max-width: 560px;
    margin: 0 auto;
    padding: var(--s-3) var(--s-8);
    font-size: var(--fs-xl);
}

@media (max-width: 768px) {
    .bottom-dock .btn-primary {
        max-width: 100%;
        padding: var(--s-4) var(--s-6);
        font-size: var(--fs-xl);
    }
}

/* --- Component deltas over base.css ---
   .btn: positions and clips the absolute .btn-timer-overlay countdown bar.
   .card: anchors the absolute children (e.g. chart-empty) and keeps the
   historic vertical rhythm; base.css .card sets neither. */
.btn {
    position: relative;
    overflow: hidden;
}

.card {
    margin-bottom: var(--s-4);
    position: relative;
}

@media (max-width: 767px) {
    #stats-graphs-area {
        height: auto !important;
        min-height: 220px;
        max-height: 300px;
    }
}

.loading-shimmer {
    display: inline-block;
    background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--border) 50%, var(--bg-surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    color: transparent !important;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.card-header {
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--s-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-transform: none;
    letter-spacing: -0.2px;
}

select {
    background: var(--bg-surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-sm);
    font-size: var(--fs-md);
    font-weight: 500;
    font-family: inherit;
    outline: none;
    min-width: 100px;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
}

select:hover {
    border-color: var(--text-secondary);
    background: var(--bg-surface);
}

.stepper-mini {
    display: flex;
    align-items: center;
    background: transparent;
    gap: var(--s-1);
}

.stepper-mini button {
    width: 36px;
    height: 36px;
    background: var(--bg-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-xl);
    font-weight: 300;
    cursor: pointer;
    border-radius: var(--r-sm);
    user-select: none;
    border: 1px solid var(--border);
    transition: all 0.2s var(--ease-smooth);
}

.stepper-mini button:hover {
    border-color: var(--text-secondary);
    background: var(--bg-surface);
}

.stepper-mini button:active {
    background: var(--text-primary);
    color: var(--bg-body);
}

.stepper-mini span {
    min-width: 40px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: var(--fs-md);
}

.dash-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-3);
    margin-bottom: 0;
}

.dash-col {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-surface-2);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
}

.dash-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.dash-label {
    font-size: var(--fs-2xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
    font-weight: 600;
}

.dash-val {
    font-size: var(--fs-2xl);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.2px;
}

.dash-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-xl);
    font-weight: 400;
    cursor: pointer;
    color: var(--text-secondary);
    box-shadow: 0 4px 10px oklch(0.00% 0.000 0.0 / 0.05);
    transition: transform 0.2s, background 0.2s, color 0.2s;
}

.dash-btn:active {
    background: var(--accent);
    color: var(--text-contrast);
    border-color: transparent;
}

.quick-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: var(--s-3);
}

.qs-item {
    text-align: center;
}

.qs-val {
    font-size: 2.0rem;
    font-weight: 400;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.qs-label {
    font-size: var(--fs-2xs);
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: var(--s-1);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: var(--s-2);
    margin-bottom: var(--s-2);
}

@media (min-width: 768px) {
    .mode-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: var(--s-3);
    }

    .qs-label {
        font-size: var(--fs-sm);
    }
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-3);
}

.settings-card {
    background: oklch(100.00% 0.000 89.9 / 0.02);
    padding: var(--s-3);
    border-radius: var(--r-sm);
    border: 1px dashed var(--border);
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-3);
}

@media (min-width: 768px) {
    .settings-card {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--s-4) var(--s-6);
    }

    .settings-row {
        margin-bottom: 0 !important;
    }
}

.mode-tile {
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--s-2) var(--s-1);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s var(--ease-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 84px;
    position: relative;
    overflow: hidden;
}

.mode-tile:hover {
    transform: translateY(-2px);
    background: var(--bg-surface);
    border-color: var(--accent);
}

.mode-tile .icon {
    font-size: var(--fs-2xl);
    margin-bottom: var(--s-1);
    opacity: 0.6;
    transition: all 0.3s;
}

.mode-tile .label {
    font-size: var(--fs-xs);
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.mode-tile.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 8px 24px var(--accent-glow);
    transform: scale(1.02);
    z-index: 2;
}

.mode-tile.selected .icon {
    opacity: 1;
    color: white;
    transform: scale(1.1);
}

.mode-tile.selected .label {
    color: white;
    opacity: 0.95;
}

/* Checkmark indicator for selected state */
.mode-tile::after {
    content: "✓";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 18px;
    height: 18px;
    background: oklch(100.00% 0.000 89.9 / 0.2);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-2xs);
    font-weight: bold;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s var(--ease-smooth);
}

.mode-tile.selected::after {
    opacity: 1;
    transform: scale(1);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--s-2);
    gap: var(--s-2);
    flex-wrap: nowrap;
}

.settings-row label {
    font-weight: 500;
    font-size: var(--fs-md);
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

/* Visual Style Grid - 2x2 layout */
.visual-style-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-4) var(--s-5);
    align-items: start;
}

@media (max-width: 640px) {
    .visual-style-grid {
        grid-template-columns: 1fr;
        gap: var(--s-3);
    }
}

.visual-style-item {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
}

.visual-style-label {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--s-1);
}

.visual-style-control {
    display: flex;
    align-items: center;
    gap: var(--s-2);
}

.color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    align-items: center;
    min-height: 36px;
}

.color-swatch {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--border);
    cursor: pointer;
    position: relative;
    transition: transform 0.15s var(--ease-smooth), box-shadow 0.15s var(--ease-smooth);
    box-shadow: inset 0 0 0 1px oklch(0% 0 0 / 0.08);
}

.color-swatch:hover {
    transform: scale(1.12);
}

.color-swatch:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow), inset 0 0 0 1px oklch(0% 0 0 / 0.08);
}

.color-swatch.selected {
    border-color: var(--bg-surface);
    box-shadow: 0 0 0 2px var(--accent), inset 0 0 0 1px oklch(0% 0 0 / 0.08);
    transform: scale(1.12);
}

.color-swatch.is-theme {
    background: conic-gradient(from 45deg, var(--accent), color-mix(in oklab, var(--accent) 35%, var(--bg-surface)), var(--accent));
}

.shape-set-setting {
    margin-top: var(--s-4);
    padding-top: var(--s-4);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--s-3) var(--s-4);
    align-items: center;
}

.color-set-setting {
    margin-top: var(--s-4);
    padding-top: var(--s-4);
    border-top: 1px solid var(--border);
}

.color-set-setting .color-swatches {
    margin-top: var(--s-3);
}

.sound-set-setting {
    margin-top: var(--s-4);
    padding-top: var(--s-4);
    border-top: 1px solid var(--border);
}

.sound-set-setting .visual-select {
    margin-top: var(--s-3);
}

.color-swatch.off {
    opacity: 0.28;
    filter: saturate(0.5);
    box-shadow: none;
}

.color-swatch.enabled {
    border-color: var(--bg-surface);
    box-shadow: 0 0 0 2px var(--accent), inset 0 0 0 1px oklch(0% 0 0 / 0.08);
    transform: scale(1.12);
}

.shape-set-control {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    min-width: 0;
}

.shape-preview-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--s-2);
    color: var(--accent);
    max-width: 240px;
    width: 100%;
}

.shape-preview-cell {
    aspect-ratio: 1;
    border-radius: var(--r-xs);
    background: var(--bg-surface-2);
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.shape-preview-cell:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
    transform: translateY(-2px);
}

.shape-preview-cell svg {
    width: 64%;
    height: 64%;
}

@media (max-width: 640px) {
    .shape-set-setting {
        grid-template-columns: 1fr;
    }
}

.visual-select {
    background: var(--bg-surface-2);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-sm);
    font-size: var(--fs-md);
    font-weight: 500;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    min-width: 0;
    flex: 1;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: var(--s-8);
}

.visual-select:hover {
    border-color: var(--text-secondary);
    background: var(--bg-surface);
}

.visual-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.visual-select.full-width {
    width: 100%;
}

/* Actions Section Styling */
.actions-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--s-5);
    margin-top: var(--s-5);
}

.actions-header {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: var(--s-4);
    padding-bottom: var(--s-3);
    border-bottom: 1px solid var(--border);
}

.actions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-3);
}

@media (min-width: 640px) {
    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.actions-grid .btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.confetti-particle {
    position: fixed;
    font-size: var(--fs-xl);
    pointer-events: none;
    animation: fly 1s ease-out forwards;
    z-index: 1000;
}

.rain-drop {
    position: fixed;
    font-size: var(--fs-xl);
    pointer-events: none;
    animation: drop 0.8s ease-in forwards;
    z-index: 1000;
}

@keyframes fly {
    0% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg);
    }

    100% {
        opacity: 0;
        transform: translate(var(--tx, 50px), var(--ty, -100px)) rotate(360deg);
    }
}

@keyframes drop {
    0% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(100px);
    }
}

#screen-game {
    padding: 0;
}

/* Ensure game screen covers global header (z-9999) when active and full-screen */
#screen-game.active {
    z-index: 10000;
}

#screen-game .content-scroll {
    padding: var(--s-2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-bottom: 120px;
}

.game-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--s-5);
    z-index: 20;
}

.progress-bar-container {
    position: absolute;
    top: 0;
    left: 8px;
    right: 8px;
    height: 6px;
    background: var(--bg-surface-2);
    border-radius: 999px;
    overflow: hidden;
    z-index: 30;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    border-radius: 999px;
    transition: width 0.3s linear;
}

.grid-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: var(--s-1);
    position: relative;
}

.path-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 6;
}

.path-overlay svg {
    width: 78px;
    height: 78px;
    color: var(--text-primary);
    filter: drop-shadow(0 0 10px var(--bg-body));
    transition: transform 0.15s ease;
}

.grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-cols), 1fr);
    gap: 5px;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1;
}

/* .cell uses --grid-cell variable for contrast fix */
.cell {
    background: var(--grid-cell);
    border-radius: var(--r-md);
    position: relative;
    transition: transform 0.1s;
    overflow: hidden;
}

.cell.active {
    background: var(--text-primary);
    box-shadow: 0 0 30px var(--accent-glow);
    transform: scale(0.95);
    z-index: 5;
}

.cell.active-position {
    background: var(--accent);
}

.cell.active-color {
    background: currentColor;
    box-shadow: 0 0 20px currentColor;
}

.cell.active-shape-only {
    background: transparent !important;
    box-shadow: none !important;
}

.layer-shape {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.layer-shape svg {
    width: 90%;
    height: 90%;
    fill: var(--text-primary);
}

.layer-rotation {
    transform-origin: 50% 50%;
}

@keyframes nb-rotate-cw {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes nb-rotate-ccw {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

.layer-letter {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: calc(24rem / var(--grid-cols));
    font-weight: 800;
    pointer-events: none;
    z-index: 50;
    color: var(--text-primary);
    text-shadow: 0 0 20px var(--bg-body);
}

.controls-grid {
    display: flex;
    gap: var(--s-2);
    height: 90px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.btn-control {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface-2);
    border: none;
    border-radius: var(--r-pill);
    font-size: var(--fs-xl);
    font-weight: 500;
    color: var(--text-secondary);
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-control:active {
    transform: scale(0.96);
}

.btn-control.active {
    color: var(--text-contrast);
    background: var(--accent);
    box-shadow: 0 4px 15px var(--accent-glow);
}

/* F8: hide the response labels, leaving just the key hint */
body.nc-hide-control-text .btn-control .ctl-label,
body.nc-hide-control-text .btn-control .ctl-match {
    display: none;
}

body.nc-hide-control-text .btn-control .desktop-key {
    display: inline;
    margin-left: 0;
    font-size: var(--fs-xl);
    opacity: 0.85;
}

.feedback-correct {
    border-color: var(--success) !important;
    color: var(--text-contrast) !important;
    background: var(--success) !important;
    box-shadow: 0 0 40px 8px var(--success), inset 0 0 20px rgba(255, 255, 255, 0.3) !important;
    z-index: 10;
    transform: scale(0.98);
    transition: all 0.1s ease-out;
}

.feedback-wrong {
    border-color: var(--error) !important;
    color: var(--text-contrast) !important;
    background: var(--error) !important;
    box-shadow: 0 0 40px 8px var(--error), inset 0 0 20px rgba(255, 255, 255, 0.3) !important;
    z-index: 10;
    transform: scale(0.98);
    transition: all 0.1s ease-out;
}

.feedback-miss {
    border-color: var(--error) !important;
    color: var(--error) !important;
    background: transparent !important;
    box-shadow: 0 0 30px 6px var(--error), inset 0 0 15px var(--error) !important;
    z-index: 10;
    animation: pulse-miss 0.5s ease-out;
}

@keyframes pulse-miss {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

#screen-report .content-scroll {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: var(--s-5);
    padding-bottom: 130px;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--s-4);
}

.report-title {
    font-size: var(--fs-md);
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 700;
}

.report-hero {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--s-8);
    text-align: center;
    margin-bottom: var(--s-4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 40px oklch(0.00% 0.000 0.0 / 0.04);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.hero-main-val {
    font-size: 4rem;
    font-weight: 300;
    line-height: 1;
    color: var(--accent);
    letter-spacing: -2px;
    margin-bottom: var(--s-2);
}

.hero-sub {
    font-size: var(--fs-xl);
    font-weight: 400;
    color: var(--text-primary);
}

.hero-progress-status {
    margin-top: var(--s-4);
    background: var(--bg-surface-2);
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-md);
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    align-items: flex-start;
}

.prog-row {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    gap: var(--s-2);
}

.report-grid-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-2);
    margin-bottom: var(--s-3);
}

.r-stat-box {
    background: var(--bg-surface-2);
    padding: var(--s-2);
    border-radius: var(--radius-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.r-label {
    font-size: var(--fs-2xs);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
}

.r-val {
    font-size: var(--fs-lg);
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.unified-stats-container {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    margin-bottom: var(--s-5);
}

.unified-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--s-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.uc-left {
    display: flex;
    align-items: center;
    gap: var(--s-3);
}

.uc-icon {
    font-size: var(--fs-xl);
    width: 30px;
    text-align: center;
    opacity: 0.8;
}

.uc-title {
    font-weight: 700;
    font-size: var(--fs-md);
    color: var(--text-primary);
    text-transform: capitalize;
}

.uc-perc {
    font-size: var(--fs-xl);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.uc-details {
    font-size: var(--fs-2xs);
    color: var(--text-secondary);
    margin-top: var(--s-1);
}

.btn-timer-overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 0%;
    background: oklch(0.00% 0.000 0.0 / 0.1);
    pointer-events: none;
    transition: none;
    z-index: 0;
}

.btn-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: var(--s-2);
}

.chart-area-wrapper {
    margin-top: var(--s-2);
    position: relative;
}

.chart-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--s-2);
}

.chart-title-area {
    font-weight: 800;
    color: var(--text-primary);
    font-size: var(--fs-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.range-select {
    appearance: none;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: var(--s-1) var(--s-2);
    border-radius: var(--r-lg);
    font-size: var(--fs-xs);
    font-weight: 600;
    cursor: pointer;
    outline: none;
    text-align: center;
}

.chart-card-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--s-3) var(--s-2);
    margin-bottom: var(--s-4);
}

.chart-container {
    position: relative;
    height: 200px;
    width: 100%;
}

/* --- Modal textarea delta. The modal shell (.modal-overlay/.modal-card/
   .modal-title) comes from base.css verbatim; nback only styles the
   textarea itself. (color/margin-bottom come from base.css .modal-txt —
   they already won the tie before this extraction.) --- */
.modal-txt {
    width: 100%;
    height: 100px;
    padding: var(--s-2);
    border-radius: var(--r-xs);
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    resize: none;
    font-family: inherit;
}

/* Desktop Shortcut Hints */
.desktop-key {
    display: none;
    font-weight: 400;
    opacity: 0.6;
    margin-left: 5px;
    font-size: 0.8em;
}

@media (min-width: 768px) {
    .desktop-key {
        display: inline;
    }
}

.settings-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-4);
}

@media (min-width: 768px) {
    .settings-dashboard-grid {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

@media (min-width: 1024px) {
    .settings-dashboard-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* Visuals come from base.css .panel (added in the template); this keeps only
   the grid-stretch behavior the layout relies on. */
.dashboard-card-inner {
    height: 100%;
}

.shortcut-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--s-2);
    margin-top: var(--s-3);
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    background: var(--bg-surface-2);
    padding: var(--s-2);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

.kbd-key {
    background: var(--bg-surface);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: var(--s-1) var(--s-2);
    font-family: monospace;
    font-weight: 700;
    box-shadow: 0 2px 0 var(--border);
    min-width: 24px;
    text-align: center;
    font-size: var(--fs-xs);
}

button.kbd-key {
    cursor: pointer;
    line-height: 1.2;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

button.kbd-key:hover {
    border-color: var(--accent);
}

.kbd-key.listening {
    background: var(--accent);
    color: var(--bg-body);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.kbd-label {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

/* ===== MENU LAYOUT ===== */
/* Slim progress strip — horizontal, compact */
.nb-progress-strip {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    margin-bottom: var(--s-4);
    margin-top: var(--s-4);
}
.nb-strip-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--s-2);
    flex: 1;
    min-width: 0;
}
.nb-strip-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: var(--s-1) var(--s-2);
    border-right: 1px solid var(--border);
}
.nb-strip-stat:last-child { border-right: none; }
.nb-strip-stat .qs-val {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}
.nb-strip-stat .qs-label {
    font-size: var(--fs-2xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    font-weight: 700;
    margin-top: var(--s-1);
}
.nb-last-session .btn {
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .nb-progress-strip { flex-wrap: wrap; }
    .nb-strip-stats { grid-template-columns: repeat(2, 1fr); }
    .nb-strip-stat:nth-child(2) { border-right: none; }
}

/* Section heading above the setup grid */
.nb-section-title {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--fs-lg);
    font-weight: 800;
    color: var(--text-primary);
    margin: var(--s-1) var(--s-1) var(--s-4);
    letter-spacing: -0.01em;
}
.nb-section-title .nb-section-sub {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: auto;
    text-transform: none;
    letter-spacing: 0;
}

/* History chart — modest, lives at the bottom */
.nb-chart-card { margin-bottom: var(--s-4); }
.nb-chart-body {
    position: relative;
    width: 100%;
    height: 200px;
    margin-top: var(--s-3);
}
#chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    text-align: center;
    color: var(--text-secondary);
    pointer-events: none;
}
#chart-empty .ce-icon { color: var(--text-secondary); opacity: 0.6; }
#chart-empty .ce-text { font-size: var(--fs-sm); font-weight: 600; opacity: 0.75; max-width: 240px; }

/* Two-line START button in the dock (carries the live session summary) */
.nb-start { flex-direction: column; line-height: 1.15; padding-top: var(--s-3); padding-bottom: var(--s-3); }
.nb-start .nb-start-main { font-size: var(--fs-2xl); font-weight: 800; }
.nb-start .nb-start-sub {
    font-size: var(--fs-sm);
    font-weight: 600;
    opacity: 0.9;
    margin-top: var(--s-1);
}

/* ===== MAKEOVER: hierarchy + spacing ===== */

/* Last-session strip (replaces the empty dash board) */
.nb-last-session {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    margin-top: var(--s-4);
    margin-bottom: var(--s-4);
}

.nb-last-session[hidden] {
    display: none;
}

.nls-main {
    display: flex;
    align-items: baseline;
    gap: var(--s-2);
    min-width: 0;
}

.nls-label {
    font-size: var(--fs-2xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--text-secondary);
}

.nls-val {
    font-weight: 800;
    font-size: var(--fs-lg);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Two independent columns for settings + actions (no masonry holes) */
.nb-two-col {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    margin-bottom: var(--s-4);
}

.nb-col {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    min-width: 0;
}

.nb-col > .dashboard-card-inner,
.nb-col > .actions-section,
.nb-col > #keyboard-shortcuts-tile {
    margin-top: 0;
    margin-bottom: 0;
}

.nb-col > #keyboard-shortcuts-tile {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
}

/* On mobile the columns dissolve so cards can be re-interleaved: Game Modes
   stays right after Session Setup, and the rest keeps its original order. */
@media (max-width: 767px) {
    .nb-two-col .nb-col {
        display: contents;
    }

    .nb-setup-card { order: 1; }
    .nb-modes-card { order: 2; }
    .nb-appearance-card { order: 3; }
    .nb-difficulty-card { order: 4; }
    .nb-behavior-card { order: 5; }
    .nb-col-right .actions-section { order: 6; }
    #keyboard-shortcuts-tile { order: 7; }
}

@media (min-width: 768px) {
    .nb-two-col {
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: start;
        column-gap: var(--s-4);
    }

    .nb-setup-card .dash-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.dash-col-derived {
    opacity: 0.92;
}

/* Quick-play + mode-preset chips */
.nb-quick-row,
.nb-preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}

.nb-quick-label {
    margin-top: var(--s-4);
    margin-bottom: var(--s-2);
    font-size: var(--fs-2xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.nb-quick-row {
    margin-top: 0;
}

.nb-preset-row {
    margin-bottom: var(--s-3);
}

.nb-quick {
    appearance: none;
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    background: var(--bg-surface-2);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: var(--fs-xs);
    font-weight: 700;
    cursor: pointer;
    transition: color 0.2s var(--ease-smooth), border-color 0.2s var(--ease-smooth), background 0.2s var(--ease-smooth);
}

.nb-quick:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--bg-surface);
}

.nb-quick.active {
    color: var(--text-contrast);
    background: var(--accent);
    border-color: var(--accent);
}

/* Modes card is primary and full-width; never stretch to fill a flex line */
.nb-modes-card {
    margin-bottom: var(--s-4);
    height: auto;
}

.nb-card-hint {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: auto;
    text-align: right;
}

/* Sub-label used by the adaptive-engine rows */
.lbl-sm {
    font-size: var(--fs-sm);
}

.nb-chart-card .card-header {
    margin-bottom: 0;
}

#keyboard-shortcuts-tile {
    padding: var(--s-3) var(--s-5);
}

/* One-line plain-language consequence under jargon controls */
.settings-hint {
    grid-column: 1 / -1;
    margin: -4px 0 4px;
    font-size: var(--fs-xs);
    line-height: 1.4;
    color: var(--text-secondary);
}

/* Let the grid gap own row spacing (margin + gap was doubling on mobile) */
.settings-grid .settings-row {
    margin-bottom: 0;
}



/* Switch + inline controls */
.nb-inline {
    display: flex;
    align-items: center;
    gap: var(--s-2);
}

.nb-switch {
    position: relative;
    width: 46px;
    height: 26px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    background: var(--bg-surface-2);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.nb-switch .nb-switch-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--text-secondary);
    transition: transform 0.2s ease, background 0.2s ease;
}

.nb-switch[aria-checked="true"] {
    background: var(--accent);
    border-color: var(--accent);
}

.nb-switch[aria-checked="true"] .nb-switch-knob {
    transform: translateX(20px);
    background: white;
}

.nb-switch:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Volume: value + mute */
.nb-vol {
    display: flex;
    align-items: center;
    gap: var(--s-2);
}

.nb-mute {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: var(--fs-lg);
    line-height: 1;
    transition: border-color 0.2s ease;
}

.nb-mute:hover {
    border-color: var(--accent);
}

#setting-volume {
    width: 90px;
    accent-color: var(--accent);
}

.nb-vol-val {
    min-width: 40px;
    text-align: right;
    font-weight: 700;
    font-size: var(--fs-xs);
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

@media (max-width: 480px) {
    #setting-volume {
        width: 70px;
    }
}

/* Larger help targets inside the menu */
#screen-menu .help-icon {
    width: 22px;
    height: 22px;
    font-size: var(--fs-sm);
}
