/* Trap Word — tokens, layout, components, animations, reduced-motion overrides.
   Started from the UI mock-ups' mock.css; tokens match UI-SPEC.md. */

:root {
  --bg: #121213;
  --surface: #1a1a1b;
  --border: #3a3a3c;
  --border-filled: #565758;
  --text: #ffffff;
  --text-muted: #818384;
  --tile-green: #538d4e;
  --tile-yellow: #b59f3b;
  --tile-gray: #3a3a3c;
  --key-bg: #818384;
  --accent: #4a90d9;
  --negative: #e5484d;
  --positive: #6fcf73;

  --diff-easy: #6fcf73;
  --diff-average: #818384;
  --diff-tricky: #d9b44a;
  --diff-hard: #f08c3a;
  --diff-brutal: #e5484d;

  --tile: 52px;
  --tile-gap: 5px;
  --key-h: 58px;
  --key-gap: 6px;
  --score-col: 40px;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

:root[data-contrast="high"] {
  --tile-green: #f5793a;
  --tile-yellow: #85c0f9;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; color: var(--text); font-family: var(--font); font-size: 16px; }
body { background: transparent; }
/* Decorative backdrop: fixed, behind everything, faint enough not to compete with the board. */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: url(img/bg.webp) center / cover no-repeat; opacity: 0.09;
}
body:has(.app--play)::before { opacity: 0.045; }   /* quieter behind the boards */
body { min-height: 100dvh; -webkit-text-size-adjust: 100%; }
button { font-family: inherit; color: inherit; }
button, [role="radio"] { -webkit-tap-highlight-color: transparent; }
.sr-only { position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: flex; flex-direction: column; min-height: 100dvh; }
.app__main { flex: 1 1 auto; min-height: 0; }

/* ---------- Header ---------- */
.header {
  height: 56px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.header .logo { grid-column: 1; }
.header-right { grid-column: 3; }
.logo { display: flex; align-items: center; color: var(--text); text-decoration: none; }
.logo img { height: 44px; width: auto; display: block; }
.header-right { justify-self: end; display: flex; gap: 12px; align-items: center; color: var(--text-muted); font-size: 0.8125rem; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: none;
  color: var(--text-muted); font-size: 0.75rem; font-weight: 700; cursor: pointer; padding: 0;
}
.icon-btn[aria-pressed="true"] { color: var(--text); border-color: var(--accent); }
.toggle-row { padding: 8px 16px 0; flex-shrink: 0; }
.toggle-row[hidden] { display: none; }

/* ---------- Hero logo (before the game starts) ---------- */
.hero { display: none; justify-content: center; padding: 12px 16px 0; flex-shrink: 0; }
.app--hero .hero { display: flex; }
.hero img { width: min(100%, 440px); height: auto; display: block; }
.app--hero .header .logo { visibility: hidden; }   /* the hero replaces the wordmark; controls stay put */

/* ---------- View toggle ---------- */
.toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.toggle--full { display: flex; }
.toggle--full .seg { flex: 1; }
.seg {
  padding: 6px 16px; background: none; border: 0; color: var(--text-muted);
  font-size: 0.875rem; font-weight: 600; cursor: pointer;
}
.seg[aria-checked="true"] { background: var(--accent); color: #fff; }
.seg:disabled { opacity: 0.4; cursor: default; }
.toggle--header { justify-self: center; }

/* ---------- Status banner ---------- */
.banner {
  min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 8px 16px 0; border-radius: var(--radius); background: var(--surface);
  font-size: 0.9375rem; font-weight: 600; padding: 0 12px; text-align: center; flex-shrink: 0;
}
.banner--turn { background: var(--accent); color: #fff; font-weight: 700; }
.banner--pulse { animation: banner-pulse 2s ease-out 1; }
.banner--final { justify-content: space-between; }
.banner .btn { height: 32px; padding: 0 14px; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; flex-shrink: 0; }
@keyframes pulse { 50% { opacity: 0.25; } }
@keyframes banner-pulse { 0% { box-shadow: 0 0 0 0 rgba(74,144,217,0.8); } 100% { box-shadow: 0 0 0 14px rgba(74,144,217,0); } }

.reconnect {
  margin: 6px 16px 0; padding: 4px 12px; border-radius: var(--radius); text-align: center;
  background: color-mix(in srgb, var(--negative) 25%, transparent); font-size: 0.8125rem; font-weight: 600; flex-shrink: 0;
}

/* ---------- Opponent strip ---------- */
.strip {
  height: 48px; margin: 8px 16px 0; padding: 0 12px; border-radius: var(--radius);
  background: var(--surface); display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.strip .name { font-weight: 700; }
.strip .score { font-weight: 800; font-variant-numeric: tabular-nums; }
.strip .muted { color: var(--text-muted); font-size: 0.875rem; }
.strip .view-link {
  margin-left: auto; color: var(--accent); font-size: 0.875rem; background: none; border: 0; cursor: pointer; padding: 8px 0 8px 8px;
}
.strip--flash { animation: strip-flash 0.9s ease-out 1; }
@keyframes strip-flash { 0% { background: color-mix(in srgb, var(--accent) 45%, var(--surface)); } 100% { background: var(--surface); } }

/* ---------- Boards layout ---------- */
.boards {
  display: grid; grid-template-columns: repeat(2, minmax(0, 480px)); gap: 48px;
  justify-content: center; padding: 16px;
}
.boards--single { grid-template-columns: minmax(0, 480px); }
.kb-dock { padding: 0 16px 16px; display: flex; justify-content: center; }
.kb-dock > .keyboard { width: 100%; max-width: 520px; }

/* ---------- Board panel ---------- */
.panel { position: relative; padding: 16px; border-radius: var(--radius); outline: 1px solid transparent; }
.panel--active { outline: 2px solid var(--accent); }
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.panel-head .name { font-size: 1.125rem; font-weight: 700; overflow-wrap: anywhere; }
.panel-head .chip { margin-left: auto; }

.pill {
  font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.04em; padding: 3px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--text); white-space: nowrap;
}
.pill--done { background: color-mix(in srgb, var(--tile-green) 30%, transparent); }

.chip {
  font-size: 0.75rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip--easy    { color: var(--diff-easy);    background: color-mix(in srgb, var(--diff-easy) 20%, transparent); }
.chip--average { color: var(--diff-average); background: color-mix(in srgb, var(--diff-average) 20%, transparent); }
.chip--tricky  { color: var(--diff-tricky);  background: color-mix(in srgb, var(--diff-tricky) 20%, transparent); }
.chip--hard    { color: var(--diff-hard);    background: color-mix(in srgb, var(--diff-hard) 20%, transparent); }
.chip--brutal  { color: var(--diff-brutal);  background: color-mix(in srgb, var(--diff-brutal) 20%, transparent); }

.setword { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.8125rem; margin-bottom: 12px; flex-wrap: wrap; }
.mini-tiles { display: flex; gap: 3px; }
.mini-tile {
  width: 24px; height: 24px; display: grid; place-items: center; font-size: 0.8125rem; font-weight: 700;
  border: 1px solid var(--border-filled); color: var(--text); text-transform: uppercase;
}
.mini-tile.tile--g { background: var(--tile-green); border-color: var(--tile-green); }
.mini-tile.tile--y { background: var(--tile-yellow); border-color: var(--tile-yellow); }
.mini-tile.tile--b { background: var(--tile-gray); border-color: var(--tile-gray); }
.mini-tiles--flip .mini-tile { animation: flip 600ms ease-in-out 1; }

/* ---------- Grid + row scores ---------- */
.grid { display: grid; grid-template-columns: auto var(--score-col); row-gap: var(--tile-gap); justify-content: center; position: relative; }
.row { display: flex; gap: var(--tile-gap); }
.row--shake { animation: shake 0.5s; }
.row--pending .tile { animation: pending-pulse 0.9s ease-in-out infinite; }
.tile {
  width: var(--tile); height: var(--tile); border: 2px solid var(--border);
  display: grid; place-items: center; font-size: calc(var(--tile) * 0.55); font-weight: 700;
  text-transform: uppercase; line-height: 1; user-select: none;
}
.tile--typed { border-color: var(--border-filled); }
.tile--pop { animation: pop 100ms ease-in-out 1; }
.tile--g { background: var(--tile-green);  border-color: var(--tile-green); }
.tile--y { background: var(--tile-yellow); border-color: var(--tile-yellow); }
.tile--b { background: var(--tile-gray);   border-color: var(--tile-gray); }
.tile--flip { animation: flip 350ms ease-in-out 1; }
.tile--bounce { animation: bounce 700ms ease-in-out 1; animation-delay: var(--d, 0ms); }
.row-score {
  align-self: center; justify-self: center; background: none; border: 0; padding: 4px; min-width: 32px; min-height: 32px;
  color: var(--text); font-size: 0.875rem; font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer;
}
.row-score--neg { color: var(--negative); }
.row-score--hidden { visibility: hidden; }
.row-score--in { animation: fade-in 200ms ease-out 1; }
.row-score-spacer { display: block; }

@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); }
}
@keyframes bounce {
  0%, 20% { transform: translateY(0); } 40% { transform: translateY(-24%); } 50% { transform: translateY(4%); }
  60% { transform: translateY(-10%); } 80% { transform: translateY(2%); } 100% { transform: translateY(0); }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pending-pulse { 50% { opacity: 0.55; } }

/* ---------- Total ---------- */
.total { text-align: center; margin: 14px 0 12px; position: relative; }
.total-label { color: var(--text-muted); font-size: 0.8125rem; }
.total-num { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.float-pts {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%); font-weight: 800; font-size: 1.125rem;
  color: var(--positive); pointer-events: none; animation: float-up 800ms ease-out forwards;
}
.float-pts--neg { color: var(--negative); }
@keyframes float-up { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -24px); } }

/* ---------- Breakdown popover ---------- */
.popover {
  position: fixed; width: 240px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; font-size: 0.8125rem; z-index: 5;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.popover table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.popover td { padding: 2px 0; vertical-align: top; }
.popover td.num { text-align: right; font-weight: 700; white-space: nowrap; padding-left: 8px; }
.popover .note { color: var(--negative); font-size: 0.75rem; font-weight: 400; }
.popover .sum td { border-top: 1px solid var(--border); padding-top: 6px; font-weight: 800; }
.popover .neg { color: var(--negative); }

/* ---------- Keyboard ---------- */
.keyboard { display: flex; flex-direction: column; gap: 8px; user-select: none; touch-action: manipulation; }
.kb-row { display: flex; gap: var(--key-gap); justify-content: center; }
.key {
  flex: 1 1 0; max-width: 43px; height: var(--key-h); border: 0; border-radius: 4px; padding: 0;
  background: var(--key-bg); color: var(--text); font-size: 0.8125rem; font-weight: 700; cursor: pointer;
  display: grid; place-items: center; text-transform: uppercase;
}
.key--wide { flex: 1.5 1 0; max-width: 65px; font-size: 0.75rem; }
.key--g { background: var(--tile-green); }
.key--y { background: var(--tile-yellow); }
.key--b { background: var(--tile-gray); }
.keyboard--disabled .key { opacity: 0.5; }
.keyboard--readonly .key { cursor: default; }
.keyboard--mini { --key-h: 35px; --key-gap: 4px; gap: 5px; max-width: 60%; margin: 0 auto; width: 100%; }
.keyboard--mini .key { max-width: 26px; font-size: 0.625rem; }
.keyboard--mini .key--wide { max-width: 39px; font-size: 0.5625rem; }
.kb-caption { text-align: center; color: var(--text-muted); font-size: 0.75rem; margin-top: 8px; }

/* ---------- Buttons ---------- */
.btn {
  height: 44px; padding: 0 20px; border-radius: var(--radius); font-size: 0.9375rem; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn--primary { background: var(--accent); color: #fff; border: 0; }
.btn--secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn--block { width: 100%; }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.4; cursor: default; }
.btn[aria-busy="true"] { pointer-events: none; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast-layer { position: fixed; left: 0; right: 0; top: 128px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 30; }
.toast {
  background: var(--text); color: var(--bg); font-size: 0.875rem; font-weight: 700; padding: 10px 14px; border-radius: 4px;
  animation: fade-in 120ms ease-out 1;
}

/* ---------- Modal ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: grid; place-items: center; padding: 16px; z-index: 20; overflow-y: auto; }
.modal { width: 100%; max-width: 420px; background: var(--surface); border-radius: 12px; padding: 24px; max-height: calc(100dvh - 32px); overflow-y: auto; }
.modal h2 { margin: 0 0 12px; font-size: 1.25rem; }
.modal p { line-height: 1.5; }
.modal-actions { display: flex; gap: 12px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }
.modal--wide { max-width: 560px; }
.modal .muted { color: var(--text-muted); }

/* ---------- Setup screens ---------- */
.setup-col { max-width: 480px; margin: 0 auto; padding: 16px; width: 100%; }
.landing { text-align: center; padding-top: 2vh; }
.landing .tagline { color: var(--text-muted); margin: 0 0 32px; text-wrap: balance; }
.field {
  width: 100%; height: 48px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 1rem; padding: 0 14px; margin-bottom: 12px; font-family: inherit;
}
.field:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 0.875rem; margin-top: 20px; padding: 8px; text-decoration: underline; }
.card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: var(--surface); margin-top: 16px; }
.card h2 { margin: 0 0 12px; font-size: 1.125rem; }
.invite-link { display: flex; gap: 8px; }
.invite-link .field { margin: 0; flex: 1; min-width: 0; font-size: 0.875rem; }
.game-code { text-align: center; font-size: 2rem; font-weight: 800; letter-spacing: 0.3em; margin: 20px 0 4px; padding-left: 0.3em; }
.hint { text-align: center; color: var(--text-muted); font-size: 0.8125rem; }
.invited { font-size: 1.125rem; text-align: center; margin: 24px 0 16px; line-height: 1.4; }
.center-msg { text-align: center; padding-top: 10vh; }

.picker-heading { text-align: center; font-size: 1.125rem; font-weight: 700; margin: 16px 0 12px; }
.picker-tiles { --tile: 60px; display: flex; gap: var(--tile-gap); justify-content: center; }
.picker-tiles--loading .tile { animation: pending-pulse 0.9s ease-in-out infinite; }
.picker-status { text-align: center; font-size: 0.875rem; font-weight: 700; margin: 10px 0; min-height: 1.3em; }
.picker-status--ok { color: var(--positive); }
.picker-status--bad { color: var(--negative); }
.diff-card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.diff-top { display: flex; align-items: center; gap: 12px; }
.diff-mult { font-size: 2.5rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.meter { position: relative; height: 6px; border-radius: 3px; background: var(--border); margin: 18px 0 6px; }
.meter-mid { position: absolute; left: 50%; top: -4px; width: 1px; height: 14px; background: var(--text-muted); }
.meter-mark { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); transform: translate(-50%, -50%); }
.meter-ends { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 0.75rem; }
.diff-reason { margin-top: 10px; font-size: 0.875rem; }
.locked-summary { text-align: center; margin: 24px 0; font-size: 1rem; line-height: 1.6; }
.locked-summary strong { letter-spacing: 0.1em; }

/* ---------- Coin toss ---------- */
.coin-wrap { text-align: center; }
.coin { width: 120px; height: 120px; margin: 8px auto 20px; position: relative; transform-style: preserve-3d; perspective: 600px; animation: coin 1.2s ease-out forwards; }
.coin-face {
  position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; font-size: 3rem; font-weight: 800;
  background: var(--accent); color: #fff; border: 6px solid #fff3; backface-visibility: hidden;
}
.coin-face--back { transform: rotateY(180deg); background: #7a5cc4; }
@keyframes coin { from { transform: rotateY(0); } to { transform: rotateY(var(--coin-end, 1800deg)); } }
.coin-text { font-size: 1.25rem; opacity: 0; animation: fade-in 300ms ease-out 1.2s forwards; }

/* ---------- Finish modal ---------- */
/* Seat colors: player 1 green, player 2 yellow (they follow the high-contrast tokens) */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; flex-shrink: 0; vertical-align: middle; }
.dot--green { background: var(--tile-green); }
.dot--yellow { background: var(--tile-yellow); }
.panel-head .name, .strip .name { display: inline-flex; align-items: center; }

.finish-chars { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; justify-items: center; margin-bottom: 4px; }
.finish-col h3 { display: flex; align-items: center; }
.finish-char { display: flex; align-items: flex-end; justify-content: center; transform-origin: 50% 95%; }
.finish-char--big { height: 130px; }     /* the winner stands taller */
.finish-char--small { height: 100px; }
.finish-char--even { height: 115px; }
.finish-char img { height: 100%; width: auto; display: block; }
.finish-char .char-flip { transform: scaleX(-1); }
.finish-char--stoked { animation: mascot-hop 1s cubic-bezier(.2,.8,.3,1) 1, mascot-bob 1.8s ease-in-out 1s infinite; }
.finish-char--happy { animation: mascot-pop 0.7s ease-out 1, mascot-sway 3s ease-in-out 0.7s infinite; }
.finish-char--sad { animation: mascot-droop 1.2s ease-out 1, mascot-sadsway 3.6s ease-in-out 1.2s infinite; }
@keyframes mascot-hop {
  0% { transform: translateY(36px) scale(0.5) rotate(-14deg); opacity: 0; }
  55% { transform: translateY(-14px) scale(1.08) rotate(5deg); opacity: 1; }
  100% { transform: none; opacity: 1; }
}
@keyframes mascot-bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
@keyframes mascot-pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.06); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes mascot-sway { 50% { transform: rotate(2deg); } }
@keyframes mascot-droop { 0% { transform: translateY(-16px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes mascot-sadsway { 50% { transform: rotate(-2deg) translateY(2px); } }
.finish-head { text-align: center; }
.finish-title { font-size: 2rem; font-weight: 800; }
.finish-score { color: var(--text-muted); font-size: 1.125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.finish-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 20px 0; }
.finish-col h3 { margin: 0 0 8px; font-size: 1rem; overflow-wrap: anywhere; }
.finish-col table { width: 100%; font-size: 0.8125rem; border-collapse: collapse; margin-top: 10px; font-variant-numeric: tabular-nums; }
.finish-col td.num { text-align: right; font-weight: 700; }
.finish-col .sum td { border-top: 1px solid var(--border); padding-top: 4px; font-weight: 800; }
.finish-col .neg { color: var(--negative); }
.finish-actions { display: flex; gap: 12px; }
.finish-actions .btn { flex: 1; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.confetti span { position: absolute; top: -12px; width: 8px; height: 8px; animation: confetti-fall 1s ease-in forwards; }
@keyframes confetti-fall { to { transform: translate(var(--dx), 105vh) rotate(var(--rot)); opacity: 0.9; } }

/* ---------- Narrow screens ---------- */
@media (max-width: 899px) {
  :root { --key-h: 48px; --tile-gap: 4px; --key-gap: 5px; }
  .header { height: 48px; grid-template-columns: 1fr auto; }
  .header-right { grid-column: 2; }
  .logo img { height: 28px; }
  .toggle--header { display: none; }
  .banner { min-height: 36px; margin-top: 6px; }
  .strip { height: 40px; margin-top: 6px; }
  .hero img { width: min(100%, 340px); }

  /* Game screen: the page is exactly one viewport tall and nothing scrolls during play. */
  .app--play { height: 100dvh; overflow: hidden; }
  .app--play .app__main { overflow-y: auto; display: flex; flex-direction: column; }
  .app--play .boards { padding: 6px 16px 0; gap: 8px; grid-template-columns: minmax(0, 1fr); flex: 1 1 auto; min-height: 0; justify-content: stretch; }
  .app--play .panel { padding: 0; outline: 0; }
  .app--play .panel-head { margin-bottom: 6px; }
  .app--play .setword { display: none; }
  .app--play .total { margin: 6px 0 0; display: flex; justify-content: center; align-items: baseline; gap: 6px; }
  .app--play .total-num { font-size: 1.5rem; }
  .app--play .kb-dock { padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); flex-shrink: 0; }
  .app--play .kb-dock > .keyboard { gap: 6px; }
  .app--play .key { max-width: 33px; }
  .app--play .key--wide { max-width: 52px; }
  .app--play .keyboard--mini { max-width: none; }

  /* Word picker: keyboard pinned to the bottom, content above it scrolls only if it must */
  .app--setup { height: 100dvh; overflow: hidden; }
  .app--setup .app__main { overflow-y: auto; }
  .app--setup .kb-dock { padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); flex-shrink: 0; }
  .app--setup .kb-dock > .keyboard { gap: 6px; }
  .app--setup .key { max-width: 33px; }
  .app--setup .key--wide { max-width: 52px; }
  .app--setup .hero { display: none; }   /* the picker needs the height */
  .app--setup .header .logo { visibility: visible; }
  .app--setup .setup-col { padding: 4px 16px 8px; }
  .app--setup .picker-heading { margin: 6px 0 8px; }
  .app--setup .picker-tiles { --tile: 52px; }
  .app--setup .picker-status { margin: 6px 0; }
  .app--setup .diff-card { padding: 12px; margin-bottom: 8px; }
  .app--setup .diff-mult { font-size: 2.25rem; }
  .app--setup .meter { margin: 14px 0 6px; }

  .app--single { --tile: max(34px, min(15vw, calc((100dvh - 410px) / 6.5))); }
  .app--both {
    --tile: clamp(24px, calc(((100vw - 24px) / 2 - 34px) / 5), 36px); --score-col: 22px; --tile-gap: 3px;
  }
  .app--both .boards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 6px 8px 0; }
  .app--both .row-score { font-size: 0.75rem; padding: 2px; min-width: 22px; }
  .app--both .panel-head { gap: 4px; }
  .app--both .panel-head .name { font-size: 1rem; }
  .app--both .panel-head .chip { margin-left: 0; font-size: 0.6875rem; padding: 2px 6px; }
  .app--both .total-num { font-size: 1.25rem; }
  .app--both .strip { display: none; }

  .finish-cols { grid-template-columns: 1fr; gap: 8px; }
  .finish-char--big { height: 92px; }
  .finish-char--small { height: 72px; }
  .finish-char--even { height: 82px; }
  .finish-chars { gap: 8px; }
  .finish-actions { position: sticky; bottom: -20px; background: var(--surface); padding: 8px 0 2px; margin-top: 4px; }
  .modal { padding: 20px; }
}

/* Wide screens: tile size by view */
@media (min-width: 900px) {
  .app--single { --tile: 60px; }
  .app--both { --tile: 52px; }
  .toggle-row { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .coin { transform: rotateY(var(--coin-end, 0deg)); }
  .coin-text { opacity: 1; }
  .float-pts { display: none; }
}
