/*
  Snakle: one-column game shell. The board is the only loud thing on screen.
  Identity: a coral snake (red, yellow, ink bands) on sage grass, chunky cream letter keycaps,
  gold for every reward. Chrome stays quiet so the snake and the tiles carry the color.
*/

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #eff5e9;
  --surface: #ffffff;
  --surface-2: #e4ecdc;
  --ink: #10302d;
  --muted: #566f6b;
  --line: #d3dfca;
  --coral: #ff5a4a;
  --coral-deep: #c8402f;
  --gold: #ffc83d;
  --gold-deep: #d99a00;
  --gold-ink: #2a1d00;

  --board-a: #cae7b6;
  --board-b: #bfdfaa;
  --board-edge: #8dbb77;
  --tile: #fffaf0;
  --tile-edge: #dccfae;
  --tile-ink: #10302d;
  --hot: #ffc83d;
  --hot-edge: #d99a00;
  --hot-ink: #2a1d00;
  --snake: #ff5a4a;
  --snake-dark: #e2402f;
  --snake-ink: #10302d;
  --tongue: #e11d48;

  --shadow: 0 12px 32px rgba(16, 48, 45, 0.16);
  --display: "Bricolage Grotesque", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1d1b;
    --surface: #152826;
    --surface-2: #1d3532;
    --ink: #e9f4ee;
    --muted: #8fa9a2;
    --line: #264340;
    --coral-deep: #b53b2c;
    --board-a: #25443d;
    --board-b: #203b35;
    --board-edge: #386a5c;
    --snake-ink: #061a17;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1d1b;
  --surface: #152826;
  --surface-2: #1d3532;
  --ink: #e9f4ee;
  --muted: #8fa9a2;
  --line: #264340;
  --coral-deep: #b53b2c;
  --board-a: #25443d;
  --board-b: #203b35;
  --board-edge: #386a5c;
  --snake-ink: #061a17;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

h1, h2, h3, p { margin: 0; }
h2, h3, .display { font-family: var(--display); font-weight: 800; letter-spacing: -0.01em; text-wrap: balance; }

.ico { display: block; flex: none; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 22px;
  border: 0;
  border-radius: 16px;
  font: 800 17px/1 var(--display);
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

.btn.wide { width: 100%; }

.btn.primary {
  background: var(--coral);
  color: var(--ink);
  box-shadow: 0 5px 0 var(--coral-deep);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--coral-deep); }

.btn.ghost {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--line), inset 0 0 0 2px var(--line);
}
.btn.ghost:hover { background: var(--surface-2); }
.btn.ghost:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line), inset 0 0 0 2px var(--line); }

.btn.big { min-height: 64px; font-size: 21px; border-radius: 20px; }

.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 700 15px var(--text);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.link:hover { color: var(--ink); }
.link .ico { width: 18px; height: 18px; }

.icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.94); }

/* ---------- board frame (shared by game and home hero) ---------- */

.board-frame {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--board-a);
  box-shadow: 0 0 0 5px var(--board-edge), var(--shadow);
}

.board-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.board-frame.hit::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #ff3b30;
  pointer-events: none;
  animation: flash 0.55s ease-out forwards;
}

@keyframes flash {
  0% { opacity: 0.5; }
  100% { opacity: 0; }
}

.praise {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 2;
  font: 800 clamp(30px, 9vw, 50px)/1 var(--display);
  color: #fff;
  text-shadow: 0 3px 0 rgba(16, 48, 45, 0.55), 0 0 18px rgba(16, 48, 45, 0.4);
  transform: translate(-50%, -50%) scale(0.5);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.praise.big { font-size: clamp(36px, 12vw, 64px); color: var(--gold); }
.praise.show { animation: praise 1.1s cubic-bezier(0.2, 1.2, 0.3, 1) forwards; }

@keyframes praise {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.5); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.18); }
  34% { transform: translate(-50%, -50%) scale(1); }
  76% { opacity: 1; transform: translate(-50%, -70%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -95%) scale(1); }
}

/* ---------- play screen ---------- */

body.play {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

.app {
  height: 100vh;
  height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: env(safe-area-inset-top) 14px calc(env(safe-area-inset-bottom) + 12px);
}

.bar {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 52px;
  margin: 0 -8px;
}

.bar-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  line-height: 1.15;
}
.bar-title strong { display: block; font: 800 17px var(--display); }
.bar-title span { color: var(--muted); font-size: 13px; font-weight: 600; }

.hud { display: flex; flex-direction: column; gap: 10px; }

.hud-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.score-block { display: flex; align-items: baseline; gap: 8px; transform-origin: left bottom; }
.score-block strong {
  font: 800 46px/0.95 var(--display);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.score-block span { color: var(--muted); font-size: 14px; font-weight: 600; }
.score-block b { color: var(--ink); font-variant-numeric: tabular-nums; }
.score-block.bump { animation: bump 0.4s cubic-bezier(0.2, 1.6, 0.4, 1); }

@keyframes bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

.pips { display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: 3px; padding-bottom: 6px; }
.pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  transition: background 0.2s, transform 0.3s cubic-bezier(0.2, 1.8, 0.4, 1);
}
.pip.on { background: var(--coral); transform: scale(1.15); }

.meter {
  position: relative;
  height: 12px;
  margin: 4px 4px 12px 0;
  border-radius: 99px;
  background: var(--surface-2);
}
.meter-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--coral);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.5s cubic-bezier(0.2, 1.15, 0.3, 1), background 0.3s;
}
.meter-fill.gold { background: var(--gold); }

.mark {
  position: absolute;
  top: 50%;
  display: flex;
  align-items: center;
  height: 24px;
  padding: 0 7px;
  border-radius: 99px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: inset 0 0 0 2px var(--line);
  transform: translate(-50%, -50%);
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.mark .ico { width: 12px; height: 12px; }
.mark.m3 { transform: translate(-100%, -50%); }
.mark.on { background: var(--gold); color: var(--gold-ink); box-shadow: 0 2px 0 var(--gold-deep); }
.mark.pop { animation: markpop 0.5s cubic-bezier(0.2, 1.8, 0.4, 1); }
.meter.has-friend { margin-bottom: 36px; }
.mark.friend {
  top: calc(100% + 21px);
  gap: 3px;
  padding: 0 8px 0 6px;
  background: #4da3ff;
  color: #06223f;
  box-shadow: 0 2px 0 #2f7fd6;
  font: 800 12px var(--display);
}
.mark.friend .ico { width: 13px; height: 13px; }
.mark.friend.on { background: #3ecf8e; box-shadow: 0 2px 0 #23a46a; color: #05301d; }

@keyframes markpop {
  0% { scale: 1; }
  40% { scale: 1.5; }
  100% { scale: 1; }
}

.tray {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
}
.tray-main { flex: 1; min-width: 0; display: flex; align-items: center; height: 60px; }
.word { display: flex; gap: 5px; width: 100%; }
.key {
  display: grid;
  place-items: center;
  flex: 0 1 38px;
  min-width: 0;
  aspect-ratio: 38 / 46;
  border-radius: 10px;
  background: var(--tile);
  color: var(--tile-ink);
  font: 800 clamp(16px, 5.4vw, 25px)/1 var(--display);
  box-shadow: 0 4px 0 var(--tile-edge);
  transition: background 0.15s, box-shadow 0.15s;
}
.word.valid .key { background: var(--gold); color: var(--gold-ink); box-shadow: 0 4px 0 var(--gold-deep); }
.key.pop { animation: keypop 0.3s cubic-bezier(0.2, 1.8, 0.4, 1); }
.key.slot {
  background: transparent;
  box-shadow: inset 0 0 0 2.5px var(--line);
  opacity: 0.9;
}
.key.mini {
  flex: none;
  width: 34px;
  aspect-ratio: 34 / 40;
  font-size: 20px;
  border-radius: 9px;
  box-shadow: 0 3px 0 var(--tile-edge);
}

@keyframes keypop {
  0% { transform: translateY(-14px) scale(0.6); opacity: 0; }
  100% { transform: none; opacity: 1; }
}

.lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 108px;
  height: 58px;
  padding: 0 16px;
  border: 0;
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--muted);
  font: 800 17px/1 var(--display);
  box-shadow: 0 4px 0 var(--line);
  touch-action: none;
}
.lock:disabled { cursor: default; }
.lock-pts { font-size: 14px; font-variant-numeric: tabular-nums; }
.lock-pts:empty { display: none; }
.lock.ready {
  background: var(--gold);
  color: var(--gold-ink);
  box-shadow: 0 5px 0 var(--gold-deep);
  animation: ready 1s ease-in-out infinite;
}
.lock.ready:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold-deep); }

@keyframes ready {
  0%, 100% { filter: none; }
  50% { filter: brightness(1.12) saturate(1.1); }
}

.board-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
}

.pad {
  display: none;
  grid-template-columns: repeat(3, 66px);
  grid-template-areas: ". up ." "left down right";
  justify-content: center;
  gap: 8px;
  padding: 2px 0 10px;
}
body[data-pad="on"] .pad { display: grid; }
@media (pointer: coarse) {
  body[data-pad="auto"] .pad { display: grid; }
}

.pad button {
  display: grid;
  place-items: center;
  height: 54px;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--line), inset 0 0 0 2px var(--line);
  touch-action: none;
}
.pad button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line), inset 0 0 0 2px var(--line); }
.pad button[data-dir="up"] { grid-area: up; }
.pad button[data-dir="left"] { grid-area: left; }
.pad button[data-dir="down"] { grid-area: down; }
.pad button[data-dir="right"] { grid-area: right; }
.pad [data-dir="up"] .ico { transform: rotate(90deg); }
.pad [data-dir="right"] .ico { transform: rotate(180deg); }
.pad [data-dir="down"] .ico { transform: rotate(-90deg); }

.fx {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

@media (max-height: 700px) {
  .score-block strong { font-size: 38px; }
  .tray, .tray-main { min-height: 54px; height: 54px; }
  .lock { height: 52px; }
  .bar { min-height: 46px; }
  .pad button { height: 46px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .app {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 320px);
    grid-template-rows: auto auto auto 1fr auto;
    grid-template-areas: "bar bar" "board hud" "board tray" "board ." "board pad";
    column-gap: 18px;
  }
  .bar { grid-area: bar; }
  .hud { grid-area: hud; }
  .tray { grid-area: tray; }
  .board-wrap { grid-area: board; }
  .pad { grid-area: pad; grid-template-columns: repeat(3, 58px); }
}

/* ---------- sheets ---------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: env(safe-area-inset-top) 12px calc(env(safe-area-inset-bottom) + 12px);
  background: rgba(7, 24, 22, 0.55);
  opacity: 0;
  transition: opacity 0.2s;
  touch-action: none;
}
.scrim.show { opacity: 1; }
.scrim.clear { background: transparent; pointer-events: none; }

.sheet:focus { outline: none; }
.sheet {
  position: relative;
  width: min(460px, 100%);
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  padding: 26px 22px 20px;
  border-radius: 28px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 -8px 50px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
  touch-action: pan-y;
  transform: translateY(28px) scale(0.98);
  transition: transform 0.32s cubic-bezier(0.2, 1.25, 0.3, 1);
  overscroll-behavior: contain;
}
.scrim.show .sheet { transform: none; }

@media (min-width: 700px) {
  .scrim { align-items: center; padding-bottom: 12px; }
}

.sheet-x {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
}
.sheet-x:hover { background: var(--surface-2); color: var(--ink); }

.sheet-body { display: flex; flex-direction: column; gap: 14px; }
.sheet h2 { font-size: 30px; line-height: 1.05; }
.sheet h3 { font-size: 15px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.sheet .fine { color: var(--muted); font-size: 13px; }

.foot { display: flex; align-items: center; justify-content: center; gap: 10px; }

/* result */

.sheet.result { text-align: center; }
.result .sheet-body { gap: 12px; align-items: stretch; }
.eyebrow { color: var(--muted); font: 700 13px var(--text); letter-spacing: 0.08em; text-transform: uppercase; }
.result h2 { font-size: 36px; }
.bigstars { display: flex; justify-content: center; gap: 4px; }
.bigstar { color: var(--line); transition: color 0.2s; }
.bigstar .ico { width: 62px; height: 62px; }
.bigstar.lit { color: var(--gold); filter: drop-shadow(0 3px 0 var(--gold-deep)); }
.bigstar.pop { animation: starpop 0.55s cubic-bezier(0.2, 1.9, 0.4, 1); }
.bigstar:nth-child(2) { margin-top: -8px; }

@keyframes starpop {
  0% { transform: scale(0.2) rotate(-40deg); }
  60% { transform: scale(1.35) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}

.bigscore { font: 800 84px/0.95 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.rel { display: flex; justify-content: center; align-items: center; gap: 8px; }
.pill {
  padding: 6px 12px;
  border-radius: 99px;
  background: var(--surface-2);
  font: 800 14px var(--display);
}
.vs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 6px 9px;
  border-radius: 99px;
  font: 800 14px var(--display);
  font-variant-numeric: tabular-nums;
}
.vs .ico { width: 15px; height: 15px; }
.vs.up { background: #3ecf8e; color: #05301d; }
.vs.down { background: #4da3ff; color: #06223f; }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--c) 20%, var(--surface));
  box-shadow: inset 0 0 0 2px var(--c);
  font: 800 14px var(--display);
  letter-spacing: 0.05em;
}
.chip b { font-weight: 600; opacity: 0.65; letter-spacing: 0; }

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 12px 0;
  border-block: 2px solid var(--line);
}
.facts b { display: block; font: 800 22px var(--display); font-variant-numeric: tabular-nums; }
.facts span { color: var(--muted); font-size: 13px; font-weight: 600; }

.streakbox {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}
.streakbox b { color: var(--ink); font: 800 28px var(--display); }
.streakbox .flame { color: var(--coral); }
.streakbox .flame .ico { width: 28px; height: 28px; }
.streakbox.milestone .flame { animation: wiggle 0.8s ease-in-out infinite; color: var(--gold-deep); }

@keyframes wiggle {
  0%, 100% { transform: rotate(-6deg) scale(1); }
  50% { transform: rotate(6deg) scale(1.18); }
}

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-row .btn { min-height: 50px; padding: 0 12px; font-size: 15px; }
.next { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 14px; }
.next .ico { width: 17px; height: 17px; }
.next b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* crash */

.sheet.mini { padding: 18px 18px 10px; }
.mini .sheet-body { gap: 10px; }
.crash h2 { font-size: 26px; }
.mini .btn { min-height: 50px; }
.left { display: flex; flex-wrap: wrap; gap: 6px; }
.meter.small { height: 8px; margin: 0; }
.meter.small div {
  height: 100%;
  border-radius: inherit;
  background: var(--coral);
  transform-origin: left;
}
.progress { font-size: 14px; color: var(--muted); font-weight: 600; }
.progress b { color: var(--ink); }
.hint-out {
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--gold) 22%, var(--surface));
  font-weight: 700;
  font-size: 15px;
}
.paused { text-align: center; }

/* how to play */

.how .steps { list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; }
.how .steps li { display: flex; gap: 14px; align-items: center; font: 800 18px var(--display); }
.how .ic {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--coral);
  color: var(--ink);
}
.how .ic .ico { width: 26px; height: 26px; }
.how .ic.key { background: var(--tile); color: var(--tile-ink); box-shadow: 0 3px 0 var(--tile-edge); font: 800 24px var(--display); }
.scale { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.scale li { display: grid; grid-template-columns: 28px 1fr 34px; align-items: center; gap: 10px; }
.scale .k {
  display: grid;
  place-items: center;
  height: 26px;
  border-radius: 8px;
  background: var(--c);
  color: #10302d;
  font: 800 14px var(--display);
}
.scale .fill { display: block; height: 10px; border-radius: 99px; background: var(--c); opacity: 0.85; }
.scale b { font: 800 15px var(--display); text-align: right; font-variant-numeric: tabular-nums; }
.stars-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--muted); font-size: 14px; font-weight: 700; }
.stars-note .starline:not(:first-child) { margin-left: 8px; }
.starline { display: inline-flex; color: var(--gold-deep); vertical-align: middle; }
.starline .ico { width: 15px; height: 15px; }

/* settings */

.settings .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  font-weight: 700;
}
.settings .row.stack { flex-direction: column; align-items: stretch; gap: 8px; }

input[role="switch"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 54px;
  height: 32px;
  margin: 0;
  border-radius: 99px;
  background: var(--line);
  cursor: pointer;
  transition: background 0.2s;
}
input[role="switch"]::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.2, 1.4, 0.4, 1);
}
input[role="switch"]:checked { background: var(--coral); }
input[role="switch"]:checked::after { transform: translateX(22px); }

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
}
.seg button {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: 700 15px var(--text);
}
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 2px 0 var(--line), 0 0 0 1.5px var(--line); }

/* stats */

.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.grid4 b { display: block; font: 800 30px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.grid4 span { color: var(--muted); font-size: 12px; font-weight: 600; }
.bars {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 130px;
  padding-top: 6px;
}
.bars .col {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 2px;
}
.bars .col i { display: block; width: 100%; border-radius: 6px 6px 3px 3px; background: var(--board-edge); }
.bars.idle .col i { background: var(--surface-2); }
.bars .col.s2 i { background: var(--coral); }
.bars .col.s3 i { background: var(--gold); }
.bars em { font: 700 10px var(--text); font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
.bars span { font: 600 9px var(--text); color: var(--muted); }

/* toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 90px);
  z-index: 80;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  font-size: 15px;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 1.3, 0.3, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- home ---------- */

body.home { min-height: 100vh; min-height: 100dvh; touch-action: manipulation; }

.shell {
  width: min(500px, 100%);
  margin: 0 auto;
  padding: calc(8px + env(safe-area-inset-top)) 18px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.top { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.top nav { display: flex; gap: 2px; margin-right: -8px; }

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 800 32px/1 var(--display);
  letter-spacing: -0.03em;
}
.logo svg { width: 38px; height: 38px; border-radius: 11px; }

.hero { display: flex; flex-direction: column; gap: 14px; }
.hero .board-frame { width: 100%; aspect-ratio: 1; margin: 0; }
.hero-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hero-meta strong { font: 800 24px/1.1 var(--display); letter-spacing: -0.02em; }
.hero-meta span { color: var(--muted); font-weight: 600; font-size: 15px; }

.nudge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--coral) 16%, var(--surface));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--coral) 55%, transparent);
  font-weight: 700;
  font-size: 15px;
}
.nudge .flame { color: var(--coral); }
.nudge .flame .ico { width: 24px; height: 24px; }
.nudge b { font: 800 20px var(--display); font-variant-numeric: tabular-nums; }
.nudge .sep { margin-left: auto; color: var(--muted); }
.nudge .sep .ico { width: 20px; height: 20px; }
.challenge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 16px;
  background: #4da3ff;
  color: #06223f;
  box-shadow: 0 4px 0 #2f7fd6;
  font: 800 22px var(--display);
}
.challenge .ico { width: 26px; height: 26px; }

.card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--line);
}
.card h3 { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.streak-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.streak-num { display: flex; align-items: center; gap: 8px; }
.streak-num .flame { color: var(--line); }
.streak-num.live .flame { color: var(--coral); }
.streak-num .flame .ico { width: 34px; height: 34px; }
.streak-num b { font: 800 44px/1 var(--display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.streak-num span { color: var(--muted); font-weight: 700; font-size: 15px; }
.best-line { text-align: right; color: var(--muted); font-size: 13px; font-weight: 600; }
.best-line b { display: block; color: var(--ink); font: 800 22px var(--display); }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--muted); font: 700 12px var(--text); }
.day i {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 13px;
  background: var(--surface-2);
  color: transparent;
}
.day i .ico { width: 55%; height: 55%; }
.day.yes i { background: var(--coral); color: var(--ink); }
.day.yes.gold i { background: var(--gold); color: var(--gold-ink); }
.day.today { color: var(--ink); }
.day.today i { box-shadow: inset 0 0 0 2.5px var(--ink); }
.day.today.yes i { box-shadow: none; }

.done {
  display: flex;
  align-items: center;
  gap: 14px;
}
.done .bigstars { justify-content: flex-start; gap: 0; }
.done .bigstar .ico { width: 34px; height: 34px; }
.done .bigstar:nth-child(2) { margin-top: 0; }
.done .bigstar.lit { filter: none; }
.done-main { flex: 1; min-width: 0; }
.done-main b { display: block; font: 800 34px/1 var(--display); font-variant-numeric: tabular-nums; }
.done-main span { color: var(--muted); font-size: 14px; font-weight: 600; }

.more { display: flex; flex-direction: column; gap: 10px; }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
