/* ═══════════════════════════════════════════════
   DESIGN SYSTEM – SudokuPro
   White / grey-blue / clean / modern
═══════════════════════════════════════════════ */
:root {
  --bg:          #FFFFFF;
  --surface:     #F4F6F9;
  --surface-2:   #EDF0F7;
  --border:      #E2E8F0;
  --primary:     #3B5BDB;
  --primary-lt:  #748FFC;
  --primary-bg:  #EEF2FF;
  --text:        #1A1A2E;
  --text-2:      #6B7280;
  --text-3:      #9CA3AF;
  --error:       #EF4444;
  --success:     #10B981;
  --warn:        #F59E0B;
  --event-clr:   #E84393;
  --tourney-clr: #3B5BDB;
  --daily-clr:   #F59E0B;
  --shadow-sm:   0 1px 4px rgba(0,0,0,.06);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10);
  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  20px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.dark {
  --bg:        #0F1117;
  --surface:   #1A1D27;
  --surface-2: #222636;
  --border:    #2D3148;
  --text:      #E8ECF4;
  --text-2:    #9CA3AF;
  --text-3:    #6B7280;
  --primary-bg:#1E2448;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.4);
}

/* ─── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; border: none; background: none; }
input  { font: inherit; }
ul { padding-left: 1.4rem; }
li { margin-bottom: .5rem; }

/* ─── Screen system ─────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; }

.page-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px;
  overscroll-behavior: contain;
}
.page-bottom-pad { height: 100px; }
.page-head {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  padding: 20px 0 12px;
}
.section-label {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-2);
  margin: 20px 0 10px;
}

/* ─── Splash ────────────────────────────────────────────────── */
#screen-splash {
  justify-content: center;
  align-items: center;
  background: var(--bg);
}
.splash-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.splash-logo { animation: pop .5s ease; }
.splash-title { font-size: 2rem; font-weight: 800; color: var(--primary); }
.splash-sub   { font-size: .95rem; color: var(--text-2); }
.splash-loader {
  width: 140px; height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 24px;
}
.splash-bar {
  height: 100%; width: 0;
  background: var(--primary);
  border-radius: 2px;
  animation: loadbar 1.1s ease forwards;
}
@keyframes loadbar { to { width: 100%; } }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ─── Tab bar ───────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 3px;
  padding: 10px 0;
  color: var(--text-3);
  font-size: .72rem;
  font-weight: 500;
  transition: color .15s;
}
.tab-btn svg { transition: stroke .15s; }
.tab-btn.active { color: var(--primary); }
.tab-btn.active svg { stroke: var(--primary); }

/* ─── Tab content ───────────────────────────────────────────── */
.tab-content { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.tab-content.active { display: flex; }
#screen-main { flex-direction: column; }

/* ─── Home header ───────────────────────────────────────────── */
.home-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0 4px;
}
.home-title { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.btn-install {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary); color: white;
  padding: 7px 14px; border-radius: var(--r-sm);
  font-size: .8rem; font-weight: 600;
}

/* ─── Best score card ───────────────────────────────────────── */
.best-score-card {
  background: linear-gradient(135deg, var(--primary) 0%, #5472f0 100%);
  border-radius: var(--r-lg);
  padding: 24px 20px;
  text-align: center;
  margin: 12px 0;
  color: white;
  box-shadow: var(--shadow-md);
}
.bsc-label { font-size: .75rem; font-weight: 600; opacity: .8; letter-spacing: .05em; text-transform: uppercase; }
.bsc-value { font-size: 3rem; font-weight: 800; line-height: 1; margin: 8px 0 4px; }
.bsc-sub   { font-size: .8rem; opacity: .7; }

/* ─── Action row ────────────────────────────────────────────── */
.action-row {
  display: flex; gap: 10px; margin-bottom: 4px;
}
.btn-continue {
  flex: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  transition: background .15s;
  box-shadow: var(--shadow-sm);
}
.btn-continue:not(.disabled):hover { background: var(--surface-2); }
.btn-continue.disabled { opacity: .45; cursor: not-allowed; }
.cont-left { display: flex; align-items: center; gap: 12px; }
.cont-left svg { color: var(--primary); }
.cont-title { font-weight: 600; font-size: .95rem; }
.cont-meta  { font-size: .78rem; color: var(--text-2); }

.btn-primary {
  background: var(--primary);
  color: white;
  font-weight: 700;
  border-radius: var(--r-md);
  padding: 14px 20px;
  white-space: nowrap;
  transition: opacity .15s;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { opacity: .88; }
.btn-primary.full-w { width: 100%; margin-bottom: 10px; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  font-weight: 600;
  border-radius: var(--r-md);
  padding: 13px 20px;
}
.btn-outline.full-w { width: 100%; margin-bottom: 10px; }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
  border-radius: var(--r-md);
  padding: 13px 20px;
}
.btn-ghost.full-w { width: 100%; }
.btn-outline-sm {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 14px;
  font-size: .82rem;
  font-weight: 500;
}
.btn-outline-sm.danger { color: var(--error); border-color: var(--error); }
.btn-danger {
  background: var(--error); color: white;
  font-weight: 700; border-radius: var(--r-md);
  padding: 13px 24px;
}

/* ─── Mode grid ─────────────────────────────────────────────── */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}
.mode-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 14px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: background .15s, transform .1s;
  box-shadow: var(--shadow-sm);
}
.mode-card:hover { background: var(--surface-2); transform: translateY(-1px); }
.mc-dots { font-size: .65rem; letter-spacing: 2px; }
.mc-name { font-weight: 700; font-size: .9rem; color: var(--text); }
.mc-pts  { font-size: .72rem; color: var(--text-3); }

.easy-dots   { color: #10B981; }
.medium-dots { color: #F59E0B; }
.hard-dots   { color: #EF4444; }
.expert-dots { color: #8B5CF6; }
.master-dots { color: #EC4899; }
.extreme-dots{ color: #1A1A2E; }
.dark .extreme-dots { color: #E8ECF4; }

/* ─── Challenge carousel ────────────────────────────────────── */
.challenge-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 2px 12px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}
.challenge-carousel::-webkit-scrollbar { display: none; }

.challenge-slide {
  flex: 0 0 78vw;
  max-width: 280px;
  min-width: 220px;
  scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 6px;
  padding: 20px 18px 18px;
  border-radius: var(--r-lg);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: transform .12s;
  text-align: left;
}
.challenge-slide:hover { transform: translateY(-2px); }

.daily-slide {
  background: linear-gradient(145deg, #E8F4FD, #D6EBF8);
  border: 1px solid #BAD6EF;
  color: #1A3A52;
}
.tourney-slide {
  background: linear-gradient(145deg, #3B5BDB, #4C6EF5);
  color: white;
}
.event-slide {
  background: linear-gradient(145deg, #E84393, #C2185B);
  color: white;
}

.cs-badge {
  position: absolute; top: 12px; right: 14px;
  font-size: .6rem; font-weight: 800; letter-spacing: .1em;
  background: rgba(255,255,255,.25); color: white;
  padding: 3px 8px; border-radius: 20px;
}
.cs-chip {
  display: inline-block;
  font-size: .68rem; font-weight: 700; letter-spacing: .06em;
  background: rgba(26,58,82,.12); color: #1A3A52;
  padding: 3px 10px; border-radius: 20px;
  margin-bottom: 2px;
}
.cs-icon { font-size: 2rem; margin: 4px 0; }
.cs-title { font-size: 1.1rem; font-weight: 800; line-height: 1.2; }
.cs-sub   { font-size: .78rem; opacity: .75; }
.cs-bonus { font-size: .78rem; font-weight: 700; opacity: .85; }
.cs-countdown {
  font-size: .78rem; font-weight: 700;
  background: rgba(255,255,255,.18);
  padding: 3px 10px; border-radius: 20px;
  margin-top: 2px;
}
.cs-cta {
  margin-top: 8px;
  font-size: .82rem; font-weight: 800;
  background: rgba(255,255,255,.22);
  padding: 6px 14px; border-radius: var(--r-sm);
  letter-spacing: .03em;
}
.daily-slide .cs-cta {
  background: rgba(26,58,82,.12);
  color: #1A3A52;
}

/* ─── Special modes ─────────────────────────────────────────── */
.special-list { display: flex; gap: 10px; margin-bottom: 4px; }
.special-card {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.sc-icon { font-size: 1.4rem; }
.sc-name { font-size: .85rem; font-weight: 600; color: var(--text); }
.sc-tag  {
  font-size: .65rem; font-weight: 700; letter-spacing: .05em;
  background: var(--primary-bg); color: var(--primary);
  padding: 2px 8px; border-radius: 20px;
}

/* ─── Statistics ────────────────────────────────────────────── */
.stats-mode-tabs {
  display: block;
  padding: 4px 0;
}
.stats-tab-row {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding-bottom: 4px;
}
.stats-tab-row::-webkit-scrollbar { display: none; }
.mode-tab-btn {
  white-space: nowrap;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: .82rem;
  font-weight: 500;
  transition: all .15s;
}
.mode-tab-btn.active {
  background: var(--primary); color: white; border-color: var(--primary);
}

.stats-period-row {
  padding: 6px 0 10px;
}
.btn-period-filter {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: .82rem; font-weight: 600;
  color: var(--text);
  transition: background .15s, border-color .15s;
}
.btn-period-filter:hover { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); }
.btn-period-filter svg { stroke: var(--text-2); }

/* Stats group sections (Classic / Challenges) */
.stats-group-hd {
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3);
  padding: 14px 0 6px;
}

/* Period option list in bottom sheet */
.period-option-list {
  display: flex; flex-direction: column;
}
.period-opt {
  padding: 16px 8px;
  font-size: 1rem; font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  text-align: left;
  transition: background .12s, color .12s;
  border-radius: 0;
}
.period-opt:first-child { border-radius: var(--r-sm) var(--r-sm) 0 0; }
.period-opt:last-child  { border-bottom: none; }
.period-opt:hover       { background: var(--primary-bg); color: var(--primary); }
.period-opt.active      { color: var(--primary); font-weight: 700; }
.period-modal-cancel    { padding: 12px 0 4px; }

.stats-cards-wrap { display: flex; flex-direction: column; gap: 12px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card-head {
  font-size: .72rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-2); margin-bottom: 14px;
}
.stat-grid4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; }
.si { text-align: center; }
.sv { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.sl { font-size: .7rem; color: var(--text-2); margin-top: 2px; }
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.stat-row:last-child { border-bottom: none; }
.stat-row .sl { font-size: .88rem; color: var(--text-2); }
.stat-row .sv { font-size: .95rem; font-weight: 700; color: var(--text); }

.stats-reset-row {
  display: flex; gap: 10px; padding: 16px 0;
}

/* ─── Options list ──────────────────────────────────────────── */
.options-list { display: flex; flex-direction: column; padding-top: 8px; }
.opt-row {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-align: left;
  width: 100%;
  background: transparent;
}
.opt-icon  { font-size: 1.1rem; width: 24px; text-align: center; }
.opt-label { flex: 1; font-size: .95rem; font-weight: 500; }
.opt-chevron { color: var(--text-3); font-size: 1.1rem; }
.opt-badge {
  font-size: .75rem; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; background: var(--primary-bg); color: var(--primary);
}
.opt-badge.green { background: #D1FAE5; color: #065F46; }
.opt-divider { height: 20px; }

/* ─── Sub-screen ────────────────────────────────────────────── */
.sub-screen { background: var(--bg); }
.sub-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.sub-title { font-weight: 700; font-size: 1.05rem; }

.btn-icon-sm {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text);
  background: transparent;
  transition: background .15s;
}
.btn-icon-sm:hover { background: var(--surface); }

/* ─── Content pages ─────────────────────────────────────────── */
.content-page { padding-top: 16px; }
.info-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px;
  margin-bottom: 12px;
}
.info-icon { font-size: 1.8rem; margin-bottom: 10px; }
.info-block h3 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.info-block p  { color: var(--text-2); font-size: .9rem; line-height: 1.55; }
.rule-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px 0; border-bottom: 1px solid var(--border);
}
.rule-num {
  width: 28px; height: 28px; min-width: 28px;
  background: var(--primary); color: white;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem;
}
.rule-item p { color: var(--text-2); font-size: .9rem; line-height: 1.55; margin: 0; }
.faq-item { padding: 16px 0; border-bottom: 1px solid var(--border); }
.faq-item h4 { font-size: .95rem; font-weight: 700; margin-bottom: 6px; }
.faq-item p  { color: var(--text-2); font-size: .88rem; line-height: 1.5; }
.center-content { text-align: center; display: flex; flex-direction: column; align-items: center; }
.center-content h2  { font-size: 1.4rem; font-weight: 800; margin: 12px 0 8px; }
.center-content p   { color: var(--text-2); max-width: 320px; margin-bottom: 10px; }
.muted { color: var(--text-2); }
.small { font-size: .8rem; }

/* ─── Settings toggles ──────────────────────────────────────── */
.settings-list { padding-top: 8px; }
.set-group-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-3);
  padding: 16px 0 6px;
}
.set-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: .95rem;
  color: var(--text);
}
.toggle {
  appearance: none; -webkit-appearance: none;
  width: 44px; height: 26px;
  background: var(--border);
  border-radius: 13px;
  cursor: pointer;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: white;
  transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle:checked { background: var(--primary); }
.toggle:checked::after { transform: translateX(18px); }

/* ─── Ticket screen ─────────────────────────────────────────── */
.ticket-hero { padding: 32px 0 16px; }
.ticket-count { font-size: 4rem; font-weight: 800; color: var(--primary); }
.ticket-label { font-size: .9rem; color: var(--text-2); margin-top: 4px; }
.ticket-info  { color: var(--text-2); font-size: .9rem; margin: 16px 0 20px; line-height: 1.5; }

/* ─── About / Remove Ads ────────────────────────────────────── */
.about-logo { margin: 24px 0 8px; }
.remove-ads-icon { font-size: 3rem; margin: 24px 0 8px; }
.price-tag {
  font-size: 2rem; font-weight: 800;
  color: var(--primary); margin: 8px 0 16px;
}
.full-w { width: 100%; }

/* ─── Game screen ───────────────────────────────────────────── */
.game-shell {
  flex: 1;
  display: flex; flex-direction: column;
  padding: 0;
  overflow: hidden;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}
.game-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.game-center { text-align: center; }
.game-mode {
  font-size: .78rem; font-weight: 800;
  letter-spacing: .1em; color: var(--primary);
}
.game-meta-row {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: .88rem; color: var(--text-2); margin-top: 2px;
}
.game-timer { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.game-sep   { color: var(--text-3); }
.game-errors { display: flex; align-items: center; gap: 4px; font-size: .85rem; }
.edot {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid var(--border);
  display: inline-block;
}
.edot.filled { background: var(--error); border-color: var(--error); }

.game-score-bar {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px;
  background: var(--primary-bg);
}
.gsb-label { font-size: .75rem; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .06em; }
.gsb-value { font-size: 1.1rem; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }

/* ─── Sudoku board ──────────────────────────────────────────── */
.board-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 12px 16px;
  overflow: hidden;
}
.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  width: min(100%, 480px);
  aspect-ratio: 1 / 1;
  border: 2.5px solid var(--text);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg);
}
.cell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  border: .5px solid var(--border);
  font-size: clamp(.9rem, 4vw, 1.5rem);
  font-weight: 700;
  color: var(--primary);
  background: var(--bg);
  cursor: pointer;
  user-select: none;
  transition: background .08s;
  outline: none;
}
.cell.bx-r { border-right: 2px solid var(--text); }
.cell.bx-b { border-bottom: 2px solid var(--text); }
.cell.fixed  { background: var(--surface); color: var(--text); }
.cell.sel    { background: #C5D3FF !important; }
.cell.same-n { background: #DDE4FF; }
.cell.peer   { background: #EEF2FF; }
.cell.err    { color: var(--error); }
.cell.ok     { color: var(--primary); }
.dark .cell.sel    { background: #2A3568 !important; }
.dark .cell.same-n { background: #1E2448; }
.dark .cell.peer   { background: #1A1D27; }

/* Notes grid inside cell */
.notes-g {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%; height: 100%;
  padding: 2px;
}
.notes-g span {
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(.4rem, 1.3vw, .65rem);
  font-weight: 600;
  color: var(--text-2);
  line-height: 1;
}

/* ─── Number pad ────────────────────────────────────────────── */
.number-pad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
  padding: 6px 16px;
}
.number-pad button {
  height: clamp(40px, 9vw, 56px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  transition: background .1s, transform .08s;
}
.number-pad button:hover  { background: var(--primary-bg); }
.number-pad button:active { transform: scale(.93); }

/* ─── Game tools ────────────────────────────────────────────── */
.game-tools {
  display: flex; gap: 8px;
  padding: 8px 16px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.tool-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: .72rem;
  font-weight: 600;
  color: var(--text);
  transition: background .12s, color .12s;
}
.tool-btn svg { stroke: var(--text); transition: stroke .12s; }
.tool-btn:hover, .tool-btn.active {
  background: var(--primary-bg);
  color: var(--primary);
}
.tool-btn:hover svg, .tool-btn.active svg { stroke: var(--primary); }

/* ─── Modals ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-backdrop.active { display: flex; }

.modal-card {
  background: var(--bg);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 28px 24px 40px;
  width: 100%; max-width: 480px;
  box-shadow: 0 -4px 32px rgba(0,0,0,.15);
}
.modal-title {
  font-size: 1.2rem; font-weight: 800;
  margin-bottom: 20px; text-align: center;
}
.modal-text { color: var(--text-2); font-size: .9rem; margin-bottom: 20px; text-align: center; line-height: 1.5; }
.modal-btn-row {
  display: flex; gap: 10px;
}
.modal-btn-row .btn-outline, .modal-btn-row .btn-danger { flex: 1; }

/* Mode select sheet */
.modal-sheet {
  background: var(--bg);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 12px 20px 40px;
  width: 100%; max-width: 520px;
  box-shadow: 0 -4px 32px rgba(0,0,0,.15);
}
.modal-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; font-weight: 700; font-size: 1.05rem;
}

.mode-pick-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mpb {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 16px 12px;
  border-radius: var(--r-md);
  font-weight: 700; font-size: 1rem;
  transition: transform .1s, opacity .1s;
  color: white;
  box-shadow: var(--shadow-sm);
}
.mpb span { font-size: .75rem; font-weight: 500; opacity: .85; }
.mpb:hover { transform: translateY(-1px); opacity: .92; }
.mpb.easy    { background: #10B981; }
.mpb.medium  { background: #F59E0B; }
.mpb.hard    { background: #EF4444; }
.mpb.expert  { background: #8B5CF6; }
.mpb.master  { background: #EC4899; }
.mpb.extreme { background: #1A1A2E; }

/* ─── Win modal ─────────────────────────────────────────────── */
.win-modal { text-align: center; }
.win-new-best {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--warn); color: #78350F;
  border-radius: 20px; padding: 6px 16px;
  font-size: .8rem; font-weight: 800;
  margin-bottom: 12px; letter-spacing: .03em;
}
.win-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; }
.win-score-big { font-size: 3.5rem; font-weight: 900; color: var(--primary); margin-bottom: 16px; }
.win-stats-row { display: flex; justify-content: center; gap: 24px; margin-bottom: 16px; }
.win-stat { text-align: center; }
.ws-v { font-size: 1.2rem; font-weight: 800; }
.ws-l { font-size: .72rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.win-breakdown { margin-bottom: 20px; }
.bd-row {
  display: flex; justify-content: space-between;
  padding: 5px 0; font-size: .85rem;
  border-bottom: 1px solid var(--border);
}
.bd-row:last-child { border-bottom: none; }
.bd-row.pos span:last-child { color: var(--success); font-weight: 700; }
.bd-row.neg span:last-child { color: var(--error);   font-weight: 700; }

/* ─── Toast ─────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 90px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1A1A2E; color: white;
  padding: 10px 20px; border-radius: 20px;
  font-size: .85rem; font-weight: 500;
  opacity: 0; transition: opacity .25s, transform .25s;
  z-index: 9999; white-space: nowrap;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.dark #toast { background: #E8ECF4; color: #1A1A2E; }

/* ─── Responsive ────────────────────────────────────────────── */
@media (min-width: 600px) {
  .mode-grid { grid-template-columns: repeat(3, 1fr); }
  .number-pad button { height: 52px; }
  .game-shell { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
@media (max-width: 360px) {
  .mode-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid4 { grid-template-columns: 1fr 1fr; }
}
