/* Sokoban — a warm diorama. Colours that depend on the chosen world arrive
   as custom properties from themes.js; the board itself is a canvas. */

:root {
  --bg-a: #efe5d6;
  --bg-b: #d6c7b0;
  --blob1: rgba(255, 246, 228, 0.9);
  --blob2: rgba(222, 160, 92, 0.32);
  --blob3: rgba(176, 106, 76, 0.22);
  --ink: #2e241b;
  --ink-soft: #6e604f;
  --paper: #f8f2e8;
  --paper-2: #ede3d4;
  --line: rgba(70, 50, 30, 0.13);
  --accent: #9c5f35;
  --accent-hi: #c98a52;
  --accent-ink: #fff8ef;
  --chip: rgba(255, 255, 255, 0.42);
  --chip-line: rgba(255, 255, 255, 0.55);
  --good: #2f7a4c;
  --gold: #b07a1a;
  --radius: 18px;
  --ease: cubic-bezier(0.4, 0.1, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.5, 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;
  color-scheme: light;
}
:root[data-dark="1"] { color-scheme: dark; }

* { 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%;
  -webkit-touch-callout: none;
  transition: background 0.8s, color 0.4s;
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------------------------------------------------------- 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.6;
  will-change: transform;
  transition: background 0.8s;
}
.bg .b1 { width: 60vmax; height: 60vmax; left: -20vmax; top: -25vmax; background: var(--blob1); animation: drift 48s ease-in-out infinite alternate; }
.bg .b2 { width: 50vmax; height: 50vmax; right: -20vmax; bottom: -20vmax; background: var(--blob2); animation: drift 60s ease-in-out infinite alternate-reverse; }
.bg .b3 { width: 40vmax; height: 40vmax; left: 30vw; bottom: -25vmax; background: var(--blob3); 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: 820px;
  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; min-width: 0; }
.brand img { width: 40px; height: 40px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25)); }
.brand span { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.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; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { display: flex; gap: 2px; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  width: 44px;
  height: 44px;
  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, .tab 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: 1.15fr 1fr 1fr 1fr;
  gap: 8px;
  padding: 4px 16px 6px;
}
.stat {
  background: var(--chip);
  border: 1px solid var(--chip-line);
  box-shadow: 0 1px 2px rgba(60, 45, 30, 0.06);
  border-radius: 12px;
  padding: 6px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  min-width: 0;
}
.stat span { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stat b { font-family: var(--serif); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat b i { font-style: normal; }
.stat b small { font-size: 12px; font-weight: 500; color: var(--ink-soft); margin-left: 1px; }
.stat b.word { font-size: 16px; padding-top: 3px; }

.stage {
  flex: 1;
  min-height: 0;
  position: relative;
}
.board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  cursor: pointer;
  transition: opacity 0.4s, filter 0.4s;
}
.board.dim { opacity: 0.35; filter: blur(2px); }

.generating {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  color: var(--ink);
  padding: 14px 20px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(30, 20, 10, 0.25);
  font-size: 15px;
  animation: popc 0.3s var(--ease);
  white-space: nowrap;
}
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid color-mix(in oklab, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.actions {
  display: flex;
  gap: 8px;
  padding: 6px 16px 14px;
}
.btn {
  appearance: none;
  flex: 1;
  min-width: 0;
  border: 1px solid color-mix(in oklab, var(--ink) 14%, transparent);
  background: var(--chip);
  color: var(--ink);
  font: 500 15px var(--sans);
  padding: 11px 10px;
  min-height: 46px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(60, 45, 30, 0.08);
  transition: transform 0.15s, background 0.2s, opacity 0.2s, box-shadow 0.2s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.btn svg { width: 19px; height: 19px; flex: 0 0 auto; }
.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, var(--accent-hi), var(--accent));
  color: var(--accent-ink);
  border-color: color-mix(in oklab, var(--accent) 70%, black);
  box-shadow: 0 4px 12px -4px color-mix(in oklab, var(--accent) 70%, black), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary.thinking { animation: breathe 0.8s ease-in-out infinite; }
.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; border-color: var(--line); }
@keyframes breathe { 50% { opacity: 0.6; } }
#btn-next { animation: popc2 0.4s var(--spring); }
@keyframes popc2 { from { transform: scale(0.85); opacity: 0; } }

/* -------------------------------------------------------- sheets, dialogs */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(30, 22, 14, 0.38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade 0.25s;
}
@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(30, 22, 14, 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; }
.note { font-size: 13px; margin: 8px 2px 0; }

@media (min-width: 700px) and (min-height: 560px) {
  .sheet {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 24px;
    max-height: 82dvh;
    animation: pop 0.28s var(--ease);
  }
  .levels-sheet { max-width: 640px; }
}
@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);
  color: var(--ink);
  border-radius: 24px;
  padding: 26px 24px 22px;
  box-shadow: 0 20px 60px rgba(30, 22, 14, 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 { padding-top: 20px; }
.result .glow {
  position: absolute;
  inset: -40% -20% auto;
  height: 70%;
  background: radial-gradient(ellipse at 50% 40%, color-mix(in oklab, var(--gold) 40%, transparent), transparent 65%);
  pointer-events: none;
  opacity: 0.75;
}
.result h2 { position: relative; font-size: 30px; }
.result[data-perfect="1"] h2 { animation: shimmer 2.4s ease-in-out infinite; }
@keyframes shimmer { 50% { text-shadow: 0 0 18px color-mix(in oklab, var(--gold) 70%, white); } }
.stars { position: relative; display: flex; justify-content: center; gap: 6px; margin-bottom: 6px; }
.stars svg { width: 34px; height: 34px; fill: color-mix(in oklab, var(--ink) 12%, transparent); stroke: none; }
.stars svg.on { fill: var(--gold); filter: drop-shadow(0 2px 4px color-mix(in oklab, var(--gold) 50%, transparent)); animation: star 0.5s var(--spring) both; animation-delay: var(--d); }
.stars svg:nth-child(2) { width: 40px; height: 40px; margin-top: -6px; }
@keyframes star { from { transform: scale(0.2) rotate(-40deg); opacity: 0; } }
.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.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; min-width: 0; }
.result-stats span, .summary span { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.result-stats b, .summary b { font-family: var(--serif); font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.final-score { display: flex; flex-direction: column; align-items: center; margin: 4px 0 18px; }
.final-score span { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.final-score b { font-family: var(--serif); font-size: 44px; font-weight: 600; line-height: 1.05; }

/* --------------------------------------------------------------- levels */
.tabs {
  display: flex;
  gap: 6px;
  padding: 4px 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 0 0 auto;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font: 500 14px var(--sans);
  padding: 8px 13px;
  min-height: 40px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.tab small { font-size: 11.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.tab svg { width: 18px; height: 18px; align-self: center; }
.tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tab[aria-selected="true"] small { color: color-mix(in oklab, var(--accent-ink) 75%, transparent); }
.tier-progress { margin: 0 0 12px; font-size: 13.5px; }
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 10px;
}
.card {
  appearance: none;
  position: relative;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 14px;
  padding: 8px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
  font: inherit;
}
.card:active { transform: scale(0.96); }
.card:hover { border-color: color-mix(in oklab, var(--accent) 45%, transparent); }
.card canvas { width: 56px; height: 56px; }
.card .row1 { display: flex; align-items: center; gap: 5px; line-height: 1.1; }
.card .num { font-family: var(--serif); font-weight: 600; font-size: 15px; color: var(--ink); }
.card .par, .card .best { font-size: 11px; line-height: 1.2; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.card.solved { background: color-mix(in oklab, var(--good) 10%, var(--paper-2)); }
.card.current { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent); }
.card.started::after {
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-hi);
}
.mini-stars { display: flex; gap: 1px; }
.mini-stars svg { width: 12px; height: 12px; fill: color-mix(in oklab, var(--ink) 15%, transparent); }
.mini-stars svg.on { fill: var(--gold); }
.card .best { font-weight: 600; color: var(--ink); }
.card.perfect .best { color: var(--good); }
.tier-progress small { display: block; font-size: 12px; margin-top: 2px; opacity: 0.85; }

.endless-text { margin: 4px 0 14px; }
.endless-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.endless-pick {
  appearance: none;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 16px;
  padding: 16px 12px;
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font: inherit;
  transition: transform 0.15s, border-color 0.2s;
}
.endless-pick:active { transform: scale(0.97); }
.endless-pick:hover { border-color: var(--accent); }
.endless-pick b { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.pips { display: flex; gap: 4px; }
.pips i { width: 8px; height: 8px; border-radius: 2px; background: var(--accent-hi); }
.endless-count { margin-top: 16px; font-size: 13.5px; text-align: center; }

/* ------------------------------------------------------------- results */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 82px 1fr 44px; align-items: center; gap: 10px; font-size: 13.5px; }
.bar i { height: 8px; border-radius: 99px; background: var(--paper-2); overflow: hidden; display: block; }
.bar b { display: block; height: 100%; width: var(--p); border-radius: 99px; background: linear-gradient(90deg, var(--accent-hi), var(--accent)); }
.bar small { text-align: right; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
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.moves, th.pushes, th.time, th.score, td.moves, td.pushes, td.time, td.score { text-align: right; }
td.level { white-space: normal; }
td.score { font-family: var(--serif); font-weight: 600; font-size: 15px; }
tr.perfect td.pushes { color: var(--good); font-weight: 600; }
@media (max-width: 420px) { th.moves, td.moves { 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;
  min-height: 42px;
  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: var(--paper); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent); }
.opts.lang .opt, .opts.pace .opt { padding-left: 14px; min-width: 96px; justify-content: center; }
.swatch { display: inline-block; width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }
.sw-warehouse { background: radial-gradient(circle at 70% 70%, #e6c06a 0 18%, transparent 20%), linear-gradient(180deg, #cfb68e 0 34%, #b56d4d 34% 52%, #d8caad 52%); }
.sw-greenhouse { background: radial-gradient(circle at 68% 68%, #f39ab6 0 16%, transparent 18%), linear-gradient(180deg, #5f9150 0 34%, #3f6b38 34% 52%, #e2d6b8 52%); }
.sw-glacier { background: radial-gradient(circle at 68% 68%, #7ff3dc 0 16%, transparent 18%), linear-gradient(180deg, #e6eff8 0 34%, #7fb3db 34% 52%, #2e4a68 52%); }
.sw-auto { background: linear-gradient(135deg, #cfb68e 0 50%, #2e4a68 50%); }
.toggle { display: flex; align-items: center; gap: 12px; margin-top: 20px; cursor: pointer; font-size: 15px; line-height: 1.35; min-height: 32px; }
.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) 22%, var(--paper)); 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-hi); 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: color-mix(in oklab, var(--ink) 92%, transparent);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  width: max-content;
  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); }

:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
.board:focus-visible { outline: none; }

/* ------------------------------------------------------- small screens */
@media (max-height: 640px) {
  .top { padding-top: 6px; }
  .brand small { display: none; }
  .brand b { font-size: 19px; }
  .stat b { font-size: 17px; }
  .actions { padding-bottom: 10px; }
  .btn { padding: 8px 8px; min-height: 42px; }
}
@media (max-width: 520px) {
  .btn { flex-direction: column; gap: 3px; padding: 7px 4px 6px; font-size: 12.5px; }
  .btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .btn svg { width: 21px; height: 21px; }
  .stats { gap: 6px; }
}
@media (max-width: 389px) {
  .top { padding: 10px 8px 4px 14px; gap: 6px; }
  .brand { gap: 8px; }
  .brand img { width: 36px; height: 36px; }
  .brand b { font-size: 21px; }
  .brand small { font-size: 10.5px; letter-spacing: 0.05em; }
  .menu { gap: 0; }
  .icon-btn { width: 42px; }
  .stats { padding-left: 12px; padding-right: 12px; gap: 5px; }
  .stat span { font-size: 10px; letter-spacing: 0.05em; }
  .actions { padding-left: 12px; padding-right: 12px; gap: 6px; }
}
@media (min-width: 900px) and (min-height: 700px) {
  .brand b { font-size: 26px; }
}
/* Landscape phones: stats and actions move to the sides of the board. */
@media (orientation: landscape) and (max-height: 500px) {
  .app { display: grid; grid-template-columns: 172px 1fr 150px; grid-template-rows: auto 1fr; max-width: none; }
  .top { grid-column: 1 / 2; grid-row: 1; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 10px 4px 14px; }
  .stats { grid-column: 1; grid-row: 2; grid-template-columns: 1fr 1fr; align-content: start; padding: 4px 10px 10px 14px; }
  .stage { grid-column: 2; grid-row: 1 / 3; }
  .actions { grid-column: 3; grid-row: 1 / 3; flex-direction: column; justify-content: center; padding: 10px 14px 10px 6px; }
  .actions .btn { flex: 0 0 auto; flex-direction: row; font-size: 13.5px; }
  .toast { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .bg .blob { animation: none; }
  .sheet, .dialog, .backdrop, .stars svg.on, #btn-next, .generating { animation: none; transition-duration: 0.01s; }
}
