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

/* ── Design tokens (light / default) ────────────────── */
:root {
    --bg: #eef1fb;
    --surface: #ffffff;
    --surface-solid: #ffffff;
    --border: rgba(180,190,220,0.55);
    --border-strong: #b0b8d0;
    --text: #1a1d2e;
    --text-muted: #7880a0;
    --accent: #4a6cf7;
    --accent-grad: linear-gradient(135deg,#4a6cf7 0%,#6c5ce7 100%);
    --accent-light: rgba(74,108,247,0.10);
    --accent-hover: #3859e8;
    --cell-given: #1a1d2e;
    --cell-user: #4a6cf7;
    --cell-error: #e84a4a;
    --cell-selected-bg: #d4dcff;
    --cell-peer-bg: #eef1ff;
    --cell-same-bg: #c8d2ff;
    --accent-rgb: 74,108,247;
    --shine: 0 2px 0 rgba(255,255,255,0.8) inset;
    --shadow: 0 4px 24px rgba(74,108,247,0.13);
    --glass-blur: none;
    --body-bg: radial-gradient(900px 600px at 100% 0%, rgba(233,239,255,.75) 0%, transparent 55%),
               linear-gradient(180deg,#eef1fb 0%,#f4f6ff 100%);
}

/* ── Dark theme ──────────────────────────────────────── */
body[data-theme="dark"] {
    --bg: #1a1a2e;
    --surface: rgba(30,32,52,0.90);
    --surface-solid: #1e2034;
    --border: rgba(80,90,140,0.50);
    --border-strong: #3a4060;
    --text: #e8eaf6;
    --text-muted: #8892b0;
    --accent: #6c8ff7;
    --accent-grad: linear-gradient(135deg,#5575f0 0%,#7c6cf7 100%);
    --accent-light: rgba(108,143,247,0.15);
    --accent-hover: #4d6fe0;
    --cell-given: #e8eaf6;
    --cell-user: #6c8ff7;
    --cell-error: #f47d7d;
    --cell-selected-bg: #2a3060;
    --cell-peer-bg: #22253e;
    --cell-same-bg: #303570;
    --accent-rgb: 108,143,247;
    --shine: 0 2px 0 rgba(255,255,255,0.06) inset;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --body-bg: radial-gradient(1200px 800px at 20% 20%, rgba(74,108,247,.15) 0%, transparent 60%),
               radial-gradient(900px 700px at 80% 80%, rgba(108,92,231,.15) 0%, transparent 55%),
               #1a1a2e;
}

/* ── Beige theme ─────────────────────────────────────── */
body[data-theme="beige"] {
    --bg: #F5F5DC;
    --surface: rgba(255,253,240,0.90);
    --surface-solid: #fffdf0;
    --border: rgba(210,195,165,0.60);
    --border-strong: #d4b896;
    --text: #3a2e1e;
    --text-muted: #8a7a5a;
    --accent: #c8894a;
    --accent-grad: linear-gradient(135deg,#c8894a 0%,#e0a870 100%);
    --accent-light: rgba(200,137,74,0.12);
    --accent-hover: #b07030;
    --cell-given: #3a2e1e;
    --cell-user: #c8894a;
    --cell-error: #d94040;
    --cell-selected-bg: #f0d8b8;
    --cell-peer-bg: #fdf5e8;
    --cell-same-bg: #ead0a0;
    --accent-rgb: 200,137,74;
    --shine: 0 2px 0 rgba(255,255,255,0.5) inset;
    --shadow: 0 4px 24px rgba(150,100,40,0.15);
    --body-bg: radial-gradient(1200px 800px at 20% 20%, #F5F5DC 0%, transparent 60%),
               radial-gradient(900px 700px at 80% 80%, #D4A574 0%, transparent 55%),
               #F5F5DC;
}

/* ── Grey theme ──────────────────────────────────────── */
body[data-theme="grey"] {
    --bg: #7a7a7a;
    --surface: rgba(170,170,170,0.80);
    --surface-solid: #b0b0b0;
    --border: rgba(100,100,100,0.45);
    --border-strong: #646464;
    --text: #1a1a1a;
    --text-muted: #3a3a3a;
    --accent: #4a4a4a;
    --accent-grad: linear-gradient(135deg,#505050 0%,#707070 100%);
    --accent-light: rgba(60,60,60,0.15);
    --accent-hover: #333333;
    --cell-given: #1a1a1a;
    --cell-user: #2a2a2a;
    --cell-error: #cc3030;
    --cell-selected-bg: #c8c8c8;
    --cell-peer-bg: #d8d8d8;
    --cell-same-bg: #b8b8b8;
    --accent-rgb: 74,74,74;
    --shine: none;
    --shadow: 0 4px 24px rgba(0,0,0,0.25);
    --body-bg: radial-gradient(1200px 800px at 20% 20%, #909090 0%, transparent 60%),
               #7a7a7a;
}

/* ── Vibe theme ──────────────────────────────────────── */
body[data-theme="vibe"] {
    --bg: #080618;
    --glass-blur: blur(18px) saturate(160%);
    --surface: rgba(20,14,50,0.88);
    --surface-solid: #140e32;
    --border: rgba(120,90,220,0.45);
    --border-strong: #5840b0;
    --text: #f0eeff;
    --text-muted: #9488cc;
    --accent: #8b7cf8;
    --accent-grad: linear-gradient(135deg,#4a90e2 0%,#8b7cf8 45%,#e040fb 100%);
    --accent-light: rgba(139,124,248,0.18);
    --accent-hover: #6050e0;
    --cell-given: #f0eeff;
    --cell-user: #a99cff;
    --cell-error: #ff6b6b;
    --cell-selected-bg: #2e2068;
    --cell-peer-bg: #1c1648;
    --cell-same-bg: #3c2890;
    --accent-rgb: 139,124,248;
    --shine: 0 2px 0 rgba(255,255,255,0.08) inset;
    --shadow: 0 4px 40px rgba(139,124,248,0.45);
    --body-bg:
        radial-gradient(ellipse 900px 700px at 5% 10%, rgba(100,60,255,.45) 0%, transparent 55%),
        radial-gradient(ellipse 700px 900px at 92% 90%, rgba(224,64,251,.38) 0%, transparent 55%),
        radial-gradient(ellipse 500px 500px at 55% 45%, rgba(0,180,255,.12) 0%, transparent 60%),
        #080618;
}

/* ── Glass theme ─────────────────────────────────────── */
body[data-theme="glass"] {
    --bg: #dce8ff;
    --glass-blur: blur(18px) saturate(160%);
    --surface: rgba(255,255,255,0.50);
    --surface-solid: rgba(255,255,255,0.75);
    --border: rgba(180,200,255,0.50);
    --border-strong: rgba(140,170,255,0.65);
    --text: #1a2050;
    --text-muted: #5060a0;
    --accent: #4060e8;
    --accent-grad: linear-gradient(135deg,#4060e8 0%,#7060f8 100%);
    --accent-light: rgba(64,96,232,0.12);
    --accent-hover: #2a48c8;
    --cell-given: #1a2050;
    --cell-user: #4060e8;
    --cell-error: #d93030;
    --cell-selected-bg: rgba(180,200,255,0.55);
    --cell-peer-bg: rgba(220,232,255,0.40);
    --cell-same-bg: rgba(160,185,255,0.50);
    --accent-rgb: 64,96,232;
    --shine: 0 2px 0 rgba(255,255,255,0.5) inset;
    --shadow: 0 4px 24px rgba(64,96,232,0.18);
    --body-bg: radial-gradient(1200px 800px at 20% 20%, rgba(180,200,255,.55) 0%, transparent 60%),
               radial-gradient(900px 700px at 80% 80%, rgba(140,160,255,.40) 0%, transparent 55%),
               #dce8ff;
}

/* Canvas background — strictly behind everything */
#bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--body-bg, var(--bg));
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    isolation: isolate;
}

/* ── Unified site header ─────────────────────────────── */
.site-header {
    background: var(--surface);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

/* ── Top bar ─────────────────────────────────────────── */
.topbar {
    background: transparent;
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    height: 52px;
    flex-shrink: 0;
}

.topbar-inner {
    width: 100%;
    max-width: 1020px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

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

.logo {
    font-family: 'Syne', sans-serif;
    font-size: 1.8rem;
    font-weight: 800;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -1px;
    padding-top: 6px;
}

.game-tabs {
    display: flex;
    gap: 2px;
}

.tab {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.tab:hover { color: var(--text); background: var(--bg); }
.tab.active { color: var(--accent); font-weight: 700; background: var(--accent-light); }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg); color: var(--accent); }

/* ── Mode bar ────────────────────────────────────────── */
.mode-bar {
    background: transparent;
    border-bottom: none;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 48px;
    flex-shrink: 0;
}

.mode-bar-inner {
    width: 100%;
    max-width: 1020px;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 24px;
}

.mode-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 7px 16px;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.mode-btn:hover { color: var(--text); background: var(--bg); }

.mode-btn.active {
    color: var(--accent);
    font-weight: 700;
    background: var(--accent-light);
}

.mode-btn-mp {
    margin-left: auto;
    color: var(--accent);
    font-weight: 700;
}
.mode-btn-mp:hover { color: var(--accent); background: var(--accent-light); }

/* ── Difficulty bar ──────────────────────────────────── */
.difficulty-bar {
    background: transparent;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 32px;
    flex-shrink: 0;
}

.difficulty-bar-inner {
    width: 100%;
    max-width: 1020px;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 24px;
}

.diff-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    position: relative;
}

.diff-btn:hover { color: var(--text); }

.diff-btn.active {
    color: var(--accent);
    font-weight: 700;
}

.diff-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 14px;
    right: 14px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
    z-index: 1;
}

/* ── Game area ───────────────────────────────────────── */
.game-area {
    flex: 1;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 40px;
    padding: 32px 24px 40px;
    max-width: 1020px;
    margin: 0 auto;
    width: 100%;
    min-height: 0;
}

/* ── Board ───────────────────────────────────────────── */
.board-section {
    flex-shrink: 0;
}

.board-wrapper {
    position: relative;
    display: inline-block;
}

.board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    width: 576px;
    height: 576px;
    background: var(--surface-solid);
    border: 2.5px solid var(--text);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 48px rgba(var(--accent-rgb),0.20), 0 2px 12px rgba(0,0,0,0.08), var(--shine);
}

.cell {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
    user-select: none;
    position: relative;
}

/* Remove right border on col 9, bottom on row 9 */
.cell:nth-child(9n) { border-right: none; }
.cell:nth-child(n+73) { border-bottom: none; }

/* Box borders (thick every 3) — black on all themes */
.cell[data-col="2"], .cell[data-col="5"] {
    border-right: 2px solid #000;
}
.cell[data-row="2"], .cell[data-row="5"] {
    border-bottom: 2px solid #000;
}

/* States */
.cell.given { color: var(--cell-given); }
.cell.user-filled { color: var(--cell-user); }
.cell.error { color: var(--cell-error); }

.cell.selected { background: var(--cell-selected-bg); }
.cell.peer { background: var(--cell-peer-bg); }
.cell.same-value { background: var(--cell-same-bg); }
.cell.selected.same-value { background: var(--cell-selected-bg); }

.cell:hover:not(.selected):not(.given) { background: var(--cell-peer-bg); }

/* Notes */
.cell-notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    padding: 2px;
}

.note {
    font-size: 0.55rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ── Emoji / Music cells ─────────────────────────────── */
.cell.emoji-cell { font-size: 1.3rem; }
.num-btn.emoji-btn { font-size: 1.2rem; }

/* ── Killer Sudoku ───────────────────────────────────── */
.board.killer-board .cell {
    border-right: 1px solid rgba(0,0,0,0.05);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    color: var(--cell-given);
}
.board.killer-board .cell[data-col="2"],
.board.killer-board .cell[data-col="5"] {
    border-right: 2px solid var(--border-strong);
}
.board.killer-board .cell[data-row="2"],
.board.killer-board .cell[data-row="5"] {
    border-bottom: 2px solid var(--border-strong);
}
.board.killer-board .cell.given        { color: var(--cell-given); }
.board.killer-board .cell.user-filled:not(.error) { color: var(--cell-user); }
.board.killer-board .cell.error        { color: var(--cell-error); }

.cell.killer-border-top    { border-top:    2px dashed var(--accent) !important; }
.cell.killer-border-right  { border-right:  2px dashed var(--accent) !important; }
.cell.killer-border-bottom { border-bottom: 2px dashed var(--accent) !important; }
.cell.killer-border-left   { border-left:   2px dashed var(--accent) !important; }

.cage-sum {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    pointer-events: none;
    z-index: 2;
}

/* ── Color Sudoku ────────────────────────────────────── */
.cell.color-cell {
    border: 2px solid transparent;
    transition: filter 0.1s, border-color 0.1s;
}
.cell.color-cell.selected  { filter: brightness(1.15); }
.cell.color-cell.peer      { filter: brightness(0.92); }
.cell.color-cell.error-color { outline: 3px solid var(--cell-error) !important; }
/* restore inner grid lines that color-cell's transparent border erases */
.board.color-board .cell {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.board.color-board .cell[data-col="2"],
.board.color-board .cell[data-col="5"] { border-right: 2px solid #000; }
.board.color-board .cell[data-row="2"],
.board.color-board .cell[data-row="5"] { border-bottom: 2px solid #000; }

/* ── Controls section ────────────────────────────────── */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    min-width: 220px;
}

/* Stats */
.stats-row {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow), var(--shine);
}

.stat { flex: 1; }

.stat-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.stat-divider {
    width: 1px;
    height: 32px;
    background: var(--border);
}

.timer-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.timer-pause-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0.5;
    transition: opacity 0.15s;
    padding: 2px;
    line-height: 1;
}
.timer-pause-btn:hover { opacity: 1; }

/* Actions */
.action-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.action-btn {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    padding: 10px 4px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    box-shadow: var(--shadow), var(--shine);
}

.action-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(var(--accent-rgb),0.2), var(--shine);
}
.action-btn:active { transform: translateY(0); }
.action-btn.active { background: var(--accent-light); border-color: var(--accent); }

.action-icon { display: flex; align-items: center; justify-content: center; line-height: 1; color: var(--text-muted); }
.action-btn:hover .action-icon, .action-btn.active .action-icon { color: var(--accent); }

.action-label {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-muted);
    font-family: inherit;
}

/* Numpad */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.num-btn {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    padding: 18px 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
    box-shadow: var(--shadow), var(--shine);
}

.num-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--accent-rgb),0.2), var(--shine);
}
.num-btn:active { transform: translateY(0); }
.num-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.num-btn.complete { color: var(--text-muted); opacity: 0.5; }

.color-num-btn.active { animation: color-tap 0.18s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes color-tap {
    0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,255,255,0); }
    35%  { transform: scale(0.82); box-shadow: 0 0 0 6px rgba(255,255,255,0.35); }
    70%  { transform: scale(1.08); box-shadow: 0 0 0 3px rgba(255,255,255,0.15); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

/* New game button */
.new-game-btn {
    background: var(--accent-grad);
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 14px;
    width: 100%;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 20px rgba(var(--accent-rgb),0.40), 0 1px 0 rgba(255,255,255,0.2) inset;
    letter-spacing: 0.3px;
    position: relative;
    overflow: hidden;
}

.new-game-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,0.24) 50%, transparent 65%);
    transform: translateX(-120%);
    transition: transform 0.5s ease;
}

.new-game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 32px rgba(var(--accent-rgb),0.50), 0 1px 0 rgba(255,255,255,0.2) inset;
}
.new-game-btn:hover::after { transform: translateX(120%); }
.new-game-btn:active { transform: translateY(0); }

/* ── Pause overlay ───────────────────────────────────── */
.pause-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26,29,46,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.pause-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 48px 40px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}

.pause-icon { font-size: 2.5rem; }
.pause-card p { font-size: 1.1rem; color: var(--text-muted); }
.pause-card .new-game-btn { margin-top: 8px; }

/* ── Modals ──────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26,29,46,0.55);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 200;
    overflow-y: auto;
    padding: 24px 16px;
}

.modal-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 48px 40px 40px;
    text-align: center;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
    margin: auto 0;
    flex-shrink: 0;
}

.modal-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent-grad);
    border-radius: 0;
}

.modal-emoji { font-size: 3rem; }

.modal-card h2 {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: 'Syne', sans-serif;
    color: var(--text);
}

.modal-card p { color: var(--text-muted); font-size: 0.95rem; }

.modal-stats {
    display: flex;
    gap: 32px;
    margin: 8px 0;
}

.modal-stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.modal-stat-label { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.modal-stat-value { font-size: 1.4rem; font-weight: 800; color: var(--text); }

.modal-card .new-game-btn { margin-top: 8px; width: 200px; }

/* ── Modal close button ──────────────────────────────── */
.settings-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.settings-close:hover { background: var(--accent-light); color: var(--text); }

/* ── Mood bar ────────────────────────────────────────── */
.mood-bar {
    background: transparent;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 40px;
    flex-shrink: 0;
}

.mood-bar-inner {
    width: 100%;
    max-width: 1020px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 24px;
    overflow-x: auto;
    scrollbar-width: none;
}
.mood-bar-inner::-webkit-scrollbar { display: none; }

.mood-sep {
    width: 1px;
    height: 16px;
    background: var(--border);
    flex-shrink: 0;
}

.bg-card {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
}

.bg-card .theme-swatches {
    display: flex;
    justify-content: space-between;
    flex-wrap: nowrap;
}

.bg-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin: 0;
}

.bg-dropdown-sep {
    height: 1px;
    background: var(--border);
}

.anim-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.anim-btn {
    background: var(--accent-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 7px 8px;
    transition: all 0.15s;
    text-align: center;
    white-space: nowrap;
}

.anim-btn:hover { color: var(--text); border-color: var(--accent); }
.anim-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.theme-swatches {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.swatch {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: transform 0.15s;
    outline: none;
    flex-shrink: 0;
}

.swatch[data-theme="light"] { box-shadow: inset 0 0 0 1.5px rgba(0,0,0,0.12); }
.swatch:hover { transform: scale(1.15); }
.swatch.active { transform: scale(1.08); }

/* ── Win modal ───────────────────────────────────────── */
.win-card {
    min-width: 320px;
    max-width: 400px;
    width: 90vw;
}

.win-confetti {
    font-size: 3rem;
    animation: bounce 0.6s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes bounce {
    0%,100% { transform: scale(1); }
    30%      { transform: scale(1.3) rotate(-8deg); }
    60%      { transform: scale(0.9) rotate(5deg); }
}

.win-card h2 {
    font-size: 1.6rem;
    font-weight: 800;
    font-family: 'Syne', sans-serif;
    color: var(--text);
    margin: 0;
}

.win-sub {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: -4px 0 4px;
}

.win-stats {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--accent-light);
    border-radius: 14px;
    padding: 16px 8px;
    width: 100%;
    margin: 4px 0;
}

.win-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.win-stat-icon { font-size: 1.1rem; }
.win-stat-value { font-size: 1.25rem; font-weight: 800; color: var(--text); }
.win-stat-label { font-size: 0.7rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); }

.win-stat-divider { width: 1px; height: 40px; background: var(--border); }

/* Bar chart */
.win-chart-section {
    width: 100%;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
}

.win-chart-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.win-chart {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.chart-row {
    display: grid;
    grid-template-columns: 52px 1fr 48px;
    align-items: center;
    gap: 8px;
}

.chart-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: right;
}

.chart-bar-wrap {
    background: var(--accent-light);
    border-radius: 4px;
    height: 10px;
    overflow: hidden;
}

.chart-bar {
    height: 100%;
    border-radius: 4px;
    background: var(--accent-grad);
    transition: width 0.6s cubic-bezier(.22,.68,0,1.2);
    min-width: 4px;
}

.chart-bar.current { box-shadow: 0 0 8px rgba(var(--accent-rgb),0.5); }

.chart-time {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text);
}

.chart-time.current { color: var(--accent); }

/* ── Entrance animations ─────────────────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

.board-section {
    animation: fadeUp 0.45s cubic-bezier(.22,.68,0,1.2) both;
}

.controls-section {
    animation: fadeUp 0.45s 0.08s cubic-bezier(.22,.68,0,1.2) both;
}

/* cell pop-in on new game */
@keyframes cellIn {
    from { transform: scale(0.82); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.board.animating .cell.given {
    animation: cellIn 0.22s ease both;
}

/* ── Footer ──────────────────────────────────────────── */
.site-footer {
    display: flex;
    justify-content: center;
    padding: 18px 24px;
    flex-shrink: 0;
}

.footer-inner {
    width: 100%;
    max-width: 1020px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.footer-logo {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--accent);
}

.footer-tagline {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.footer-sep {
    font-size: 0.78rem;
    color: var(--border);
}

.footer-copy {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* ── Leaderboard modal ───────────────────────────────── */
.lb-card {
    min-width: 340px;
    max-width: 460px;
    width: 92vw;
    gap: 14px;
    align-items: stretch;
    text-align: left;
}
.lb-card::before { display: none; }
.bg-card::before { display: none; }

.lb-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.lb-eyebrow {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-bottom: 2px;
}

.lb-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    font-family: 'Syne', sans-serif;
    color: var(--text);
    text-align: left;
}

.lb-tabs {
    display: flex;
    gap: 0;
    background: var(--accent-light);
    border-radius: 10px;
    padding: 3px;
}

.lb-tab {
    flex: 1;
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 7px 0;
    transition: all 0.15s;
}

.lb-tab.active {
    background: var(--surface-solid);
    color: var(--accent);
    box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

.lb-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.lb-filter {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 5px 12px;
    transition: all 0.15s;
}

.lb-filter:hover { color: var(--text); border-color: var(--accent); }
.lb-filter.active { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

/* Best times row */
.lb-best-times {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.lb-best-card {
    background: var(--accent-light);
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lb-best-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
}

.lb-best-value {
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--text);
}

.lb-best-value.has-time { color: var(--accent); }

/* Recent games list */
.lb-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-top: 24px;
    margin-bottom: 6px;
}

.lb-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
}

.lb-entry {
    display: grid;
    grid-template-columns: 28px 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.85rem;
}

.lb-entry.highlight {
    border-color: var(--accent);
    background: var(--accent-light);
}

.lb-rank {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
}

.lb-rank.gold   { color: #f5a623; }
.lb-rank.silver { color: #9b9b9b; }
.lb-rank.bronze { color: #c4703e; }

.lb-entry-diff {
    font-weight: 600;
    color: var(--text);
    text-transform: capitalize;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-entry-stat {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.lb-entry-time {
    font-weight: 800;
    font-size: 0.92rem;
    color: var(--text);
    white-space: nowrap;
}

.lb-entry-time.best { color: var(--accent); }

.lb-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 20px 0;
}

.lb-close-btn { margin-top: 4px; width: 100% !important; }


/* ── Hamburger menu ──────────────────────────────────── */

#hamburgerBtn { display: none; }

.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1100;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.drawer-overlay.open { display: block; }

.hamburger-drawer {
    position: fixed;
    top: 0; right: 0;
    width: 280px;
    height: 100dvh;
    background: var(--surface-solid);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 32px rgba(0,0,0,0.18);
    z-index: 1200;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    padding: 14px 16px 32px;
    gap: 0;
}
.hamburger-drawer.open { transform: translateX(0); }

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.drawer-title {
    font-family: 'Syne', sans-serif;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text);
}

.drawer-sep {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

.drawer-section { padding: 4px 0 8px; }

.drawer-section-label {
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 8px;
}

.drawer-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.drawer-choice-btn {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.drawer-choice-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}
.drawer-choice-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.drawer-mp-btn {
    border-color: var(--accent);
    color: var(--accent);
}
.drawer-mp-btn:hover {
    background: var(--accent);
    color: #fff;
}
.drawer-newgame-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.drawer-newgame-btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.drawer-swatches {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.drawer-swatch {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    outline: none;
    flex-shrink: 0;
}
.drawer-swatch:hover { transform: scale(1.15); }
.drawer-swatch.active {
    border-color: var(--accent);
    transform: scale(1.1);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.drawer-anim-group { grid-template-columns: 1fr 1fr; }

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 860px) {
    /* ── Header: compact ── */
    .topbar            { height: 56px; }
    .topbar-inner      { padding: 0 12px; }
    .logo              { font-size: 1.3rem; }
    .icon-btn          { width: 42px; height: 42px; }
    .icon-btn svg      { width: 22px; height: 22px; }

    /* Hide bars and mood icon; show hamburger */
    .mode-bar          { display: none; }
    .difficulty-bar    { display: none; }
    .bg-picker         { display: none; }
    #hamburgerBtn      { display: flex; }

    /* ── Game area: stacked ── */
    .game-area {
        flex-direction: column;
        align-items: center;
        padding: 16px 8px 80px;
        gap: 6px;
    }

    /* Board */
    .board { width: min(94vw, 480px); height: min(94vw, 480px); border-radius: 12px; }
    .cell           { width: auto; height: auto; font-size: clamp(1.1rem, 5.5vw, 1.85rem); }
    .cell.emoji-cell { font-size: clamp(1rem, 5vw, 1.6rem); }
    .cell-notes     { font-size: clamp(0.4rem, 1.3vw, 0.65rem); }

    /* Controls */
    .controls-section  { width: min(94vw, 480px); gap: 6px; }
    .stats-row         { padding: 5px 10px; border-radius: 10px; }
    .stat-value        { font-size: 0.9rem; }
    .stat-label        { font-size: 0.6rem; }
    .stat-divider      { height: 20px; }
    .action-btn        { padding: 5px 3px 4px; border-radius: 9px; }
    .action-icon svg   { width: 16px; height: 16px; }
    .action-label      { font-size: 0.58rem; }
    .numpad            { grid-template-columns: repeat(9, 1fr); gap: 3px; }
    .num-btn           { font-size: 1.2rem; padding: 9px 0; border-radius: 9px; }
    .new-game-btn      { padding: 9px; font-size: 0.88rem; border-radius: 9px; }

    /* ── Floating buttons ── */
    .fab-stack { right: 12px; bottom: 12px; gap: 8px; }
    .share-floating-btn, .report-floating-btn, .new-game-fab { width: 38px; height: 38px; }
    .share-menu { right: 12px; bottom: 132px; }

    /* Hide regular New Game and all FABs on mobile/tablet */
    .new-game-btn#newGameBtn { display: none !important; }
    .new-game-fab            { display: none !important; }
    .share-floating-btn,
    .report-floating-btn     { display: none !important; }

    /* ── MP bar ── */
    .mp-bar-inner { padding: 0 10px; gap: 8px; }
    .mp-progress-row { min-width: 110px; }

    /* ── Modals ── */
    .modal-card  { padding: 28px 18px 22px; }
    .win-card    { min-width: unset; width: 92vw; }
    .win-stats   { padding: 10px 4px; }

    /* ── Footer ── */
    .site-footer       { padding: 12px 12px; }
    .footer-tagline    { display: none; }
    .footer-sep:nth-child(4) { display: none; }
}

/* ── Phone (≤ 600px): tighter sizing ── */
@media (max-width: 600px) {
    .game-area        { padding: 12px 2px 80px; gap: 5px; }
    .board            { width: min(98vw, 370px); height: min(98vw, 370px); }
    .controls-section { width: min(98vw, 370px); }
    .cell             { font-size: clamp(1rem, 5.5vw, 1.5rem); }
    .cell.emoji-cell  { font-size: clamp(0.95rem, 5vw, 1.35rem); }
    .cell-notes       { font-size: clamp(0.38rem, 1.2vw, 0.58rem); }

    /* Footer compact */
    .site-footer { padding: 10px 8px; }
    .footer-inner { flex-wrap: wrap; gap: 6px; row-gap: 4px; padding-top: 12px; }
    .footer-logo  { font-size: 0.78rem; }
    .footer-copy  { margin-left: 0; }
}

/* ── Small phones (≤ 390px) ── */
@media (max-width: 390px) {
    .logo  { font-size: 1.1rem; }
    .topbar-inner { padding: 0 8px; }

    .game-area { padding: 3px 8px 5px; gap: 4px; }
    .board { width: min(96vw, 300px); height: min(96vw, 300px); }
    .controls-section { width: min(96vw, 300px); gap: 4px; }

    .mode-btn { font-size: 0.7rem; padding: 4px 6px; }
    .num-btn  { font-size: 1.1rem; padding: 8px 0; }
    .stats-row { padding: 4px 8px; }

    .mood-bar-inner { gap: 6px; padding: 0 10px; }
    .swatch         { width: 20px; height: 20px; border-radius: 6px; }
}

/* ── Rooms modal ─────────────────────────────────────── */
.rooms-card {
    max-width: 420px;
    width: 90vw;
}

.rooms-card .lb-header {
    justify-content: center;
    text-align: center;
}

.rooms-card .lb-header h2,
.rooms-card .lb-eyebrow {
    text-align: center;
}

.rooms-card .new-game-btn {
    width: 100%;
    margin-top: 16px;
}

.rooms-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.rooms-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 14px 12px;
    border-radius: 12px;
    border: none;
    background: var(--accent-grad);
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
    white-space: nowrap;
}

.rooms-action-btn:hover { opacity: .88; }
.rooms-action-btn.secondary {
    background: var(--surface-solid);
    color: var(--text);
    border: 1px solid var(--border-strong);
}

.rooms-join-row {
    display: flex;
    gap: 8px;
}

.rooms-code-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border-strong);
    background: var(--surface-solid);
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    outline: none;
}

.rooms-code-input:focus { border-color: var(--accent); }

.rooms-join-btn {
    padding: 10px 18px;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s;
}

.rooms-join-btn:hover { background: var(--accent-hover); }

.rooms-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    padding: 6px 0;
    background: none;
    border: none;
    color: var(--accent);
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 14px;
    text-align: center;
}

.rooms-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
    margin-top: 14px;
    text-align: center;
}

.rooms-option-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.rooms-opt {
    padding: 7px 14px;
    border-radius: 8px;
    border: 1.5px solid var(--border-strong);
    background: var(--surface-solid);
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}

.rooms-opt:hover { border-color: var(--accent); }
.rooms-opt.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.rooms-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.room-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--surface-solid);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    gap: 10px;
}

.room-card-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.room-card-title {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text);
    text-transform: capitalize;
}

.room-card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.room-card-join {
    padding: 7px 14px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.rooms-refresh-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 9px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.rooms-refresh-btn:hover { border-color: var(--accent); color: var(--accent); }

.rooms-copy-btn {
    padding: 10px 24px;
    border-radius: 10px;
    border: 1.5px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-family: 'Outfit', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
}

/* ── Multiplayer status bar ──────────────────────────── */
.mp-bar {
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
}

.mp-bar-inner {
    max-width: 1020px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.mp-bar-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.mp-progress-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 200px;
}

.mp-prog-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.mp-prog-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.mp-prog-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width .4s ease;
}

.mp-prog-fill.mp-opp { background: #e84a4a; }

.mp-leave-btn {
    padding: 5px 12px;
    border-radius: 7px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.mp-leave-btn:hover { border-color: #e84a4a; color: #e84a4a; }

/* ── Language picker ─────────────────────────────────── */
.lang-picker {
    position: relative;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

#langCode {
    font-family: 'Outfit', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    min-width: 150px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lang-opt {
    padding: 8px 12px;
    border: none;
    background: none;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: background .12s;
}

.lang-opt:hover { background: var(--accent-light); }
.lang-opt.active { background: var(--accent-light); color: var(--accent); font-weight: 700; }

/* ── Footer link ─────────────────────────────────────── */
.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color .15s;
}
.footer-link:hover { color: var(--accent); }

/* ── FAB stack container ─────────────────────────────────── */
.fab-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 10px;
    z-index: 9999;
}

/* ── Share & Chat floating buttons ──────────────────────── */
.share-floating-btn,
.report-floating-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 14px rgba(0,0,0,0.22);
    flex-shrink: 0;
}
.report-floating-btn {
    background: var(--accent);
    color: #fff;
}
.share-floating-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
}
.new-game-fab {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 14px rgba(0,0,0,0.22);
    flex-shrink: 0;
    background: var(--accent);
    color: #fff;
}
.share-floating-btn:hover,
.report-floating-btn:hover,
.new-game-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,0.28);
}

.share-menu {
    position: fixed;
    right: 20px;
    bottom: 132px;
    z-index: 10000;
    width: 170px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    display: none;
    flex-direction: column;
    gap: 3px;
}
.share-menu.open { display: flex; }

.share-menu-item {
    width: 100%;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 9px 12px;
    transition: background 0.15s;
}
.share-menu-item:hover { background: var(--accent-light); }

.share-menu-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 0.72rem;
    font-weight: 800;
}
.share-icon-whatsapp  { background: #25d366; }
.share-icon-facebook  { background: #1877f2; }
.share-icon-x         { background: #111; }
.share-icon-telegram  { background: #2aabee; }
.share-icon-copy      { background: var(--accent); }

/* ── Report / Feedback modal ─────────────────────────── */
.report-modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 36px 40px 32px;
    max-width: 480px;
    width: 92%;
    position: relative;
    box-shadow: 0 24px 60px rgba(0,0,0,0.2);
}
.report-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: var(--accent-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}
.report-close-btn:hover { color: var(--text); }
.report-kicker {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.report-title {
    font-family: 'Syne', sans-serif;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    text-align: center;
    color: var(--accent);
    margin-bottom: 8px;
}
.report-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.93rem;
    margin-bottom: 22px;
    line-height: 1.6;
}
.report-type-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
.report-type-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.report-type-btn:hover,
.report-type-btn.selected {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}
.report-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.93rem;
    margin-bottom: 12px;
    box-sizing: border-box;
    transition: border-color 0.15s;
    resize: none;
    display: block;
}
.report-input:focus { outline: none; border-color: var(--accent); }
.report-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
}
@media (max-width: 480px) {
    .report-modal-card { padding: 26px 20px 24px; }
}

/* ── Vibe board glow ─────────────────────────────────────── */
body[data-theme="vibe"] .board {
    border-color: rgba(150,120,255,0.7);
    box-shadow: 0 0 60px rgba(139,124,248,0.45), 0 12px 48px rgba(0,0,0,0.65), var(--shine);
}

/* ── Display heading font ────────────────────────────────── */
.report-title,
.modal-stat-value,
.stat-value {
    font-family: 'Syne', sans-serif;
}

/* ── Collaborative: opponent board ───────────────────────── */
.opp-board-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 8px;
}

.board.board-readonly {
    cursor: default;
    pointer-events: none;
}

.opp-board-section .board {
    width: 288px;
    height: 288px;
    box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.12), var(--shine);
}

.opp-board-section .cell {
    width: auto;
    height: auto;
    font-size: 0.82rem;
}

.game-area.collab-mode {
    max-width: 1100px;
}

@media (max-width: 860px) {
    .opp-board-section .board {
        width: min(92vw, 440px);
        height: min(92vw, 440px);
    }
    .opp-board-section .cell { width: auto; height: auto; font-size: 1.1rem; }
}

/* ── Room notification toasts ────────────────────────── */
.toast-container {
    position: fixed;
    left: 16px;
    bottom: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.room-toast {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.16);
    pointer-events: auto;
    max-width: 280px;
    animation: toastIn 0.28s cubic-bezier(.22,.68,0,1.2) both;
}

.room-toast.room-toast-exit {
    animation: toastOut 0.25s ease both;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-16px) scale(0.95); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to   { opacity: 0; transform: translateX(-16px) scale(0.95); }
}

.room-toast-icon { font-size: 1.3rem; flex-shrink: 0; }

.room-toast-body { flex: 1; min-width: 0; }
.room-toast-title { font-size: 0.84rem; font-weight: 700; color: var(--text); }
.room-toast-sub   { font-size: 0.72rem; color: var(--text-muted); text-transform: capitalize; margin-top: 1px; }

.room-toast-join {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 5px 11px;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.room-toast-join:hover { opacity: 0.88; }

.room-toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 2px 4px;
    border-radius: 4px;
    flex-shrink: 0;
    line-height: 1;
    transition: color 0.15s;
}
.room-toast-close:hover { color: var(--text); }
