/* ============ Base ============ */
:root {
  /* Theme tokens are injected at runtime from src/core/themes.js */
  --bg: #f4efe4; --surface: #fff; --surface2: #eee; --text: #222; --muted: #888;
  --boardBg: #fff; --lineThin: #ddd; --lineThick: #333;
  --given: #222; --user: #2f5fa7; --note: #777;
  --peer: rgba(0,0,0,.05); --same: rgba(0,0,0,.1); --selected: rgba(0,0,0,.2);
  --error: #c0392b; --errorBg: rgba(192,57,43,.12); --accent: #2f5fa7; --accentText: #fff;
  --radius: 14px; --shadow: none;
  --font-ui: 'Nunito', system-ui, sans-serif; --font-num: 'Nunito', system-ui, sans-serif;
  --ease: cubic-bezier(.2,.8,.2,1);
}

[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-ui);
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  transition: color .3s;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2 { margin: 0; }
.muted { color: var(--muted); }

#app { position: relative; z-index: 1; min-height: 100dvh; }
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; animation: screen-in .35s var(--ease); }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

.icon { width: 1.25em; height: 1.25em; display: inline-block; vertical-align: middle; flex: none; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .85em 1.4em; border-radius: calc(var(--radius) * .8 + 4px);
  background: var(--surface); color: var(--text);
  font-weight: 700; font-size: 1rem;
  box-shadow: 0 1px 0 rgba(0,0,0,.04), var(--shadow-soft, 0 4px 14px rgba(0,0,0,.06));
  transition: transform .15s var(--ease), background .2s, box-shadow .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accentText); }
.btn-ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost.danger { color: var(--error); }
.btn-big { width: 100%; padding: 1.05em 1.4em; font-size: 1.08rem; flex-wrap: wrap; }
.btn-big small { width: 100%; font-weight: 600; font-size: .78rem; opacity: .75; margin-top: -.2em; }
.btn-big small:empty { display: none; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; color: var(--text);
  transition: background .2s, transform .15s;
}
.icon-btn:hover { background: var(--surface2); }
.icon-btn:active { transform: scale(.92); }

.chip-btn {
  display: flex; flex-direction: column; align-items: center; gap: .35em;
  padding: .9em .6em; border-radius: var(--radius);
  background: var(--surface); flex: 1; font-weight: 700; font-size: .85rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
  transition: transform .15s var(--ease);
}
.chip-btn .icon { width: 1.6em; height: 1.6em; color: var(--accent); }
.chip-btn:hover { transform: translateY(-2px); }

/* ============ Home ============ */
#screen-home { align-items: center; justify-content: center; padding: 24px 16px; }
.home-inner { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.logo {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px;
  width: 92px; height: 92px; padding: 8px; margin-bottom: 18px;
  background: var(--surface); border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
  animation: logo-float 5s ease-in-out infinite;
}
.logo span { border-radius: 5px; background: var(--surface2); }
.logo span:nth-child(1), .logo span:nth-child(5), .logo span:nth-child(9) { background: var(--accent); }
.logo span:nth-child(3), .logo span:nth-child(7) { background: var(--user); opacity: .55; }
@keyframes logo-float { 50% { transform: translateY(-6px) rotate(-2deg); } }
.title { font-size: 2.6rem; font-weight: 800; letter-spacing: .02em; }
.tagline { margin: .3em 0 2em; color: var(--muted); }
.home-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.home-row { display: flex; gap: 10px; width: 100%; margin-top: 22px; }

/* Glass / surfaces readable on gradients */
[data-glass="true"] .btn:not(.btn-primary):not(.btn-ghost),
[data-glass="true"] .chip-btn,
[data-glass="true"] .logo,
[data-glass="true"] .numpad button,
[data-glass="true"] dialog { backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); }

/* ============ Game screen ============ */
#screen-game { flex-direction: column; align-items: center; padding: max(8px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.game-header {
  width: 100%; max-width: 980px; display: flex; align-items: center; gap: 8px; padding: 4px 0 10px;
}
.header-center { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 2px; }
.pill {
  padding: .3em .85em; border-radius: 999px; background: var(--surface); font-weight: 800; font-size: .85rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.mistakes { font-size: .85rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
.mistakes.bump { animation: bump .4s; color: var(--error); }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; padding: 0 6px; min-width: 3.6em; text-align: right; }

.game-layout {
  --board: min(calc(100vw - 32px), calc(100dvh - 330px), 560px);
  width: 100%; max-width: 980px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; flex: 1;
}
@media (max-height: 640px) { .game-layout { --board: min(calc(100vw - 32px), calc(100dvh - 290px), 560px); } }

@media (min-width: 860px) {
  .game-layout {
    --board: min(calc(100dvh - 110px), 600px);
    flex-direction: row; align-items: center; justify-content: center; gap: 36px; flex: 1;
  }
  .controls { width: 300px; }
  .numpad { grid-template-columns: repeat(3, 1fr) !important; }
  .numpad button { aspect-ratio: 1.15; font-size: 2rem !important; }
}

/* ============ Board ============ */
.board-wrap { position: relative; width: var(--board); flex: none; }
.board {
  container-type: inline-size;
  width: 100%; aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr);
  background: var(--boardBg);
  border: 2.5px solid var(--lineThick);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: manipulation;
  transition: filter .3s, box-shadow .3s;
}
[data-glass="true"] .board { backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%); }

.cell {
  position: relative; display: grid; place-items: center;
  border-right: 1px solid var(--lineThin); border-bottom: 1px solid var(--lineThin);
  font-family: var(--font-num); font-size: 6.2cqi; line-height: 1;
  color: var(--user); cursor: pointer;
  transition: background-color .15s;
}
.cell.c2, .cell.c5 { border-right: 2.5px solid var(--lineThick); }
.cell.c8 { border-right: 0; }
.cell.r2, .cell.r5 { border-bottom: 2.5px solid var(--lineThick); }
.cell.r8 { border-bottom: 0; }
.cell.given { color: var(--given); font-weight: 700; }
.cell.user { font-weight: 600; }
.cell.peer { background: var(--peer); }
.cell.same { background: var(--same); }
.cell.selected { background: var(--selected); }
.cell.wrong { color: var(--error); background: var(--errorBg); }
.cell.wrong.selected { background: color-mix(in srgb, var(--errorBg), var(--selected)); }
.cell .v { display: block; }
.cell.pop .v { animation: pop .28s var(--ease); }
.cell.shake { animation: shake .35s; }
.cell.flash::after {
  content: ''; position: absolute; inset: 0; background: var(--accent); opacity: 0;
  animation: flash .6s var(--d, 0s) ease-out;
  pointer-events: none;
}

.notes {
  position: absolute; inset: 6%; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  font-size: 2.3cqi; color: var(--note); font-weight: 700; font-family: var(--font-ui);
}
.notes span { display: grid; place-items: center; border-radius: 30%; }
.notes span.hl { background: var(--accent); color: var(--accentText); }

/* Neon glow */
[data-glow="true"] .board { box-shadow: var(--shadow); }
[data-glow="true"] .cell.user .v { text-shadow: 0 0 6px var(--user), 0 0 14px var(--user); }
[data-glow="true"] .cell.given .v { text-shadow: 0 0 8px rgba(255,255,255,.35); }
[data-glow="true"] .title { text-shadow: 0 0 12px var(--accent), 0 0 28px var(--accent); }

/* Pixel */
[data-pixel="true"] .cell { font-size: 4.2cqi; }
[data-pixel="true"] .notes { font-size: 1.8cqi; font-family: 'Press Start 2P', monospace; }
[data-pixel="true"] .btn, [data-pixel="true"] .chip-btn, [data-pixel="true"] .numpad button, [data-pixel="true"] .pill { border-radius: 0; box-shadow: 4px 4px 0 #0d0f24; }
[data-pixel="true"] .title, [data-pixel="true"] .timer { font-family: 'Press Start 2P', monospace; font-size: 1.6rem; }
[data-pixel="true"] .timer { font-size: .8rem; }

/* Thai ornament frame */
[data-ornament="thai"] .board-wrap::before {
  content: ''; position: absolute; inset: -18px; border-radius: calc(var(--radius) + 14px); z-index: -1;
  background:
    radial-gradient(circle at 50% 50%, #e2b04a 0 2px, transparent 3px) 0 0 / 14px 14px,
    linear-gradient(135deg, #741624, #5c0d18);
  box-shadow: inset 0 0 0 2px #b8862b;
}
[data-ornament="thai"] .title { color: #e2b04a; text-shadow: 0 2px 0 #2e040b; }
[data-ornament="thai"] .logo { box-shadow: 0 0 0 2px #e2b04a, 0 10px 30px rgba(0,0,0,.4); }

/* Pause */
.pause-overlay {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  font-weight: 800; color: var(--text);
}
.board-wrap.paused .board { filter: blur(10px) saturate(.6); }
.board-wrap.paused .pause-overlay { display: flex; }
.play-big {
  width: 80px; height: 80px; border-radius: 50%; background: var(--accent); color: var(--accentText);
  display: grid; place-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.2);
  transition: transform .15s var(--ease);
}
.play-big:hover { transform: scale(1.06); }
.play-big .icon { width: 36px; height: 36px; }

/* ============ Controls ============ */
.controls { width: var(--board); display: flex; flex-direction: column; gap: 14px; }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 0; border-radius: var(--radius); font-size: .78rem; font-weight: 700; color: var(--muted);
  transition: color .2s, transform .15s;
}
.tool:hover { color: var(--text); }
.tool:active { transform: scale(.92); }
.tool:disabled { opacity: .35; pointer-events: none; }
.tool-icon {
  position: relative; width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: var(--text); box-shadow: 0 3px 10px rgba(0,0,0,.06);
  transition: background .2s, color .2s;
}
.tool-icon .icon { width: 24px; height: 24px; }
.tool.active { color: var(--accent); }
.tool.active .tool-icon { background: var(--accent); color: var(--accentText); }
.badge {
  position: absolute; top: -4px; right: -8px; min-width: 22px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: var(--accentText);
  font-size: .66rem; font-weight: 800; display: grid; place-items: center; font-style: normal;
  border: 2px solid var(--boardBg);
}
.badge:empty { display: none; }
.tool.active .badge { background: var(--accentText); color: var(--accent); }

.numpad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.numpad button {
  position: relative; aspect-ratio: .62; border-radius: calc(var(--radius) * .7);
  background: var(--surface); color: var(--padText, var(--user));
  font-family: var(--font-num); font-size: clamp(1.3rem, 6.2vw, 2rem); font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(0,0,0,.06);
  transition: transform .12s var(--ease), opacity .3s, background .2s;
}
.numpad button:active { transform: scale(.9); }
.numpad button small { font-family: var(--font-ui); font-size: .62rem; color: var(--muted); font-weight: 700; margin-top: 2px; }
.numpad button.done { opacity: .25; }
.numpad.hide-done button.done { visibility: hidden; }
.numpad.notes-mode button { color: var(--note); font-size: clamp(1rem, 4.8vw, 1.5rem); }
[data-pixel="true"] .numpad button { font-size: clamp(.9rem, 4vw, 1.3rem); }

/* ============ Dialogs ============ */
dialog {
  border: 0; padding: 24px 20px 16px; border-radius: calc(var(--radius) + 8px);
  background: var(--surface); color: var(--text);
  width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 40px);
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  font-family: var(--font-ui);
}
dialog[open] { animation: dlg-in .3s var(--ease); display: flex; flex-direction: column; gap: 14px; }
dialog.wide { width: min(720px, calc(100vw - 32px)); }
dialog.center { text-align: center; align-items: center; }
dialog::backdrop { background: rgba(10,10,20,.45); backdrop-filter: blur(4px); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(16px) scale(.97); } }
dialog h2 { font-size: 1.35rem; font-weight: 800; }
[data-dark="true"] dialog { background: color-mix(in srgb, var(--surface) 92%, #000); }
[data-glass="true"] dialog { background: rgba(20,60,90,.75); }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; }
.dlg-actions.col { flex-direction: column; width: 100%; }
.dlg-actions.col .btn { width: 100%; }

.level-list { display: flex; flex-direction: column; gap: 10px; }
.level-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 1em 1.1em; border-radius: var(--radius); background: var(--surface2); font-weight: 800; font-size: 1.05rem;
  transition: transform .15s var(--ease);
}
.level-btn:hover { transform: translateX(4px); }
.level-btn .dots { display: flex; gap: 4px; }
.level-btn .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); opacity: .25; }
.level-btn .dots i.on { opacity: 1; }
.level-btn small { color: var(--muted); font-weight: 600; font-size: .78rem; display: block; text-align: left; }

/* Theme picker */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); grid-auto-rows: max-content; gap: 12px; overflow: auto; padding: 4px; min-height: 0; }
.theme-card {
  border-radius: 16px; overflow: hidden; text-align: left; padding: 0;
  outline: 3px solid transparent; outline-offset: 2px;
  transition: transform .15s var(--ease), outline-color .2s;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}
.theme-card:hover { transform: translateY(-3px); }
.theme-card.active { outline-color: var(--accent); }
.theme-card .tc-bg { background: var(--bg); padding: 14px; display: grid; place-items: center; }
.theme-card .tc-board {
  display: grid; grid-template-columns: repeat(3, 1fr); width: 84px; aspect-ratio: 1;
  background: var(--boardBg); border: 2px solid var(--lineThick); border-radius: min(var(--radius), 10px); overflow: hidden;
  box-shadow: var(--shadow);
}
.theme-card .tc-board span {
  display: grid; place-items: center; font-family: var(--font-num); font-size: 15px; color: var(--given); font-weight: 700;
  border-right: 1px solid var(--lineThin); border-bottom: 1px solid var(--lineThin);
}
.theme-card .tc-board span.u { color: var(--user); font-weight: 600; }
.theme-card .tc-board span.s { background: var(--selected); }
.theme-card .tc-board span.p { background: var(--peer); }
.theme-card .tc-name { padding: 10px 12px; background: var(--surfaceSolid, var(--surface)); color: var(--text); font-weight: 800; font-size: .88rem; font-family: var(--font-ui); display: flex; gap: 6px; align-items: center; }
.theme-card .tc-board[data-pixel="true"] span { font-size: 9px; }

/* Stats */
.streaks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats-tabs { display: flex; gap: 6px; background: var(--surface2); padding: 4px; border-radius: 999px; }
.stats-tabs button { flex: 1; padding: .5em; border-radius: 999px; font-weight: 700; font-size: .85rem; color: var(--muted); }
.stats-tabs button.active { background: var(--accent); color: var(--accentText); }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface2); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .8rem; font-weight: 700; }

/* Settings */
.set-group { margin-bottom: 8px; }
.set-group h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 8px 0 6px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--surface2); font-weight: 600; }
.set-row:last-child { border-bottom: 0; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--surface2); transition: background .2s; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.2); transition: transform .2s var(--ease); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.seg { display: flex; background: var(--surface2); padding: 3px; border-radius: 999px; }
.seg button { padding: .35em .8em; border-radius: 999px; font-size: .82rem; font-weight: 700; color: var(--muted); }
.seg button.active { background: var(--accent); color: var(--accentText); }

/* Result */
.result-icon { font-size: 3.6rem; animation: bounce-in .6s var(--ease); }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.result-stats .stat { padding: 10px; }
.result-stats .stat b { font-size: 1.2rem; }
.new-best { color: var(--accent); font-weight: 800; animation: pulse 1.2s infinite; }

/* ============ Decorations ============ */
#deco { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
#deco i { position: absolute; display: block; will-change: transform; }
.p-petals { top: -30px; width: 14px; height: 11px; background: var(--particle, #ffc0d3); border-radius: 80% 0 80% 0; opacity: .85; animation: fall linear infinite; }
.p-leaves { top: -30px; width: 14px; height: 9px; background: var(--particle, #8fb573); border-radius: 0 90% 0 90%; opacity: .6; animation: fall linear infinite; }
.p-bubbles { bottom: -30px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.45); background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.35), transparent 60%); animation: rise linear infinite; }
.p-stars { width: 2px; height: 2px; border-radius: 50%; background: #fff; animation: twinkle ease-in-out infinite; }
@keyframes fall {
  0% { transform: translate3d(0, 0, 0) rotate(0); }
  50% { transform: translate3d(60px, 55vh, 0) rotate(200deg); }
  100% { transform: translate3d(-20px, 110vh, 0) rotate(420deg); }
}
@keyframes rise {
  0% { transform: translate3d(0, 0, 0); opacity: 0; }
  10% { opacity: 1; }
  50% { transform: translate3d(20px, -55vh, 0); }
  100% { transform: translate3d(-10px, -115vh, 0); opacity: .2; }
}
@keyframes twinkle { 0%, 100% { opacity: .15; transform: scale(1); } 50% { opacity: 1; transform: scale(1.6); } }

.p-snow {
  top: -20px; width: 9px; height: 9px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 4px rgba(74,127,181,.55); opacity: .95; animation: snowfall linear infinite;
}
@keyframes snowfall {
  0% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(18px, 27vh, 0); }
  50% { transform: translate3d(-10px, 55vh, 0); }
  75% { transform: translate3d(14px, 82vh, 0); }
  100% { transform: translate3d(0, 110vh, 0); }
}

/* Aurora: slow drifting light ribbons behind everything */
[data-aurora="true"] #deco::before,
[data-aurora="true"] #deco::after {
  content: ''; position: absolute; left: -30%; right: -30%; height: 55vh; top: -10vh;
  background: linear-gradient(100deg, transparent 10%, rgba(64,224,170,.28) 35%, rgba(120,140,255,.22) 55%, transparent 80%);
  filter: blur(50px); transform-origin: 50% 0;
  animation: aurora 14s ease-in-out infinite alternate;
}
[data-aurora="true"] #deco::after {
  top: 5vh; height: 40vh; animation-duration: 19s; animation-direction: alternate-reverse;
  background: linear-gradient(80deg, transparent 15%, rgba(170,90,255,.25) 45%, rgba(64,224,170,.18) 65%, transparent 85%);
}
@keyframes aurora {
  0% { transform: translateX(-8%) skewY(-6deg) scaleY(.9); opacity: .7; }
  50% { opacity: 1; }
  100% { transform: translateX(8%) skewY(5deg) scaleY(1.15); opacity: .8; }
}

/* Chalkboard: dusty chalk strokes */
[data-chalk="true"] .cell .v,
[data-chalk="true"] .numpad button > span { text-shadow: 0 0 1px currentColor, 1px 1px 0 rgba(255,255,255,.08); letter-spacing: .02em; }
[data-chalk="true"] .board { background-image: radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px); background-size: 5px 5px; }
[data-chalk="true"] .cell { font-size: 7cqi; }
[data-chalk="true"] .title { font-family: 'Patrick Hand', var(--font-ui); font-weight: 400; font-size: 3.2rem; }

/* Minimal collection: flat surfaces, hairline borders, no glow */
[data-minimal="true"] .btn:not(.btn-ghost),
[data-minimal="true"] .chip-btn,
[data-minimal="true"] .tool-icon,
[data-minimal="true"] .numpad button,
[data-minimal="true"] .pill,
[data-minimal="true"] .logo { box-shadow: none; border: 1px solid var(--lineThin); }
[data-minimal="true"] .btn-primary { border-color: var(--accent); }
[data-minimal="true"] .chip-btn .icon { color: var(--lineThick); }
[data-minimal="true"] .board { border-width: 1.5px; box-shadow: 0 1px 3px rgba(43,43,40,.08); }
[data-minimal="true"] .cell.c2, [data-minimal="true"] .cell.c5 { border-right-width: 1.5px; }
[data-minimal="true"] .cell.r2, [data-minimal="true"] .cell.r5 { border-bottom-width: 1.5px; }
[data-minimal="true"] .logo { animation: none; }
[data-minimal="true"] .title { font-weight: 700; letter-spacing: 0; }
[data-minimal="true"] dialog { box-shadow: 0 12px 40px rgba(0,0,0,.15); }
.tc-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); flex: none; }

/* Font picker */
#settings-body { overflow: auto; min-height: 0; margin: 0 -4px; padding: 0 4px; }
.font-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 4px 0 8px; }
.font-opt {
  text-align: left; padding: 10px 12px; border-radius: 12px; background: var(--surface2);
  border: 2px solid transparent; transition: border-color .2s, transform .15s var(--ease);
}
.font-opt:active { transform: scale(.97); }
.font-opt.active { border-color: var(--accent); }
.font-opt b { display: block; font-size: 1.15rem; font-weight: 600; line-height: 1.3; }
.font-opt small { display: block; color: var(--muted); font-size: .72rem; font-weight: 700; margin-top: 2px; }

/* A chosen font overrides theme-specific display fonts too */
[data-custom-font="true"] .title,
[data-custom-font="true"] .timer,
[data-custom-font="true"] .notes { font-family: var(--font-ui) !important; }
[data-custom-font="true"][data-pixel="true"] .cell { font-size: 6.2cqi; }
[data-custom-font="true"][data-pixel="true"] .numpad button { font-size: clamp(1.3rem, 6.2vw, 2rem); }
[data-custom-font="true"][data-pixel="true"] .title { font-size: 2.6rem; }
[data-custom-font="true"][data-pixel="true"] .timer { font-size: 1rem; }

/* Theme picker groups */
.theme-group-title {
  grid-column: 1 / -1; margin: 6px 2px -2px; font-size: .75rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1000; }

/* ============ Animations ============ */
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
@keyframes flash { 0% { opacity: 0; } 30% { opacity: .35; } 100% { opacity: 0; } }
@keyframes bump { 50% { transform: scale(1.25); } }
@keyframes bounce-in { 0% { transform: scale(0) rotate(-20deg); } 60% { transform: scale(1.2) rotate(8deg); } 100% { transform: scale(1); } }
@keyframes pulse { 50% { opacity: .55; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  #deco { display: none; }
}
