﻿/*
  Rank & Stress
  Layout concept: a graph-paper notebook. Each answer is a rung; the red column is the spine that holds a puzzle together.
*/
:root {
  --paper: #F1F6FC;
  --surface: #FFFFFF;
  --surface-2: #E6EEF9;
  --grid: #D0DFF0;
  --ink: #14203A;
  --ink-2: #485879;
  --ink-3: #6E7E9E;
  --edge: #2A3A5F;
  --red: #D4301F;
  --red-soft: #FDE4E0;
  --on-red: #FFFFFF;
  --hl: #FFE27A;
  --hl-ink: #14203A;
  --hl-word: #D6E4FA;
  --cell: #FFFFFF;
  --key-cell: #FFF0ED;
  --ok: #0F6B48;
  --ok-soft: #D9F1E5;
  --bad: #B3261E;
  --rev: #2250D6;
  --focus: #2250D6;

  --f-display: "Bricolage Grotesque", "Manrope", "Segoe UI", system-ui, sans-serif;
  --f-body: "Hanken Grotesk", "Manrope", "Segoe UI", system-ui, sans-serif;
  --f-hand: "Kalam", "Segoe Print", "Bradley Hand", cursive;
  --f-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --tabs-h: 54px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0C1424;
    --surface: #14213A;
    --surface-2: #1A2A48;
    --grid: #18263F;
    --ink: #E8EEFA;
    --ink-2: #A9B7D3;
    --ink-3: #7787A8;
    --edge: #8FA3CB;
    --red: #FF6A56;
    --red-soft: #3B1D22;
    --on-red: #1E0C0C;
    --hl: #E9C94F;
    --hl-ink: #14203A;
    --hl-word: #203764;
    --cell: #182744;
    --key-cell: #2B1F2D;
    --ok: #5BDDA6;
    --ok-soft: #12382C;
    --bad: #FF8A7C;
    --rev: #8FB2FF;
    --focus: #8FB2FF;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0C1424;
  --surface: #14213A;
  --surface-2: #1A2A48;
  --grid: #18263F;
  --ink: #E8EEFA;
  --ink-2: #A9B7D3;
  --ink-3: #7787A8;
  --edge: #8FA3CB;
  --red: #FF6A56;
  --red-soft: #3B1D22;
  --on-red: #1E0C0C;
  --hl: #E9C94F;
  --hl-ink: #14203A;
  --hl-word: #203764;
  --cell: #182744;
  --key-cell: #2B1F2D;
  --ok: #5BDDA6;
  --ok-soft: #12382C;
  --bad: #FF8A7C;
  --rev: #8FB2FF;
  --focus: #8FB2FF;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--ink);
  font: 400 1rem/1.55 var(--f-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 100; border-radius: 6px; }
.skip:focus { top: 8px; }

.wrap-x {
  width: min(1120px, 100%);
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: 600 .92rem/1 var(--f-body);
  padding: .72rem 1.05rem;
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--edge); border-radius: 8px;
  box-shadow: 3px 3px 0 var(--edge);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), background-color .15s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--edge); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--edge); }
.btn-primary { background: var(--red); color: var(--on-red); }
.btn-sm { padding: .6rem .9rem; font-size: .88rem; }
.btn-lg { padding: 1rem 1.4rem; font-size: 1.05rem; border-radius: 10px; box-shadow: 4px 4px 0 var(--edge); }
.btn-lg:hover { box-shadow: 5px 5px 0 var(--edge); }
.btn-lg svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s var(--ease); }
.btn-lg:hover svg { transform: translateX(4px); }
.btn svg.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.armed { background: var(--red); color: var(--on-red); }
.link-btn { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: .85rem; }
.link-btn:hover { color: var(--red); }

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--edge); border-radius: 8px; cursor: pointer;
  transition: transform .12s var(--ease), background-color .15s;
}
.icon-btn:hover { transform: rotate(-6deg); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .dot { fill: var(--ink); stroke: none; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}

/* ---------- top bar ---------- */
.top-in { display: flex; align-items: center; justify-content: space-between; padding-block: 14px 6px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 800 1.15rem/1 var(--f-display); letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; fill: var(--ink); }
.brand-mark .mark-spine { fill: none; stroke: var(--red); stroke-width: 2; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.help-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.help-btn .dot { fill: currentColor; stroke: none; }
.lang { display: inline-flex; border: 2px solid var(--edge); border-radius: 8px; overflow: hidden; background: var(--surface); box-shadow: 3px 3px 0 var(--edge); }
.lang button { background: none; border: 0; padding: .55rem .75rem; font: 700 .82rem/1 var(--f-mono); letter-spacing: .04em; cursor: pointer; color: var(--ink-2); transition: background-color .15s, color .15s; }
.lang button + button { border-left: 2px solid var(--edge); }
.lang button:hover { background: var(--surface-2); color: var(--ink); }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 9px; border: 2px solid var(--edge); border-radius: 99px; background: var(--hl); color: var(--hl-ink); font: 700 .82rem/1 var(--f-body); box-shadow: 2px 2px 0 var(--edge); }
.badge svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- hero ---------- */
.hero-in { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 32px; align-items: center; padding-block: clamp(20px, 4vw, 44px) clamp(24px, 4vw, 40px); }
.eyebrow { font: 500 .76rem/1.2 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
h1 {
  font: 800 clamp(3rem, 9vw, 5.6rem)/.92 var(--f-display);
  font-variation-settings: "opsz" 96;
  letter-spacing: -.035em;
  margin-top: 14px;
  text-wrap: balance;
}
h1 .amp { color: var(--red); font-style: normal; display: inline-block; transform-origin: 50% 70%; animation: amp-in .9s .5s var(--ease) both; }
.lede { margin-top: 18px; max-width: 46ch; color: var(--ink-2); font-size: 1.08rem; text-wrap: pretty; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

.hero-art { container-type: inline-size; min-width: 0; display: flex; justify-content: flex-end; }
.sils { --u: min(12px, calc((100cqw - 28px) / 38)); display: flex; gap: calc(var(--u) * 2); align-items: flex-start; }
.sil { position: relative; display: grid; grid-template-columns: repeat(var(--cols), var(--u)); row-gap: calc(var(--u) * .55); padding-block: calc(var(--u) * .5); }
.sil .b { grid-row: var(--row); height: calc(var(--u) * 1.15); background: var(--edge); border-radius: 2px; opacity: .88;
  animation: bar-in .75s calc(.15s + var(--ri) * 70ms + var(--si) * .35s) var(--ease) both,
             glint 9s calc(2.2s + var(--ri) * .3s + var(--si) * 1.2s) infinite; }
.sil .b.l { transform-origin: right center; }
.sil .b.r { transform-origin: left center; }
.sil .b.k { background: var(--red); opacity: 1; animation-name: bar-in; animation-duration: .5s; transform-origin: center; }
.sil .sp { position: absolute; top: 0; bottom: 0; left: calc(var(--left) * var(--u)); width: var(--u); border: 2px solid var(--red); border-radius: 3px; transform-origin: top; animation: spine-in .8s calc(.9s + var(--si) * .3s) var(--ease) both; }

/* ---------- tab bar ---------- */
.tabbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: color-mix(in srgb, var(--paper) 92%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-block: 2px solid var(--edge); }
.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding-block: 12px 14px; }
.tab {
  display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer;
  padding: 10px 14px; min-width: 0;
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--edge); border-radius: 10px; box-shadow: 3px 3px 0 var(--edge);
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), background-color .2s, color .2s;
}
.tab:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--edge); }
.tab:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--edge); }
.tab .t-ico { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border: 2px solid var(--edge); border-radius: 6px; background: var(--key-cell); font: 700 1.15rem/1 var(--f-hand); color: var(--ink); }
.tab .t-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab .t-text { display: grid; gap: 2px; min-width: 0; flex: 1; }
.tab .t-name { font: 800 1.05rem/1.1 var(--f-display); letter-spacing: -.01em; }
.tab .t-sub { font: 500 .72rem/1.2 var(--f-mono); color: var(--ink-2); letter-spacing: .02em; }
.tab .t-count { flex: none; font: 600 .8rem/1 var(--f-mono); background: var(--surface-2); color: var(--ink); padding: 5px 8px; border-radius: 99px; transition: background-color .3s, color .3s; font-variant-numeric: tabular-nums; }
.tab .t-count.full { background: var(--ok-soft); color: var(--ok); }
.tab[aria-selected="true"] { background: var(--red); color: var(--on-red); transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--edge); }
.tab[aria-selected="true"] .t-ico { background: var(--surface); color: var(--ink); }
.tab[aria-selected="true"] .t-sub { color: inherit; opacity: .85; }
.tab[aria-selected="true"] .t-count { background: rgba(255, 255, 255, .92); color: var(--ink); }
.tab[aria-selected="true"] .t-count.full { background: var(--ok-soft); color: var(--ok); }
.tab .t-ico .i-lock { display: none; }
.tab.locked { background: var(--surface-2); color: var(--ink-2); border-style: dashed; box-shadow: none; cursor: not-allowed; }
.tab.locked:hover, .tab.locked:active { transform: none; box-shadow: none; }
.tab.locked .t-ico { background: transparent; border-style: dashed; color: var(--ink-2); }
.tab.locked .t-ico .i-link { display: none; }
.tab.locked .t-ico .i-lock { display: block; }
.tab.locked .t-count { background: var(--surface); color: var(--ink-2); }
.tab.just-unlocked { animation: unlock .9s var(--ease); }
.tab.attn:not([aria-selected="true"]) { animation: attn 1.6s ease-in-out infinite; }

/* ---------- views ---------- */
main { min-height: 60vh; }
.view { padding-block: clamp(22px, 4vw, 40px) 56px; }
.view:not([hidden]) { animation: view-in .4s var(--ease) both; }
.sec-head { display: grid; gap: 8px; margin-bottom: 20px; }
h2 { font: 800 clamp(1.8rem, 4.5vw, 2.6rem)/1.05 var(--f-display); letter-spacing: -.025em; text-wrap: balance; }
h3 { font: 700 1.35rem/1.15 var(--f-display); letter-spacing: -.015em; }
.sec-lede, .block-lede { color: var(--ink-2); max-width: 62ch; text-wrap: pretty; }

.p-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 32px; align-items: end; margin-bottom: 18px; }
.secret { display: grid; gap: 8px; justify-items: start; }
.secret-label { font: 500 .72rem/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.secret-boxes { display: flex; gap: 5px; }
.sl { width: clamp(24px, 6.2vw, 42px); aspect-ratio: 1; display: grid; place-items: center; border: 2.5px solid var(--red); border-radius: 4px; background: var(--key-cell); font: 700 clamp(1rem, 3vw, 1.5rem)/1 var(--f-hand); color: var(--ink); transition: background-color .3s; }
.secret.done .sl { background: var(--red); color: var(--on-red); animation: hop .6s calc(var(--i) * 70ms) var(--ease) both; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.tb-main { display: flex; gap: 10px; }
.tb-side { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.toolbar .grow { flex: 1; }
.btn-ghost { background: transparent; box-shadow: none; border-color: var(--ink-3); color: var(--ink-2); }
.btn-ghost:hover { box-shadow: none; transform: none; background: var(--surface-2); color: var(--ink); border-color: var(--edge); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .88rem; cursor: pointer; user-select: none; color: var(--ink-2); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border: 2px solid var(--edge); border-radius: 99px; background: var(--surface); position: relative; transition: background-color .2s; }
.switch .track::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--edge); transition: transform .2s var(--ease), background-color .2s; }
.switch input:checked + .track { background: var(--red); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--on-red); }
.switch input:focus-visible + .track { outline: 3px solid var(--focus); outline-offset: 2px; }
.clock { font: 500 .9rem/1 var(--f-mono); color: var(--ink-2); font-variant-numeric: tabular-nums; padding: 8px 10px; border: 2px dashed var(--ink-3); border-radius: 8px; }

details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; z-index: 20; top: calc(100% + 8px); left: 0; min-width: 210px; display: grid; background: var(--surface); border: 2px solid var(--edge); border-radius: 8px; box-shadow: 4px 4px 0 var(--edge); padding: 6px; animation: view-in .18s var(--ease) both; }
.menu-panel button { text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: .9rem; display: grid; gap: 2px; }
.menu-panel button small { font-weight: 400; color: var(--ink-2); font-size: .78rem; }
.menu-panel button:hover { background: var(--surface-2); }
.menu-panel button.armed { background: var(--red); color: var(--on-red); }
.menu-panel button.armed small { color: inherit; }

/* clue bar */
.clue-bar {
  position: sticky; top: calc(var(--tabs-h) + env(safe-area-inset-top, 0px)); z-index: 15;
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; align-items: start;
  background: var(--surface); border: 2px solid var(--edge); border-radius: 10px; box-shadow: 3px 3px 0 var(--edge);
  padding: 12px 14px; margin-bottom: 14px;
}
.clue-num { grid-row: 1 / span 2; font: 800 2rem/1 var(--f-display); color: var(--red); min-width: 1.1ch; text-align: center; }
.clue-text { font-weight: 500; font-size: 1.02rem; text-wrap: pretty; }
.clue-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font: 500 .78rem/1 var(--f-mono); color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1.5px solid var(--edge); border-radius: 99px; padding: 3px 9px 3px 7px; font: 500 .72rem/1.2 var(--f-mono); color: var(--ink); background: var(--surface-2); white-space: nowrap; }
.chip svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chip.bridge-chip { background: var(--red-soft); border-color: var(--red); color: var(--ink); }
.blank { display: inline-block; width: calc(var(--n) * .62em); height: .85em; border-bottom: 2px solid var(--ink); vertical-align: baseline; margin-inline: .12em; position: relative; top: .05em; }

/* board */
.board-card { background: var(--surface); border: 2px solid var(--edge); border-radius: 12px; box-shadow: 5px 5px 0 var(--edge); padding: clamp(10px, 2.2vw, 22px); }
.bw { container-type: inline-size; overflow-x: auto; overflow-y: hidden; }
.board {
  --cw: clamp(26px, calc(100cqw / var(--cols)), 44px);
  --ch: var(--cw);
  --rg: 6px;
  position: relative; width: calc(var(--cols) * var(--cw)); margin-inline: auto;
  display: grid; row-gap: var(--rg); padding-block: var(--rg);
  outline: none;
}
@container (max-width: 620px) {
  .board { --ch: calc(var(--cw) * 1.4); --rg: 5px; }
  .cell { font-size: calc(var(--ch) * .52); }
  .cell .n { font-size: 9px; }
}
.row { display: grid; grid-template-columns: repeat(var(--cols), var(--cw)); height: var(--ch); }
.cell {
  position: relative; display: grid; place-items: center;
  background: var(--cell); border: 1.5px solid var(--edge);
  font: 700 calc(var(--cw) * .62)/1 var(--f-hand); color: var(--ink);
  cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, color .15s;
}
.board.intro .cell { animation: cell-in .5s calc(var(--r) * 65ms + var(--c) * 14ms) var(--ease) both; }
.cell .ch { display: block; transform: translateY(-.04em); }
.cell.cont { border-left-width: 0; }
.cell.brk { border-right: 3px solid var(--edge); }
.cell.key { background: var(--key-cell); }
.row.active .cell { background: var(--hl-word); }
.row.active .cell.key { background: color-mix(in srgb, var(--hl-word) 55%, var(--red-soft)); }
@media (hover: hover) { .cell:hover { background: color-mix(in srgb, var(--hl-word) 70%, var(--cell)); } }
.cell.cur, .cell.cur:hover, .row.active .cell.cur, .row.active .cell.cur.wrong, .row.solved.active .cell.cur { background: var(--hl); color: var(--hl-ink); }
.cell .n { position: absolute; top: 1px; left: 2px; font: 600 max(7px, calc(var(--cw) * .26))/1 var(--f-mono); color: var(--ink-2); pointer-events: none; }
.cell.cur .n { color: var(--hl-ink); }
.cell.rev .ch { color: var(--rev); font-style: italic; }
.cell.wrong { background: repeating-linear-gradient(135deg, var(--red-soft) 0 3px, transparent 3px 7px), var(--cell); color: var(--bad); animation: shake .4s both; }
.row.active .cell.wrong { background: repeating-linear-gradient(135deg, var(--red-soft) 0 3px, transparent 3px 7px), var(--hl-word); }
.cell.cur.wrong { background: var(--hl); }
.cell.good { animation: good .7s both; }
.row.solved .cell:not(.key):not(.cur) { background: var(--ok-soft); }
.row.solved .cell:not(.cur) { color: var(--ok); }
.row.solved.active .cell:not(.key):not(.cur) { background: color-mix(in srgb, var(--ok-soft) 70%, var(--hl-word)); }
.row.flip .cell { animation: flip .55s calc(var(--c) * 45ms) var(--ease) both; }
.cell.pop .ch { animation: pop .22s var(--ease); }

.spine {
  position: absolute; top: 0; bottom: 0; left: calc(var(--left) * var(--cw)); width: var(--cw);
  border: 2.5px solid var(--red); border-radius: 5px; pointer-events: none; transform-origin: top;
  transition: box-shadow .5s;
}
.board.intro .spine { animation: spine-in .8s .25s var(--ease) both; }
.spine.done { box-shadow: 0 0 0 4px var(--red-soft), 0 0 22px color-mix(in srgb, var(--red) 55%, transparent); }

.swipe-hint { display: none; margin-top: 10px; font: 500 .76rem/1.3 var(--f-mono); color: var(--ink-2); text-align: center; }
.solved-banner { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 14px 16px; border: 2px solid var(--ok); border-radius: 10px; background: var(--ok-soft); animation: view-in .5s var(--ease) both; }
.solved-banner[hidden] { display: none; }
.solved-banner p { flex: 1 1 260px; font-weight: 600; color: var(--ink); }
.solved-banner .kw { font-family: var(--f-display); font-weight: 800; letter-spacing: .04em; color: var(--red); }

/* clue list */
.clues { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin-top: 22px; }
.clue-item { display: grid; grid-template-columns: 2.1rem minmax(0, 1fr) auto; gap: 10px; align-items: start; width: 100%; text-align: left; background: color-mix(in srgb, var(--surface) 80%, transparent); border: 2px solid transparent; border-bottom-color: var(--grid); border-radius: 8px; padding: 10px 10px; cursor: pointer; transition: background-color .15s, border-color .15s; }
.clue-item:hover { background: var(--surface); border-color: var(--edge); }
.clue-item.active { background: var(--surface); border-color: var(--edge); box-shadow: 3px 3px 0 var(--edge); }
.clue-item .cn { font: 800 1.2rem/1.2 var(--f-display); color: var(--red); }
.clue-item .ct { font-size: .93rem; line-height: 1.45; color: var(--ink); text-wrap: pretty; }
.clue-item .ct .enum { font: 500 .78rem/1 var(--f-mono); color: var(--ink-2); margin-left: .4em; white-space: nowrap; }
.clue-item .ck { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--ink-3); display: grid; place-items: center; margin-top: 2px; transition: background-color .25s, border-color .25s; }
.clue-item .ck svg { width: 12px; height: 12px; fill: none; stroke: var(--on-red); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset .35s .1s var(--ease); }
.clue-item.solved .ck { background: var(--ok); border-color: var(--ok); }
.clue-item.solved .ck svg { stroke: var(--paper); stroke-dashoffset: 0; }
.clue-item .chip { margin-top: 6px; }
.clue-item .ct-wrap { display: grid; gap: 2px; min-width: 0; }

/* ---------- link page ---------- */
.block { margin-top: clamp(28px, 5vw, 52px); display: grid; gap: 12px; }
.bridge { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) clamp(56px, 14vw, 180px) minmax(0, 1fr); margin-top: 8px; }
.ladder { background: var(--surface); border: 2px solid var(--edge); border-radius: 12px; box-shadow: 4px 4px 0 var(--edge); padding: 14px clamp(10px, 2vw, 18px) 12px; display: grid; gap: 4px; align-content: start; }
.ladder-head { display: grid; gap: 8px; padding-bottom: 12px; margin-bottom: 4px; border-bottom: 2px dashed var(--grid); }
.ladder-head .secret-boxes { gap: 3px; }
.ladder-head .sl { width: clamp(15px, 3.6vw, 28px); font-size: clamp(.78rem, 2vw, 1.1rem); border-width: 2px; }
.rung { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 3px 0; position: relative; }
.rung .rn { font: 500 .7rem/1 var(--f-mono); color: var(--ink-3); width: 1.2rem; flex: none; }
.word { display: flex; flex-wrap: wrap; gap: 1px; font: 500 clamp(.68rem, 1.8vw, .9rem)/1.1 var(--f-mono); }
.word .l { display: inline-grid; place-items: center; min-width: 1ch; height: 1.5em; padding-inline: 1px; border-bottom: 2px solid var(--ink-3); color: transparent; transition: color .3s, border-color .3s; }
.word .l.sp { border: 0; min-width: .6ch; }
.word .l.k { border-bottom-color: var(--red); }
.rung.solved .l { color: var(--ink); border-bottom-color: var(--ok); }
.rung.solved .l.k { color: var(--red); font-weight: 500; border-bottom-color: var(--red); }
.rung.shared::after { content: ""; position: absolute; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: var(--red); }
.ladder.a .rung.shared::after { right: -15px; }
.ladder.b .rung.shared::after { left: -15px; }
.lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.lines path { fill: none; stroke: var(--red); stroke-width: 2.5; stroke-linecap: round; }
.lines path.dim { stroke-dasharray: .018 .03; stroke-width: 2; opacity: .55; }
.lines path.live { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s var(--ease) forwards; }
.lines path.live.static { animation: none; stroke-dashoffset: 0; }

.map-head { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; align-items: end; }
.meter { display: flex; align-items: center; gap: 10px; font: 500 .85rem/1 var(--f-mono); color: var(--ink-2); }
.meter .bar { width: 120px; height: 8px; border: 2px solid var(--edge); border-radius: 99px; overflow: hidden; background: var(--surface); }
.meter .bar i { display: block; height: 100%; width: 0; background: var(--red); transition: width .6s var(--ease); }
.map { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 8px; align-items: start; }
.grp { background: var(--surface); border: 2px solid var(--edge); border-radius: 12px; box-shadow: 4px 4px 0 var(--edge); padding: 16px; display: grid; gap: 12px; }
.grp-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; }
.grp-step { font: 800 1.9rem/1 var(--f-display); color: var(--red); }
.grp-head h4 { margin: 0; font: 700 1.15rem/1.2 var(--f-display); }
.grp-count { font: 500 .78rem/1 var(--f-mono); color: var(--ink-2); }
.grp-lede { grid-column: 2 / -1; color: var(--ink-2); font-size: .9rem; line-height: 1.45; }
.terms { display: grid; gap: 8px; }
.term { border: 2px solid var(--grid); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; transition: border-color .3s, background-color .3s; }
.term-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.term-name { font: 700 1rem/1.2 var(--f-display); }
.term .lock { width: 16px; height: 16px; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.term .lock-open { display: none; }
.term-body { color: var(--ink-2); font-size: .9rem; line-height: 1.5; text-wrap: pretty; }
.term .refs { display: flex; flex-wrap: wrap; gap: 6px; }
.term.locked .term-name { color: transparent; background: repeating-linear-gradient(90deg, var(--grid) 0 6px, transparent 6px 9px); border-radius: 3px; width: 9ch; height: 1.1em; user-select: none; }
.term.locked .term-body { font-size: .82rem; }
.term.locked .refs button { cursor: pointer; }
.term.unlocked { border-color: var(--ok); background: color-mix(in srgb, var(--ok-soft) 45%, var(--surface)); }
.term.unlocked .lock-shut { display: none; }
.term.unlocked .lock-open { display: block; stroke: var(--ok); }
.term.just { animation: unlock .9s var(--ease); }
.chip-btn { cursor: pointer; font: inherit; }
button.chip:hover { background: var(--hl-word); }

.thread { border: 2px solid var(--edge); border-radius: 14px; background: var(--surface); box-shadow: 5px 5px 0 var(--edge); padding: clamp(18px, 3.2vw, 32px); }
.thread.locked { border-style: dashed; box-shadow: none; background: color-mix(in srgb, var(--surface) 55%, transparent); }
.thread h3 { margin-bottom: 4px; }
.thread-words { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 14px 0 12px; }
.thread-words .plus { font: 800 1.8rem/1 var(--f-display); color: var(--ink-3); }
.thread-words .secret-boxes .sl { width: clamp(22px, 4.4vw, 34px); }
.thread p.body { max-width: 66ch; text-wrap: pretty; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.stat { border: 2px solid var(--edge); border-radius: 8px; padding: 8px 12px; background: var(--paper); display: grid; gap: 2px; min-width: 110px; }
.stat b { font: 500 1.1rem/1 var(--f-mono); font-variant-numeric: tabular-nums; }
.stat span { font: 500 .7rem/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }

/* ---------- footer, toast, dialog ---------- */
.foot { border-top: 2px solid var(--edge); background: var(--surface); padding-block: 22px calc(22px + env(safe-area-inset-bottom, 0px)); }
.foot-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; align-items: center; font-size: .88rem; color: var(--ink-2); }
.foot-note { flex: 1 1 320px; }

#kb { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; font-size: 16px; pointer-events: none; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 24px); max-width: min(92vw, 460px); background: var(--ink); color: var(--paper); border-radius: 10px; padding: 12px 16px; font-weight: 600; font-size: .92rem; opacity: 0; pointer-events: none; z-index: 70; transition: opacity .25s, transform .35s var(--ease); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

dialog { border: 2px solid var(--edge); border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: 6px 6px 0 var(--edge); padding: 0; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(8, 14, 28, .55); backdrop-filter: blur(3px); }
dialog[open] { animation: view-in .3s var(--ease) both; }
.help-in { padding: 24px; display: grid; gap: 16px; }
.help-list { display: grid; gap: 10px; }
.help-list li { padding-left: 18px; position: relative; line-height: 1.5; }
.help-list li::before { content: ""; position: absolute; left: 0; top: .6em; width: 8px; height: 8px; background: var(--red); border-radius: 1px; }
.help-in .btn { justify-self: start; }

/* ---------- keyframes ---------- */
@keyframes attn { 0%, 100% { box-shadow: 3px 3px 0 var(--edge), 0 0 0 0 color-mix(in srgb, var(--red) 55%, transparent); } 50% { box-shadow: 3px 3px 0 var(--edge), 0 0 0 7px color-mix(in srgb, var(--red) 0%, transparent); } }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes amp-in { 0% { opacity: 0; transform: translateY(.4em) rotate(-24deg) scale(.6); } 70% { transform: translateY(-.04em) rotate(6deg) scale(1.06); } 100% { opacity: 1; transform: none; } }
@keyframes bar-in { from { transform: scaleX(0); opacity: 0; } to { transform: none; } }
@keyframes spine-in { from { transform: scaleY(0); } to { transform: none; } }
@keyframes glint { 0%, 6%, 100% { background-color: var(--edge); } 2.5% { background-color: var(--red); } }
@keyframes cell-in { from { opacity: 0; transform: translateY(8px) scale(.8); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: translateY(-.04em) scale(.5); } 60% { transform: translateY(-.04em) scale(1.25); } 100% { transform: translateY(-.04em) scale(1); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-3px); } 40% { transform: translateX(3px); } 60% { transform: translateX(-2px); } 80% { transform: translateX(2px); } }
@keyframes good { 0% { box-shadow: inset 0 0 0 0 var(--ok); } 30% { box-shadow: inset 0 0 0 99px var(--ok-soft); } 100% { box-shadow: inset 0 0 0 0 transparent; } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); background-color: var(--ok); } 100% { transform: rotateX(0); } }
@keyframes hop { 0% { transform: translateY(0); } 40% { transform: translateY(-12px) rotate(-4deg); } 100% { transform: none; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes unlock { 0% { transform: scale(.97); box-shadow: 0 0 0 0 var(--ok); } 40% { transform: scale(1.02); box-shadow: 0 0 0 8px color-mix(in srgb, var(--ok) 30%, transparent); } 100% { transform: none; box-shadow: 0 0 0 0 transparent; } }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .hero-in { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .hero-art { justify-content: flex-start; }
  .map { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .p-head { grid-template-columns: minmax(0, 1fr); }
  .clues { grid-template-columns: minmax(0, 1fr); }
  .clue-num { font-size: 1.6rem; }
  .swipe-hint { display: block; }

  .top-in { padding-block: 10px 2px; gap: 8px; }
  .hero-art { display: none; }
  .hero-in { padding-block: 14px 22px; gap: 0; }
  h1 { font-size: clamp(2.7rem, 15vw, 3.6rem); margin-top: 10px; }
  .lede { margin-top: 12px; font-size: 1rem; }
  .cta { margin-top: 18px; flex-wrap: nowrap; }
  .cta .btn { flex: 1 1 0; padding: .95rem .6rem; font-size: 1rem; }
  .cta .btn-primary { flex: 1.4 1 0; }

  /* the tab bar scrolls away on phones so the clue bar can own the top of the screen */
  .tabbar { position: static; }
  .tabs { gap: 8px; padding-block: 10px 12px; }
  .tab { flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 9px 4px 10px; }
  .tab .t-ico, .tab .t-sub { display: none; }
  .tab.locked .t-ico { display: grid; width: 22px; height: 22px; border: 0; }
  .tab.locked .t-ico svg { width: 16px; height: 16px; }
  .tab .t-text { flex: none; }
  .tab .t-name { font-size: .92rem; }
  .view { padding-block: 18px 40px; }

  h2 { font-size: 1.7rem; }
  .p-head { gap: 14px; margin-bottom: 14px; }
  .sec-lede { font-size: .95rem; }
  .secret-boxes { gap: 4px; }
  .sl { width: auto; flex: 1 1 0; max-width: 38px; }

  .toolbar { display: grid; gap: 12px; }
  .tb-main { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .tb-main .btn, .tb-main details.menu summary { width: 100%; padding: .85rem .6rem; font-size: 1rem; }
  details.menu summary { display: flex; }
  .menu-panel { left: auto; right: 0; min-width: min(260px, 80vw); }
  .tb-side { justify-content: space-between; gap: 10px; }
  .tb-side .grow { display: none; }

  .clue-bar { padding: 9px 12px; gap: 2px 12px; margin-bottom: 12px; box-shadow: 0 3px 0 var(--edge); }
  .clue-text { font-size: .92rem; line-height: 1.38; }
  .clue-meta { font-size: .72rem; gap: 10px; }
  .clue-meta .bridge-chip { display: none; }
  .board-card { padding: 12px 8px 12px; border-radius: 12px; box-shadow: 4px 4px 0 var(--edge); }
  .bw { padding-inline: 2px; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .cell { scroll-margin-top: 150px; scroll-margin-bottom: 60px; }
  .clues { margin-top: 18px; }
  .rung .rn { display: none; }

  .bridge { grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr); }
  .ladder { --lp: 8px; min-width: 0; box-shadow: 3px 3px 0 var(--edge); }
  .ladder-head .secret-label { font-size: .62rem; letter-spacing: .06em; }
  .ladder-head .secret-boxes { gap: 2px; }
  .ladder-head .sl { min-width: 0; overflow: hidden; width: auto; flex: 1 1 0; max-width: none; border-width: 1.5px; border-radius: 3px; font-size: .7rem; }
  .map-head { align-items: start; }
  .grp { padding: 14px 12px; }
}
@media (max-width: 480px) {
  .brand > span { font-size: 1rem; }
  .brand-mark { width: 26px; height: 26px; }
  .help-btn span { display: none; }
  .help-btn { padding: .6rem .7rem; }
  .lang button { padding: .55rem .6rem; }
  .top-actions { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .lines path.live { stroke-dashoffset: 0; }
}


