/* Detour — an old explorer's workshop table: map paper with folds and grain,
   a wooden rim, copper and brass, carved stones, a wax seal. Light: cream
   paper and ink; dark: a night-blue sea chart, light ink, glowing copper.
   Motion is transform/opacity only; reduced motion turns travel into fades. */

:root {
  color-scheme: light;
  --f-display: "Rockwell", "Rockwell Nova", "American Typewriter", "Roboto Slab", "Zilla Slab", "Courier New", Georgia, serif;
  --f-body: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --page: #EADFC8;
  --page-2: #DFD1B3;
  --paper: #F7F0E1;
  --paper-2: #F3EAD7;
  --ink: #2B2A33;
  --muted: #5C5866;
  --line: rgba(90, 64, 30, 0.16);
  --line-2: rgba(90, 64, 30, 0.08);
  --brass: #C58B2B;
  --brass-ink: #8A5A12;
  --brass-hi: #F2C46A;
  --patina: #3E8C84;
  --patina-ink: #2E6E67;
  --wax: #C0452F;
  --wax-ink: #A8381F;
  --gold: #E9C25A;
  --primary: #8E5A16;
  --primary-2: #B07322;
  --on-primary: #FFF6E6;
  --wood-1: #8A5D38;
  --wood-2: #6A4428;
  --wood-3: #4A2E19;
  --wood-ink: #FFF4DD;
  --wood-muted: #EBD3AE;
  --felt: #3B2A1D;
  --shadow: 0 1px 2px rgba(60, 40, 15, 0.12), 0 10px 28px -14px rgba(60, 40, 15, 0.45);
  --shadow-lift: 0 2px 4px rgba(60, 40, 15, 0.14), 0 22px 50px -20px rgba(60, 40, 15, 0.55);
  --radius: 18px;
  --ca-accent: #9B6D22; /* the accounts SDK's sheets and chip: the catalogue brass, deepened to 4.5:1 for white */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease: cubic-bezier(0.3, 0.7, 0.2, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #10161F;
  --page-2: #0B1018;
  --paper: #1B2330;
  --paper-2: #172030;
  --ink: #E8DFC9;
  --muted: #A9A28F;
  --line: rgba(232, 223, 201, 0.14);
  --line-2: rgba(232, 223, 201, 0.07);
  --brass: #E0A84A;
  --brass-ink: #E0A84A;
  --brass-hi: #FFD58A;
  --patina: #5FB3A9;
  --patina-ink: #5FB3A9;
  --wax: #D9614B;
  --wax-ink: #F08A73;
  --primary: #E0A84A;
  --primary-2: #F2C46A;
  --on-primary: #1B1A22;
  --wood-1: #4F3726;
  --wood-2: #3B281B;
  --wood-3: #281A10;
  --wood-ink: #F3E6CC;
  --wood-muted: #CDB894;
  --felt: #0A0E14;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 30px -14px rgba(0, 0, 0, 0.8);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.4), 0 24px 54px -18px rgba(0, 0, 0, 0.9);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--page); }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font: 16px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 700px at 20% -10%, color-mix(in srgb, var(--paper) 70%, transparent), transparent 70%),
    radial-gradient(900px 600px at 110% 110%, var(--page-2), transparent 70%),
    var(--page);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.warn { color: var(--wax-ink); font-weight: 600; }
.display { font-family: var(--f-display); font-weight: 700; letter-spacing: 0.01em; text-shadow: 0 1px 0 color-mix(in srgb, var(--paper) 60%, transparent); }
.icon { flex: none; }

/* ---- the shell ---------------------------------------------------------------------------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; padding: var(--safe-t) var(--safe-r) 0 var(--safe-l); }
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 10px max(14px, var(--safe-r)) 10px max(14px, var(--safe-l));
  max-width: 1100px; width: 100%; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; border: 0; background: none; padding: 4px; margin: -4px; text-align: left; border-radius: 12px; }
.brand img { width: 38px; height: 38px; border-radius: 11px; box-shadow: var(--shadow); flex: none; }
.brand span { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand b { font-family: var(--f-display); font-size: clamp(17px, 4.6vw, 20px); letter-spacing: 0.01em; white-space: nowrap; }
.brand small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { display: flex; align-items: center; gap: 6px; }
.account-slot { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 1px 2px rgba(60, 40, 15, 0.1);
  transition: transform 0.09s var(--ease), background-color 0.15s;
}
.icon-btn:hover { background: color-mix(in srgb, var(--paper) 80%, var(--brass)); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:disabled { opacity: 0.4; }
.icon-btn.small { width: 40px; height: 40px; }
.main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 4px max(14px, var(--safe-r)) calc(28px + var(--safe-b)) max(14px, var(--safe-l)); }
.offline-bar { text-align: center; font-size: 13px; color: var(--muted); padding: 4px 12px; background: color-mix(in srgb, var(--paper) 70%, transparent); border-bottom: 1px solid var(--line-2); }

/* the play screen owns the whole viewport: no shell bar */
body[data-screen="play"] .top, body[data-screen="landing"] .top { display: none; }
body[data-screen="play"] .main { max-width: none; padding: 0; }
body[data-screen="play"] .app { padding: 0; }
body[data-screen="play"] .offline-bar { position: fixed; top: var(--safe-t); left: 50%; transform: translateX(-50%); z-index: 30; border-radius: 0 0 10px 10px; border: 0; }

/* ---- buttons ------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  font-weight: 650; font-size: 15.5px; line-height: 1.15; text-align: center;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 1px 2px rgba(60, 40, 15, 0.12);
  transition: transform 0.09s var(--ease), filter 0.15s, background-color 0.15s;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: scale(0.97) translateY(1px); }
.btn:disabled { opacity: 0.5; }
.btn.primary {
  border-color: transparent; color: var(--on-primary);
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28) inset, 0 8px 18px -10px var(--primary);
}
.btn.ghost { background: transparent; box-shadow: none; }
.btn.big { min-height: 54px; font-size: 16.5px; padding: 0 22px; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 12px; }
.btn.on { border-color: var(--brass); color: var(--brass-ink); }
.chip-btn { min-width: 48px; min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); font-weight: 700; font-variant-numeric: tabular-nums; }
.link { color: var(--brass-ink); font-weight: 650; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 14px; background: color-mix(in srgb, var(--ink) 6%, transparent); }
.seg button { min-height: 40px; min-width: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; font-size: 14.5px; color: var(--muted); transition: background-color 0.15s, color 0.15s; }
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(60, 40, 15, 0.18); }
.seg.small { flex-wrap: nowrap; }
.seg.small button { min-height: 36px; min-width: 38px; padding: 0 8px; font-size: 13px; }

.switch { position: relative; width: 52px; height: 32px; border-radius: 16px; border: 0; flex: none; background: color-mix(in srgb, var(--ink) 18%, transparent); transition: background-color 0.18s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.22s var(--spring); }
.switch.on { background: var(--patina); }
.switch.on i { transform: translateX(20px); }
.slider { -webkit-appearance: none; appearance: none; width: min(180px, 42vw); height: 32px; background: transparent; }
.slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--brass) var(--k, 50%), color-mix(in srgb, var(--ink) 16%, transparent) var(--k, 50%)); }
.slider::-moz-range-track { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 16%, transparent); }
.slider::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--brass); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: var(--paper); border: 2px solid var(--brass); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.slider::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--paper); border: 2px solid var(--brass); }

/* ---- cards and screens ------------------------------------------------------------------------- */
.screen { animation: screen-in 0.36s var(--ease) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } }
.screen-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 10px 2px 14px; }
.screen-head h1 { margin: 0; font-size: clamp(26px, 6vw, 34px); line-height: 1.1; }
.card {
  position: relative;
  background:
    linear-gradient(180deg, color-mix(in srgb, #fff 18%, transparent), transparent 40%),
    var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
:root[data-theme="dark"] .card { background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%), var(--paper); }
.card h2.small, .display.small { font-size: 20px; margin: 0 0 10px; }
.eyebrow { margin: 0; font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brass-ink); font-weight: 700; }
h3.sub { margin: 18px 0 8px; font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* home */
.daily-card { padding: 20px; overflow: hidden; }
.daily-card::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(500px 220px at 85% 0%, color-mix(in srgb, var(--brass) 20%, transparent), transparent 70%); }
.daily-top { position: relative; display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; }
.daily-top h2 { margin: 2px 0 6px; font-size: clamp(26px, 7vw, 36px); line-height: 1.05; }
.daily-best { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; font-size: 18px; }
.daily-best b { font-size: 26px; font-family: var(--f-display); }
.daily-friends { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 26px; }
.daily-art { flex: none; width: 132px; min-height: 100px; display: grid; place-items: center; }
.daily-art .thumb { border-radius: 8px; box-shadow: var(--shadow); transform: rotate(2.5deg); }
.daily-bottom { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 14px; }
.countdown { color: var(--muted); font-size: 14px; }
.streak { position: relative; display: inline-flex; align-items: center; gap: 6px; margin: 12px 0 0; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--wax) 12%, transparent); color: var(--wax-ink); font-weight: 650; font-size: 14px; }
.need-net { position: relative; margin-top: 12px; padding: 12px; border-radius: 12px; background: color-mix(in srgb, var(--ink) 5%, transparent); }
.need-net p { margin: 0 0 8px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile {
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  min-height: 132px; padding: 16px; text-align: left; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--paper); box-shadow: var(--shadow);
  transition: transform 0.18s var(--spring), box-shadow 0.18s;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.tile:active { transform: scale(0.98); }
.tile-icon { position: relative; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: var(--on-primary); background: linear-gradient(160deg, var(--primary-2), var(--primary)); }
.tile-text { position: relative; display: flex; flex-direction: column; gap: 2px; }
.tile-text b { font-family: var(--f-display); font-size: 18px; }
.tile-text small { color: var(--muted); font-size: 13.5px; line-height: 1.3; }
.tile-meta { position: relative; display: inline-flex; align-items: center; gap: 5px; color: var(--brass-ink); font-weight: 650; font-size: 14px; }
.tile.decor .tile-map { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.38; }
.challenges ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.challenge-list li { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: color-mix(in srgb, var(--ink) 4%, transparent); }
.ch-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.ch-text b { font-weight: 650; font-size: 14.5px; overflow-wrap: anywhere; }

.avatar { display: inline-grid; place-items: center; width: var(--av-size, 28px); height: var(--av-size, 28px); border-radius: 50%; flex: none; background: var(--av, var(--patina)); color: #fff; font-weight: 750; font-size: calc(var(--av-size, 28px) * 0.46); box-shadow: 0 0 0 2px var(--paper); }
.avatar.me { box-shadow: 0 0 0 2px var(--brass); }
.faces { display: inline-flex; }
.faces .avatar + .avatar { margin-left: -6px; }

/* campaign */
.band { margin-bottom: 22px; }
.band-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 6px 12px; margin: 0 2px 10px; }
.band-head h2 { margin: 0; font-size: 22px; }
.band-meta { display: inline-flex; align-items: center; gap: 6px; color: var(--brass-ink); font-weight: 650; }
.band-meta .muted { margin-left: 6px; font-weight: 500; }
.badge-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--gold) 30%, transparent); color: var(--brass-ink); font-weight: 700; font-size: 13px; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.level-card {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-height: 112px; padding: 10px 11px; border-radius: 14px; text-align: left;
  border: 1px solid var(--line); background: var(--paper); box-shadow: var(--shadow);
  transition: transform 0.18s var(--spring), box-shadow 0.18s;
}
.level-card:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.level-card:active:not(:disabled) { transform: scale(0.97); }
.level-card.locked { opacity: 0.5; box-shadow: none; background: color-mix(in srgb, var(--paper) 60%, transparent); }
.lv-num { font-family: var(--f-display); font-size: 22px; line-height: 1; }
.lv-best { font-weight: 700; font-size: 15px; }
.lv-lock { color: var(--muted); }
.lv-friends { display: flex; align-items: center; gap: 6px; margin-top: auto; min-height: 22px; }
.ahead { color: var(--brass-ink); opacity: 0.75; font-size: 12px; font-weight: 700; }
.stars { display: inline-flex; gap: 1px; color: color-mix(in srgb, var(--ink) 20%, transparent); }
.stars .st.on { color: var(--brass); }
.stars.big { gap: 4px; }
.stars.big .st { color: color-mix(in srgb, var(--ink) 16%, transparent); }
.stars.big .st.on { color: color-mix(in srgb, var(--ink) 16%, transparent); }
.stars.big .st.on.lit { color: var(--brass); animation: star-pop 0.4s var(--spring); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--brass) 60%, transparent)); }
@keyframes star-pop { from { transform: scale(0.4) rotate(-30deg); } }

/* free */
.field-label { margin: 10px 0 6px; font-weight: 650; font-size: 14px; color: var(--muted); }
.code-row { display: flex; gap: 10px; }
.code-input {
  flex: 1; min-width: 0; height: 54px; padding: 0 16px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--paper-2);
  font-family: var(--f-display); font-size: 24px; letter-spacing: 0.22em; text-transform: uppercase;
}
.code-input:focus { outline: 2px solid var(--brass); outline-offset: 1px; }
.code-input::placeholder { color: var(--muted); opacity: 0.45; }
.set-row .seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); width: 100%; }
.code-input.bad { border-color: var(--wax); animation: nudge 0.18s linear 2; }
.field-msg { margin: 8px 2px 0; font-size: 13.5px; color: var(--muted); }
.free .seg { margin-bottom: 4px; }
.free .btn.big { margin-top: 16px; width: 100%; }
.recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.recent-row { width: 100%; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; min-height: 52px; padding: 6px 12px; border-radius: 12px; border: 1px solid var(--line-2); background: color-mix(in srgb, var(--ink) 3%, transparent); text-align: left; }
.recent-row .code { font-family: var(--f-display); letter-spacing: 0.12em; font-size: 17px; }

/* atlas */
.month-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.month-head h2 { margin: 0; font-size: 22px; text-transform: capitalize; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; touch-action: pan-y; }
.cal-wd { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.cal-day { position: relative; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; border: 1px dashed var(--line); background: transparent; font-size: 13px; color: var(--muted); padding: 0; }
.cal-day.future { opacity: 0.35; }
.cal-day.today { border: 1.5px solid var(--brass); color: var(--ink); }
.cal-day.rest { border-style: solid; opacity: 0.7; }
.cal-day.rest .icon { position: absolute; bottom: 8%; right: 8%; opacity: 0.6; }
.cal-day.stamp { border: 0; color: #FFF6E6; font-weight: 750; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18), 0 2px 5px rgba(60, 40, 15, 0.25); transition: transform 0.15s var(--spring); }
.cal-day.stamp:hover { transform: scale(1.06) rotate(-4deg); }
.cal-day.stamp.ink { background: radial-gradient(circle at 35% 30%, #57545F, #2B2A33); }
.cal-day.stamp.patina { background: radial-gradient(circle at 35% 30%, #5BA59C, #2E6E67); }
.cal-day.stamp.brass { background: radial-gradient(circle at 35% 30%, #D9A14A, #8A5A12); }
.cal-day.stamp.wax { background: radial-gradient(circle at 35% 30%, #D8644D, #9C3420); }
.cal-day.stamp.gold { box-shadow: 0 0 0 3px var(--gold), 0 2px 6px rgba(60, 40, 15, 0.3); }
:root[data-theme="dark"] .cal-day.stamp.ink { background: radial-gradient(circle at 35% 30%, #D6CDB8, #A29A85); color: #1B2330; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 14px 0 4px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg i { width: 12px; height: 12px; border-radius: 50%; }
.lg.ink i { background: #2B2A33; } :root[data-theme="dark"] .lg.ink i { background: #C9C0AA; }
.lg.patina i { background: #2E6E67; } .lg.brass i { background: #8A5A12; } .lg.wax i { background: #9C3420; }
.lg.gold i { background: transparent; box-shadow: inset 0 0 0 2.5px var(--gold); }
.map-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chapter-stars { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.chapter-stars li { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr auto; align-items: center; gap: 10px; font-size: 14.5px; }
.bar, .progress { position: relative; height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--ink) 10%, transparent); overflow: hidden; display: block; }
.bar::after, .progress::after { content: ""; position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--k, 0)); background: linear-gradient(90deg, var(--brass), var(--brass-hi)); border-radius: 4px; transition: transform 0.6s var(--ease); }
.progress { margin-top: 6px; width: 100%; }
.progress.wide { height: 10px; border-radius: 5px; margin: 8px 0; }
.month-map { width: 100%; height: auto; border-radius: 12px; box-shadow: var(--shadow); }

/* styles */
.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.style-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 10px; border-radius: 14px; border: 1.5px solid var(--line); background: color-mix(in srgb, var(--ink) 3%, transparent); text-align: center; transition: transform 0.15s var(--spring), border-color 0.15s; }
.style-item:hover:not(.locked) { transform: translateY(-2px); }
.style-item.on { border-color: var(--brass); background: color-mix(in srgb, var(--brass) 12%, transparent); }
.style-item.locked { opacity: 0.62; cursor: default; }
.style-item b { font-size: 14.5px; }
.style-item small { color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.style-item.on small { color: var(--brass-ink); font-weight: 650; }
.sw { position: relative; width: 56px; height: 56px; display: grid; place-items: center; }
.swatch { width: 56px; height: 56px; border-radius: 12px; }
.sw-lock { position: absolute; right: -4px; bottom: -4px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--paper); box-shadow: var(--shadow); color: var(--muted); }

/* stats */
.title-card h2 { margin: 4px 0 6px; font-size: clamp(24px, 6vw, 32px); }
.title-card p { margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 14px; border-radius: 16px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.stat-icon { grid-row: span 2; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--brass-ink); background: color-mix(in srgb, var(--brass) 16%, transparent); }
.stat-label { font-size: 13px; color: var(--muted); line-height: 1.25; }
.stat b { font-family: var(--f-display); font-size: 21px; }

/* ---- the play table ---------------------------------------------------------------------------- */
.screen.play { animation: fade-in 0.3s ease both; }
@keyframes fade-in { from { opacity: 0; } }
.table {
  position: relative;
  height: 100dvh;
  display: grid;
  grid-template-areas: "top" "felt" "bottom";
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--felt);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.rim {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  color: var(--wood-ink);
  background:
    repeating-linear-gradient(92deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(88deg, rgba(0, 0, 0, 0.07) 0 1px, transparent 1px 13px),
    linear-gradient(180deg, var(--wood-1), var(--wood-2) 60%, var(--wood-3));
}
.rim-top { grid-area: top; padding: calc(8px + var(--safe-t)) max(8px, var(--safe-r)) 8px max(8px, var(--safe-l)); box-shadow: 0 2px 0 rgba(255, 255, 255, 0.08) inset, 0 6px 14px -6px rgba(0, 0, 0, 0.6); }
.rim-bottom { grid-area: bottom; flex-wrap: wrap; padding: 8px max(8px, var(--safe-r)) calc(8px + var(--safe-b)) max(8px, var(--safe-l)); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 -6px 14px -6px rgba(0, 0, 0, 0.6); }
.rim-btn { width: 48px; height: 48px; background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.16); color: var(--wood-ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14); }
.rim-btn:hover { background: rgba(255, 255, 255, 0.18); }
.rim-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.rim-title b { font-family: var(--f-display); font-size: clamp(15px, 4.2vw, 19px); overflow-wrap: anywhere; }
.rim-title small { color: var(--wood-muted); font-size: clamp(11.5px, 3.2vw, 13px); }
.counter { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; align-items: center; column-gap: 6px; padding: 4px 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.22); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4); }
.counter-label { grid-column: span 2; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--wood-muted); }
.odometer { display: inline-flex; font-family: var(--f-display); font-size: 26px; font-weight: 700; line-height: 1; color: #FFE6B0; }
.digit { display: inline-block; height: 1.1em; width: 0.64em; overflow: hidden; transition: width 0.2s; -webkit-mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent); mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent); }
.digit.blank { width: 0; }
.strip { display: flex; flex-direction: column; transform: translateY(calc(var(--d, 0) * -1.1em)); transition: transform 0.32s cubic-bezier(0.3, 0.75, 0.25, 1.05); }
.strip.instant { transition: none; }
.strip span { height: 1.1em; line-height: 1.1em; text-align: center; }
.gain { font-weight: 750; font-size: 15px; color: var(--brass-hi); opacity: 0.85; }
.gain.flash { animation: gain-flash 0.3s ease-out; }
@keyframes gain-flash { 0% { color: #fff; text-shadow: 0 0 10px var(--brass-hi); transform: scale(1.25); opacity: 1; } 100% { transform: none; } }
.table.tut-counter .counter { box-shadow: 0 0 0 3px var(--brass-hi), 0 0 24px var(--brass); animation: glow 1.2s ease-in-out infinite alternate; }
.table.tut-go .go { box-shadow: 0 0 0 3px var(--brass-hi), 0 0 24px var(--brass); animation: glow 1.2s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 0 3px var(--brass-hi), 0 0 6px var(--brass); } }

.felt {
  grid-area: felt; position: relative; min-height: 0;
  display: grid; place-items: center; padding: 8px max(8px, var(--safe-l));
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(255, 220, 160, 0.08), transparent 70%),
    var(--felt);
  overflow: hidden;
}
.felt.scrolls { overflow: auto; place-items: start; touch-action: none; }
.board-wrap { position: relative; transform-origin: var(--zx, 50%) var(--zy, 50%); transform: scale(var(--zoom, 1)); transition: transform 0.4s var(--ease); }
.board-wrap.zoomed { transition: transform 0.45s var(--ease); }
.board {
  position: relative; width: var(--board-w, 300px); height: var(--board-h, 300px);
  border-radius: 6px; touch-action: none; cursor: crosshair;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 3px 0 rgba(0, 0, 0, 0.18), 0 18px 40px -12px rgba(0, 0, 0, 0.75);
}
.board:focus-visible { outline: 3px solid var(--brass); outline-offset: 4px; }
.board canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 6px; }
.table.replaying .board { cursor: pointer; }
.table.expired .board { cursor: default; }
.board-wrap.shake { animation: nudge 0.18s linear; }
.board-wrap.tremble { animation: tremble 0.14s linear; }
@keyframes nudge { 0%, 100% { translate: 0; } 20% { translate: -6px 0; } 40% { translate: 5px 0; } 60% { translate: -4px 0; } 80% { translate: 2px 0; } }
@keyframes tremble { 0%, 100% { translate: 0; } 33% { translate: 0 1px; } 66% { translate: 0 -0.5px; } }

.bubble {
  position: absolute; left: 0; top: 0; z-index: 4; pointer-events: none;
  transform: translate(var(--bx, 0), var(--by, 0)) translate(-50%, -100%) scale(0.8);
  opacity: 0; transition: opacity 0.12s, transform 0.12s var(--spring);
  min-width: 44px; padding: 4px 12px; border-radius: 999px; text-align: center;
  font: 800 18px/1.2 var(--f-display); font-variant-numeric: tabular-nums;
  background: #FFF6E6; color: #2B2A33; box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.6);
}
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px; background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 2px; }
.bubble.show { opacity: 1; transform: translate(var(--bx, 0), var(--by, 0)) translate(-50%, -100%) scale(1); }
.bubble.plus { background: linear-gradient(180deg, #F6C46C, #C58B2B); color: #2B1A05; }
.bubble.minus { background: #2B2A33; color: #FFE6B0; }
.bubble.blocked { background: #C0452F; color: #fff; }
.tip { position: absolute; top: 10px; left: 50%; z-index: 5; transform: translate(-50%, -8px); opacity: 0; pointer-events: none; padding: 6px 14px; border-radius: 999px; background: rgba(20, 14, 8, 0.82); color: #FFF4DD; font-size: 14px; font-weight: 600; text-align: center; max-width: calc(100% - 24px); transition: opacity 0.2s, transform 0.2s var(--ease); }
.tip.show { opacity: 1; transform: translate(-50%, 0); }

.tray { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 100%; justify-content: center; min-height: 16px; }
.tray .slot { width: 15px; height: 15px; display: grid; place-items: center; }
.mini-stone { display: block; width: 14px; height: 14px; border-radius: 3px; background: linear-gradient(135deg, #D8D2C6, #A39E95 45%, #77716A); box-shadow: 0 2px 0 #5F5A52, 0 2px 3px rgba(0, 0, 0, 0.4); transition: transform 0.2s var(--spring), opacity 0.2s; }
.slot.used .mini-stone { transform: scale(0.55); opacity: 0.35; box-shadow: none; background: transparent; outline: 1.5px dashed var(--wood-muted); outline-offset: 1px; }
.tray.empty .mini-stone { filter: grayscale(1); }
.tray.nudge { animation: nudge 0.18s linear; }
.tools { display: flex; gap: 6px; flex: 1; justify-content: flex-start; min-width: 0; }
.tool { position: relative; min-width: 48px; height: 52px; padding: 0 6px; flex: 1 1 0; max-width: 92px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(255, 255, 255, 0.08); color: var(--wood-ink); transition: transform 0.09s var(--ease), background-color 0.15s, opacity 0.15s; }
.tool:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }
.tool:active:not(:disabled) { transform: scale(0.93) translateY(1px); }
.tool:disabled { opacity: 0.35; }
.tool[aria-pressed="false"] { opacity: 0.7; }
.tool-label { display: none; font-size: 11px; font-weight: 650; line-height: 1.1; text-align: center; }
.tool .badge { position: absolute; top: 3px; right: 5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; font-size: 11px; font-weight: 800; line-height: 18px; background: var(--brass); color: #2B1A05; }
.go {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 108px; height: 56px; padding: 0 18px; border-radius: 16px; border: 0;
  font: 800 17px/1.1 var(--f-display); color: #2B1A05;
  background: linear-gradient(180deg, #FFD98E, #E0A84A 45%, #B97A22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -3px 0 rgba(0, 0, 0, 0.18), 0 8px 18px -8px rgba(0, 0, 0, 0.8);
  transition: transform 0.09s var(--ease), filter 0.15s, flex-grow 0.25s;
}
.go:hover:not(:disabled) { filter: brightness(1.05); }
.go:active:not(:disabled) { transform: scale(0.96) translateY(1px); }
.go:disabled { filter: grayscale(0.7) brightness(0.8); }
.go.confirm { background: linear-gradient(180deg, #FFB38E, #E06A4A 45%, #A8381F); color: #fff; flex: 1; animation: pulse 1s ease-in-out infinite alternate; }
.rim-bottom:has(.go.confirm) .tools { display: none; }
@keyframes pulse { to { filter: brightness(1.1); } }
.go-label { text-align: center; }

.fly-stone { position: fixed; left: -8px; top: -8px; z-index: 50; width: 16px; height: 16px; border-radius: 4px; pointer-events: none; background: linear-gradient(135deg, #D8D2C6, #A39E95 45%, #77716A); box-shadow: 0 2px 0 #5F5A52, 0 4px 8px rgba(0, 0, 0, 0.4); }
.fly-stone.bad { background: #E06A4A; box-shadow: 0 0 12px #C0452F; }

/* the coach (tutorial, a friend's stones) */
.coach { position: absolute; z-index: 6; left: 50%; top: calc(var(--rim-h, 72px) + 10px); transform: translateX(-50%); width: min(420px, calc(100% - 20px)); padding: 12px 14px; border-radius: 16px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow-lift); animation: rise 0.36s var(--spring) both; display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; }
.coach p { margin: 0; font-weight: 600; }
.coach-step { font-family: var(--f-display); color: var(--brass-ink); font-weight: 800; }
.coach-actions { grid-column: span 2; display: flex; justify-content: flex-end; gap: 8px; }
.coach.friend { grid-template-columns: 1fr auto; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 14px); } }

/* the result card */
.result {
  position: absolute; z-index: 8; left: 0; right: 0; bottom: 0;
  max-height: 64%; overflow: auto; overscroll-behavior: contain;
  padding: 0 max(10px, var(--safe-r)) calc(10px + var(--safe-b)) max(10px, var(--safe-l));
  transform: translateY(105%); transition: transform 0.5s var(--spring);
}
.result.in { transform: none; }
.result-inner { position: relative; max-width: 560px; margin: 0 auto; padding: 18px 18px 14px; border-radius: 22px 22px 18px 18px; background: linear-gradient(180deg, color-mix(in srgb, #fff 16%, transparent), transparent 30%), var(--paper); color: var(--ink); box-shadow: 0 -10px 40px -12px rgba(0, 0, 0, 0.7); border: 1px solid var(--line); }
.table:has(.result.in) .felt .board-wrap { opacity: 0.86; }
.felt .board-wrap { translate: 0 calc(-1 * var(--lift, 0px)); transition: transform 0.4s var(--ease), translate 0.5s var(--spring), opacity 0.3s; }
.result-head { display: flex; align-items: center; gap: 16px; }
.result-head h2 { margin: 0 0 4px; font: 800 clamp(20px, 5.4vw, 26px)/1.15 var(--f-display); }
.seal { position: relative; flex: none; width: 96px; height: 96px; display: grid; place-items: center; transform: rotate(-6deg); }
.seal-svg { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 3px 4px rgba(80, 20, 10, 0.4)); }
.seal-edge { fill: #B23A24; }
.seal-ring { fill: none; stroke: rgba(255, 220, 200, 0.35); stroke-width: 2; }
.seal.gold .seal-edge { fill: #B23A24; stroke: var(--gold); stroke-width: 4; }
.seal-num { position: relative; font: 800 21px/1 var(--f-display); color: #FFF1E2; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); letter-spacing: -0.01em; }
.seal.slam { animation: slam 0.42s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes slam { 0% { transform: scale(1.7) rotate(8deg); opacity: 0.4; } 38% { transform: scale(0.9) rotate(-8deg); opacity: 1; } 70% { transform: scale(1.04) rotate(-5deg); } 100% { transform: rotate(-6deg); } }
.master-badge { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 3px 10px; border-radius: 999px; background: linear-gradient(90deg, #F3D27A, #E0A84A); color: #3A2205; font-weight: 800; font-size: 13px; animation: badge-spin 0.8s var(--spring) both 1.3s; }
@keyframes badge-spin { from { transform: rotateY(180deg) scale(0.5); opacity: 0; } }
.result-lines p { margin: 6px 0; }
.result-lines .steps { font-weight: 700; font-size: 17px; }
.result-lines .more { color: var(--brass-ink); font-weight: 650; }
.result-lines .newbest { color: var(--patina-ink); font-weight: 750; }
.result-lines .say { font-style: italic; color: var(--muted); }
.analysis { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--wax) 10%, transparent); color: var(--ink); }
.analysis .icon { color: var(--wax-ink); margin-top: 1px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.result-actions .btn.primary { flex: 1 1 140px; }
.result-actions > .btn:not(.primary) { flex: 1 1 110px; }
.replay-pair { display: inline-flex; gap: 6px; flex: 1 1 160px; }
.replay-pair .btn { flex: 1; }
.result-extra { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.result-extra .btn { flex: 1 1 150px; }
.result-friends h3 { margin: 16px 0 8px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.board-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.board-rows li { display: grid; grid-template-columns: 24px auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px; min-height: 40px; padding: 4px 8px; border-radius: 10px; font-size: 14.5px; }
.board-rows li.me { background: color-mix(in srgb, var(--brass) 16%, transparent); font-weight: 700; }
.board-rows li.gap { display: block; min-height: 0; text-align: center; color: var(--muted); }
.board-rows .rank { color: var(--muted); font-weight: 700; text-align: right; }
.board-rows .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-rows .heart { color: var(--wax); margin-left: 4px; }
.board-rows .pct { font-weight: 750; }
.board-rows .stones { color: var(--muted); font-size: 12.5px; }
.invite { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--patina) 10%, transparent); color: var(--patina-ink); }
.invite p { margin: 0; color: var(--ink); }
.ghost-line { color: var(--muted); font-style: italic; }
.stamps-got h3 { margin-top: 12px; }
.stamp-row { display: flex; flex-wrap: wrap; gap: 8px; }
.stamp-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px 3px 3px; border-radius: 999px; background: color-mix(in srgb, var(--wax) 10%, transparent); font-size: 18px; }

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 9; }
.confetti .icon { position: absolute; left: var(--x); bottom: 30%; color: var(--brass); animation: gear-up 1.5s var(--ease) var(--d) both; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3)); }
@keyframes gear-up { 0% { transform: translateY(40px) rotate(0) scale(0.4); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(var(--h)) rotate(var(--r)) scale(1); opacity: 0; } }

/* landscape: the controls go to the right rim */
@media (orientation: landscape) and (min-aspect-ratio: 5/4) {
  .table { grid-template-areas: "felt top" "felt bottom"; grid-template-columns: minmax(0, 1fr) clamp(220px, 30vw, 320px); grid-template-rows: auto minmax(0, 1fr); }
  .rim { box-shadow: 6px 0 14px -6px rgba(0, 0, 0, 0.6) inset; }
  .rim-top { flex-wrap: wrap; align-content: flex-start; padding: calc(10px + var(--safe-t)) max(10px, var(--safe-r)) 6px 12px; }
  .rim-top .counter { order: 5; flex: 1 1 100%; grid-template-columns: auto 1fr; justify-items: start; align-items: baseline; column-gap: 10px; padding: 8px 14px; }
  .rim-top .odometer { font-size: 34px; }
  .rim-bottom { flex-direction: column; align-items: stretch; justify-content: flex-start; flex-wrap: nowrap; gap: 12px; padding: 6px max(10px, var(--safe-r)) calc(12px + var(--safe-b)) 12px; }
  .tray { flex: none; justify-content: flex-start; }
  .tools { flex: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tool { max-width: none; height: 58px; }
  .tool-label { display: block; }
  .go { width: 100%; margin-top: auto; height: 60px; }
  .felt { padding: 8px 8px 8px max(8px, var(--safe-l)); }
  .result { left: auto; right: 0; top: 0; bottom: 0; width: clamp(260px, 38vw, 420px); max-height: none; padding: calc(8px + var(--safe-t)) max(8px, var(--safe-r)) calc(8px + var(--safe-b)) 8px; transform: translateX(105%); }
  .result-inner { border-radius: 18px; min-height: 100%; }
  .coach { left: calc((100% - clamp(220px, 30vw, 320px)) / 2); top: 12px; }
}
@media (min-width: 480px) and (orientation: portrait) {
  .tool-label { display: block; }
  .tool { height: 56px; }
}
@media (max-width: 339px) {
  .rim-btn { width: 44px; height: 44px; }
  .counter { padding: 3px 8px; }
  .odometer { font-size: 22px; }
  .go { min-width: 84px; padding: 0 12px; font-size: 15px; }
  .tools { gap: 4px; }
  .tool { min-width: 44px; padding: 0 2px; }
}

/* ---- landing -------------------------------------------------------------------------------------- */
body[data-screen="landing"] .main { max-width: 1100px; padding-bottom: calc(96px + var(--safe-b)); }
.landing-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; }
.landing-brand { display: flex; align-items: center; gap: 10px; }
.landing-brand img { border-radius: 10px; box-shadow: var(--shadow); }
.landing-brand b { font-family: var(--f-display); font-size: clamp(17px, 4.6vw, 20px); white-space: nowrap; }
.landing-tools { display: flex; align-items: center; gap: 8px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; align-items: center; margin: 18px 0 30px; animation: hero-in 0.6s ease-out both; }
@keyframes hero-in { from { opacity: 0; transform: translateY(12px); } }
.hero h1 { margin: 0 0 14px; font-size: clamp(30px, 6.4vw, 54px); line-height: 1.04; }
.hero .lead { margin: 0 0 22px; font-size: clamp(16px, 2.4vw, 19px); color: var(--muted); max-width: 46ch; }
.hero-figure { margin: 0; position: relative; justify-self: center; padding: 14px; border-radius: 22px; background: linear-gradient(180deg, var(--wood-1), var(--wood-3)); box-shadow: var(--shadow-lift); }
.hero-board { position: relative; width: min(320px, 76vw); aspect-ratio: 1; border-radius: 8px; overflow: hidden; }
.hero-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-counter { position: absolute; top: -16px; right: -10px; display: flex; flex-direction: column; align-items: center; padding: 6px 14px; border-radius: 14px; background: var(--paper); box-shadow: var(--shadow-lift); }
.hero-counter span { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.hero-count { font: 800 30px/1 var(--f-display); color: var(--brass-ink); }
.hero-count.bump { animation: gain-flash 0.3s ease-out; }
.taster header h2 { margin: 0 0 4px; font-size: 24px; }
.taster header p { margin: 0 0 12px; }
.taster-host { position: relative; height: clamp(480px, 84vh, 640px); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.taster-host > .screen { height: 100%; }
.taster-host .table { height: 100%; }
.taster-host .result { max-height: 86%; }
.taster-host .result-head .seal { width: 84px; height: 84px; }
.taster-host .rim-top { padding-top: 8px; }
.taster-host .rim-bottom { padding-bottom: 8px; }
.feature-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.feature h3 { margin: 12px 0 6px; font-family: var(--f-display); font-size: 19px; }
.feature p { margin: 0; font-size: 14.5px; }
.feature-art { width: 100%; height: auto; display: block; }
.fa-paper { fill: var(--paper-2); stroke: var(--line); }
.fa-route { fill: none; stroke: var(--brass); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.fa-ghost { fill: none; stroke: var(--ink); stroke-opacity: 0.4; stroke-width: 3; stroke-dasharray: 6 5; stroke-linecap: round; animation: dash 3s linear 3; }
.fa-stone { fill: #A39E95; stroke: #5F5A52; stroke-width: 1.5; animation: drop 3s var(--spring) 3; }
.fa-bubble rect { fill: #E0A84A; }
.fa-bubble text { font: 800 12px var(--f-display); fill: #2B1A05; }
.fa-bubble { animation: pop 3s var(--spring) 3; transform-origin: 113px 15px; }
.fa-day { fill: none; stroke: var(--line); stroke-width: 1.2; }
.fa-day.today { stroke: var(--brass); stroke-width: 2; }
.fa-stamp { fill: var(--wax); animation: drop 3s var(--spring) 3; transform-origin: 61px 58px; }
.fa-av.a0 { fill: #5FA3D6; } .fa-av.a1 { fill: #D6875F; } .fa-av.a2 { fill: #8FBF6A; }
.fa-bar { fill: var(--brass); opacity: 0.75; }
.fa-row { animation: slide 3s var(--ease) 3; }
.fa-row.r1 { animation-delay: 0.12s; } .fa-row.r2 { animation-delay: 0.24s; }
@keyframes dash { to { stroke-dashoffset: -66; } }
@keyframes drop { 0%, 20% { transform: translateY(-14px); opacity: 0; } 40%, 100% { transform: none; opacity: 1; } }
@keyframes pop { 0%, 40% { transform: scale(0); } 55%, 100% { transform: scale(1); } }
@keyframes slide { 0% { transform: translateX(-20px); opacity: 0; } 30%, 100% { transform: none; opacity: 1; } }
.landing-foot { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 0; }
.signin-bar { position: fixed; z-index: 30; left: 50%; bottom: calc(12px + var(--safe-b)); transform: translateX(-50%); width: min(720px, calc(100% - 24px)); display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 16px; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: var(--shadow-lift); border: 1px solid var(--line); font-size: 14px; }
.signin-bar span { flex: 1; }
.fa-emoji { font-size: 20px; animation: pop 3s var(--spring) 3; transform-origin: 134px 30px; }

/* ---- sheets ---------------------------------------------------------------------------------------- */
.sheet {
  border: 0; padding: 0; color: var(--ink);
  width: min(520px, calc(100vw - 20px)); max-height: min(88dvh, 820px);
  border-radius: 22px; background: var(--paper); box-shadow: var(--shadow-lift);
  overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in 0.32s var(--spring); }
.sheet.closing { animation: sheet-out 0.16s ease-in forwards; }
.sheet::backdrop { background: rgba(14, 10, 6, 0.48); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sheet.wide { width: min(900px, calc(100vw - 20px)); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(0.98); } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(16px) scale(0.98); } }
@media (max-width: 560px) {
  .sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92dvh; padding-bottom: var(--safe-b); }
  @keyframes sheet-in { from { transform: translateY(100%); } }
  @keyframes sheet-out { to { transform: translateY(100%); } }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 10px 20px; border-bottom: 1px solid var(--line-2); }
.sheet-head h2 { margin: 0; font-size: 22px; }
.sheet-body { padding: 8px 20px 20px; overflow: auto; overscroll-behavior: contain; }
.set-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.set-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 160px; }
.set-text small { font-size: 12.5px; line-height: 1.3; }
.help-cards { touch-action: pan-y; }
.help-card { min-height: 236px; animation: fade-in 0.25s ease both; }
.help-card h3 { margin: 12px 0 6px; font-size: 21px; }
.help-card p { margin: 0; font-size: 15.5px; }
.help-art { width: 100%; height: auto; display: block; }
.ha-paper { fill: var(--paper-2); stroke: var(--line); }
.ha-route { fill: none; stroke: var(--brass); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 400; animation: draw 2.4s var(--ease) both; }
.ha-ghost { fill: none; stroke: var(--ink); stroke-opacity: 0.35; stroke-width: 3; stroke-dasharray: 6 6; }
.ha-stone { fill: #A39E95; stroke: #5F5A52; stroke-width: 2; }
.ha-start { fill: var(--patina); } .ha-goal { fill: #F4A63B; }
.ha-cell { fill: none; stroke: var(--line); stroke-width: 1.5; }
.ha-bug { fill: #B86A2C; animation: walk 2.4s var(--ease) infinite alternate; }
.ha-x { stroke: var(--wax); stroke-width: 4; stroke-linecap: round; }
.ha-arrow { fill: var(--wax); }
.ha-text { font: 700 14px var(--f-body); fill: var(--muted); }
.ha-seal { fill: #B23A24; animation: drop 2.4s var(--spring) both; transform-origin: 60px 48px; }
.ha-pct { font: 800 17px var(--f-display); fill: #FFF1E2; }
.ha-star { fill: color-mix(in srgb, var(--ink) 15%, transparent); } .ha-star.on { fill: var(--brass); }
.ha-tele { fill: none; stroke: var(--patina); stroke-width: 4; stroke-dasharray: 10 6; }
.ha-jump { fill: none; stroke: var(--brass); stroke-width: 3; stroke-dasharray: 5 5; animation: dash 2.4s linear infinite; }
.ha-flag { fill: var(--wax); stroke: var(--brass-ink); stroke-width: 2; }
@keyframes draw { from { stroke-dashoffset: 400; } to { stroke-dashoffset: 0; } }
@keyframes walk { to { transform: translateX(56px); } }
.help-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0; }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: color-mix(in srgb, var(--ink) 18%, transparent); transition: transform 0.2s, background-color 0.2s; }
.dots i.on { background: var(--brass); transform: scale(1.3); }
.keys { color: var(--muted); }
.marks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.mark { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px; border-radius: 16px; border: 1.5px solid var(--line); background: color-mix(in srgb, var(--ink) 3%, transparent); transition: transform 0.15s var(--spring); }
.mark.on { border-color: var(--wax); background: color-mix(in srgb, var(--wax) 10%, transparent); transform: scale(1.04); }
.mark .emoji { font-size: 32px; line-height: 1; }
.sheet .btn.big { width: 100%; }
.sol-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.sol-list li { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; }
.sol-list .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; }
.locked-note { display: flex; gap: 8px; align-items: flex-start; }
.day-sheet { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0; }
.big-pct { font: 800 44px/1 var(--f-display); margin: 0; color: var(--wax-ink); }
.map-sheet canvas { display: block; }
.celebrate-body { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 8px 0; }
.celebrate-body h3 { margin: 0; font-size: 26px; color: var(--brass-ink); }
.medal { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; color: #3A2205; background: radial-gradient(circle at 35% 30%, #FFE7A3, #E0A84A 60%, #A8701E); box-shadow: var(--shadow-lift); animation: slam 0.5s var(--spring) both; }
.unlock { display: flex; align-items: center; gap: 10px; margin: 0; }
.unlock .swatch { width: 36px; height: 36px; }

.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 14px; background: #2B2A33; color: #FFF4DD; font-weight: 600; font-size: 14.5px; box-shadow: var(--shadow-lift); transition: opacity 0.2s, transform 0.25s var(--spring); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body[data-screen="play"] .toast { bottom: calc(130px + var(--safe-b)); }

.screen.loading { min-height: 70dvh; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; color: var(--wood-ink); background: var(--felt); }
body[data-screen="play"] .screen.loading { min-height: 100dvh; }
.screen.loading.quiet > * { opacity: 0; }
.screen.loading > * { transition: opacity 0.3s; }
.spinner { color: var(--brass); animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.screen.loading.failed { color: var(--wood-ink); }

/* ---- small screens ---------------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; gap: 22px; margin-top: 4px; }
  .hero-figure { order: -1; }
  .feature-cards { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr; }
  .tile { min-height: 0; flex-direction: row; align-items: center; padding: 14px; }
  .tile-meta { margin-left: auto; }
}
@media (max-width: 420px) {
  .brand small { display: none; }
  .top:has(#nav-back:not([hidden])) .brand img { display: none; }
  .daily-art { width: 96px; }
  .daily-art .thumb { width: 96px; height: auto; }
  .daily-bottom .btn { flex: 1 1 100%; }
  .signin-bar { flex-direction: column; align-items: stretch; text-align: center; }
  .code-row { flex-direction: column; }
}
@media (max-width: 340px) {
  .daily-top { flex-direction: column; }
  .daily-art { display: none; }
}

/* ---- reduced motion: fades instead of travel ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) *, :root:not([data-motion="full"]) *::before, :root:not([data-motion="full"]) *::after { animation-duration: 0.15s !important; animation-iteration-count: 1 !important; transition-duration: 0.15s !important; }
}
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { animation-duration: 0.15s !important; animation-iteration-count: 1 !important; transition-duration: 0.15s !important; }
:root[data-motion="reduce"] .result { transform: none; opacity: 0; transition: opacity 0.15s !important; }
:root[data-motion="reduce"] .result.in { opacity: 1; }
:root[data-motion="reduce"] .board-wrap { transform: none !important; }
:root[data-motion="reduce"] .seal.slam, :root[data-motion="reduce"] .board-wrap.shake, :root[data-motion="reduce"] .board-wrap.tremble, :root[data-motion="reduce"] .spinner { animation: none !important; }
:root[data-motion="reduce"] .confetti { display: none; }
