/* ─── Reset & Base ─── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    -webkit-font-smoothing: none;
    image-rendering: pixelated;
}

:root {
    /* ── Palette ── */
    --bg: #0a0c08;
    --surface: #111409;
    --surface2: #191c0f;
    --surface3: #22260f;
    --border: #3a4020;
    --border-h: #6a7030;

    /* Phosphor amber accent */
    --accent: #d4a017;
    --accent2: #f5c842;
    --accent-glow: rgba(212, 160, 23, 0.30);

    /* Secondary terminal green */
    --green-ph: #39ff14;
    --green-dim: #1a8c00;

    /* Danger red */
    --red: #cc2200;
    --red-hi: #ff3311;

    /* Number colours — classic CGA palette */
    --n1: #5599ff;
    --n2: #39ff14;
    --n3: #ff3311;
    --n4: #aa44ff;
    --n5: #ff8800;
    --n6: #00ffcc;
    --n7: #ff44aa;
    --n8: #888888;

    /* Text */
    --text: #e8d87a;
    --text-muted: #6b6030;
    --text-dim: #a09040;

    /* Layout */
    --cell-size: 36px;
    --gap: 3px;

    /* Fonts */
    --font-ui: 'Press Start 2P', monospace;
    --font-mono: 'VT323', monospace;

    /* Easings */
    --easing: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

html,
body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    overflow: hidden;
    user-select: none;
}

/* ─── CRT scanline overlay ─── */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(to bottom,
            transparent 0px,
            transparent 2px,
            rgba(0, 0, 0, 0.18) 2px,
            rgba(0, 0, 0, 0.18) 4px);
    pointer-events: none;
    z-index: 10000;
}

/* ─── Screens ─── */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s var(--ease-out);
    overflow: hidden;
    will-change: opacity;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

/* ─── Background phosphor grid ─── */
.bg-orbs {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(rgba(52, 60, 20, 0.15) 1px, transparent 1px),
        linear-gradient(90deg, rgba(52, 60, 20, 0.15) 1px, transparent 1px);
    background-size: 32px 32px;
}

/* orb elements repurposed as ambient phosphor glows */
.orb {
    position: absolute;
    border-radius: 50%;
    opacity: 1;
    will-change: transform;
    transform: translateZ(0);
    animation: float 12s ease-in-out infinite;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(212, 160, 23, 0.09) 0%, transparent 70%);
    top: -120px;
    left: -80px;
    animation-delay: 0s;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(57, 255, 20, 0.06) 0%, transparent 70%);
    bottom: -80px;
    right: -80px;
    animation-delay: -5s;
}

.orb-3 {
    width: 240px;
    height: 240px;
    background: radial-gradient(circle, rgba(212, 160, 23, 0.06) 0%, transparent 70%);
    top: 40%;
    left: 55%;
    animation-delay: -9s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    40% {
        transform: translate(20px, -20px);
    }

    70% {
        transform: translate(-14px, 14px);
    }
}

/* ─── START SCREEN ─── */
.start-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    width: 100%;
    max-width: 700px;
    padding: 32px 20px;
}

/* Logo */
.logo-area {
    text-align: center;
}

.logo-icon {
    font-size: 64px;
    line-height: 1;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 20px rgba(212, 160, 23, 0.7));
    animation: pulse-icon 4s ease-in-out infinite;
}

@keyframes pulse-icon {

    0%,
    100% {
        filter: drop-shadow(0 0 20px rgba(212, 160, 23, 0.7));
    }

    50% {
        filter: drop-shadow(0 0 36px rgba(212, 160, 23, 1.0));
    }
}

.game-title {
    font-family: var(--font-ui);
    font-size: clamp(1.6rem, 5vw, 2.8rem);
    font-weight: 400;
    letter-spacing: 2px;
    color: var(--accent2);
    text-shadow:
        0 0 8px var(--accent),
        0 0 24px rgba(212, 160, 23, 0.5),
        3px 3px 0px rgba(0, 0, 0, 0.8);
    line-height: 1.2;
    text-transform: uppercase;
}

.game-subtitle {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    color: var(--green-ph);
    text-shadow: 0 0 8px var(--green-ph);
    letter-spacing: 4px;
    margin-top: 10px;
    text-transform: uppercase;
}

/* Section label */
.section-label {
    font-family: var(--font-ui);
    font-size: 0.55rem;
    font-weight: 400;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 16px;
}

/* Difficulty section */
.difficulty-section {
    width: 100%;
}

.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

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

/* Retro bevel card */
.diff-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 2px solid var(--border);
    /* classic "outset" bevel */
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.12),
        inset -1px -1px 0 rgba(0, 0, 0, 0.6),
        2px 2px 0 rgba(0, 0, 0, 0.8);
    border-radius: 0;
    padding: 18px 12px;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
    position: relative;
    overflow: hidden;
}

.diff-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.15s;
}

.diff-card:hover {
    border-color: var(--border-h);
    background: var(--surface2);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.18),
        inset -1px -1px 0 rgba(0, 0, 0, 0.7),
        3px 3px 0 rgba(0, 0, 0, 0.9);
}

.diff-card.selected {
    border-color: var(--accent);
    background: var(--surface2);
    box-shadow:
        inset 1px 1px 0 rgba(212, 160, 23, 0.25),
        inset -1px -1px 0 rgba(0, 0, 0, 0.6),
        0 0 12px var(--accent-glow),
        2px 2px 0 rgba(0, 0, 0, 0.8);
}

.diff-card.selected::before {
    opacity: 0.06;
}

.diff-icon {
    font-size: 1.6rem;
    line-height: 1;
    position: relative;
    z-index: 1;
}

.diff-name {
    font-family: var(--font-ui);
    font-size: 0.5rem;
    font-weight: 400;
    color: var(--text);
    position: relative;
    z-index: 1;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.diff-details {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-muted);
    position: relative;
    z-index: 1;
}

.diff-bar {
    width: 100%;
    height: 4px;
    background: var(--surface3);
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
    z-index: 1;
    margin-top: 4px;
}

.diff-fill {
    height: 100%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

/* Custom panel */
.custom-panel {
    margin-top: 16px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.35s var(--ease-out), opacity 0.3s;
}

.custom-panel.open {
    max-height: 120px;
    opacity: 1;
}

.custom-inputs {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.custom-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-family: var(--font-ui);
    font-size: 0.45rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.custom-input {
    width: 80px;
    padding: 8px 12px;
    background: var(--surface2);
    border: 2px solid var(--border);
    box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.6), inset -1px -1px 0 rgba(255, 255, 230, 0.06);
    border-radius: 0;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 1.4rem;
    text-align: center;
    outline: none;
    transition: border-color 0.15s;
}

.custom-input:focus {
    border-color: var(--accent);
    box-shadow:
        inset 2px 2px 0 rgba(0, 0, 0, 0.6),
        0 0 8px var(--accent-glow);
}

/* Start button */
.start-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 40px;
    background: var(--accent);
    border: 2px solid var(--accent2);
    border-radius: 0;
    /* outset bevel */
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.4),
        inset -2px -2px 0 rgba(0, 0, 0, 0.5),
        4px 4px 0 rgba(0, 0, 0, 0.8),
        0 0 24px var(--accent-glow);
    color: #0a0c08;
    font-family: var(--font-ui);
    font-size: 0.65rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.1s;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.start-btn:hover {
    background: var(--accent2);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.5),
        inset -2px -2px 0 rgba(0, 0, 0, 0.4),
        6px 6px 0 rgba(0, 0, 0, 0.9),
        0 0 36px rgba(212, 160, 23, 0.55);
    transform: translate(-1px, -1px);
}

.start-btn:active {
    box-shadow:
        inset 2px 2px 0 rgba(0, 0, 0, 0.5),
        inset -1px -1px 0 rgba(255, 255, 230, 0.2),
        2px 2px 0 rgba(0, 0, 0, 0.7);
    transform: translate(2px, 2px);
}

.btn-text {
    position: relative;
}

.btn-icon {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    transition: transform 0.2s;
}

.start-btn:hover .btn-icon {
    transform: translateX(4px);
}

/* Instructions */
.instructions {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
}

.instructions span {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: 0;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.7);
}

/* ─── GAME SCREEN ─── */
.game-bg .orb-1 {
    opacity: 0.5;
}

.game-bg .orb-2 {
    opacity: 0.4;
}

.game-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 2px solid var(--border);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.8), 0 4px 16px rgba(0, 0, 0, 0.5);
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface2);
    border: 2px solid var(--border);
    border-radius: 0;
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.1),
        inset -1px -1px 0 rgba(0, 0, 0, 0.5),
        2px 2px 0 rgba(0, 0, 0, 0.7);
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.1s;
}

.icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent2);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.15),
        inset -1px -1px 0 rgba(0, 0, 0, 0.5),
        2px 2px 0 rgba(0, 0, 0, 0.8),
        0 0 8px var(--accent-glow);
}

.hud {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface2);
    border: 2px solid var(--border);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.08),
        inset -1px -1px 0 rgba(0, 0, 0, 0.6),
        2px 2px 0 rgba(0, 0, 0, 0.7);
    padding: 6px 14px;
    border-radius: 0;
}

.hud-icon {
    font-size: 1rem;
}

.hud-value {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 400;
    color: var(--accent2);
    text-shadow: 0 0 8px var(--accent);
    min-width: 38px;
    text-align: right;
    letter-spacing: 2px;
}

.reset-btn {
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
    background: var(--surface2);
    border: 2px solid var(--border);
    border-radius: 0;
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.1),
        inset -1px -1px 0 rgba(0, 0, 0, 0.5),
        2px 2px 0 rgba(0, 0, 0, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    line-height: 1;
}

.reset-btn:hover {
    border-color: var(--accent);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.15),
        inset -1px -1px 0 rgba(0, 0, 0, 0.5),
        2px 2px 0 rgba(0, 0, 0, 0.8),
        0 0 12px var(--accent-glow);
    transform: translate(-1px, -1px);
}

.reset-btn:active {
    transform: translate(2px, 2px);
    box-shadow:
        inset 2px 2px 0 rgba(0, 0, 0, 0.6),
        1px 1px 0 rgba(0, 0, 0, 0.7);
}

.diff-badge {
    background: var(--accent);
    color: #0a0c08;
    font-family: var(--font-ui);
    font-size: 0.42rem;
    font-weight: 400;
    letter-spacing: 2px;
    padding: 5px 10px;
    border-radius: 0;
    text-transform: uppercase;
    border: 1px solid var(--accent2);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.7);
}

/* ─── BOARD ─── */
.game-area {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: 100%;
    padding-top: 72px;
    overflow: auto;
}

.board-wrapper {
    padding: 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.07),
        inset -1px -1px 0 rgba(0, 0, 0, 0.6),
        4px 4px 0 rgba(0, 0, 0, 0.8),
        0 8px 32px rgba(0, 0, 0, 0.6);
    border-radius: 0;
    margin: 16px;
}

.board {
    display: grid;
    gap: var(--gap);
}

/* ─── CELL ─── */
.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 400;
    cursor: pointer;
    transition: background-color 0.08s, border-color 0.08s, box-shadow 0.08s;
    position: relative;
    border: 1.5px solid transparent;
    will-change: background-color;
    contain: layout style;
}

/* Hidden cell — outset bevel */
.cell.hidden {
    background: var(--surface2);
    border-color: var(--border);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.12),
        inset -1px -1px 0 rgba(0, 0, 0, 0.6),
        1px 1px 0 rgba(0, 0, 0, 0.6);
}

.cell.hidden:hover {
    background: var(--surface3);
    border-color: var(--border-h);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.18),
        inset -1px -1px 0 rgba(0, 0, 0, 0.6),
        1px 1px 0 rgba(0, 0, 0, 0.7),
        0 0 6px rgba(212, 160, 23, 0.15);
}

.cell.hidden:active {
    background: var(--surface);
    box-shadow:
        inset 2px 2px 0 rgba(0, 0, 0, 0.6),
        inset -1px -1px 0 rgba(255, 255, 230, 0.06);
}

/* Revealed cell — inset (pressed) */
.cell.revealed {
    background: rgba(10, 12, 8, 0.85);
    border-color: rgba(58, 64, 32, 0.4);
    box-shadow:
        inset 1px 1px 0 rgba(0, 0, 0, 0.6),
        inset -1px -1px 0 rgba(255, 255, 230, 0.04);
    cursor: default;
}

/* Flagged */
.cell.flagged {
    background: rgba(212, 160, 23, 0.1);
    border-color: rgba(212, 160, 23, 0.5);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.12),
        inset -1px -1px 0 rgba(0, 0, 0, 0.6),
        1px 1px 0 rgba(0, 0, 0, 0.6),
        0 0 8px rgba(212, 160, 23, 0.3);
}

.cell.flagged::after {
    content: '🚩';
    font-size: 1rem;
    animation: flag-pop 0.2s var(--easing) forwards;
}

@keyframes flag-pop {
    0% {
        transform: scale(0) rotate(-20deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
    }
}

/* Questioned */
.cell.questioned {
    background: rgba(57, 255, 20, 0.08);
    border-color: rgba(57, 255, 20, 0.4);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.1),
        inset -1px -1px 0 rgba(0, 0, 0, 0.5),
        1px 1px 0 rgba(0, 0, 0, 0.6),
        0 0 6px rgba(57, 255, 20, 0.2);
}

.cell.questioned::after {
    content: '❓';
    font-size: 0.9rem;
    animation: flag-pop 0.2s var(--easing) forwards;
}

/* Mine */
.cell.mine-revealed {
    background: rgba(204, 34, 0, 0.15);
    border-color: rgba(204, 34, 0, 0.4);
    box-shadow:
        inset 1px 1px 0 rgba(255, 100, 80, 0.1),
        inset -1px -1px 0 rgba(0, 0, 0, 0.6);
    cursor: default;
}

.cell.mine-revealed::after {
    content: '💣';
    font-size: 1rem;
}

.cell.mine-hit {
    background: rgba(204, 34, 0, 0.40) !important;
    border-color: var(--red-hi) !important;
    box-shadow: 0 0 16px rgba(255, 51, 17, 0.6) !important;
}

.cell.mine-hit::after {
    content: '💥';
    font-size: 1rem;
}

/* Correct flag */
.cell.correct-flag::after {
    content: '✅';
    font-size: 0.9rem;
}

/* Reveal anim */
.cell.reveal-anim {
    animation: reveal-cell 0.15s var(--easing) forwards;
}

@keyframes reveal-cell {
    0% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

/* Number colours */
.n1 {
    color: var(--n1);
    text-shadow: 0 0 6px rgba(85, 153, 255, 0.5);
}

.n2 {
    color: var(--n2);
    text-shadow: 0 0 6px rgba(57, 255, 20, 0.5);
}

.n3 {
    color: var(--n3);
    text-shadow: 0 0 6px rgba(255, 51, 17, 0.5);
}

.n4 {
    color: var(--n4);
    text-shadow: 0 0 6px rgba(170, 68, 255, 0.5);
}

.n5 {
    color: var(--n5);
    text-shadow: 0 0 6px rgba(255, 136, 0, 0.5);
}

.n6 {
    color: var(--n6);
    text-shadow: 0 0 6px rgba(0, 255, 204, 0.5);
}

.n7 {
    color: var(--n7);
    text-shadow: 0 0 6px rgba(255, 68, 170, 0.5);
}

.n8 {
    color: var(--n8);
}

/* ─── MODAL ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.80);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    will-change: opacity;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--surface);
    border: 2px solid var(--border);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.1),
        inset -1px -1px 0 rgba(0, 0, 0, 0.7),
        6px 6px 0 rgba(0, 0, 0, 0.9),
        0 0 40px rgba(212, 160, 23, 0.15);
    border-radius: 0;
    padding: 36px 48px;
    text-align: center;
    transform: translateY(24px);
    opacity: 0;
    transition: transform 0.28s var(--ease-out), opacity 0.22s;
    will-change: transform, opacity;
    min-width: 320px;
}

.modal-overlay.open .modal {
    transform: translateY(0);
    opacity: 1;
}

.modal-emoji {
    font-size: 3.5rem;
    line-height: 1;
    margin-bottom: 16px;
    animation: bounce-in 0.45s var(--easing) forwards;
}

@keyframes bounce-in {
    0% {
        transform: scale(0);
    }

    60% {
        transform: scale(1.2);
    }

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

.modal-title {
    font-family: var(--font-ui);
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--accent2);
    text-shadow: 0 0 10px var(--accent), 2px 2px 0 rgba(0, 0, 0, 0.8);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.modal-subtitle {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.modal-stats {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.stat-chip {
    background: var(--surface2);
    border: 2px solid var(--border);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.06),
        inset -1px -1px 0 rgba(0, 0, 0, 0.5),
        2px 2px 0 rgba(0, 0, 0, 0.7);
    border-radius: 0;
    padding: 8px 14px;
    font-size: 0.8rem;
}

.stat-chip .stat-label {
    font-family: var(--font-ui);
    font-size: 0.38rem;
    color: var(--text-muted);
    display: block;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.stat-chip .stat-val {
    font-family: var(--font-mono);
    font-weight: 400;
    color: var(--accent2);
    font-size: 1.4rem;
    text-shadow: 0 0 6px var(--accent);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    padding: 10px 24px;
    border-radius: 0;
    font-family: var(--font-ui);
    font-size: 0.5rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.1s;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.modal-btn.primary {
    background: var(--accent);
    border: 2px solid var(--accent2);
    color: #0a0c08;
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.35),
        inset -1px -1px 0 rgba(0, 0, 0, 0.4),
        3px 3px 0 rgba(0, 0, 0, 0.8),
        0 0 16px var(--accent-glow);
}

.modal-btn.primary:hover {
    background: var(--accent2);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.4),
        inset -1px -1px 0 rgba(0, 0, 0, 0.3),
        4px 4px 0 rgba(0, 0, 0, 0.9),
        0 0 24px rgba(212, 160, 23, 0.5);
    transform: translate(-1px, -1px);
}

.modal-btn.primary:active {
    transform: translate(2px, 2px);
    box-shadow:
        inset 2px 2px 0 rgba(0, 0, 0, 0.4),
        1px 1px 0 rgba(0, 0, 0, 0.7);
}

.modal-btn.secondary {
    background: var(--surface2);
    color: var(--text-dim);
    border: 2px solid var(--border);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.08),
        inset -1px -1px 0 rgba(0, 0, 0, 0.5),
        3px 3px 0 rgba(0, 0, 0, 0.8);
}

.modal-btn.secondary:hover {
    border-color: var(--border-h);
    color: var(--text);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.1),
        inset -1px -1px 0 rgba(0, 0, 0, 0.5),
        4px 4px 0 rgba(0, 0, 0, 0.9);
    transform: translate(-1px, -1px);
}

.modal-btn.secondary:active {
    transform: translate(2px, 2px);
    box-shadow:
        inset 2px 2px 0 rgba(0, 0, 0, 0.5),
        1px 1px 0 rgba(0, 0, 0, 0.7);
}

/* ─── Win celebration ─── */
@keyframes confetti-float {
    0% {
        transform: translateY(0) rotate(0deg) scaleX(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-100vh) rotate(720deg) scaleX(-1);
        opacity: 0;
    }
}

.confetti-piece {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 0;
    pointer-events: none;
    z-index: 999;
    animation: confetti-float linear forwards;
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
    :root {
        --cell-size: 30px;
        --gap: 2px;
    }

    .hud {
        gap: 10px;
    }

    .hud-item {
        padding: 5px 8px;
    }

    .hud-value {
        font-size: 1.3rem;
    }

    .game-title {
        font-size: 1.2rem;
    }

    .modal {
        padding: 24px 20px;
    }
}

/* ─── Action bar ─── */
.action-bar {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 12px 20px 18px;
    flex-shrink: 0;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    border: 2px solid var(--border);
    border-radius: 0;
    background: var(--surface2);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.08),
        inset -1px -1px 0 rgba(0, 0, 0, 0.5),
        2px 2px 0 rgba(0, 0, 0, 0.7);
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 0.45rem;
    font-weight: 400;
    cursor: pointer;
    transition: background-color 0.1s, border-color 0.1s, color 0.1s, box-shadow 0.1s;
    white-space: nowrap;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.action-btn:hover {
    border-color: var(--border-h);
    color: var(--text-dim);
}

.action-btn.active {
    background: rgba(212, 160, 23, 0.12);
    border-color: var(--accent);
    color: var(--accent2);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 230, 0.1),
        inset -1px -1px 0 rgba(0, 0, 0, 0.5),
        2px 2px 0 rgba(0, 0, 0, 0.7),
        0 0 12px var(--accent-glow);
}

.act-icon {
    font-size: 1rem;
    line-height: 1;
}

.act-label {
    font-size: 0.45rem;
}

@media (max-width: 480px) {
    .action-bar {
        gap: 7px;
        padding: 8px 10px 14px;
    }

    .action-btn {
        padding: 8px 12px;
    }

    .act-label {
        display: none;
    }
}

/* ─── Long-press ring ─── */
.lp-ring-wrap {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    width: 56px;
    height: 56px;
    transform: translate(-50%, -50%);
}

.lp-ring-wrap svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.lp-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 230, 0.1);
    stroke-width: 3;
}

.lp-ring-prog {
    fill: none;
    stroke: var(--accent2);
    stroke-width: 3;
    stroke-linecap: square;
    stroke-dasharray: 138;
    stroke-dashoffset: 138;
    transition: stroke-dashoffset linear;
}

.lp-ring-wrap.flag-mode .lp-ring-prog {
    stroke: var(--green-ph);
}

/* ─── Tap ripple feedback ─── */
.tap-ripple {
    position: fixed;
    width: 40px;
    height: 40px;
    border-radius: 0;
    border: 2px solid rgba(212, 160, 23, 0.6);
    pointer-events: none;
    z-index: 9998;
    transform: translate(-50%, -50%) scale(0);
    animation: tap-out 0.35s ease-out forwards;
}

@keyframes tap-out {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

::-webkit-scrollbar-thumb {
    background: var(--border-h);
    border-radius: 0;
}