/* Peanut's Memory Legend. Shell: casual-game-shell (header · main · footer, drawer, pages, tokens).
   Breakpoints change tokens, not selectors; game parts (board, cards, rooms) follow. */
@font-face { font-family: Nunito; src: url("./assets/nunito-latin.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }

:root {
  --paper: #f5eedf;
  --cream: #fffaf0;
  --ink: #55463d;
  --muted: #84725f;
  --line: #cdb995;
  --primary: #56708c;      /* dusty blue, Peanut's card backs */
  --select: #6f8a68;       /* sage, as in the rest of the family */
  --focus: #627c5c;
  --coin: #f1d98f;
  --coin-ink: #6e4f14;
  --coin-edge: #cfae5a;
  --peach: #ee9f8a;
  --mustard: #e2b443;
  --back: #7c93b5;
  --ctl: 44px;
  --icon: 20px;
  --r-ctl: 10px;
  --gap: 14px;
  --pad: 22px;
  --ctl-shadow: #c3ab86;
  --frame: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 80' preserveAspectRatio='none'%3E%3Crect x='4' y='4' width='192' height='72' rx='10' fill='none' stroke='%23fffaf0' stroke-opacity='.5'/%3E%3Cpath d='M9 16v-4h5m172 0h5v4M9 64v4h5m172 0h5v-4' fill='none' stroke='%239e8057' stroke-opacity='.4'/%3E%3C/svg%3E");
  --card-back: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg fill='%23fffaf0' fill-opacity='.85'%3E%3Cpath d='m10 5 1.6 3.4 3.7.5-2.7 2.6.7 3.7-3.3-1.8-3.3 1.8.7-3.7-2.7-2.6 3.7-.5Z'/%3E%3Cpath d='m30 25 1.6 3.4 3.7.5-2.7 2.6.7 3.7-3.3-1.8-3.3 1.8.7-3.7-2.7-2.6 3.7-.5Z'/%3E%3C/g%3E%3Cg fill='%23fffaf0' fill-opacity='.45'%3E%3Ccircle cx='30' cy='9' r='1.6'/%3E%3Ccircle cx='10' cy='29' r='1.6'/%3E%3C/g%3E%3C/svg%3E");
  font-family: Nunito, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
  font-synthesis: none;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 700px) { :root { --gap: 10px; --pad: 16px; } }
@media (orientation: landscape) and (max-height: 600px) { :root { --gap: 7px; --pad: 12px; } }
@media (min-width: 701px) and (min-height: 581px) { :root { --gap: 14px; --pad: 28px; } }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--paper);
  background-image: radial-gradient(#a3896220 .8px, transparent .8px);
  background-size: 8px 8px;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, ol, ul { margin: 0; }
b, h1, h2, strong { font-weight: 800; }
svg { display: block; }
img { display: block; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .13em; color: var(--muted); text-transform: uppercase; }
.muted, .note { color: var(--muted); font-weight: 600; }
.note { font-size: 14px; }

/* ===== Controls: game pieces ===== */
button {
  font: inherit; font-weight: 800; color: var(--ink);
  min-height: var(--ctl);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  background-image: var(--frame), linear-gradient(#fffbf0, #f1e4c9);
  background-size: 100% 100%;
  box-shadow: 0 4px var(--ctl-shadow), inset 0 2px #fff9;
  cursor: pointer; touch-action: manipulation; white-space: nowrap;
  transition: transform .13s, filter .13s, box-shadow .13s;
}
button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px var(--ctl-shadow), inset 0 2px #fff9; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (hover: hover) { button:not(:disabled):hover { filter: brightness(1.04); transform: translateY(-1px); } button:not(:disabled):active { transform: translateY(3px); } }
button.primary {
  color: #fff;
  background-image: var(--frame), linear-gradient(color-mix(in srgb, var(--primary) 78%, white), var(--primary));
  border-color: color-mix(in srgb, var(--primary) 78%, black);
  box-shadow: 0 4px color-mix(in srgb, var(--primary) 62%, black), inset 0 2px #ffffff4d;
}
button.primary:active:not(:disabled) { box-shadow: 0 1px color-mix(in srgb, var(--primary) 62%, black), inset 0 2px #ffffff4d; }
button[aria-pressed="true"] {
  background-image: var(--frame), linear-gradient(color-mix(in srgb, var(--select) 20%, var(--cream)), color-mix(in srgb, var(--select) 36%, var(--cream)));
  border-color: color-mix(in srgb, var(--select) 80%, white);
  box-shadow: 0 4px color-mix(in srgb, var(--select) 55%, var(--paper)), inset 0 2px #fff9;
}
button > svg { width: var(--icon); height: var(--icon); flex: none; }
.icon-button { position: relative; width: var(--ctl); padding: 0; flex: none; }
button.big { min-height: 48px; font-size: 17px; }

/* ===== Shell: one grid, three rows ===== */
.shell {
  height: 100dvh;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); gap: var(--gap);
  padding:
    max(calc(var(--pad) - 6px), env(safe-area-inset-top))
    max(var(--pad), env(safe-area-inset-right))
    max(calc(var(--pad) - 6px), env(safe-area-inset-bottom))
    max(var(--pad), env(safe-area-inset-left));
}
header, footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.header-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: var(--ctl); color: inherit; text-decoration: none; font-size: 19px; line-height: 1.1; border-radius: 10px; }
.brand svg { width: 44px; height: 44px; flex: none; }
.brand span { min-width: 0; display: block; }
.brand b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 900; }
.brand small { display: block; margin-top: 5px; font-size: 10px; font-weight: 800; letter-spacing: .13em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coin-pill {
  min-height: var(--ctl); height: var(--ctl); padding: 0 12px 0 9px; gap: 6px; flex: none;
  border-radius: calc(var(--ctl) / 2); border-color: var(--coin-edge); color: var(--coin-ink); font-weight: 900; font-size: 15px; line-height: 1;
  background-image: linear-gradient(#fbeec0, var(--coin));
  box-shadow: 0 4px #c9a653, inset 0 2px #fff9;
}
.coin-pill:active:not(:disabled) { box-shadow: 0 1px #c9a653, inset 0 2px #fff9; }
.coin-pill.bump { animation: bump .45s ease-out; }
@keyframes bump { 40% { transform: scale(1.12); } }
.update-button::after, #menu-button::after {
  content: ""; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--peach); border: 1.5px solid var(--cream); box-shadow: 0 0 0 1px #c9715c55;
}
#menu-button::after { display: none; }
#menu-button.downloading::after { display: block; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: .55; } }

main.main { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.screen { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
body[data-page] .screen { display: none; }
footer { border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent); padding-top: 6px; min-height: 28px; font-size: 13px; color: var(--muted); font-weight: 700; }
footer #status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
footer .tagline { display: none; flex: none; }

.panel { padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); border-radius: 14px; background: #fffdf6; display: flex; flex-direction: column; gap: 6px; }
.card-panel { background: var(--cream); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 4px var(--ctl-shadow), inset 0 2px #fff9; }

/* ===== Home ===== */
.home { min-height: 0; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(290px, .85fr); gap: var(--gap); align-items: center; }
.hero { min-height: 0; height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); align-items: center; justify-items: center; gap: 4px; text-align: center; }
.hero h1 { font-size: clamp(24px, 3.4vw, 34px); line-height: 1.08; font-weight: 900; }
.hero h1 em { font-style: normal; color: var(--primary); }
.mascot { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.launch { padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.album-pick { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; }
.album-pick h2 { font-size: 20px; line-height: 1.15; }
.album-pick p { font-size: 14px; }
.emblem { --size: 72px; position: relative; width: var(--size); height: var(--size); flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 5px; border-radius: 14px; background: var(--tint, #f3ead8); border: 1px solid color-mix(in srgb, var(--line) 80%, transparent); }
.emblem .pic { width: 100%; height: 100%; }
.found-bar { height: 8px; border-radius: 4px; background: #efe4cd; overflow: hidden; margin-top: 6px; }
.found-bar i { display: block; height: 100%; background: var(--select); border-radius: 4px; }
.home-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-stats span { display: flex; flex-direction: column; align-items: center; padding: 6px; border-radius: 12px; background: #fffdf6; border: 1px solid color-mix(in srgb, var(--line) 60%, transparent); font-size: 12px; font-weight: 700; color: var(--muted); }
.home-stats b { font-size: 20px; color: var(--ink); line-height: 1.2; }
.start-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.start-actions button { min-height: 48px; padding: 8px 10px; }

/* ===== Play ===== */
.play { min-height: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.play .hud { grid-row: 1; } .play .timebar { grid-row: 2; } .play > .board-wrap { grid-row: 3; } .play .feedback-row { grid-row: 4; }
.hud { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-score { display: flex; align-items: baseline; gap: 6px; min-width: 0; flex: none; }
.hud-score b { font-size: 26px; line-height: 1; }
.hud-score small { font-size: 12px; font-weight: 700; color: var(--muted); }
.hud-mid { flex: 1; min-width: 0; display: flex; gap: 6px; justify-content: safe center; overflow: hidden; }
.narrow-only { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px; border-radius: 15px; background: #fffdf6; border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); font-size: 13px; font-weight: 800; white-space: nowrap; }
.chip.combo { background: color-mix(in srgb, var(--mustard) 25%, var(--cream)); border-color: color-mix(in srgb, var(--mustard) 60%, white); }
.chip.you { background: color-mix(in srgb, var(--select) 22%, var(--cream)); border-color: color-mix(in srgb, var(--select) 60%, white); }
.chip .rank { color: var(--muted); }
.clock { flex: none; min-width: 64px; height: 36px; display: grid; place-items: center; padding: 0 10px; border-radius: 18px; background: var(--cream); border: 1px solid var(--line); font-size: 18px; font-weight: 900; }
.clock.urgent { color: #b3523e; border-color: var(--peach); background: #fde9e1; }
.timebar { height: 6px; border-radius: 3px; background: #ebdfc6; overflow: hidden; }
.timebar i { display: block; height: 100%; width: 100%; background: var(--primary); border-radius: 3px; transition: width .2s linear; }
.board-wrap { min-height: 0; min-width: 0; display: grid; place-items: center; overflow: hidden; }
.board { --card: 64px; --cols: 4; --board-gap: 10px; display: grid; grid-template-columns: repeat(var(--cols), var(--card)); gap: var(--board-gap); }
.feedback-row { min-height: var(--ctl); display: flex; align-items: center; justify-content: center; gap: 12px; text-align: center; }
.feedback { font-weight: 800; min-width: 0; }
.feedback[data-tone="good"] { color: var(--select); }
.feedback[data-tone="miss"] { color: #b3523e; }
.peek-meter { width: 72px; height: 8px; border-radius: 4px; background: #ebdfc6; overflow: hidden; flex: none; }
.peek-meter i { display: block; height: 100%; background: var(--mustard); border-radius: 4px; transform-origin: left; }

/* Cards: a two-faced flip. The front only holds a picture once that picture may be seen. */
button.card { width: var(--card); height: var(--card); min-height: 0; padding: 0; border: 0; border-radius: calc(var(--card) * .16); background: none; box-shadow: none; perspective: 700px; }
button.card:active:not(:disabled) { transform: none; box-shadow: none; }
@media (hover: hover) { button.card:not(:disabled):hover { transform: none; filter: none; } button.card[data-state="down"]:not(:disabled):hover .card-inner { transform: translateY(-2px); } }
.card-inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .34s cubic-bezier(.3, .7, .3, 1.15); }
.card[data-state="up"] .card-inner, .card[data-state="miss"] .card-inner, .card[data-state="matched"] .card-inner, .card[data-state="peek"] .card-inner { transform: rotateY(180deg); }
.card[data-state="down"]:active .card-inner { transform: scale(.95); }
.face { position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit; backface-visibility: hidden; -webkit-backface-visibility: hidden; border: 1px solid var(--line); box-shadow: 0 3px var(--ctl-shadow), inset 0 2px #fff9; }
.face.back { border-color: color-mix(in srgb, var(--back) 70%, black); background: var(--card-back) center / 70% auto no-repeat, linear-gradient(color-mix(in srgb, var(--back) 82%, white), var(--back)); box-shadow: 0 3px color-mix(in srgb, var(--back) 55%, black), inset 0 0 0 3px #fffaf055; }
.face.front { transform: rotateY(180deg); background: var(--cream); }
.face.front .pic { width: 80%; height: 80%; }
.card[data-state="matched"] .face.front { background: color-mix(in srgb, var(--select) 14%, var(--cream)); border-color: color-mix(in srgb, var(--select) 70%, white); box-shadow: 0 3px color-mix(in srgb, var(--select) 45%, var(--paper)), inset 0 2px #fff9; }
.card[data-state="matched"] .pic { opacity: .72; }
.card[data-state="matched"].fresh .face.front { animation: pop .42s ease-out; }
.card[data-state="miss"] .face.front { background: #fdeee8; border-color: var(--peach); }
.card[data-state="miss"] .card-inner { animation: shake .36s ease-in-out .3s; }
@keyframes pop { 45% { transform: rotateY(180deg) scale(1.1); } }
@keyframes shake { 25% { translate: -3px 0; } 75% { translate: 3px 0; } }
.board.cleared .card .face.front { animation: pop .5s ease-out; }

/* ===== Friends: room screens and the match strip ===== */
.room { min-height: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 10px; padding: 14px; }
.room-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.room-head h2 { font-size: 22px; }
.steps { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.steps li { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 4px; font-size: 13px; font-weight: 800; color: var(--muted); border-radius: 12px; border: 1px solid transparent; }
.steps li .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #f3e8cf; border: 1px solid var(--line); font-size: 12px; flex: none; }
.steps li[data-state="done"] .n { background: color-mix(in srgb, var(--select) 30%, var(--cream)); }
.steps li[aria-current="step"] { color: var(--ink); background: color-mix(in srgb, var(--select) 14%, var(--cream)); border-color: color-mix(in srgb, var(--select) 55%, white); }
.steps li[aria-current="step"] .n { background: var(--select); border-color: var(--select); color: #fff; }
.room-status { text-align: center; font-weight: 800; padding: 6px 10px; border-radius: 12px; background: #fffdf6; border: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.room-status[data-tone="go"] { background: color-mix(in srgb, var(--select) 14%, var(--cream)); }
.room-status[data-tone="warn"] { background: #fdeee8; border-color: var(--peach); }
.room-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 12px; align-content: start; }
.room-info { display: flex; flex-direction: column; gap: 8px; }
.room-code { font-size: 30px; font-weight: 900; letter-spacing: .14em; line-height: 1.1; }
.room-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }
.room-actions button { flex: 1 1 140px; max-width: 260px; }
.players { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.players li { min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 4px 10px; border-radius: 12px; background: #fffdf6; border: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.players li.you { border-color: color-mix(in srgb, var(--select) 60%, white); }
.players li[data-state="left"], .players li[data-state="offline"] { color: var(--muted); }
.player-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; font-weight: 800; overflow: hidden; white-space: nowrap; }
.player-name .rank { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #f3e8cf; font-size: 13px; flex: none; }
.host-badge svg { width: 18px; height: 18px; color: var(--mustard); }
.you-badge { padding: 1px 8px; border-radius: 10px; background: var(--select); color: #fff; font-size: 12px; }
.player-status { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--muted); font-size: 14px; }
.player-status svg { width: 18px; height: 18px; }
.player-status .ok { color: var(--select); }
.coin-line { display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 800; color: var(--coin-ink); }
.coin-line svg { width: 20px; height: 20px; }
.race { display: flex; gap: 6px; min-width: 0; }
.countdown { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 10px; background: color-mix(in srgb, var(--paper) 94%, transparent); pointer-events: none; }
.countdown strong { font-size: 120px; line-height: 1; font-weight: 900; color: var(--primary); animation: count .9s ease-out infinite; }
@keyframes count { from { transform: scale(1.25); opacity: .4; } 30% { transform: scale(1); opacity: 1; } }

/* ===== Results ===== */
.results { min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 10px; padding: 16px; }
.results-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 2px; }
.results h2 { font-size: 26px; }
.total { font-size: 54px; font-weight: 900; line-height: 1; color: var(--primary); }
.stats { width: 100%; max-width: 560px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stats span { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 12px; background: #fffdf6; border: 1px solid color-mix(in srgb, var(--line) 60%, transparent); font-size: 12px; font-weight: 700; color: var(--muted); }
.stats b { font-size: 20px; color: var(--ink); }
.stats .coin-stat b { color: var(--coin-ink); }
.new-finds { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.new-finds .pic { width: 34px; height: 34px; padding: 3px; border-radius: 8px; background: var(--cream); border: 1px solid var(--line); }
.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; width: 100%; }
.actions button { flex: 1 1 140px; max-width: 240px; }
.results .players { width: 100%; max-width: 520px; text-align: left; }
.results .steps { width: 100%; }
.results .room-status { width: 100%; }

/* ===== Pages ===== */
.sheet-page {
  min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 12px;
  padding: 14px; background: var(--cream); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 4px var(--ctl-shadow), inset 0 2px #fff9;
}
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.dialog-head h2 { font-size: 22px; line-height: 1.2; min-width: 0; }
.dialog-head h2:focus { outline: none; }
.dialog-head h2:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sheet-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 12px; }
.sheet-foot { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }
.sheet-foot button { flex: 1 1 140px; max-width: 280px; }
.sheet-body h3 { font-size: 15px; font-weight: 800; }
.steps-list { padding-left: 22px; display: flex; flex-direction: column; gap: 4px; }
.help-step { flex-direction: row; align-items: flex-start; gap: 12px; }
.help-step .help-icon { width: 26px; height: 26px; flex: none; color: var(--primary); margin-top: 2px; }
.toggle-row { width: 100%; justify-content: flex-start; gap: 12px; min-height: 52px; text-align: left; }
.toggle-row .state { margin-left: auto; font-size: 14px; letter-spacing: .04em; color: var(--muted); }
.toggle-row[aria-pressed="true"] .state { color: var(--select); }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding: 2px 2px 6px; }
.album-card { flex-direction: column; justify-content: flex-start; gap: 6px; height: 168px; padding: 12px 8px; text-align: center; }
.album-card strong { font-size: 15px; line-height: 1.2; }
.album-card .line { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 22px; font-size: 13px; font-weight: 800; color: var(--muted); }
.album-card .line svg { width: 18px; height: 18px; }
.album-card.locked { color: var(--muted); }
.album-card.locked .emblem .pic { filter: grayscale(.85); opacity: .5; }
.lock-badge { display: none; position: absolute; right: -6px; bottom: -6px; width: 26px; height: 26px; border-radius: 50%; background: var(--cream); border: 1px solid var(--line); place-items: center; color: var(--muted); }
.lock-badge svg { width: 16px; height: 16px; }
.locked .lock-badge { display: grid; }
.legend-badge { position: absolute; left: -6px; top: -6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--mustard); color: #fff; border: 1px solid #c29330; }
.legend-badge svg { width: 15px; height: 15px; }
.unlock-album { display: flex; align-items: center; gap: 14px; }
.unlock-album h3 { font-size: 20px; }
.price-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.price-strip div { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px; border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); border-radius: 14px; background: #fffdf6; font-size: 13px; color: var(--muted); font-weight: 700; }
.price-strip b { display: flex; align-items: center; gap: 5px; font-size: 20px; color: var(--coin-ink); }
.price-strip b svg { width: 20px; height: 20px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.friends-grid, .friends-side { display: flex; flex-direction: column; gap: 12px; }
.name-picks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.name-picks button { padding: 6px 4px; font-size: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; }
.field input { font: inherit; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; min-height: var(--ctl); padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: #fffdf6; color: var(--ink); }
.field input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.error { color: #b3523e; font-weight: 800; min-height: 1.4em; }
.invite { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: center; }
.qr { width: min(200px, 60vw); padding: 8px; background: #fff; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; }
.qr svg { width: 100%; height: auto; }
.invite a { color: var(--primary); font-weight: 700; word-break: break-all; }

/* ===== Menu drawer ===== */
.menu-scrim { position: fixed; inset: 0; z-index: 40; background: #55463d4d; }
.menu-drawer {
  position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(300px, 86vw);
  display: flex; flex-direction: column; gap: 8px;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) 14px;
  background: radial-gradient(#a389622e .7px, transparent .8px) 0 0 / 8px 8px, var(--cream);
  border-left: 2px solid #cbb48f; box-shadow: -12px 0 40px #55463d33;
  overflow-y: auto; overscroll-behavior: contain;
}
.menu-drawer:not([hidden]) { animation: menu-in .18s ease-out; }
@keyframes menu-in { from { transform: translateX(100%); } }
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid #d5bfa0; }
.menu-head h2 { font-size: 20px; font-weight: 900; }
.menu-item { width: 100%; height: 48px; min-height: 48px; flex: none; justify-content: flex-start; gap: 12px; padding: 0 14px; text-align: left; }
.menu-item svg { color: var(--primary); }

#toast { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 60; max-width: 90%; padding: 10px 18px; border-radius: 12px; background: var(--ink); color: var(--cream); font-weight: 800; box-shadow: 0 4px 15px #0002; pointer-events: none; text-align: center; }
#toast:empty { display: none; }

/* ===== Short screens ===== */
@media (max-height: 690px) {
  .brand small, footer .tagline, .hero .eyebrow { display: none !important; }
}

/* ===== Phone portrait ===== */
@media (max-width: 700px) {
  .brand { font-size: 17px; }
  .brand svg { width: 38px; height: 38px; }
  .header-actions { gap: 8px; }
  footer { font-size: 12px; min-height: 24px; padding-top: 4px; }
  .home { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; align-items: stretch; }
  .hero h1 { font-size: 24px; }
  .launch { padding: 12px; gap: 10px; }
  .emblem { --size: 64px; }
  .room-body { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps li { flex-direction: column; gap: 2px; font-size: 12px; }
  .hud-score b { font-size: 22px; }
  .name-picks button { font-size: 14px; }
  .wide-only { display: none; }
  .narrow-only { display: inline; }
}

/* ===== Narrow portrait floor: the page may scroll rather than squeeze the board ===== */
@media (max-width: 380px) and (orientation: portrait) {
  html, body { height: auto; overflow-x: hidden; overflow-y: auto; }
  .shell { height: 100dvh; min-height: 540px; }
  .brand svg { width: 34px; height: 34px; }
  .brand { gap: 7px; font-size: 16px; }
  .coin-pill { padding: 0 10px 0 8px; font-size: 14px; }
  .hero h1 { font-size: 21px; }
  .start-actions { gap: 10px; }
  .hud { gap: 6px; }
  .clock { min-width: 56px; font-size: 16px; }
  .chip { padding: 0 8px; font-size: 12px; }
  .name-picks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .start-actions button > svg, #ready-peek > svg { display: none; }
  .peek-meter { width: 36px; }
  .feedback-row { gap: 8px; }
}

/* ===== Phone landscape: the HUD moves beside the board ===== */
@media (orientation: landscape) and (max-height: 600px) {
  .brand { font-size: 15px; }
  .brand svg { width: 34px; height: 34px; }
  footer { min-height: 22px; padding-top: 3px; font-size: 12px; }
  .home { grid-template-columns: minmax(0, 1fr) minmax(300px, 1fr); grid-template-rows: minmax(0, 1fr); align-items: center; }
  .steps li { flex-direction: row; gap: 5px; padding: 3px 4px; }
  .steps li .n { width: 20px; height: 20px; font-size: 11px; }
  .room-body { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
  .wide-only { display: inline; }
  .narrow-only { display: none; }
  .hero h1 { font-size: 20px; }
  .launch { padding: 10px 12px; gap: 8px; }
  .emblem { --size: 58px; }
  .album-pick h2 { font-size: 17px; }
  .home-stats b { font-size: 16px; }
  .play { grid-template-columns: 168px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 10px; }
  .play-side { grid-row: 1; grid-column: 1; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
  .play .hud { flex-direction: column; align-items: stretch; gap: 6px; }
  .play .hud-mid { flex-direction: column; align-items: flex-start; flex: none; }
  .play .hud-score { justify-content: flex-start; }
  .play .race { flex-direction: column; }
  .play .hud .icon-button { align-self: flex-start; }
  .play .feedback-row { flex-direction: column; align-items: stretch; justify-content: flex-end; margin-top: auto; text-align: left; }
  .play .board-wrap { grid-row: 1; grid-column: 2; }
  .play .clock-row { display: flex; gap: 8px; align-items: center; }
  .sheet-page { padding: 10px 12px; gap: 8px; }
  .dialog-head { padding-bottom: 6px; }
  .dialog-head h2 { font-size: 18px; }
  .room { padding: 10px 12px; gap: 6px; }
  .friends-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .friends-grid .emblem { --size: 48px; }
  .friends-grid .panel { padding: 8px 10px; }
  .room-head h2 { display: none; }
  .room-head { justify-content: stretch; }
  .room-head .steps { flex: 1; }
  .room-code { font-size: 24px; }
  .results { padding: 10px; gap: 6px; }
  .results h2 { font-size: 20px; }
  .total { font-size: 40px; }
  .stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .stats span { padding: 4px; }
  .stats b { font-size: 16px; }
  .countdown strong { font-size: 90px; }
}
.play-side { display: contents; }
.clock-row { display: contents; }
@media (orientation: landscape) and (max-height: 600px) { .play-side, .play .clock-row { display: flex; } }

/* ===== Desktop: framed board on a deeper paper table ===== */
@media (min-width: 701px) and (min-height: 581px) {
  body { display: grid; place-items: center; padding: 16px;
    background-color: #e6d6b8;
    background-image: radial-gradient(#8f714a2e .9px, transparent .9px), linear-gradient(#ecdfc6, #dfcca9);
    background-size: 9px 9px, 100% 100%; }
  .shell { position: relative; width: min(980px, 100%); height: min(720px, calc(100dvh - 32px));
    background: var(--paper) radial-gradient(#a3896220 .8px, transparent .8px) 0 0 / 8px 8px;
    border: 3px solid #c3a779; outline: 2px solid #fff9ec; outline-offset: -9px; border-radius: 30px;
    box-shadow: 0 10px 0 #b89a70, 0 26px 60px #55463d33, inset 0 2px #fffc; }
  .shell::before, .shell::after { content: ""; position: absolute; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: #b59a73; box-shadow: inset 0 1px 2px #0003; }
  .shell::before { left: 12px; } .shell::after { right: 12px; }
  footer .tagline { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
