/* =========================================================================
   Daily Puzzles — design system
   "Sunday puzzle page meets candy shop": warm paper, inky outlines,
   offset shadows, and a signature colour for every game.
   ========================================================================= */

@font-face {
  font-family: 'Bricolage';
  src: url('../fonts/bricolage.woff2') format('woff2-variations'), url('../fonts/bricolage.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #fff6e9;
  --bg-dots: #f3e6d1;
  --surface: #ffffff;
  --surface-2: #fbf2e4;
  --ink: #1d1a16;
  --muted: #6b6358;
  --edge: #1d1a16;
  --soft: #eadcc6;
  --ok: #2f9e5b;
  --close: #f2b705;
  --bad: #e5484d;
  --miss: #8d857a;

  /* game colours */
  --c-fold: #ff8a3d;
  --c-birdaday: #33b679;
  --c-ripple: #7b6cf6;
  --c-rungs: #ff5a5f;
  --c-tangle: #ffc93c;
  --c-pantry: #e45fa8;
  --c-overlap: #3ab0e2;
  --c-timeline: #a3d65c;

  --accent: #1d1a16;
  --on-accent: #ffffff;

  --paper: #fffdf6;
  --paper-edge: #b9ae98;
  --flap: #ffe2c7;
  --ghost: #e4d6bf;

  --radius: 18px;
  --radius-sm: 12px;
  --bw: 2.5px;
  --shadow: 4px 4px 0 var(--edge);
  --shadow-sm: 2px 2px 0 var(--edge);
  --display: 'Bricolage', ui-rounded, system-ui, sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15130f;
    --bg-dots: #1f1c17;
    --surface: #221f1a;
    --surface-2: #2a2620;
    --ink: #f6efe3;
    --muted: #b1a796;
    --edge: #000000;
    --soft: #3a352d;
    --miss: #5d574e;
    --paper: #f6efe0;
    --paper-edge: #8d846f;
    --flap: #ffd6b0;
    --ghost: #3a352d;
    --shadow: 4px 4px 0 #000;
    --shadow-sm: 2px 2px 0 #000;
  }
  .card, .btn, .modal, .summary, .clue, .guess-name, .option, .icon-btn, .back, .ripple-board, .board-frame, .progress, .stat {
    outline: 1px solid rgb(255 255 255 / 0.1);
  }
}

/* Each game page sets body[data-game]; that game's colour becomes the accent. */
body[data-game='fold'] { --accent: var(--c-fold); --on-accent: #1d1a16; }
body[data-game='birdaday'] { --accent: var(--c-birdaday); --on-accent: #10261a; }
body[data-game='ripple'] { --accent: var(--c-ripple); --on-accent: #ffffff; }
body[data-game='rungs'] { --accent: var(--c-rungs); --on-accent: #ffffff; }
body[data-game='tangle'] { --accent: var(--c-tangle); --on-accent: #1d1a16; }
body[data-game='pantry'] { --accent: var(--c-pantry); --on-accent: #ffffff; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dots) 1.2px, transparent 1.2px);
  background-size: 18px 18px;
  color: var(--ink);
  font: 16px/1.5 var(--body);
}

a { color: inherit; }
h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0 0 0.5rem; text-wrap: balance; letter-spacing: -0.01em; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 1rem calc(4rem + env(safe-area-inset-bottom));
}

/* ---------- header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  padding-top: max(0.6rem, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.topbar h1 { margin: 0; display: flex; align-items: center; gap: 0.45rem; font-size: 1.45rem; font-weight: 800; }
.topbar h1 .game-dot { width: 0.8rem; height: 0.8rem; border-radius: 50%; background: var(--accent); border: 2px solid var(--edge); }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--display); font-weight: 800; font-size: 1.15rem; text-decoration: none; white-space: nowrap; }
.brand .logo { width: 32px; height: 32px; flex: none; }
.back {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: var(--bw) solid var(--edge);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.back svg { width: 18px; height: 18px; }
.actions { display: flex; justify-content: flex-end; gap: 0.35rem; }
.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: var(--bw) solid var(--edge);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.icon-btn:active, .back:active { transform: translate(2px, 2px); box-shadow: none; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.signed-in { background: var(--c-birdaday); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 50px;
  padding: 0.65rem 1.3rem;
  border: var(--bw) solid var(--edge);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font: inherit;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
body:not([data-game]) .btn.primary { background: var(--ink); color: var(--bg); }
.btn:focus-visible, .option:focus-visible, .icon-btn:focus-visible, .card:focus-visible, .tile:focus-visible, .letter:focus-visible, .key:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- modal & toast ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  justify-items: center;
  background: rgb(20 15 10 / 0.5);
  animation: fade 0.15s ease-out;
}
.modal {
  position: relative;
  width: min(100%, 480px);
  max-height: 88dvh;
  overflow: auto;
  padding: 1.5rem 1.4rem calc(1.5rem + env(safe-area-inset-bottom));
  border: var(--bw) solid var(--edge);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  animation: sheet 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@media (min-width: 600px) {
  .overlay { align-items: center; padding: 1rem; }
  .modal { border-bottom: var(--bw) solid var(--edge); border-radius: 24px; box-shadow: 8px 8px 0 var(--edge); }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.modal h2 { font-size: 1.6rem; padding-right: 2.5rem; }
.modal-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 38px;
  height: 38px;
  border: var(--bw) solid var(--edge);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.help-list { padding-left: 1.1rem; }
.help-list li { margin-bottom: 0.4rem; }
.help-steps { display: flex; gap: 0.5rem; margin: 0.5rem 0 1rem; }
.help-steps svg { flex: 1; min-width: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.5rem + env(safe-area-inset-bottom));
  z-index: 30;
  transform: translate(-50%, 1rem);
  opacity: 0;
  padding: 0.75rem 1.2rem;
  border: var(--bw) solid var(--edge);
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--display);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; text-align: center; margin: 1rem 0; }
.stat { padding: 0.6rem 0.2rem; border: var(--bw) solid var(--edge); border-radius: var(--radius-sm); background: var(--surface-2); }
.stat strong { display: block; font-family: var(--display); font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.75rem; color: var(--muted); }
.stat-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; padding-top: 1rem; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; }
.signin { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.signin input { flex: 1 1 200px; }

input[type='text'], input[type='email'] {
  min-height: 52px;
  padding: 0.6rem 1rem;
  border: var(--bw) solid var(--edge);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  box-shadow: inset 2px 2px 0 var(--soft);
}
input:focus { outline: 3px solid var(--accent); outline-offset: 1px; }

/* ---------- home ---------- */
.today { margin: 0.5rem 0 1.25rem; }
.today .date { font-family: var(--display); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; color: var(--muted); }
.today h1 { font-size: clamp(2.2rem, 10vw, 3.1rem); font-weight: 800; margin: 0.15rem 0 0.85rem; }
.progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: var(--bw) solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.progress-dots { display: flex; gap: 0.3rem; }
.progress-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--edge); background: var(--surface-2); }
.progress-text { flex: 1; font-weight: 700; font-size: 0.95rem; line-height: 1.3; }
.progress-text small { display: block; font-weight: 400; color: var(--muted); }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 196px;
  padding: 0.9rem;
  border: var(--bw) solid var(--edge);
  border-radius: var(--radius);
  background: var(--card, var(--surface));
  color: var(--card-ink, var(--ink));
  box-shadow: var(--shadow);
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.1s, box-shadow 0.1s;
}
a.card:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--edge); }
a.card:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--edge); }
.card .icon { width: 56px; height: 56px; margin-bottom: auto; }
.card strong { font-family: var(--display); font-size: 1.35rem; font-weight: 800; line-height: 1.05; }
.card .tagline { font-size: 0.82rem; line-height: 1.3; opacity: 0.9; }
.card .status {
  align-self: flex-start;
  margin-top: 0.35rem;
  padding: 0.2rem 0.7rem;
  border: 2px solid var(--edge);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.85rem;
}
.card.done .status { background: var(--ink); color: var(--bg); }
.card .streak { position: absolute; top: 0.75rem; right: 0.8rem; font-family: var(--display); font-weight: 800; font-size: 0.9rem; }
.card.new::after {
  content: 'NEW';
  position: absolute;
  top: 0.8rem;
  right: -1.9rem;
  transform: rotate(35deg);
  padding: 0.1rem 2.2rem;
  background: var(--edge);
  color: #fff;
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
}
.soon-title { margin: 2rem 0 0.75rem; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.cards.soon { grid-template-columns: 1fr; }
.cards.soon .card { min-height: 0; flex-direction: row; align-items: center; gap: 0.8rem; background: transparent; box-shadow: none; border-style: dashed; color: var(--muted); }
.cards.soon .icon { width: 36px; height: 36px; margin: 0; flex: none; opacity: 0.6; }
.cards.soon .card-text { display: grid; }
.footer-note { margin-top: 2rem; text-align: center; font-size: 0.85rem; color: var(--muted); }

/* ---------- shared game bits ---------- */
.round-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.85rem; font-size: 0.9rem; color: var(--muted); font-weight: 600; }
.dots { display: flex; gap: 0.3rem; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--edge); background: var(--surface); }
.dot.now { background: var(--accent); }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }

.summary {
  position: relative;
  overflow: hidden;
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  text-align: center;
  padding: 1.6rem 1.1rem 1.4rem;
  margin-bottom: 1.25rem;
  border: var(--bw) solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.summary::before { content: ''; position: absolute; inset: 0 0 auto; height: 12px; background: var(--accent); border-bottom: var(--bw) solid var(--edge); }
.summary h2 { font-size: 1.7rem; margin-top: 0.4rem; }
.summary p { margin: 0; }
.summary .btn { width: min(100%, 320px); }
.big { font-family: var(--display); font-size: 2.8rem; font-weight: 800; line-height: 1; }
.squares { font-size: 1.5rem; letter-spacing: 0.1em; white-space: pre-line; }
.small-squares { font-size: 1.1rem; line-height: 1.35; }
.feedback { min-height: 1.5em; text-align: center; font-family: var(--display); font-weight: 700; font-size: 1.1rem; margin: 0.75rem 0; }
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--bad); }
.next { display: flex; width: min(100%, 320px); margin: 0 auto; }
.next[hidden] { display: none; }

/* ---------- Fold ---------- */
.steps { display: flex; gap: 0.5rem; align-items: flex-start; margin-bottom: 0.75rem; }
.steps figure { flex: 1 1 0; min-width: 0; max-width: 160px; margin: 0; text-align: center; }
.steps figcaption { font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.steps figure.punch svg { background: color-mix(in srgb, var(--accent) 25%, transparent); border-radius: 10px; }
.prompt { text-align: center; font-family: var(--display); font-weight: 700; font-size: 1.15rem; margin: 0.25rem 0 0.85rem; }
.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
.option {
  position: relative;
  padding: 0.5rem;
  border: var(--bw) solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.option:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.option:disabled { cursor: default; }
.option.correct { background: color-mix(in srgb, var(--ok) 25%, var(--surface)); outline: 3px solid var(--ok); }
.option.wrong { background: color-mix(in srgb, var(--bad) 18%, var(--surface)); outline: 3px solid var(--bad); }
.option:disabled:not(.correct):not(.wrong) { opacity: 0.45; }
.option svg { margin-top: 0.6rem; }
.opt-label { position: absolute; top: 0.25rem; left: 0.6rem; font-family: var(--display); font-size: 0.85rem; font-weight: 800; color: var(--muted); }
svg { display: block; width: 100%; height: auto; }
svg .ghost { fill: none; stroke: var(--ghost); stroke-width: 1.5; stroke-dasharray: 3 3; }
svg .paper { fill: var(--paper); stroke: var(--paper-edge); stroke-width: 1.5; }
svg .flap { fill: var(--flap); stroke: var(--paper-edge); stroke-width: 1.5; }
svg .grid { stroke: var(--paper-edge); stroke-opacity: 0.25; stroke-width: 0.6; }
svg .foldline { stroke: #d2551a; stroke-width: 1.8; stroke-dasharray: 4 3; }
svg .arrow { fill: none; stroke: #d2551a; stroke-width: 2.4; }
svg .arrowhead { fill: #d2551a; }
svg .hole { fill: #2a2722; }

.review { margin-top: 1.5rem; }
.review h3 { font-size: 1.15rem; }
.review-row { display: grid; grid-template-columns: 1.5rem 1fr 22%; gap: 0.5rem; align-items: center; padding: 0.5rem 0; border-top: 2px dashed var(--soft); }
.review-n { font-family: var(--display); font-weight: 800; color: var(--muted); }
.review-steps { display: flex; gap: 0.25rem; }
.review-steps svg { flex: 1; min-width: 0; max-width: 90px; }

/* ---------- Birdaday ---------- */
.clues { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.55rem; }
.clue { padding: 0.75rem 0.95rem; border: var(--bw) solid var(--edge); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-sm); }
.clue p { margin: 0.25rem 0 0; }
.clue-label { display: inline-block; font-family: var(--display); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.1rem 0.55rem; border: 2px solid var(--edge); border-radius: 999px; background: var(--accent); color: var(--on-accent); }
.clue.locked { background: transparent; border-style: dashed; box-shadow: none; padding: 0.5rem 0.95rem; }
.clue.locked .clue-label { background: transparent; border: 0; color: var(--muted); padding: 0; }
.clue.locked p { font-size: 0.85rem; }

.guesses { display: grid; gap: 0.4rem; margin-bottom: 1rem; }
.guess-row { display: grid; grid-template-columns: 1fr repeat(3, 3rem); gap: 0.35rem; align-items: center; }
.guess-row.head { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.guess-row.head span:not(:first-child) { text-align: center; }
.guess-name { font-weight: 700; font-size: 0.95rem; padding: 0.5rem 0.6rem; border: var(--bw) solid var(--edge); border-radius: 10px; background: var(--surface); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guess-row.correct .guess-name { background: var(--ok); color: #fff; }
.chip { display: grid; place-items: center; height: 2.5rem; border: var(--bw) solid var(--edge); border-radius: 10px; color: #fff; font-weight: 800; }
.chip.match { background: var(--ok); }
.chip.close { background: var(--close); color: #2b2205; }
.chip.miss { background: var(--miss); }
.chip.up, .chip.down { background: var(--surface); color: var(--ink); }

.guess-input { position: relative; }
.guess-input input { width: 100%; }
.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 4;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  border: var(--bw) solid var(--edge);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.suggestions li { padding: 0.65rem 0.75rem; border-radius: 8px; cursor: pointer; font-weight: 600; }
.suggestions li.active, .suggestions li:hover { background: color-mix(in srgb, var(--accent) 28%, var(--surface)); }
.bird-name { font-size: 2.1rem; }

/* ---------- Ripple ---------- */
.ripple-count strong { color: var(--ink); }
.ripple-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: min(100%, 420px);
  margin: 0.5rem auto 0.85rem;
  padding: 8px;
  border: var(--bw) solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}
.ripple-board .cell { position: relative; aspect-ratio: 1; border-radius: 10px; background: color-mix(in srgb, var(--soft) 55%, transparent); transition: background 0.15s; }
.ripple-board .cell.trail { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.tile {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: var(--bw) solid var(--edge);
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 3px 0 var(--edge);
  cursor: pointer;
  transition: transform 0.08s;
}
.tile:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge); }
.tile:disabled { cursor: default; }
.tile.burst { background: var(--c-tangle); color: #1d1a16; }
.tile .face { width: 60%; display: grid; }
.tile .face svg { width: 100%; height: auto; }
.tile.popping { animation: pop 0.3s ease-out forwards; pointer-events: none; }
@keyframes pop {
  0% { transform: scale(1); opacity: 1; }
  40% { transform: scale(1.25); opacity: 0.9; }
  100% { transform: scale(0); opacity: 0; }
}
.tile.numbered .face { width: 42%; opacity: 0.5; }
.step-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: auto;
  width: 1.9rem;
  height: 1.9rem;
  border: 2px solid var(--edge);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 800;
}
.solution { width: 100%; }
.solution .ripple-board { width: min(100%, 300px); }
.help-tiles { display: grid; grid-template-columns: 48px 1fr; gap: 0.5rem 0.75rem; align-items: center; margin: 0.75rem 0; }
.tile.demo { position: relative; width: 48px; height: 48px; cursor: default; }

@media (max-width: 380px) {
  .guess-row { grid-template-columns: 1fr repeat(3, 2.6rem); }
  .brand span { display: none; }
  .cards { gap: 0.65rem; }
  .card { min-height: 176px; padding: 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .tile.popping { opacity: 0; }
}

/* ---------- Rungs ---------- */
.rungs-head { display: flex; justify-content: space-between; align-items: stretch; gap: 0.75rem; margin-bottom: 0.9rem; }
.theme-pill, .pool {
  display: grid;
  align-content: center;
  padding: 0.45rem 0.9rem;
  border: var(--bw) solid var(--edge);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1.1;
}
.theme-pill { flex: 1; }
.theme-pill small, .pool small { font-family: var(--body); font-weight: 600; font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.pool { text-align: center; min-width: 5.5rem; }
.pool strong { font-size: 1.5rem; }
.ladder {
  position: relative;
  display: grid;
  gap: 0.6rem;
  padding: 0.25rem 0.9rem;
  margin-bottom: 1rem;
}
.ladder::before, .ladder::after {
  content: '';
  position: absolute;
  top: -0.25rem;
  bottom: -0.25rem;
  width: 8px;
  border: var(--bw) solid var(--edge);
  border-radius: 6px;
  background: var(--accent);
}
.ladder::before { left: 0; }
.ladder::after { right: 0; }
.rung {
  position: relative;
  padding: 0.55rem 0.6rem 0.6rem;
  border: var(--bw) solid var(--edge);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.rung:not(.active):not(.solved) { opacity: 0.55; box-shadow: none; border-style: dashed; }
.rung.active { box-shadow: var(--shadow); }
.rung-label { display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; font-weight: 700; color: var(--muted); margin-bottom: 0.35rem; text-transform: uppercase; letter-spacing: 0.05em; }
.rung-label span { display: grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--ink); color: var(--bg); font-family: var(--display); }
.rows { display: grid; gap: 0.3rem; justify-content: center; }
.row { display: flex; gap: 0.3rem; justify-content: center; }
.row .cell {
  display: grid;
  place-items: center;
  width: clamp(2.3rem, 12vw, 3rem);
  aspect-ratio: 1;
  border: var(--bw) solid var(--soft);
  border-radius: 10px;
  background: var(--surface);
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.2rem, 6vw, 1.55rem);
  text-transform: uppercase;
}
.row .cell.typed { border-color: var(--edge); animation: bump 0.1s; }
.row .cell.hit { background: var(--accent); color: var(--on-accent); border-color: var(--edge); }
.row .cell.near { background: var(--surface); border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--accent); }
.row .cell.miss { background: var(--soft); color: var(--muted); border-color: var(--soft); }
.row.locked .cell { border-style: dashed; }
.row.answer .cell { opacity: 0.6; }
.row.reveal .cell { animation: flip 0.4s ease both; animation-delay: calc(var(--i) * 110ms); }
.row.shake { animation: shake 0.35s; }
.row.demo { justify-content: flex-start; margin: 0.5rem 0; }
.row.demo .cell { width: 2.4rem; font-size: 1.2rem; }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes bump { 50% { transform: scale(1.08); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.keyboard {
  position: sticky;
  bottom: 0;
  display: grid;
  gap: 0.4rem;
  padding: 0.6rem 0.2rem calc(0.6rem + env(safe-area-inset-bottom));
  margin: 0 -1rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
}
.krow { display: flex; gap: 0.3rem; justify-content: center; }
.key {
  flex: 1 1 0;
  max-width: 2.6rem;
  min-height: 3.3rem;
  padding: 0;
  border: 2px solid var(--edge);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--edge);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
}
.key:active { transform: translateY(2px); box-shadow: none; }
.key.wide { max-width: 4rem; flex-grow: 1.6; font-size: 0.8rem; }
.key.hit { background: var(--accent); color: var(--on-accent); }
.key.near { box-shadow: inset 0 0 0 3px var(--accent), 0 2px 0 var(--edge); }
.key.miss { background: var(--soft); color: var(--muted); }
body[data-game='rungs'] main { padding-bottom: 0; }

/* ---------- Tangle ---------- */
.tangle-head { display: flex; justify-content: space-between; align-items: stretch; gap: 0.75rem; margin-bottom: 0.6rem; }
.tray { min-height: 2.6rem; text-align: center; font-family: var(--display); font-weight: 800; font-size: 1.8rem; letter-spacing: 0.12em; }
.board-frame {
  position: relative;
  width: min(100%, 400px);
  margin: 0 auto 1rem;
  padding: 10px;
  border: var(--bw) solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.tangle-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.tangle-lines { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); pointer-events: none; z-index: 0; }
.tangle-lines polyline { fill: none; stroke-width: 38; stroke-linecap: round; stroke-linejoin: round; opacity: 0.55; }
.tangle-lines polyline.trace { stroke-width: 30; opacity: 0.25; }
.tangle-lines polyline.reveal-line { stroke-width: 14; opacity: 0.8; stroke-dasharray: 2 26; }
.letter {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.2rem, 6.5vw, 1.7rem);
  cursor: pointer;
  transition: transform 0.08s;
}
.letter.selected { background: var(--ink); color: var(--bg); transform: scale(1.08); }
.letter.found { color: #1d1a16; }
.letter.found::after { content: none; }
.letter.hinted { box-shadow: inset 0 0 0 3px var(--accent); animation: pulse 1.4s infinite; }
.letter.revealed { background: var(--accent); color: var(--on-accent); border: 2px solid var(--edge); }
@keyframes pulse { 50% { box-shadow: inset 0 0 0 6px var(--accent); } }
.tangle-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }

/* ---------- Pantry ---------- */
.recipe {
  position: relative;
  margin-bottom: 1rem;
  padding: 1rem 1.1rem 0.8rem 1.1rem;
  border: var(--bw) solid var(--edge);
  border-radius: var(--radius-sm);
  background:
    repeating-linear-gradient(to bottom, transparent 0 2.15rem, color-mix(in srgb, #3ab0e2 25%, transparent) 2.15rem calc(2.15rem + 1px)),
    var(--paper);
  color: #1d1a16;
  box-shadow: var(--shadow);
}
.recipe::before { content: ''; position: absolute; top: 0; bottom: 0; left: 2.4rem; width: 2px; background: color-mix(in srgb, var(--c-rungs) 45%, transparent); }
.recipe-title { font-family: var(--display); font-weight: 800; font-size: 1.2rem; padding-left: 1.9rem; margin-bottom: 0.2rem; }
.recipe ol { margin: 0; padding-left: 3.1rem; }
.recipe .ing { min-height: 2.15rem; display: flex; align-items: center; font-size: 1.05rem; font-weight: 600; animation: inkin 0.35s ease-out; }
.recipe .ing::marker { font-family: var(--display); font-weight: 800; color: #8a7f6d; }
.recipe .ing.locked { color: #b5aa96; font-weight: 400; letter-spacing: 0.2em; animation: none; }
@keyframes inkin { from { opacity: 0; transform: translateX(-6px); } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pantry-guesses .guess-row { grid-template-columns: 1fr repeat(2, 3.6rem); }
.guess-name small, .suggestions small { font-weight: 500; color: var(--muted); }
.guess-row.correct .guess-name small { color: inherit; opacity: 0.85; }
@media (prefers-color-scheme: dark) {
  .tangle-lines polyline.found { opacity: 0.9; }
  .tangle-lines polyline.trace { stroke: #f6efe3; opacity: 0.3; }
}
