    :root {
      --bg: #f0f4ff;
      --surface: #ffffff;
      --surface2: #f8f9fe;
      --border: #e4e8f5;
      --text: #1a1d2e;
      --text2: #6b7280;
      --text3: #9ca3af;
      --accent: #3b82f6;
      --accent2: #2563eb;
      --accent-light: #dbeafe;
      --red: #ef4444;
      --red-light: #fee2e2;
      --green: #22c55e;
      --gold: #f59e0b;
      --cell-fixed: #1a1d2e;
      --cell-user: #2563eb;
      --cell-bg: #ffffff;
      --cell-selected: #3b82f6;
      --cell-highlight: #eff6ff;
      --cell-border: #e4e8f5;
      --cell-block-border: #1a1d2e;
      --grid-wall: #1a1d2e;
      --memo-color: #6b7280;
      --font-scale: 1;
    }
    .dark {
      --bg: #0f1117;
      --surface: #1a1d2e;
      --surface2: #232636;
      --border: #2d3148;
      --text: #f0f4ff;
      --text2: #9ca3af;
      --text3: #6b7280;
      --accent: #60a5fa;
      --accent2: #3b82f6;
      --accent-light: #1e3a5f;
      --cell-fixed: #e2e8f0;
      --cell-user: #60a5fa;
      --cell-bg: #1a1d2e;
      --cell-selected: #2563eb;
      --cell-highlight: #1e2d4a;
      --cell-border: #2d3148;
      --cell-block-border: #475569;
      --grid-wall: #475569;
      --memo-color: #6b7280;
    }
    /* ── 中級・上級テーマ — strictly matches sudoku-advanced.html ── */
    .theme-hard {
      --bg: #1e293b;
      --surface: rgba(255,255,255,0.1);
      --surface2: rgba(255,255,255,0.05);
      --border: rgba(255,255,255,0.2);
      --text: #f8fafc;
      --text2: #94a3b8;
      --text3: #64748b;
      --accent: #ef4444;
      --accent2: #dc2626;
      --accent-light: rgba(239,68,68,0.3);
      --red: #dc2626;
      --red-light: #fecaca;
      --green: #22c55e;
      --gold: #f59e0b;
      --cell-fixed: #1e293b;
      --cell-user: #dc2626;
      --cell-bg: #ffffff;
      --cell-selected: #ef4444;
      --cell-highlight: #fef2f2;
      --cell-border: #cbd5e1;
      --cell-block-border: #1e293b;
      --grid-wall: #1e293b;
      --memo-color: #64748b;
    }
    /* ── 超上級テーマ (gold/night — strictly matches sudoku-extreme.html) ── */
    .theme-expert {
      --bg: #0f0f23;
      --surface: #1a1a2e;
      --surface2: #16213e;
      --border: #3d3d6b;
      --text: #e2e8f0;
      --text2: #94a3b8;
      --text3: #64748b;
      --accent: #ffd700;
      --accent2: #f59e0b;
      --accent-light: rgba(255,215,0,0.2);
      --red: #ff6b6b;
      --red-light: rgba(255,107,107,0.2);
      --green: #4ade80;
      --gold: #ffd700;
      --cell-fixed: #ffd700;
      --cell-user: #4ade80;
      --cell-bg: #1a1a2e;
      --cell-selected: #ffd700;
      --cell-highlight: rgba(255,215,0,0.1);
      --cell-border: #3d3d6b;
      --cell-block-border: #ffd700;
      --grid-wall: #0f0f23;
      --memo-color: #64748b;
    }

    /* ── Dark mode + difficulty theme composites ── */
    /* dark mode + hard: fix white cell-bg and cell-fixed contrast */
    .dark .theme-hard {
      --cell-bg: #1e293b;
      --cell-fixed: #e2e8f0;
      --cell-highlight: rgba(239,68,68,0.15);
    }
    /* dark mode + expert: already dark, ensure cell-fixed gold is preserved */
    .dark .theme-expert {
      --cell-fixed: #ffd700;
    }

    /* sudoku-grid wrapper gets the gradient container look */
    .theme-expert .sudoku-wrap {
      padding: 0 12px;
    }
    .theme-expert .sudoku-grid {
      box-shadow: 0 0 40px rgba(255,215,0,0.2), 0 8px 32px rgba(0,0,0,0.4);
      outline: 1px solid rgba(255,215,0,0.3);
      border-radius: 4px;
    }
    /* fixed numbers get gold text-shadow glow */
    .theme-expert .cell:not(.user-val) {
      text-shadow: 0 0 8px rgba(255,215,0,0.4);
    }
    /* selected cell: gradient + dark text */
    .theme-expert .cell.selected {
      background: linear-gradient(135deg, #ffd700, #ff6b6b) !important;
      color: #0f0f23 !important;
      text-shadow: none !important;
    }
    .theme-expert .cell.conflict {
      background: rgba(255,107,107,0.2) !important;
      color: #ff6b6b !important;
      text-shadow: 0 0 10px rgba(255,107,107,0.5) !important;
    }
    /* numpad candidate highlight: gold glow */
    .theme-expert .num-btn.candidate-hi {
      background: rgba(255,215,0,0.2);
      border-color: #ffd700;
      color: #ffd700;
      box-shadow: 0 0 10px rgba(255,215,0,0.3);
    }
    /* back btn / icon btns */
    .theme-expert .game-back-btn,
    .theme-expert .game-icon-btn {
      background: rgba(255,255,255,0.05);
      border-color: rgba(255,215,0,0.2);
      color: #e2e8f0;
    }
    .theme-expert .game-stat-val { color: #ffd700; font-family: 'DM Mono', monospace; }
    .theme-expert .game-diff-label { color: #94a3b8; }
    .theme-expert .game-title { color: #ffd700; text-shadow: 0 0 20px rgba(255,215,0,0.4); }
    /* wave animation: gold pulse */
    .theme-expert .cell.anim-wave { animation: waveCell-expert 0.5s ease-out !important; }
    @keyframes waveCell-expert {
      0%   { background: rgba(255,215,0,0.1); }
      40%  { background: rgba(255,215,0,0.4); color: #0f0f23; }
      100% { background: rgba(255,215,0,0.1); }
    }
    /* rainbow completion: matches extreme palette */
    .theme-expert .cell.anim-rainbow { animation: rainbowCell-expert 1.5s ease-out; }
    @keyframes rainbowCell-expert {
      0%   { background: rgba(255,107,107,0.3); }
      25%  { background: rgba(74,222,128,0.3); }
      50%  { background: rgba(96,165,250,0.3); }
      75%  { background: rgba(192,132,252,0.3); }
      100% { background: rgba(255,215,0,0.3); }
    }
    /* glow animation for cell input */
    .theme-expert .cell.anim-glow { animation: glowCell-expert 0.6s ease-out; }
    @keyframes glowCell-expert {
      0%,100% { box-shadow: 0 0 0 rgba(255,215,0,0); }
      50%      { box-shadow: 0 0 25px rgba(255,215,0,0.8); }
    }
    /* sparkle dot */
    .sparkle-expert {
      position: fixed;
      width: 8px;
      height: 8px;
      background: #ffd700;
      border-radius: 50%;
      pointer-events: none;
      z-index: 500;
      box-shadow: 0 0 10px #ffd700;
      animation: sparkleAnim 0.6s ease-out forwards;
    }
    @keyframes sparkleAnim {
      0%   { opacity: 0; transform: scale(0); }
      50%  { opacity: 1; transform: scale(1); }
      100% { opacity: 0; transform: scale(0); }
    }
    /* combo popup override for expert: gold, rotates */
    .theme-expert ~ .combo-popup,
    .combo-popup.expert-combo {
      color: #ffd700 !important;
      text-shadow: 0 0 30px rgba(255,215,0,0.8), 0 0 60px rgba(255,107,107,0.5) !important;
      font-size: 48px !important;
    }
    @keyframes comboAnimExpert {
      0%   { transform: translate(-50%,-50%) scale(0.5) rotate(-10deg); opacity: 0; }
      20%  { transform: translate(-50%,-50%) scale(1.3) rotate(5deg);  opacity: 1; }
      100% { transform: translate(-50%,-50%) scale(1)   rotate(0deg);  opacity: 0; }
    }
    .combo-popup.expert-combo.show { animation: comboAnimExpert 1s ease-out forwards !important; }

    /* ── 中級・上級テーマ CSS — strictly matches sudoku-advanced.html ── */
    /* Background gradient on game screen */
    .theme-hard { background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important; }

    /* Numpad buttons: glass style */
    .theme-hard .num-btn {
      background: rgba(255,255,255,0.1);
      border-color: rgba(255,255,255,0.2);
      color: #f8fafc;
    }
    .theme-hard .num-btn.candidate-hi {
      background: rgba(239,68,68,0.3);
      border-color: #ef4444;
      color: #fca5a5;
    }
    /* Topbar buttons */
    .theme-hard .game-back-btn,
    .theme-hard .game-icon-btn {
      background: rgba(255,255,255,0.1);
      border-color: rgba(255,255,255,0.2);
      color: #f8fafc;
    }
    .theme-hard .game-stat-val { color: #f8fafc; }
    .theme-hard .game-diff-label { color: #94a3b8; }
    .theme-hard .game-title { color: #f8fafc; }

    /* Cell animations — exact sudoku-advanced values */
    .theme-hard .cell.anim-wave { animation: waveCell-hard 0.5s ease-out !important; }
    @keyframes waveCell-hard {
      0%   { background: #fef2f2; }
      50%  { background: #f87171; }
      100% { background: #fef2f2; }
    }
    .theme-hard .cell.anim-glow { animation: glowCell-hard 0.6s ease-out; }
    @keyframes glowCell-hard {
      0%,100% { box-shadow: 0 0 0 rgba(239,68,68,0); }
      50%     { box-shadow: 0 0 20px rgba(239,68,68,0.6); }
    }
    .theme-hard .cell.anim-rainbow { animation: rainbowCell-hard 1s ease-out; }
    @keyframes rainbowCell-hard {
      0%   { background: #fef3c7; }
      25%  { background: #d1fae5; }
      50%  { background: #dbeafe; }
      75%  { background: #fce7f3; }
      100% { background: #fef3c7; }
    }
    /* combo popup: amber, no rotation */
    .combo-popup.hard-combo {
      color: #f59e0b !important;
      text-shadow: 0 3px 12px rgba(245,158,11,0.5) !important;
      font-size: 42px !important;
    }
    @keyframes comboAnimHard {
      0%   { transform: translate(-50%,-50%) scale(0.5); opacity: 0; }
      20%  { transform: translate(-50%,-50%) scale(1.2); opacity: 1; }
      100% { transform: translate(-50%,-50%) scale(1);   opacity: 0; }
    }
    .combo-popup.hard-combo.show { animation: comboAnimHard 0.8s ease-out forwards !important; }

    * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
    body {
      font-family: 'Noto Sans JP', sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
      min-height: 100dvh;
      display: flex;
      justify-content: center;
      align-items: flex-start;
      overflow-x: hidden;
      font-size: calc(16px * var(--font-scale));
    }
    /* ── App Shell ── */
    #app {
      width: 100%;
      max-width: 430px;
      min-height: 100vh;
      min-height: 100dvh;
      background: var(--bg);
      position: relative;
      overflow: hidden;
    }
    .screen {
      position: absolute;
      top: env(safe-area-inset-top);
      right: env(safe-area-inset-right);
      bottom: env(safe-area-inset-bottom);
      left: env(safe-area-inset-left);
      display: flex;
      flex-direction: column;
      opacity: 0;
      pointer-events: none;
      transform: translateX(20px);
      transition: opacity 0.2s ease, transform 0.2s ease;
    }
    .screen.active {
      opacity: 1;
      pointer-events: all;
      transform: translateX(0);
    }

    /* ── SCROLL WRAPPER (used by screens with bottom-nav) ── */
    .screen-scroll {
      flex: 1;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }

    /* ── HOME SCREEN ── */
    .home-header {
      padding: 60px 24px 20px;
      text-align: center;
    }
    .home-tagline {
      font-size: 11px;
      color: var(--text2);
      font-weight: 500;
      letter-spacing: 0.05em;
      margin-bottom: 4px;
    }
    .home-logo {
      font-size: 36px;
      font-weight: 900;
      color: var(--text);
      letter-spacing: -1px;
    }
    .home-logo span { color: var(--accent); }
    .home-banner {
      margin: 0 20px 16px;
      background: var(--surface);
      border-radius: 16px;
      overflow: hidden;
      border: 1px solid var(--border);
    }
    .home-banner-inner {
      padding: 20px;
      display: flex;
      flex-direction: column;
      gap: 14px;
    }
    .continue-card {
      background: var(--accent);
      border-radius: 12px;
      padding: 16px 18px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      cursor: pointer;
      transition: transform 0.15s, box-shadow 0.15s;
      box-shadow: 0 4px 16px rgba(59,130,246,0.35);
    }
    .continue-card:active { transform: scale(0.98); }
    .continue-card-left { display: flex; flex-direction: column; gap: 2px; }
    .continue-card-label { font-size: 11px; color: rgba(255,255,255,0.75); font-weight: 500; }
    .continue-card-title { font-size: 16px; font-weight: 700; color: #fff; }
    .continue-card-sub { font-size: 11px; color: rgba(255,255,255,0.7); }
    .continue-card-arrow { color: rgba(255,255,255,0.8); font-size: 20px; }
    .daily-card {
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 14px 16px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      cursor: pointer;
    }
    .daily-card:active { background: var(--accent-light); }
    .daily-card-left { display: flex; align-items: center; gap: 10px; }
    .daily-card-icon { font-size: 24px; }
    .daily-card-title { font-size: 14px; font-weight: 600; color: var(--text); }
    .daily-card-sub { font-size: 11px; color: var(--text2); margin-top: 1px; }
    .daily-card-chevron { color: var(--text3); font-size: 16px; }
    .home-new-btn {
      margin: 0 20px 8px;
      background: var(--surface);
      border: 1.5px solid var(--border);
      border-radius: 14px;
      padding: 16px;
      font-size: 15px;
      font-weight: 600;
      color: var(--text);
      cursor: pointer;
      width: calc(100% - 40px);
      transition: background 0.15s;
    }
    .home-new-btn:active { background: var(--accent-light); color: var(--accent); }

    /* ── GUEST SAVE BANNER ── */
    .guest-save-banner {
      margin: 0 20px 12px;
      background: var(--surface);
      border: 1.5px solid var(--accent);
      border-radius: 14px;
      padding: 16px 18px;
      text-align: center;
    }
    .guest-save-banner-icon { font-size: 22px; margin-bottom: 6px; }
    .guest-save-banner-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
    .guest-save-banner-desc { font-size: 12px; color: var(--text2); margin-bottom: 12px; line-height: 1.4; }
    .guest-save-banner-google {
      width: 100%; padding: 10px; background: #fff; color: #333;
      border: 1.5px solid #ddd; border-radius: 10px; font-size: 13px; font-weight: 600;
      cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 8px;
    }
    .guest-save-banner-email {
      width: 100%; padding: 10px; background: var(--accent); color: #fff;
      border: none; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
    }

    /* ── BOTTOM NAV ── */
    .bottom-nav {
      height: 72px;
      flex-shrink: 0;
      background: var(--surface);
      border-top: 1px solid var(--border);
      display: flex;
      align-items: center;
    }
    .nav-item {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 3px;
      padding: 10px 0;
      cursor: pointer;
      color: var(--text3);
      transition: color 0.15s;
    }
    .nav-item.active { color: var(--accent); }
    .nav-item svg { width: 22px; height: 22px; }
    .nav-item span { font-size: 10px; font-weight: 600; }

    /* ── CONFIRM DIALOG ── */
    .confirm-overlay {
      position: fixed; inset: 0; background: rgba(0,0,0,.55);
      display: flex; align-items: center; justify-content: center; z-index: 9999;
    }
    .confirm-dialog {
      background: var(--surface); border-radius: 18px; padding: 26px 22px 20px;
      max-width: 310px; width: 88%; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,.25);
    }
    .confirm-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 10px; color: var(--text); }
    .confirm-msg   { font-size: .875rem; color: var(--text2); margin-bottom: 22px; line-height: 1.5; }
    .confirm-btns  { display: flex; gap: 10px; }
    .confirm-btn-cancel {
      flex: 1; padding: 12px; border-radius: 10px;
      border: 1px solid var(--border); background: var(--surface2);
      color: var(--text); font-size: .9rem; font-weight: 600; cursor: pointer;
    }
    .confirm-btn-ok {
      flex: 1; padding: 12px; border-radius: 10px;
      border: none; background: var(--accent);
      color: #fff; font-size: .9rem; font-weight: 600; cursor: pointer;
    }
    .confirm-btn-ok.danger { background: #ef4444; }

    /* ── PROFILE CARD (top of settings) ── */
    .profile-card {
      margin: 16px 20px 4px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 16px;
      padding: 20px 16px;
      display: flex;
      align-items: center;
      gap: 14px;
    }
    .profile-avatar {
      width: 52px; height: 52px; border-radius: 50%;
      background: var(--accent); color: #fff;
      display: flex; align-items: center; justify-content: center;
      font-size: 20px; font-weight: 800; flex-shrink: 0;
    }
    .profile-info { flex: 1; min-width: 0; }
    .profile-name {
      font-size: 15px; font-weight: 700; color: var(--text);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .profile-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
    .profile-action {
      font-size: 12px; color: var(--accent); font-weight: 600;
      cursor: pointer; flex-shrink: 0;
    }

    /* ── HOME HEADER SETTINGS BTN ── */
    .home-settings-btn {
      position: absolute; top: 16px; right: 16px;
      width: 36px; height: 36px; border-radius: 50%;
      background: var(--surface); border: 1px solid var(--border);
      display: flex; align-items: center; justify-content: center;
      cursor: pointer; color: var(--text2);
    }

    /* ── DIFFICULTY SHEET ── */
    .sheet-overlay {
      position: absolute;
      inset: 0;
      background: rgba(0,0,0,0.5);
      z-index: 100;
      display: none;
      align-items: flex-end;
    }
    .sheet-overlay.open { display: flex; }
    .sheet {
      width: 100%;
      background: var(--surface);
      border-radius: 24px 24px 0 0;
      padding: 16px 20px 40px;
      transform: translateY(100%);
      transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
    }
    .sheet-overlay.open .sheet { transform: translateY(0); }
    .sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 20px; }
    .sheet-title { font-size: 16px; font-weight: 700; color: var(--text); text-align: center; margin-bottom: 16px; }
    .diff-list { display: flex; flex-direction: column; gap: 8px; }
    .diff-item {
      display: flex;
      align-items: center;
      padding: 14px 16px;
      border-radius: 12px;
      background: var(--surface2);
      border: 1.5px solid var(--border);
      cursor: pointer;
      transition: all 0.15s;
      position: relative;
    }
    .diff-item:active { transform: scale(0.99); }
    .diff-item.locked { opacity: 0.5; cursor: default; }
    .diff-item-dot { width: 10px; height: 10px; border-radius: 50%; margin-right: 12px; flex-shrink: 0; }
    .diff-item-info { flex: 1; }
    .diff-item-name { font-size: 15px; font-weight: 600; color: var(--text); }
    .diff-item-sub { font-size: 11px; color: var(--text2); margin-top: 1px; }
    .diff-item-lock { font-size: 16px; color: var(--text3); }
    .diff-item-stars { font-size: 12px; color: var(--gold); margin-top: 2px; }

    /* ── GAME SCREEN ── */
    #screen-game {
      background: var(--bg);
    }
    .game-topbar {
      display: flex;
      align-items: center;
      padding: 12px 16px 8px;
      gap: 8px;
    }
    .game-back-btn {
      width: 36px;
      height: 36px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 10px;
      background: var(--surface);
      border: 1px solid var(--border);
      cursor: pointer;
      color: var(--text);
      font-size: 18px;
    }
    .game-topbar-center { flex: 1; text-align: center; }
    .game-diff-label { font-size: 11px; color: var(--text2); font-weight: 500; }
    .game-title { font-size: 14px; font-weight: 700; color: var(--text); }
    .game-topbar-actions { display: flex; gap: 6px; }
    .game-icon-btn {
      width: 36px;
      height: 36px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 10px;
      background: var(--surface);
      border: 1px solid var(--border);
      cursor: pointer;
      color: var(--text2);
      font-size: 16px;
      position: relative;
    }
    .game-stats-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 6px 20px 10px;
    }
    .game-stat { display: flex; align-items: center; gap: 6px; }
    .game-stat-icon { font-size: 14px; }
    .game-stat-val { font-size: 14px; font-weight: 600; color: var(--text); font-family: 'DM Mono', monospace; }
    .game-stat-val.error { color: var(--red); }
    .mistake-dots { display: flex; gap: 4px; }
    .mistake-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
    .mistake-dot.filled { background: var(--red); }

    /* ── SUDOKU GRID ── */
    .sudoku-wrap {
      padding: 0 12px;
      display: flex;
      justify-content: center;
    }
    .sudoku-grid {
      display: grid;
      grid-template-columns: repeat(9, 1fr);
      grid-template-rows: repeat(9, 1fr);
      width: min(calc(100vw - 24px), 396px);
      height: min(calc(100vw - 24px), 396px);
      border: 2px solid var(--cell-block-border);
      background: var(--grid-wall);
      border-radius: 6px;
      overflow: hidden;
      gap: 0;
    }
    .cell {
      background: var(--cell-bg);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: clamp(calc(16px * var(--font-scale)), 4.5vw, calc(22px * var(--font-scale)));
      font-weight: 700;
      color: var(--cell-fixed);
      position: relative;
      cursor: pointer;
      user-select: none;
      -webkit-user-select: none;
      transition: background 0.1s;
      border-right: 0.5px solid var(--cell-border);
      border-bottom: 0.5px solid var(--cell-border);
    }
    .cell.block-right { border-right: 2px solid var(--cell-block-border); }
    .cell.block-bottom { border-bottom: 2px solid var(--cell-block-border); }
    .cell.user-val { color: var(--cell-user); }
    .cell.selected { background: var(--cell-selected) !important; color: #fff !important; }
    .cell.highlight { background: var(--cell-highlight); }
    .cell.same-val { background: var(--accent-light); }
    .cell.conflict { background: var(--red-light) !important; color: var(--red) !important; }
    .cell .memo-grid {
      position: absolute;
      inset: 1px;
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      grid-template-rows: repeat(3, 1fr);
      font-size: clamp(calc(7px * var(--font-scale)), 1.8vw, calc(9px * var(--font-scale)));
      font-weight: 500;
      color: var(--memo-color);
      pointer-events: none;
    }
    .cell .memo-grid span { display: flex; align-items: center; justify-content: center; }
    .cell .memo-grid span.memo-hi { color: var(--accent); font-weight: 800; background: var(--accent-light); border-radius: 2px; }
    @keyframes cellPop { 0%{transform:scale(0.7);opacity:0} 60%{transform:scale(1.15)} 100%{transform:scale(1);opacity:1} }
    @keyframes cellShake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-3px)} 75%{transform:translateX(3px)} }
    @keyframes waveCell { 0%{background:var(--cell-highlight)} 40%{background:var(--accent)} 100%{background:var(--cell-highlight)} }
    @keyframes cellGlow { 0%,100%{box-shadow:0 0 0 rgba(59,130,246,0)} 50%{box-shadow:0 0 20px rgba(59,130,246,0.6)} }
    @keyframes cellRainbow { 0%{background:#fef3c7} 25%{background:#d1fae5} 50%{background:#dbeafe} 75%{background:#fce7f3} 100%{background:#fef3c7} }
    .cell.anim-pop { animation: cellPop 0.25s ease-out; }
    .cell.anim-shake { animation: cellShake 0.25s ease-out; }
    .cell.anim-wave { animation: waveCell 0.45s ease-out; color: #fff; }
    .cell.anim-glow { animation: cellGlow 0.6s ease-out; }
    .cell.anim-rainbow { animation: cellRainbow 1s ease-out; }

    /* ── NUMPAD ── */
    .numpad-section {
      padding: 12px 16px 6px;
    }
    .numpad-grid {
      display: grid;
      grid-template-columns: repeat(9, 1fr);
      gap: 5px;
    }
    .num-btn {
      aspect-ratio: 1;
      border: 1.5px solid var(--border);
      border-radius: 10px;
      background: var(--surface);
      font-size: clamp(calc(15px * var(--font-scale)), 4vw, calc(20px * var(--font-scale)));
      font-weight: 700;
      color: var(--text);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.12s;
      position: relative;
    }
    .num-btn:active { transform: scale(0.93); background: var(--accent-light); }
    .num-btn.candidate-hi { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
    .num-btn.depleted { opacity: 0.3; }
    .num-btn .num-count {
      position: absolute;
      top: 2px;
      right: 3px;
      font-size: 8px;
      font-weight: 600;
      color: var(--text3);
    }

    /* ── CONTROLS ── */
    /* ── PROGRESS BAR ── */
    .progress-bar {
      height: 6px;
      background: var(--border);
      border-radius: 3px;
      margin: 6px 16px 0;
      overflow: hidden;
    }

    .progress-fill {
      height: 100%;
      width: 0%;
      background: linear-gradient(90deg, var(--accent), var(--accent2));
      border-radius: 3px;
      transition: width 0.2s ease-out;
    }
    .theme-expert .progress-fill {
      background: linear-gradient(90deg, #ffd700, #ff6b6b);
      box-shadow: 0 0 10px rgba(255,215,0,0.5);
    }
    .theme-hard .progress-fill {
      background: linear-gradient(90deg, #ef4444, #dc2626);
    }

    /* ── CONTROLS (sudoku-extreme style) ── */
    .controls-section {
      padding: 8px 16px 4px;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .ctrl-row {
      display: flex;
      gap: 6px;
      width: 100%;
    }
    /* Base button — light theme */
    .ctrl-btn {
      flex: 1;
      padding: 12px 8px;
      font-size: 13px;
      font-weight: 600;
      border: 1.5px solid var(--border);
      border-radius: 10px;
      background: var(--surface);
      color: var(--text);
      cursor: pointer;
      transition: all 0.15s;
      text-align: center;
      white-space: nowrap;
    }
    .ctrl-btn:active { transform: scale(0.96); background: var(--accent-light); }
    .ctrl-btn.mode-active {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }
    /* ── hard/medium theme: glass dark ── */
    .theme-hard .ctrl-btn {
      background: rgba(255,255,255,0.08);
      border-color: rgba(255,255,255,0.2);
      color: #f8fafc;
    }
    .theme-hard .ctrl-btn:active { background: rgba(255,255,255,0.15); }
    .theme-hard .ctrl-btn.mode-active {
      background: #ef4444;
      border-color: #ef4444;
      color: #fff;
    }
    /* ── expert theme: gold glass ── */
    .theme-expert .ctrl-btn {
      background: rgba(255,255,255,0.05);
      border-color: rgba(255,215,0,0.2);
      color: #e2e8f0;
    }
    .theme-expert .ctrl-btn:active { background: rgba(255,215,0,0.1); }
    .theme-expert .ctrl-btn.mode-active {
      background: linear-gradient(135deg, #ffd700, #ff6b6b);
      border-color: transparent;
      color: #0f0f23;
    }

    /* ── AUTO DEMO BUTTON ── */
    .demo-btn-row { padding: 2px 16px 14px; }
    .demo-btn {
      width: 100%;
      padding: 13px;
      border-radius: 10px;
      border: none;
      font-size: 14px;
      font-weight: 700;
      cursor: pointer;
      transition: opacity 0.15s, transform 0.1s;
      /* beginner/daily: blue */
      background: linear-gradient(135deg, #3b82f6, #2563eb);
      color: #fff;
      box-shadow: 0 2px 8px rgba(59,130,246,0.4);
    }
    .demo-btn:active { transform: scale(0.98); opacity: 0.9; }
    .demo-btn:disabled { opacity: 0.55; }
    /* hard/medium: red — matches sudoku-advanced accent */
    .theme-hard .demo-btn {
      background: linear-gradient(135deg, #ef4444, #dc2626);
      color: #fff;
      box-shadow: 0 2px 8px rgba(239,68,68,0.4);
    }
    /* expert: gold→coral, dark text, gold glow — exact sudoku-extreme */
    .theme-expert .demo-btn {
      background: linear-gradient(135deg, #ffd700, #ff6b6b);
      color: #0f0f23;
      font-weight: 700;
      box-shadow: 0 0 20px rgba(255,215,0,0.4);
    }

    /* ── CANDIDATE PANEL (matches hint-panel in reference files) ── */
    .candidate-panel {
      margin: 8px 16px 0;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 12px 16px;
      text-align: center;
    }
    .candidate-panel-label {
      font-size: 11px;
      color: var(--text3);
      margin-bottom: 4px;
      font-weight: 500;
    }
    .candidate-panel-content {
      font-size: 14px;
      font-weight: 500;
      color: var(--text);
    }
    .candidate-panel-content .cand-naked  { color: var(--green); font-weight: 600; }
    .candidate-panel-content .cand-warn   { color: var(--gold);  font-weight: 600; }
    .candidate-panel-content .cand-danger { color: var(--red);   font-weight: 600; }
    /* hard/medium: white card on dark bg */
    .theme-hard .candidate-panel {
      background: rgba(255,255,255,0.95);
      border-color: transparent;
    }
    .theme-hard .candidate-panel-label  { color: #94a3b8; }
    .theme-hard .candidate-panel-content { color: #1e293b; }
    .theme-hard .candidate-panel-content .cand-naked  { color: #16a34a; }
    .theme-hard .candidate-panel-content .cand-warn   { color: #f59e0b; }
    /* expert: dark glass with gold border */
    .theme-expert .candidate-panel {
      background: rgba(30,30,63,0.95);
      border-color: rgba(255,215,0,0.2);
    }
    .theme-expert .candidate-panel-label  { color: #ffd700; }
    .theme-expert .candidate-panel-content { color: #e2e8f0; }
    .theme-expert .candidate-panel-content .cand-naked  { color: #4ade80; }
    .theme-expert .candidate-panel-content .cand-warn   { color: #fbbf24; }
    .theme-expert .candidate-panel-content .cand-danger { color: #ff6b6b; }

    /* ── PAUSE OVERLAY ── */
    .pause-overlay {
      position: absolute;
      inset: 0;
      background: rgba(0,0,0,0.85);
      z-index: 90;
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 20px;
    }
    .pause-overlay.show { display: flex; }
    .pause-title { font-size: 28px; font-weight: 900; color: #fff; }
    .pause-time { font-size: 48px; font-weight: 700; color: var(--accent); font-family: 'DM Mono', monospace; }
    .pause-btns { display: flex; flex-direction: column; gap: 10px; width: 200px; }
    .pause-btn {
      padding: 14px;
      border-radius: 14px;
      font-size: 15px;
      font-weight: 700;
      border: none;
      cursor: pointer;
      text-align: center;
    }
    .pause-btn.primary { background: var(--accent); color: #fff; }
    .pause-btn.secondary { background: rgba(255,255,255,0.1); color: #fff; }

    /* ── COMPLETION OVERLAY ── */
    .complete-overlay {
      position: absolute;
      inset: 0;
      background: rgba(0,0,0,0.7);
      z-index: 95;
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
    }
    .complete-overlay.show { display: flex; }
    .complete-card {
      background: var(--surface);
      border-radius: 24px;
      padding: 32px 28px 28px;
      width: 84%;
      text-align: center;
      box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    }
    /* hard/expert themes: force opaque white card so it's readable */
    .theme-hard .complete-card,
    .theme-expert .complete-card {
      background: #ffffff;
    }
    .theme-hard .complete-title,
    .theme-hard .complete-sub,
    .theme-hard .complete-stat-label { color: #1e293b; }
    .theme-hard .complete-stat-val { color: #ef4444; }
    .theme-hard .complete-stat { background: #f8fafc; }
    .theme-hard .complete-btn.secondary { background: #f1f5f9; color: #1e293b; border-color: #e2e8f0; }
    .theme-expert .complete-card { background: #1a1a2e; border: 1px solid rgba(255,215,0,0.3); }
    .theme-expert .complete-title { color: #ffd700; }
    .theme-expert .complete-sub,
    .theme-expert .complete-stat-label { color: #94a3b8; }
    .theme-expert .complete-stat-val { color: #ffd700; }
    .theme-expert .complete-stat { background: #0f0f23; }
    .theme-expert .complete-btn.secondary { background: rgba(255,255,255,0.05); color: #e2e8f0; border-color: rgba(255,215,0,0.2); }
    .theme-expert .complete-btn.primary { background: linear-gradient(135deg,#ffd700,#ff6b6b); color: #0f0f23; }

    /* ── GAME OVER OVERLAY ── */
    .gameover-overlay {
      position: absolute;
      inset: 0;
      background: rgba(0,0,0,0.82);
      z-index: 96;
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
    }
    .gameover-overlay.show { display: flex; }
    .gameover-card {
      background: #fff;
      border-radius: 24px;
      padding: 32px 28px 28px;
      width: 84%;
      text-align: center;
      box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    }
    .theme-hard .gameover-card { background: #fff; }
    .theme-expert .gameover-card { background: #1a1a2e; border: 1px solid rgba(255,107,107,0.4); }
    .gameover-emoji { font-size: 52px; margin-bottom: 8px; }
    .gameover-title { font-size: 24px; font-weight: 900; color: #ef4444; margin-bottom: 4px; }
    .theme-expert .gameover-title { color: #ff6b6b; }
    .gameover-sub { font-size: 13px; color: #64748b; margin-bottom: 24px; }
    .theme-expert .gameover-sub { color: #94a3b8; }
    .gameover-btns { display: flex; gap: 8px; }
    .gameover-btn {
      flex: 1;
      padding: 14px;
      border-radius: 12px;
      font-size: 14px;
      font-weight: 700;
      border: none;
      cursor: pointer;
    }
    .gameover-btn.primary { background: var(--accent); color: #fff; }
    .theme-hard .gameover-btn.primary { background: #ef4444; }
    .theme-expert .gameover-btn.primary { background: linear-gradient(135deg,#ffd700,#ff6b6b); color: #0f0f23; }
    .gameover-btn.secondary { background: #f1f5f9; color: #1e293b; }
    .theme-expert .gameover-btn.secondary { background: rgba(255,255,255,0.05); color: #e2e8f0; border: 1.5px solid rgba(255,255,255,0.1); }
    .complete-emoji { font-size: 48px; margin-bottom: 8px; }
    .complete-title { font-size: 24px; font-weight: 900; color: var(--text); margin-bottom: 4px; }
    .complete-sub { font-size: 13px; color: var(--text2); margin-bottom: 20px; }
    .complete-stats { display: flex; gap: 12px; margin-bottom: 20px; }
    .complete-stat { flex: 1; background: var(--surface2); border-radius: 12px; padding: 12px; }
    .complete-stat-val { font-size: 22px; font-weight: 900; color: var(--accent); font-family: 'DM Mono', monospace; }
    .complete-stat-label { font-size: 10px; color: var(--text2); margin-top: 2px; }
    .complete-btns { display: flex; gap: 8px; }
    .complete-btn {
      flex: 1;
      padding: 14px;
      border-radius: 12px;
      font-size: 14px;
      font-weight: 700;
      border: none;
      cursor: pointer;
    }
    .complete-btn.primary { background: var(--accent); color: #fff; }
    .complete-btn.secondary { background: var(--surface2); color: var(--text); border: 1.5px solid var(--border); }

    /* ── SHARE OVERLAY ── */
    .share-overlay {
      position: absolute;
      inset: 0;
      background: rgba(0,0,0,0.6);
      z-index: 110;
      display: none;
      align-items: flex-end;
    }
    .share-overlay.open { display: flex; }
    .share-sheet { width: 100%; background: var(--surface); border-radius: 24px 24px 0 0; padding: 20px 20px 48px; }
    .share-title { font-size: 16px; font-weight: 700; text-align: center; margin-bottom: 16px; color: var(--text); }
    .share-preview {
      background: var(--accent);
      border-radius: 14px;
      padding: 16px;
      margin-bottom: 16px;
      text-align: center;
      color: #fff;
    }
    .share-preview-logo { font-size: 18px; font-weight: 900; }
    .share-preview-sub { font-size: 11px; opacity: 0.8; margin-top: 4px; }
    .share-icons { display: flex; justify-content: space-around; }
    .share-icon-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; }
    .share-icon-circle { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; }
    .share-icon-label { font-size: 11px; color: var(--text2); }
    .share-cancel { width: 100%; margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--surface2); border: 1.5px solid var(--border); font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; }

    /* ── THEME PANEL ── */
    .theme-panel-overlay {
      position: absolute;
      inset: 0;
      background: rgba(0,0,0,0.5);
      z-index: 105;
      display: none;
      align-items: flex-end;
    }
    .theme-panel-overlay.open { display: flex; }
    .theme-panel {
      width: 100%;
      background: var(--surface);
      border-radius: 24px 24px 0 0;
      padding: 20px 20px 48px;
    }
    .theme-panel-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 16px; text-align: center; }
    .theme-swatches { display: flex; gap: 10px; margin-bottom: 20px; justify-content: center; flex-wrap: wrap; }
    .swatch {
      width: 44px;
      height: 44px;
      border-radius: 50%;
      cursor: pointer;
      border: 3px solid transparent;
      transition: transform 0.15s, border-color 0.15s;
    }
    .swatch.active { border-color: var(--text); transform: scale(1.1); }
    .theme-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 12px 0;
      border-bottom: 1px solid var(--border);
    }
    .theme-row-label { font-size: 14px; font-weight: 500; color: var(--text); }
    .toggle {
      width: 48px;
      height: 28px;
      border-radius: 14px;
      background: var(--border);
      position: relative;
      cursor: pointer;
      transition: background 0.2s;
    }
    .toggle.on { background: var(--accent); }
    .toggle-knob {
      position: absolute;
      top: 3px;
      left: 3px;
      width: 22px;
      height: 22px;
      border-radius: 50%;
      background: #fff;
      transition: left 0.2s;
      box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    }
    .toggle.on .toggle-knob { left: 23px; }
    .font-size-row { padding: 14px 0; }
    .font-size-label { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 10px; display: flex; justify-content: space-between; }
    .font-size-label span { color: var(--text2); font-size: 12px; }
    input[type=range] {
      width: 100%;
      accent-color: var(--accent);
      height: 4px;
      cursor: pointer;
    }

    /* ── DAILY SCREEN ── */
    .daily-header {
      padding: 20px 20px 16px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .daily-header-title { font-size: 20px; font-weight: 900; color: var(--text); }
    .trophy-badge {
      display: flex;
      align-items: center;
      gap: 6px;
      background: var(--surface);
      border: 1.5px solid var(--border);
      border-radius: 20px;
      padding: 6px 12px;
    }
    .trophy-badge span { font-size: 13px; font-weight: 600; color: var(--text); }
    .daily-trophy-section {
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 0 20px 20px;
    }
    .trophy-big { font-size: 72px; margin-bottom: 8px; }
    .trophy-month { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
    .trophy-arrows { display: flex; width: 100%; justify-content: space-between; align-items: center; margin-bottom: 16px; }
    .trophy-arrow { font-size: 24px; color: var(--text2); cursor: pointer; padding: 8px; }
    .calendar-grid { width: 100%; }
    .cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 6px; }
    .cal-weekday { text-align: center; font-size: 11px; color: var(--text3); font-weight: 600; padding: 4px 0; }
    .cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
    .cal-day {
      aspect-ratio: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 13px;
      font-weight: 500;
      color: var(--text2);
      border-radius: 50%;
      cursor: pointer;
      transition: background 0.15s;
      position: relative;
    }
    .cal-day:active { background: var(--accent-light); }
    .cal-day.today { background: var(--accent); color: #fff; font-weight: 700; }
    .cal-day.done::after { content: '✓'; position: absolute; bottom: 2px; right: 50%; transform: translateX(50%); font-size: 7px; color: var(--green); }
    .cal-day.empty { cursor: default; }
    .daily-progress {
      margin: 12px 20px;
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .progress-bar-track { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
    .progress-bar-fill { height: 100%; background: var(--gold); border-radius: 4px; width: 23%; }
    .progress-text { font-size: 12px; font-weight: 600; color: var(--gold); }
    .daily-play-btn {
      margin: 0 20px 16px;
      background: var(--accent);
      color: #fff;
      font-size: 15px;
      font-weight: 700;
      border: none;
      border-radius: 14px;
      padding: 16px;
      width: calc(100% - 40px);
      cursor: pointer;
      box-shadow: 0 4px 14px rgba(59,130,246,0.35);
    }

    /* ── STATS SCREEN ── */
    .stats-header {
      padding: 20px 20px 16px;
    }
    .stats-title { font-size: 20px; font-weight: 900; color: var(--text); }
    .diff-tabs {
      display: flex;
      overflow-x: auto;
      scrollbar-width: none;
      padding: 0 20px;
      gap: 8px;
      margin-bottom: 16px;
    }
    .diff-tabs::-webkit-scrollbar { display: none; }
    .diff-tab-btn {
      padding: 7px 14px;
      border-radius: 20px;
      border: 1.5px solid var(--border);
      background: var(--surface);
      font-size: 12px;
      font-weight: 600;
      color: var(--text2);
      white-space: nowrap;
      cursor: pointer;
      flex-shrink: 0;
      transition: all 0.15s;
    }
    .diff-tab-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
    .stats-cards { padding: 0 20px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 14px;
      padding: 16px;
    }
    .stat-card-val { font-size: 28px; font-weight: 900; color: var(--text); font-family: 'DM Mono', monospace; }
    .stat-card-label { font-size: 11px; color: var(--text2); margin-top: 2px; }
    .stat-card.wide { grid-column: 1/-1; }
    .best-times { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
    .best-time-row { display: flex; justify-content: space-between; align-items: center; }
    .best-time-diff { font-size: 12px; font-weight: 600; color: var(--text2); }
    .best-time-val { font-size: 14px; font-weight: 700; color: var(--text); font-family: 'DM Mono', monospace; }

    /* ── SETTINGS SCREEN ── */
    #screen-settings { overflow-y: auto; padding-bottom: 20px; }
    .settings-header {
      padding: 20px 20px 16px;
      display: flex;
      align-items: center;
      gap: 12px;
    }
    .settings-back { font-size: 22px; cursor: pointer; color: var(--text); }
    .settings-title { font-size: 20px; font-weight: 900; color: var(--text); }
    .settings-section { padding: 0 20px 8px; }
    .settings-section-title { font-size: 11px; font-weight: 700; color: var(--text3); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 6px; padding: 8px 0 0; }
    .settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin-bottom: 10px; }
    .settings-row {
      display: flex;
      align-items: center;
      padding: 14px 16px;
      border-bottom: 1px solid var(--border);
      cursor: pointer;
      transition: background 0.1s;
    }
    .settings-row:last-child { border-bottom: none; }
    .settings-row:active { background: var(--accent-light); }
    .settings-row-icon { font-size: 18px; margin-right: 12px; width: 24px; text-align: center; }
    .settings-row-label { flex: 1; font-size: 14px; font-weight: 500; color: var(--text); }
    .settings-row-value { font-size: 13px; color: var(--text2); margin-right: 6px; }
    .settings-row-chevron { font-size: 14px; color: var(--text3); }
    .premium-row {
      background: linear-gradient(135deg, #f0f7ff, #e0f2fe);
      border-bottom: 1px solid rgba(59,130,246,0.2) !important;
    }
    .dark .premium-row { background: linear-gradient(135deg, #1e3a5f, #162d4a); }
    .premium-label { color: var(--accent) !important; font-weight: 700 !important; }

    /* ── HOW TO PLAY ── */
    #screen-howto { overflow-y: auto; padding-bottom: 20px; }
    .howto-header { padding: 56px 20px 16px; display: flex; align-items: center; gap: 12px; }
    .howto-content { padding: 0 20px; }
    .howto-section { margin-bottom: 20px; }
    .howto-section-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
    .howto-badge { font-size: 11px; background: var(--accent-light); color: var(--accent); border-radius: 6px; padding: 2px 8px; font-weight: 600; }
    .howto-text { font-size: 13px; line-height: 1.7; color: var(--text2); }
    .technique-item { background: var(--surface); border-radius: 10px; padding: 12px 14px; margin-bottom: 6px; border: 1px solid var(--border); }
    .technique-name { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
    .technique-desc { font-size: 12px; color: var(--text2); line-height: 1.5; }
    .technique-level { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; display: inline-block; margin-bottom: 4px; }
    .level-beginner { background: #d1fae5; color: #065f46; }
    .level-intermediate { background: #fef3c7; color: #92400e; }
    .level-advanced { background: #fee2e2; color: #991b1b; }
    .level-expert { background: #ede9fe; color: #5b21b6; }

    /* ── OVERFLOW POPOVER ── */
    .overflow-popover {
      position: absolute;
      top: calc(100% + 6px);
      right: 0;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 14px;
      box-shadow: 0 8px 30px rgba(0,0,0,0.14);
      padding: 6px;
      z-index: 80;
      min-width: 160px;
      display: none;
      flex-direction: column;
      gap: 2px;
      transform-origin: top right;
      animation: popoverIn 0.15s ease-out;
    }
    @keyframes popoverIn {
      from { opacity: 0; transform: scale(0.92); }
      to   { opacity: 1; transform: scale(1); }
    }
    .overflow-popover.open { display: flex; }
    .popover-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 12px;
      border-radius: 10px;
      cursor: pointer;
      transition: background 0.12s;
      font-size: 13px;
      font-weight: 600;
      color: var(--text);
      white-space: nowrap;
    }
    .popover-item:active { background: var(--accent-light); color: var(--accent); }
    .popover-item svg { flex-shrink: 0; color: var(--text2); }
    .popover-divider { height: 1px; background: var(--border); margin: 2px 6px; }
    /* wrapper needs position:relative for popover to anchor correctly */
    .game-topbar-actions { position: relative; }

    /* ── CONFETTI ── */
    .confetti-piece {
      position: fixed;
      width: 10px;
      height: 10px;
      pointer-events: none;
      z-index: 999;
    }
    @keyframes confettiFall {
      0% { transform: translateY(-50px) rotate(0deg); opacity: 1; }
      100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
    }

    /* ── TOAST ── */
    .toast {
      position: fixed;
      top: calc(env(safe-area-inset-top) + 80px);
      left: 50%;
      transform: translateX(-50%) translateY(-10px);
      background: var(--text);
      color: var(--bg);
      padding: 10px 20px;
      border-radius: 20px;
      font-size: 13px;
      font-weight: 600;
      opacity: 0;
      transition: all 0.25s;
      z-index: 200;
      white-space: nowrap;
    }
    .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

    /* ── SCROLL ── */
    ::-webkit-scrollbar { display: none; }

    /* ── COMBO POPUP ── */
    .combo-popup {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%) scale(0.5);
      font-size: 42px;
      font-weight: 900;
      color: #f59e0b;
      text-shadow: 0 3px 12px rgba(245,158,11,0.5);
      pointer-events: none;
      opacity: 0;
      z-index: 150;
      transition: none;
    }
    @keyframes comboAnim {
      0%   { transform: translate(-50%,-50%) scale(0.5); opacity: 0; }
      20%  { transform: translate(-50%,-50%) scale(1.2); opacity: 1; }
      100% { transform: translate(-50%,-50%) scale(1);   opacity: 0; }
    }
    .combo-popup.show { animation: comboAnim 0.8s ease-out forwards; }

    /* ── MISC ── */
    .game-icon-btn.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

    /* ── DEBUG (remove for production) ── */
    #debug-bar {
      position: fixed;
      bottom: 90px;
      right: 12px;
      z-index: 500;
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 6px;
    }
    #debug-step-btn {
      background: #1e293b;
      color: #f8fafc;
      border: 2px solid #f59e0b;
      border-radius: 14px;
      padding: 10px 14px;
      font-size: 12px;
      font-weight: 700;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      box-shadow: 0 4px 16px rgba(0,0,0,0.35);
      letter-spacing: 0.03em;
      transition: transform 0.1s, background 0.1s;
      white-space: nowrap;
    }
    #debug-step-btn:active { transform: scale(0.95); background: #334155; }
    #debug-step-btn .dbg-bug { font-size: 15px; }
    #debug-badge {
      background: #f59e0b;
      color: #1e293b;
      font-size: 9px;
      font-weight: 800;
      letter-spacing: 0.08em;
      padding: 2px 7px;
      border-radius: 6px;
      text-transform: uppercase;
      align-self: flex-end;
    }
    #debug-step-btn.solved {
      border-color: #22c55e;
      color: #22c55e;
    }
    /* ── Score flash ── */
    /* Score flash */
    .score-flash {
      position: absolute;
      font-size: 14px;
      font-weight: 800;
      color: var(--green);
      pointer-events: none;
      opacity: 0;
      z-index: 50;
    }
    @keyframes scoreRise {
      0%{opacity:1;transform:translateY(0)} 100%{opacity:0;transform:translateY(-30px)}
    }
    .score-flash.show { animation: scoreRise 0.8s ease-out forwards; }
  /* ── AUTH SCREEN ── */
  .auth-wrap {
    flex: 1; display: flex; flex-direction: column;
    justify-content: center; padding: 32px 24px;
  }
  .auth-logo { text-align: center; margin-bottom: 36px; }
  .auth-logo-title { font-size: 38px; font-weight: 900; color: var(--text); }
  .auth-logo-title span { color: var(--accent); }
  .auth-logo-sub { font-size: 13px; color: var(--text2); margin-top: 4px; }
  .auth-tabs {
    display: flex; background: var(--surface2); border-radius: 12px;
    padding: 4px; margin-bottom: 20px;
  }
  .auth-tab {
    flex: 1; text-align: center; padding: 10px; border-radius: 9px;
    font-size: 14px; font-weight: 600; color: var(--text2); cursor: pointer;
    transition: all 0.2s;
  }
  .auth-tab.active {
    background: var(--surface); color: var(--text);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  }
  .auth-input {
    width: 100%; padding: 14px 16px; border: 1.5px solid var(--border);
    border-radius: 12px; font-size: 15px; background: var(--bg); color: var(--text);
    box-sizing: border-box; margin-bottom: 12px; outline: none;
    font-family: inherit;
  }
  .auth-input:focus { border-color: var(--accent); }
  .auth-btn {
    width: 100%; padding: 15px; border: none; border-radius: 12px;
    font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit;
    transition: opacity 0.15s, transform 0.1s;
  }
  .auth-btn:active { opacity: 0.85; transform: scale(0.97); }
  .auth-btn-primary { background: var(--accent); color: #fff; margin-bottom: 12px; }
  .auth-btn-google {
    background: var(--surface); color: var(--text); border: 1.5px solid var(--border);
    display: flex; align-items: center; justify-content: center; gap: 10px;
    margin-bottom: 12px;
  }
  .auth-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 4px 0 12px; color: var(--text3); font-size: 12px;
  }
  .auth-divider::before, .auth-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
  }
  .auth-btn-guest {
    background: transparent; color: var(--text2); border: 1.5px solid var(--border);
    margin-top: 8px;
  }
  .auth-forgot {
    text-align: center; font-size: 13px; color: var(--accent);
    cursor: pointer; margin-top: 16px;
  }

  /* Page-level loading overlay (covers auth transitions & OAuth return) */
  .page-loading-overlay {
    position: fixed; inset: 0; background: var(--bg); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 0;
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .page-loading-overlay.active { opacity: 1; pointer-events: all; }
  .page-loading-logo {
    font-size: 36px; font-weight: 900; color: var(--text);
    letter-spacing: -0.5px; line-height: 1; margin-bottom: 28px;
  }
  .page-loading-logo span { color: var(--accent); }
  .page-loading-track {
    width: 180px; height: 3px; background: var(--border);
    border-radius: 999px; overflow: hidden; margin-bottom: 16px;
  }
  .page-loading-bar {
    height: 100%; width: 0%; background: var(--accent);
    border-radius: 999px; transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .page-loading-msg {
    font-size: 13px; color: var(--text2); font-weight: 500;
    letter-spacing: 0.01em; min-height: 20px;
    transition: opacity 0.2s;
  }

  .btn-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(0,0,0,0.15);
  border-top-color: var(--accent, #4a7dff);
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}