/* Block Buster — calm, tactile blocks. Colours arrive as custom properties
   from themes.js (wood / neon / clay); the defaults below are the wood look. */

:root {
  --bg-a: #f1e8da;
  --bg-b: #d8cdbc;
  --blob-a: rgba(255, 252, 245, 0.95);
  --blob-b: rgba(240, 190, 140, 0.45);
  --blob-c: rgba(160, 200, 180, 0.4);
  --ink: #3a2f25;
  --ink-soft: #7b6b5b;
  --paper: #faf6ef;
  --paper-2: #efe7da;
  --line: rgba(70, 50, 30, 0.13);
  --accent: #c07d4f;
  --accent-2: #8d5a35;
  --accent-ink: #fff8f0;
  --board: #f6eee1;
  --board-2: #e7dac6;
  --board-rim: rgba(120, 85, 50, 0.3);
  --cell: rgba(90, 60, 30, 0.05);
  --dot: rgba(90, 65, 40, 0.22);
  --slot: rgba(255, 255, 255, 0.4);
  --glow: #f2c079;
  --tile-r: 22%;
  --p0: #e2857a; --p1: #eeab66; --p2: #e9cf6c; --p3: #9bc98c;
  --p4: #79c3b6; --p5: #80ade0; --p6: #ae96d8; --p7: #e99bb9;
  --ease: cubic-bezier(0.4, 0.1, 0.2, 1);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: linear-gradient(165deg, var(--bg-a), var(--bg-b));
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  transition: background 0.8s, color 0.4s;
}

/* ---------------------------------------------------------- background */
.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.bg .blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.7; will-change: transform; transition: background 0.8s; }
.bg .b1 { width: 60vmax; height: 60vmax; left: -20vmax; top: -25vmax; background: var(--blob-a); animation: drift 48s ease-in-out infinite alternate; }
.bg .b2 { width: 50vmax; height: 50vmax; right: -20vmax; bottom: -20vmax; background: var(--blob-b); animation: drift 60s ease-in-out infinite alternate-reverse; }
.bg .b3 { width: 40vmax; height: 40vmax; left: 30vw; bottom: -25vmax; background: var(--blob-c); animation: drift 72s ease-in-out infinite alternate; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(8vmax, 6vmax) scale(1.12); }
}

/* -------------------------------------------------------------- layout */
.app {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 4px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 40px; height: 40px; border-radius: 11px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2)); }
.brand span { display: flex; flex-direction: column; line-height: 1.1; }
.brand b { font-family: var(--serif); font-weight: 600; font-size: 22px; letter-spacing: 0.02em; }
.brand small { font-size: 11.5px; color: var(--ink-soft); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; }
.menu { display: flex; gap: 4px; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.icon-btn:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg, .btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 4px 16px 6px; }
.stat {
  background: color-mix(in oklab, var(--paper) 45%, transparent);
  border: 1px solid color-mix(in oklab, var(--paper) 60%, transparent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
}
.stat span { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.stat b { font-family: var(--serif); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; transition: transform 0.2s var(--ease), color 0.3s; }
.stat b.bump { animation: bump 0.4s var(--ease); }
.stat b.hot { color: var(--accent); }
@keyframes bump { 35% { transform: scale(1.22); } }

.stage {
  flex: 1;
  min-height: 0;
  container-type: size;
  display: grid;
  place-items: center;
  padding: 4px 16px;
}

.actions { display: flex; gap: 10px; padding: 6px 16px 14px; }
.btn {
  appearance: none;
  flex: 1;
  border: 1px solid var(--line);
  background: color-mix(in oklab, var(--paper) 60%, transparent);
  color: var(--ink);
  font: 500 15px var(--sans);
  padding: 11px 12px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s, background 0.2s, opacity 0.2s, box-shadow 0.2s;
}
.btn svg { width: 19px; height: 19px; }
.btn:hover { background: color-mix(in oklab, var(--paper) 85%, transparent); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.primary {
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 85%, white), var(--accent-2));
  color: var(--accent-ink);
  border-color: var(--accent-2);
  box-shadow: 0 4px 12px -4px color-mix(in oklab, var(--accent-2) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.subtle { flex: 0 0 auto; background: transparent; box-shadow: none; color: var(--ink-soft); font-size: 13.5px; margin: 18px auto 0; display: flex; }

/* ---------------------------------------------------------------- tiles */
.bb-tile {
  position: absolute;
  inset: 0;
  border-radius: var(--tile-r);
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
  --tc: var(--p0);
  transition: opacity 0.25s, transform 0.25s var(--ease), filter 0.3s;
}
.k0 { --tc: var(--p0); } .k1 { --tc: var(--p1); } .k2 { --tc: var(--p2); } .k3 { --tc: var(--p3); }
.k4 { --tc: var(--p4); } .k5 { --tc: var(--p5); } .k6 { --tc: var(--p6); } .k7 { --tc: var(--p7); }
.bb-tile.on {
  opacity: 1;
  transform: none;
  background: linear-gradient(160deg, color-mix(in oklab, var(--tc) 74%, white) 0%, var(--tc) 48%, color-mix(in oklab, var(--tc) 84%, black) 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    inset 2px 0 0 rgba(255, 255, 255, 0.22),
    inset 0 -3px 0 rgba(0, 0, 0, 0.16),
    inset -2px 0 0 rgba(0, 0, 0, 0.08),
    0 2px 3px rgba(60, 40, 20, 0.28);
}
.bb-tile.on::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: repeating-linear-gradient(104deg, rgba(255, 255, 255, 0.12) 0 2px, transparent 2px 6px);
  opacity: 0.55;
  pointer-events: none;
}
[data-theme="neon"] .bb-tile.on {
  background: radial-gradient(circle at 35% 28%, color-mix(in oklab, var(--tc) 55%, white), var(--tc) 52%, color-mix(in oklab, var(--tc) 72%, black) 100%);
  box-shadow:
    0 0 10px color-mix(in oklab, var(--tc) 60%, transparent),
    0 0 2px var(--tc),
    inset 0 0 0 1px color-mix(in oklab, var(--tc) 45%, white),
    inset 0 -2px 3px rgba(0, 0, 0, 0.3);
}
[data-theme="neon"] .bb-tile.on::after { display: none; }
[data-theme="clay"] .bb-tile.on {
  background: linear-gradient(150deg, color-mix(in oklab, var(--tc) 82%, white), var(--tc) 60%, color-mix(in oklab, var(--tc) 92%, black));
  box-shadow:
    inset 0 3px 4px rgba(255, 255, 255, 0.6),
    inset 0 -4px 6px rgba(0, 0, 0, 0.1),
    0 3px 6px rgba(80, 60, 100, 0.18);
}
[data-theme="clay"] .bb-tile.on::after { display: none; }

/* ---------------------------------------------------------------- board */
.bb-board {
  width: min(100cqw, 100cqh);
  aspect-ratio: 1;
  position: relative;
  border-radius: 16px;
  padding: 3%;
  background: linear-gradient(160deg, var(--board), var(--board-2));
  box-shadow:
    inset 0 0 0 1px var(--board-rim),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 20px 44px -20px rgba(30, 20, 10, 0.45),
    0 2px 6px rgba(30, 20, 10, 0.12);
  transition: background 0.6s, box-shadow 0.6s;
}
[data-theme="neon"] .bb-board { box-shadow: inset 0 0 0 1px var(--board-rim), inset 0 0 40px rgba(60, 70, 160, 0.25), 0 20px 50px -18px rgba(0, 0, 0, 0.7); }
.bb-grid {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  gap: 3px;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.bb-cell { position: relative; border-radius: 18%; background: var(--cell); }
.bb-cell::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14%;
  height: 14%;
  margin: -7% 0 0 -7%;
  border-radius: 50%;
  background: var(--dot);
}
.bb-cell::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--tile-r);
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
}
.bb-cell.ghost::after {
  opacity: 1;
  background: color-mix(in oklab, var(--tc) 42%, transparent);
  box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--tc) 75%, transparent);
}
.bb-cell.ghost.bad::after { background: rgba(225, 70, 70, 0.22); box-shadow: inset 0 0 0 2px rgba(225, 70, 70, 0.5); }
.bb-cell.will .bb-tile.on { filter: brightness(1.22) saturate(1.1); transform: scale(1.05); }
.bb-cell.will:not(.ghost)::after { opacity: 1; background: rgba(255, 255, 255, 0.18); }
.bb-cell.cursor::after { opacity: 1; box-shadow: inset 0 0 0 2px var(--accent); }

.bb-tile.pop { animation: bb-pop 0.24s var(--ease); }
@keyframes bb-pop {
  0% { transform: scale(1.2) translateY(-8%); }
  60% { transform: scale(0.96); }
  100% { transform: none; }
}
.bb-tile.clear { animation: bb-clear 0.42s var(--d, 0ms) var(--ease) forwards; }
@keyframes bb-clear {
  0% { filter: brightness(1.5); transform: scale(1.06); }
  30% { filter: brightness(1.9); transform: scale(1.1); opacity: 1; }
  100% { opacity: 0; transform: scale(0.15) rotate(10deg); filter: brightness(2.2); }
}
.bb-board.over .bb-tile.on { filter: saturate(0.2) brightness(0.92); }
.bb-board.over::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 3px rgba(225, 80, 80, 0.55), inset 0 0 48px rgba(225, 80, 80, 0.25);
  animation: bb-alert 1.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes bb-alert { 50% { opacity: 0.35; } }

.bb-float {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  z-index: 5;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(24px, 9cqw, 44px);
  line-height: 1;
  color: var(--ink);
  text-align: center;
  text-shadow: 0 2px 10px var(--paper), 0 0 2px var(--paper);
  pointer-events: none;
  animation: bb-rise 1.1s var(--ease) forwards;
}
.bb-float small { display: block; margin-top: 4px; font-family: var(--sans); font-weight: 600; font-size: 0.42em; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
@keyframes bb-rise {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(1); }
}

/* ------------------------------------------------------------ next, tray */
.bb-next {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: 26px;
  padding: 0 16px;
  --u: 6px;
  --g: 1px;
}
.bb-next span { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.bb-next-pieces { display: flex; align-items: center; gap: 12px; height: 100%; }
.bb-next .bb-piece { cursor: default; }
.bb-next .bb-tile.on { box-shadow: none; }
.bb-next .bb-tile.on::after { display: none; }

.bb-tray {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 4px 16px;
  height: clamp(88px, 15dvh, 124px);
  --u: var(--tu, 14px);
  --g: 2px;
  touch-action: none;
}
.bb-slot {
  display: grid;
  place-items: center;
  min-height: 0;
  border-radius: 16px;
  background: var(--slot);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: background 0.3s;
}
.bb-piece {
  position: relative;
  width: calc(var(--w) * var(--u));
  height: calc(var(--h) * var(--u));
  cursor: grab;
  touch-action: none;
  transition: transform 0.2s var(--ease), opacity 0.2s, filter 0.3s;
}
.bb-piece .bb-tile {
  inset: auto;
  left: calc(var(--c) * var(--u));
  top: calc(var(--r) * var(--u));
  width: calc(var(--u) - var(--g));
  height: calc(var(--u) - var(--g));
  transition: none;
}
.bb-piece.lifted { opacity: 0.2; transform: scale(0.9); }
.bb-piece.dead { opacity: 0.35; filter: saturate(0.3); }
.bb-piece.selected { transform: translateY(-6px) scale(1.1); filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.25)); }
.bb-piece.enter { animation: bb-enter 0.34s calc(var(--i, 0) * 70ms) var(--ease) backwards; }
@keyframes bb-enter { from { opacity: 0; transform: translateY(16px) scale(0.75); } }
.bb-piece.shake { animation: bb-shake 0.34s ease-in-out; }
@keyframes bb-shake {
  25% { transform: translateX(-8%); }
  50% { transform: translateX(7%); }
  75% { transform: translateX(-4%); }
}

.bb-drag {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  pointer-events: none;
  will-change: transform;
  filter: drop-shadow(0 14px 14px rgba(0, 0, 0, 0.28));
}
.bb-drag.back { transition: transform 0.24s var(--ease), opacity 0.24s; }
.bb-drag-in { position: absolute; left: 0; top: 0; transform: scale(var(--s, 1)); transform-origin: 50% 100%; transition: transform 0.16s var(--ease); }
.bb-drag .bb-tile { transition: none; }

/* -------------------------------------------------------- sheets, dialogs */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(30, 22, 16, 0.38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade 0.25s;
}
[data-theme="neon"] .backdrop { background: rgba(5, 5, 20, 0.55); }
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  z-index: 21;
  max-width: 560px;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
  padding-bottom: env(safe-area-inset-bottom);
  animation: rise 0.32s var(--ease);
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 22px; flex: 0 0 auto; }
.sheet h2, .dialog h2 { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 0; letter-spacing: 0.01em; }
.sheet-body {
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 22px 26px;
  font-size: 15px;
  line-height: 1.55;
}
.sheet-body h3 { font-family: var(--serif); font-weight: 600; font-size: 17px; margin: 20px 0 8px; color: var(--ink); }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0; padding-left: 20px; }
.prose li { margin: 4px 0; }
.muted { color: var(--ink-soft); }
.about { font-size: 13px; margin-top: 22px; text-align: center; }

@media (min-width: 700px) and (min-height: 560px) {
  .sheet { bottom: auto; top: 50%; transform: translateY(-50%); border-radius: 24px; max-height: 80dvh; animation: pop 0.28s var(--ease); }
}
@keyframes pop { from { opacity: 0; transform: translateY(-50%) scale(0.96); } }

.dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 22;
  width: min(92vw, 400px);
  background: var(--paper);
  border-radius: 24px;
  padding: 26px 24px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
  animation: popc 0.3s var(--ease);
  overflow: hidden;
}
@keyframes popc { from { opacity: 0; transform: translate(-50%, -50%) scale(0.94); } }
.dialog p { margin: 8px 0 18px; color: var(--ink-soft); font-size: 15.5px; line-height: 1.5; }
.dialog .row { display: flex; gap: 10px; }
.result .glow {
  position: absolute;
  inset: -40% -20% auto;
  height: 70%;
  background: radial-gradient(ellipse at 50% 40%, color-mix(in oklab, var(--glow) 45%, transparent), transparent 65%);
  pointer-events: none;
  opacity: 0.35;
}
.result[data-best="true"] .glow { opacity: 0.9; }
.result h2 { position: relative; font-size: 30px; }
.result[data-best="true"] h2 { animation: shimmer 2.4s ease-in-out infinite; }
@keyframes shimmer { 50% { text-shadow: 0 0 18px color-mix(in oklab, var(--glow) 80%, white); } }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 18px; }
.result-stats div, .summary div { display: flex; flex-direction: column; align-items: center; background: var(--paper-2); border-radius: 12px; padding: 8px 4px; line-height: 1.2; }
.result-stats span, .summary span { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.result-stats b, .summary b { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.result-score { display: flex; flex-direction: column; align-items: center; margin: 0 0 14px; position: relative; }
.result-score span { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.result-score b { font-family: var(--serif); font-size: 46px; font-weight: 600; line-height: 1.05; }

/* ------------------------------------------------------------- results */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th { text-align: left; vertical-align: bottom; font-weight: 500; color: var(--ink-soft); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 4px; border-bottom: 1px solid var(--line); }
td { padding: 7px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th.score, th.lines, th.combo, th.time, th.undos, td.score, td.lines, td.combo, td.time, td.undos { text-align: right; }
td.score { font-family: var(--serif); font-weight: 600; font-size: 15px; }
td.board { color: var(--ink-soft); }
@media (max-width: 440px) { th.undos, td.undos, th.board, td.board { display: none; } td { padding: 7px 3px; } }

/* ------------------------------------------------------------- settings */
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  appearance: none;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font: 500 14px var(--sans);
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.opt:active { transform: scale(0.97); }
.opt[aria-checked="true"] { border-color: var(--accent); background: color-mix(in oklab, var(--paper) 70%, white); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 25%, transparent); }
.opts.plain .opt { padding-left: 14px; min-width: 96px; justify-content: center; }
.swatch { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 26px; height: 26px; padding: 3px; border-radius: 7px; flex: 0 0 auto; background: var(--sw-bg); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.swatch i { border-radius: 2px; }
.toggle { display: flex; align-items: center; gap: 12px; margin-top: 22px; cursor: pointer; font-size: 15px; line-height: 1.35; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { flex: 0 0 auto; width: 46px; height: 28px; border-radius: 999px; background: color-mix(in oklab, var(--ink-soft) 45%, var(--paper-2)); position: relative; transition: background 0.25s; }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.25s var(--ease); }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(18px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  z-index: 15;
  background: rgba(35, 28, 22, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  max-width: min(88vw, 420px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------- small screens */
@media (max-height: 640px) {
  .top { padding-top: 6px; padding-bottom: 2px; }
  .brand small { display: none; }
  .brand b { font-size: 19px; }
  .brand img { width: 32px; height: 32px; }
  .stat { padding: 4px 6px; }
  .stat b { font-size: 17px; }
  .bb-next { height: 20px; }
  .bb-tray { height: clamp(76px, 14dvh, 100px); }
  .actions { padding-bottom: 10px; }
  .btn { padding: 9px 10px; }
}
@media (max-width: 520px) {
  .btn { flex-direction: column; gap: 3px; padding: 8px 6px 7px; font-size: 12.5px; }
  .btn span { white-space: nowrap; }
  .btn svg { width: 21px; height: 21px; }
}
@media (min-width: 900px) and (min-height: 700px) {
  .brand b { font-size: 26px; }
  .stage { padding: 10px 16px; }
  .bb-tray { height: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  .bg .blob, .bb-board.over::after, .result h2 { animation: none; }
  .bb-tile, .bb-piece, .sheet, .dialog, .backdrop, .bb-drag, .bb-drag-in, .stat b { animation: none; transition-duration: 0.01s; }
  .bb-float { animation-duration: 0.6s; }
}
