:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #ffffff;
  --well: #e9e7e0;          /* recessed areas: empty slots, tracks */
  --border: #e3e1d9;
  --border-strong: #c9c6bb;
  --text: #16161a;
  --text-2: #55545b;
  --muted: #8f8e95;
  --grid: #efede7;
  --accent: #2b6fe0;
  --good: #14823f;
  --good-bg: #e0f2e6;
  --bad: #c4412c;
  --bad-bg: #fae5e0;
  --hint-bg: #f6f4ee;
  --warn: #8a5a00;
  --warn-bg: #fbecbf;
  --ink: #16161a;           /* primary buttons and active controls */
  --on-ink: #ffffff;
  --shadow-sm: 0 1px 2px rgba(22, 22, 30, .06), 0 1px 1px rgba(22, 22, 30, .03);
  --shadow-md: 0 1px 2px rgba(22, 22, 30, .05), 0 8px 20px -10px rgba(22, 22, 30, .16);
  --shadow-lift: 0 18px 36px -10px rgba(22, 22, 30, .32), 0 3px 8px rgba(22, 22, 30, .1);
  --serif: "Literata", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.3, 1.5, .5, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0f11;
    --surface: #19191c;
    --well: #222226;
    --border: #2a2a2f;
    --border-strong: #43434a;
    --text: #f4f4f5;
    --text-2: #b6b6bd;
    --muted: #7e7e87;
    --grid: #242428;
    --accent: #6ea4ff;
    --good: #4cc47a;
    --good-bg: #13291c;
    --bad: #f0806c;
    --bad-bg: #331a15;
    --hint-bg: #1f1f23;
    --warn: #f0c75e;
    --warn-bg: #3b300f;
    --ink: #f4f4f5;
    --on-ink: #111113;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 20px -10px rgba(0, 0, 0, .6);
    --shadow-lift: 0 18px 36px -10px rgba(0, 0, 0, .7), 0 3px 8px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
header, main, footer { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
svg.defs { position: absolute; }
.g-accent { stop-color: var(--accent); }
.g-good { stop-color: var(--good); }

/* ---- Top bar ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 18px; padding-bottom: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; color: var(--text); cursor: pointer; border-radius: 8px; }
.mark { width: 30px; height: 30px; display: block; }
.mark rect { fill: var(--ink); }
.mark path { fill: none; stroke: var(--on-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
h1 { margin: 0; font: 650 1.6rem/1 var(--serif); letter-spacing: -.02em; }
.stats { display: flex; gap: 22px; margin: 0; }
.stat { display: flex; align-items: baseline; gap: 7px; }
.stat-label { font-size: .72rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.stat b { font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.how { text-align: center; color: var(--text-2); font-size: .95rem; margin: 10px auto 22px; max-width: 620px; text-wrap: balance; }

.tabs { display: inline-flex; gap: 2px; }
.tab { font-size: .85rem; font-weight: 500; padding: 5px 12px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; transition: color .15s, background-color .15s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--well); }
.fine { margin: 8px 0 0; font-size: .8rem; color: var(--muted); }
.link-btn { font: inherit; background: none; border: 0; padding: 0; color: var(--text-2); cursor: pointer; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); text-decoration-color: currentColor; }

/* ---- Board: graphs across the top, each word slot directly beneath its graph ---- */
.board {
  --gutter: clamp(26px, 3.4vw, 44px);
  --gap: clamp(5px, .8vw, 10px);
  display: grid;
  grid-template-columns: var(--gutter) repeat(var(--cols, 4), minmax(0, 1fr)) var(--gutter);
  gap: 8px var(--gap);
  max-width: calc(var(--cols, 4) * 262px + 2 * var(--gutter) + (var(--cols, 4) + 1) * var(--gap));
  margin: 0 auto; align-items: stretch;
}
.card {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 10px 6px; margin-bottom: 4px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: border-color .3s, box-shadow .3s, transform .3s var(--ease-out);
}
.card.target:hover, .card.drop-target { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-md); transform: translateY(-2px); }
.card.correct { cursor: default; transition-delay: calc(var(--i, 0) * 80ms); }
.card.correct { border-color: var(--good); box-shadow: 0 0 0 1px var(--good), var(--shadow-sm); }
.card-top { position: absolute; top: 6px; right: 6px; z-index: 1; display: flex; gap: 2px; }
.chart-caption { display: none; font-size: .62rem; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }

svg.chart { width: 100%; height: auto; display: block; touch-action: pan-y; overflow: visible; }
svg.chart text { fill: var(--muted); font-size: 10.5px; font-family: var(--sans); font-variant-numeric: tabular-nums; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
svg.chart .axis { stroke: var(--border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; transition: stroke .4s; transition-delay: inherit; }
svg.chart .area { fill: url(#area-accent); stroke: none; }
svg.chart .peak-mark { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
svg.chart .peak-dot { fill: var(--accent); }
svg.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
svg.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
/* Revealed scale: darker axis numbers, and the peak marked with its height. */
svg.chart text.scale { fill: var(--text-2); font-weight: 600; }
svg.chart .peak-guide { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 2 3; opacity: .7; vector-effect: non-scaling-stroke; }
svg.chart .peak-pt { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
svg.chart .peak-tag { fill: var(--accent); }
svg.chart text.peak-text { fill: var(--on-ink); font-weight: 700; font-size: 12.5px; letter-spacing: -.01em; }
.card.correct svg.chart .peak-guide { stroke: var(--good); }
.card.correct svg.chart .peak-pt, .card.correct svg.chart .peak-tag { fill: var(--good); }
.chart-caption.on { color: var(--accent); font-weight: 700; font-size: .68rem; }
.card.correct svg.chart .line { stroke: var(--good); }
.card.correct svg.chart .area { fill: url(#area-good); }
.card.correct svg.chart .dot { fill: var(--good); }

.guess-row {
  grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; border-radius: 14px;
  transition: background-color .25s, box-shadow .25s;
}
/* The logic helper: a band behind each past guess once the board is full — green if the
   arrangement fits that guess's score, yellow if it can't. */
.guess-row.fits { background: var(--good-bg); box-shadow: 0 0 0 4px var(--good-bg); }
.guess-row.conflict { background: var(--warn-bg); box-shadow: 0 0 0 4px var(--warn-bg); }
.guess-row.fits .row-n { color: var(--good); }
.guess-row.conflict .row-n { color: var(--warn); }
.guess-row.fits .guess-cell, .guess-row.conflict .guess-cell { background: color-mix(in srgb, var(--surface) 55%, transparent); }
.guess-row.answers .row-n { color: var(--accent); font-size: 1rem; }
.row-n, .score-cell { display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.row-n { font-size: .78rem; font-weight: 600; color: var(--muted); }
.row-n.current { color: var(--text); }
.row-n.future, .score-cell.future { opacity: .45; }
.score-cell { font-size: clamp(.78rem, 1.4vw, .95rem); color: var(--muted); font-weight: 500; }
.score-cell b { color: var(--text); font-weight: 700; font-size: 1.15em; }

/* A word wherever it appears: bank chip, placed tile, drag ghost. */
.chip, .token, .drag-ghost {
  font: 600 1rem/1.2 var(--serif); letter-spacing: -.005em; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 11px;
  box-shadow: var(--shadow-sm);
}
.guess-cell, .slot-cell {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 48px; border-radius: 12px; overflow-wrap: anywhere; hyphens: auto;
  font: 500 clamp(.74rem, 1.55vw, .98rem)/1.2 var(--serif);
}
.guess-cell { padding: 6px; background: color-mix(in srgb, var(--well) 70%, transparent); color: var(--text-2); transition: background-color .25s, color .25s; }
.guess-cell.loadable { cursor: pointer; }
.guess-cell.loadable:hover { box-shadow: inset 0 0 0 1.5px var(--border-strong); }
.guess-cell.ok { background: var(--good-bg); color: var(--good); font-weight: 600; }
.guess-cell.bad { background: var(--bad-bg); color: var(--bad); }
/* Mid-round (exact feedback) wrong words are also struck through; once the round is over red alone says it. */
.guess-cell.bad.loadable { text-decoration: line-through; text-decoration-thickness: 1px; }
.guess-cell.win { background: var(--good-bg); color: var(--good); font-weight: 600; }
.guess-cell.future { background: color-mix(in srgb, var(--well) 38%, transparent); }
.guess-cell.answer { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); }

.slot-cell {
  flex-direction: column; gap: 4px; padding: 2px; cursor: pointer;
  background: color-mix(in srgb, var(--well) 55%, transparent);
  border: 1.5px dashed var(--border-strong);
  transition: border-color .2s, background-color .2s;
}
.slot-cell.target { border-color: color-mix(in srgb, var(--accent) 60%, var(--border-strong)); animation: invite 1.4s ease-in-out infinite; }
.slot-cell.filled { background: none; border-color: transparent; padding: 0; animation: none; }
.slot-cell.target:hover, .slot-cell.drop-target { background-color: color-mix(in srgb, var(--accent) 12%, transparent); border-color: var(--accent); border-style: solid; animation: none; }
.slot-cell.correct { cursor: default; background: var(--good-bg); color: var(--good); font-weight: 600; border: 1.5px solid var(--good); flex-direction: row; gap: 6px; padding: 6px; }
.slot-cell.wrong .token { border-color: var(--bad); color: var(--bad); }
.token {
  flex: 1; align-self: stretch; display: flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 5px 6px; font-size: inherit; cursor: grab; touch-action: none;
  transition: box-shadow .2s, transform .2s var(--ease-out), border-color .2s;
}
.token:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.flying { position: relative; z-index: 6; box-shadow: var(--shadow-md); }
.dragging { opacity: .25; }
.check-btn { font: 600 .74rem var(--sans); padding: 3px 10px; margin-bottom: 3px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; }
.check-btn:hover { border-color: var(--text); }
.icon { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Status line, word bank, actions ---- */
.status-line { display: flex; align-items: center; justify-content: center; min-height: 2.6rem; margin: 6px auto 2px; max-width: 760px; text-align: center; }
.status-line > * { margin: 0; font-size: .95rem; color: var(--text-2); animation: rise .3s var(--ease-out) both; text-wrap: balance; }
.selected-def b { font-family: var(--serif); color: var(--text); }
.submit-note { color: var(--warn) !important; font-weight: 500; }
.result { font-weight: 500; }
.verdict {
  display: inline-flex; align-items: center; gap: 14px; padding: 10px 26px 10px 10px; border-radius: 999px;
  text-align: left; animation: verdict-in .5s var(--ease-spring) both; animation-delay: .25s;
}
.verdict-badge { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; color: #fff; font-size: 1.3rem; }
.verdict-badge .icon { stroke-width: 2.4; }
.verdict-text { display: flex; flex-direction: column; line-height: 1.25; }
.verdict-text b { font: 650 1.35rem/1.2 var(--serif); letter-spacing: -.01em; }
.verdict-text span { font-size: .88rem; color: var(--text-2); }
.verdict.win { background: var(--good-bg); }
.verdict.win .verdict-badge { background: var(--good); }
.verdict.win b { color: var(--good); }
.verdict.loss { background: var(--bad-bg); }
.verdict.loss .verdict-badge { background: var(--bad); }
.verdict.loss b { color: var(--bad); }

.words { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 6px; border-radius: 16px; transition: background-color .2s, box-shadow .2s; }
.words.drop-target { background: color-mix(in srgb, var(--accent) 8%, transparent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.chip-wrap { position: relative; display: inline-flex; }
.chip {
  padding: 10px 18px; cursor: grab; display: inline-flex; align-items: center; gap: 6px; font-size: 1.05rem;
  transition: transform .2s var(--ease-out), box-shadow .2s, border-color .2s, background-color .2s, color .2s;
}
.chip:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.chip:active:not(:disabled) { transform: translateY(0); }
.chip:not(:disabled) { touch-action: none; }
.chip:disabled { cursor: default; }
.chip.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), var(--shadow-md); transform: translateY(-2px); }
.chip.placed, .chip.locked { background: transparent; border-style: dashed; box-shadow: none; color: var(--muted); font-weight: 500; }
.chip.placed.selected { border-style: solid; color: var(--text); }
.chip.locked { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.chip .tag { font: 600 .72rem var(--sans); color: var(--muted); }
.chip.small { font-size: .9rem; padding: 6px 12px; border-radius: 9px; }
.drag-ghost { position: fixed; z-index: 20; pointer-events: none; padding: 10px 18px; font-size: 1.05rem; transform: translate(-50%, -120%) rotate(-3deg) scale(1.04); box-shadow: var(--shadow-lift); border-color: var(--accent); animation: lift .18s var(--ease-out); }

.actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; margin: 18px 0 0; }
/* Share sits beside Next round at the same size. */
#share { font-size: 1rem; padding: 11px 24px; min-width: 9.5em; transition: border-color .15s, background-color .2s, color .2s; }
#share.done { background: var(--good-bg); border-color: var(--good); color: var(--good); }
button.primary {
  font-size: 1rem; font-weight: 600; padding: 12px 34px; border-radius: 999px; border: 0;
  background: var(--ink); color: var(--on-ink); cursor: pointer;
  transition: transform .15s var(--ease-out), opacity .2s, box-shadow .2s;
}
button.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-md); }
button.primary:active:not(:disabled) { transform: scale(.97); }
button.primary:disabled { opacity: .28; cursor: not-allowed; }
button.ghost { font-size: 1rem; font-weight: 500; padding: 12px 20px; border-radius: 999px; border: 0; background: none; color: var(--text-2); cursor: pointer; transition: background-color .15s, color .15s, opacity .2s; }
button.ghost:hover:not(:disabled) { background: var(--well); color: var(--text); }
button.ghost:disabled { opacity: .35; cursor: default; }
#next span { display: inline-block; transition: transform .2s var(--ease-out); }
#next:hover span { transform: translateX(3px); }

.hints { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 8px; margin: 22px 0 0; }
.hint { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; padding: 4px 11px 4px 9px; border-radius: 999px; color: var(--muted); border: 1px solid transparent; transition: color .3s, background-color .3s, border-color .3s; }
.hint.on { background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 500; }
.hint.on .icon { color: var(--accent); }
.hint.fresh { animation: pop .5s var(--ease-spring) both; }

.definitions {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 18px; margin: 22px auto 0; max-width: 860px;
  display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .95rem;
}
.definitions dt { font: 600 1rem var(--serif); display: flex; align-items: center; }
.definitions dd { margin: 0; color: var(--text-2); }
.pos { font-style: italic; font-family: var(--serif); color: var(--muted); margin-right: 5px; }
@media (max-width: 560px) {
  .definitions { grid-template-columns: 1fr; }
  .definitions dd { margin-bottom: 8px; }
}

/* ---- Motion ---- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes lift { from { transform: translate(-50%, -100%) scale(.96); box-shadow: var(--shadow-sm); } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } }
@keyframes wipe { from { clip-path: inset(-10% 100% -10% -5%); } to { clip-path: inset(-10% -5% -10% -5%); } }
@keyframes stamp { from { opacity: 0; transform: scale(.94); } }
@keyframes hop { 0%, 100% { transform: none; } 40% { transform: translateY(-9px); } }
@keyframes invite { 50% { background-color: color-mix(in srgb, var(--accent) 9%, transparent); } }
@keyframes lock-in { 0% { transform: scale(.92); } 60% { transform: scale(1.04); } }
@keyframes fade { from { opacity: 0; } }
@keyframes peak-in { from { opacity: 0; transform: scale(.4); } }
@keyframes verdict-in { from { opacity: 0; transform: scale(.85); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.card.enter { animation: rise .5s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }
.card.enter .plot { animation: wipe 1s cubic-bezier(.45, 0, .2, 1) both; animation-delay: calc(var(--i, 0) * 110ms + 180ms); }
.card .labels-in { animation: fade .6s ease both; }
/* The peak tag lands with a bounce when the scale is revealed. */
.card svg.chart .peak.peak-in { animation: peak-in .55s var(--ease-spring) both; animation-delay: .15s; transform-box: fill-box; transform-origin: center; }
.words.enter .chip-wrap { animation: rise .45s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 50ms + 350ms); }
.guess-cell.stamp { animation: stamp .35s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 45ms); }
.score-cell.pop b, .score-cell.pop span { display: inline-block; }
.score-cell.pop { animation: pop .5s var(--ease-spring) both; animation-delay: calc(var(--cols, 4) * 45ms + 60ms); }
.guess-cell.celebrate { animation: hop .55s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 80ms + 150ms); }
.guess-row.shake { animation: shake .45s ease-in-out both; }
.guess-cell.answer.stamp { animation-delay: calc(var(--i, 0) * 90ms + 250ms); }
.slot-cell.lock-in { animation: lock-in .45s var(--ease-out) both; }

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

/* ---- Rules & sharing ---- */
.creator { max-width: 880px; margin: 14px auto 0; display: flex; flex-direction: column; gap: 12px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow-sm); }
.panel h2 { font: 600 1.1rem var(--serif); letter-spacing: -.01em; margin: 0 0 10px; }
.panel-hint { color: var(--text-2); font-size: .9rem; margin: 10px 0 0; max-width: 68ch; }
.panel h2 + .panel-hint { margin: -4px 0 12px; }
.field { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 0; }
.field-label { font-size: .9rem; color: var(--text-2); min-width: 120px; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 11px; background: var(--well); }
.seg { font-size: .9rem; font-weight: 500; min-width: 36px; padding: 6px 13px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; transition: background-color .15s, color .15s; }
.seg:hover { color: var(--text); }
.seg.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.peak-slider { width: min(320px, 60vw); accent-color: var(--ink); }
.peak-value { font-size: .9rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.peak-value.bad { color: var(--bad); }
.hint-board { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.hint-col { flex: 1 0 130px; min-height: 120px; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; background: color-mix(in srgb, var(--well) 50%, transparent); box-shadow: inset 0 0 0 1px var(--border); transition: background-color .15s, box-shadow .15s; }
.hint-col.off { background: none; box-shadow: inset 0 0 0 1px var(--border); }
.hint-col.drop { box-shadow: inset 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.hint-col-title { font-size: .7rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.hint-card { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 10px; cursor: grab; display: flex; flex-direction: column; gap: 2px; font-size: .8rem; line-height: 1.35; color: var(--text-2); box-shadow: var(--shadow-sm); touch-action: none; transition: transform .2s var(--ease-out), box-shadow .2s; }
.hint-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.hint-card b { color: var(--text); font-size: .9rem; }
.hint-card.dragging { opacity: .4; }
.hint-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 8px; margin-top: 12px; }
.pick-row { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.pick-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pick-controls .pick-input { flex: 1; min-width: 0; width: auto; }
.pick-controls .pick-status { flex-basis: 100%; font-size: .8rem; min-height: 1.2em; margin-top: -2px; }
.pick-preview { min-height: 40px; }
.pick-preview:empty::before { content: "Graph appears when the word is valid"; display: block; font-size: .8rem; color: var(--muted); text-align: center; padding: 12px 0; }
.pick-preview svg.chart { max-width: 190px; margin: 0 auto; }
.pick-input { font: 500 1rem var(--serif); padding: 8px 10px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); width: min(260px, 60vw); }
.pick-input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.dice { font-size: 1.1rem; background: none; border: 0; cursor: pointer; padding: 2px 4px; border-radius: 6px; transition: transform .3s var(--ease-spring); }
.dice:hover { transform: rotate(20deg) scale(1.1); }
.pick-status { font-size: .85rem; }
.pick-status.ok { color: var(--good); font-weight: 700; }
.pick-status.bad { color: var(--bad); }
.suggestions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; }
.hidden-words { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; color: var(--text-2); font-size: .9rem; }
button.secondary { font-size: .9rem; font-weight: 600; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; transition: border-color .15s, opacity .2s; }
button.secondary:hover:not(:disabled) { border-color: var(--text); }
button.secondary:disabled { opacity: .4; cursor: not-allowed; }
.creator-actions { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.share-row { display: flex; gap: 8px; }
.share-url { flex: 1; min-width: 0; font: .85rem ui-monospace, "Cascadia Code", Consolas, monospace; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.saved-intro .action-row { gap: 10px 14px; }
.saved-intro button.primary { font-size: .9rem; padding: 9px 20px; }

/* ---- Pick words (dev tool) ---- */
.pick-top { position: sticky; top: 0; z-index: 4; padding: 10px 0 10px; margin-bottom: 10px; background: var(--bg); border-bottom: 1px solid var(--border); }
.pick-tray-row { display: flex; align-items: stretch; gap: 14px; }
.pick-tray { flex: 1; display: grid; grid-template-columns: repeat(var(--slots, 4), minmax(0, 1fr)); gap: 8px; }
.tray-slot { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 6px 8px; box-shadow: var(--shadow-sm); }
.tray-slot.empty {
  display: grid; place-items: center; min-height: 92px; padding: 0; color: var(--muted); font-size: .8rem;
  background: none; border: 1.5px dashed var(--border-strong); box-shadow: none;
}
.tray-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.tray-head b { font: 600 .95rem var(--serif); overflow-wrap: anywhere; }
/* A squat sparkline: the labels would be stretched out of shape, and the word is right above. */
.tray-slot svg.chart { height: 62px; }
.tray-slot svg.chart text, .tray-slot svg.chart .peak-tag, .tray-slot svg.chart .peak-guide { display: none; }
.tray-drop { font: inherit; font-size: .75rem; line-height: 1; padding: 2px 4px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.tray-drop:hover { color: var(--bad); }
.pick-tray-side { flex: none; width: 190px; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.pick-count { margin: 0; font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pick-tray-side .primary { padding: 10px 18px; font-size: .95rem; }
.pick-tray-buttons { display: flex; align-items: center; gap: 12px; }
.pick-tray-buttons .secondary { font-size: .85rem; padding: 6px 14px; }
.pick-tray-buttons .link-btn { font-size: .85rem; }

.pick-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
#pick-search { flex: 1; min-width: 200px; width: auto; font-family: var(--sans); font-size: .95rem; }
.pick-total { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.pick-card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 10px 4px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .15s var(--ease-out);
}
.pick-card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.pick-card.chosen { border-color: var(--good); box-shadow: 0 0 0 1px var(--good), var(--shadow-sm); }
.pick-card.chosen svg.chart .line { stroke: var(--good); }
.pick-card.chosen svg.chart .area { fill: url(#area-good); }
.pick-card.chosen svg.chart .peak-pt, .pick-card.chosen svg.chart .peak-tag { fill: var(--good); }
.pick-card.chosen svg.chart .peak-guide { stroke: var(--good); }
.pick-card-head { display: flex; align-items: center; gap: 4px; }
.pick-card-head b { flex: 1; min-width: 0; font: 600 1.05rem var(--serif); overflow-wrap: anywhere; }
.pick-peak { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pick-def { margin: 2px 0 6px; font-size: .78rem; line-height: 1.35; color: var(--text-2); }
.pick-add { flex: none; width: 22px; height: 22px; padding: 0; border-radius: 50%; cursor: pointer; border: 1.5px solid var(--border-strong); background: none; color: transparent; }
.pick-add::before { content: "+"; display: block; font-size: .95rem; line-height: 19px; color: var(--text-2); }
.pick-card:hover .pick-add { border-color: var(--text-2); }
.pick-card.chosen .pick-add { background: var(--good); border-color: var(--good); }
.pick-card.chosen .pick-add::before { content: "✓"; font-size: .8rem; color: #fff; }
.pick-more { text-align: center; color: var(--muted); font-size: .85rem; padding: 18px 0; }

@media (max-width: 720px) {
  .pick-tray-row { flex-direction: column; gap: 10px; }
  .pick-tray-side { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .pick-tray { gap: 6px; }
  .tray-slot { padding: 4px 6px; }
  .tray-slot svg.chart { height: 46px; }
  .tray-slot.empty { min-height: 66px; font-size: .7rem; }
  .pick-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  /* Narrow columns: the word takes a line of its own rather than breaking apart. */
  .pick-card-head { flex-wrap: wrap; }
  .pick-card-head b { flex: 1 0 100%; font-size: .95rem; overflow-wrap: normal; }
  .pick-card svg.chart { height: 70px; }
  .pick-card svg.chart text, .pick-card svg.chart .peak-tag { display: none; }   /* the peak is in the card header */
  /* The picker is a dev tool, so its stars and delete buttons stay visible here. */
  .pick-card .star, .pick-card .delete-word { display: inline-block; }
}

/* ---- Saved words ---- */
.star, .delete-word { line-height: 1; background: none; border: 0; padding: 3px 4px; border-radius: 6px; color: var(--muted); cursor: pointer; transition: opacity .15s, color .15s; }
.star { opacity: .45; font-size: .95rem; }
.star:hover, .star.on { opacity: 1; }
.star:hover { color: #d99a00; }
.star.on { color: #e0a100; }
.delete-word { opacity: .4; font-size: .8rem; }
.delete-word:hover { opacity: 1; color: var(--bad); }
/* In the word bank the dev tools float above the chip, and only appear on hover. */
.chip-wrap .star, .chip-wrap .delete-word { position: absolute; top: -13px; z-index: 2; opacity: 0; }
.chip-wrap .star { right: 12px; }
.chip-wrap .delete-word { right: -6px; }
.chip-wrap:hover .star, .chip-wrap:hover .delete-word, .chip-wrap:focus-within .star, .chip-wrap:focus-within .delete-word { opacity: .7; }
.chip-wrap .star.on, .chip-wrap .star:hover, .chip-wrap .delete-word:hover { opacity: 1; }
.definitions dt .star { margin-left: 4px; }
.preview-star { display: flex; justify-content: flex-end; margin-bottom: -18px; position: relative; z-index: 1; }
.deleted-list { max-width: 880px; margin: 0 auto 24px; display: flex; flex-wrap: wrap; gap: 6px; }
.deleted-list .chip { cursor: pointer; }
.saved-foot { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.saved-intro { max-width: 880px; margin: 22px auto 14px; }
.saved-intro h2 { font: 600 1.35rem var(--serif); letter-spacing: -.01em; margin: 0 0 4px; }
.saved-intro p { color: var(--text-2); margin: 0 0 14px; max-width: 68ch; }
.saved-empty { max-width: 880px; margin: 0 auto; color: var(--muted); }
.saved-list { max-width: 880px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.saved-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); }
.saved-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.saved-head b { font: 600 1.1rem var(--serif); }
.saved-date { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.saved-def { margin: 0; font-size: .85rem; color: var(--text-2); }
.saved-card .link-btn { font-size: .85rem; }

/* ---- A graph opened large (phones) ---- */
.zoom {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(10, 10, 12, .6); backdrop-filter: blur(2px);
  animation: fade .2s ease both;
}
.zoom-card {
  width: min(560px, 100%); background: var(--surface); border-radius: 18px; padding: 14px;
  box-shadow: var(--shadow-lift); animation: verdict-in .25s var(--ease-out) both;
}
.zoom-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.zoom-head b { font: 650 1.3rem var(--serif); letter-spacing: -.01em; }
.zoom-chart svg.chart { width: 100%; height: auto; }
.zoom-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.zoom-hint { font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; }
.zoom-btn {
  font: 600 1rem var(--sans); min-width: 46px; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-2); cursor: pointer;
}
.zoom-btn:hover { border-color: var(--border-strong); color: var(--text); }
html.zoomed, html.zoomed body { overflow: hidden; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 40;   /* above the enlarged graph */
  background: var(--ink); color: var(--on-ink);
  border-radius: 8px; padding: 5px 10px; font-size: .8rem; font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-md); white-space: nowrap;
}
.tooltip .y { opacity: .7; }
footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 44px 16px 28px; }

/* ---- Ad slots ----
   Standard IAB sizes, reserved up front: a 320×100 mobile banner that becomes a 728×90
   leaderboard on wider screens, and a 160×600 skyscraper in the right-hand margin once
   the window is wide enough that it can't reach the board. The house banners inside are
   placeholders that AdSense replaces (see ads.js); their colors are the advertisers', so
   they don't follow the page theme. */
.ads { display: flex; flex-direction: column; align-items: center; gap: 22px; max-width: 760px; margin: 12px auto 36px; padding-top: 32px; border-top: 1px solid var(--border); }
.ad { display: flex; flex-direction: column; align-items: center; }
.ad-label { width: 100%; margin: 0 0 5px; text-align: left; font-size: .62rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.ad-box { width: 320px; height: 100px; overflow: hidden; border-radius: 10px; box-shadow: var(--shadow-sm); }
.ad-box.live { background: var(--well); box-shadow: none; }
.ad .ad-label { width: 320px; }
@media (min-width: 780px) {
  .ad .ad-label { width: 728px; }
  .ad-box { width: 728px; height: 90px; }
}

/* Level with the top of the board, and scrolling with the page rather than pinned to the
   screen: AdSense is strict about ads that follow the reader. */
.ad-rail { display: none; position: absolute; z-index: 5; right: 24px; top: 118px; }
.ad.ad-rail .ad-label { width: 160px; }
.ad-rail .ad-box { width: 160px; height: 600px; }
/* The rail needs the board (which widens with more words) plus a 184px margin each side. */
@media (min-width: 1320px) and (min-height: 700px) {
  body[data-cols="3"] .ad-rail { display: flex; }
  body[data-cols="3"] .ad-bottom-2 { display: none; }
}
@media (min-width: 1600px) and (min-height: 700px) {
  body[data-cols="4"] .ad-rail { display: flex; }
  body[data-cols="4"] .ad-bottom-2 { display: none; }
}
@media (min-width: 1860px) and (min-height: 700px) {
  body[data-cols="5"] .ad-rail { display: flex; }
  body[data-cols="5"] .ad-bottom-2 { display: none; }
}

/* House banners */
.house {
  display: flex; align-items: center; gap: 18px; width: 100%; height: 100%; padding: 0 22px;
  text-align: left; text-decoration: none; font-family: var(--sans); line-height: 1.3;
}
.house-logo { width: 56px; height: 56px; flex: none; border-radius: 12px; }
.house-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: .9rem; }
.house-copy b, .house-name { font: 650 1.3rem/1.1 var(--serif); letter-spacing: -.01em; }
.house-cta { flex: none; padding: 10px 20px; border-radius: 999px; font-size: .9rem; font-weight: 600; white-space: nowrap; transition: background-color .15s, transform .15s var(--ease-out); }
.house:hover .house-cta { transform: translateY(-1px); }

.house-ws { background: #eaf6ed; color: #2f4a3b; }
.house-ws .house-logo { border-radius: 50%; }
.house-ws b { color: #0e6e3e; }
.house-ws .house-cta { background: #2aa847; color: #fff; }
.house-ws:hover .house-cta { background: #22913c; }

.house-fm { background: #14171c; color: #b4bcc5; }
@media (prefers-color-scheme: dark) { .house-fm { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); } }
.house-fm b, .house-fm .house-name { color: #fff; }
.house-fm .house-cta { background: #fff; color: #14171c; }
.house-fm:hover .house-cta { background: #d2e4f5; }

/* Skyscraper */
.house-tall { flex-direction: column; justify-content: center; gap: 14px; padding: 24px 14px; text-align: center; }
.house-tall .house-logo { width: 64px; height: 64px; }
.house-line { font-size: .95rem; color: #d7dde3; }
.house-line.small { font-size: .78rem; color: #b4bcc5; }
.house-tall .house-cta { padding: 9px 14px; font-size: .82rem; }
.mini-grid { display: grid; grid-template-columns: repeat(5, 22px); gap: 2px; padding: 2px; margin: 6px 0; background: #14171c; outline: 2px solid #3a414b; border-radius: 2px; }
.mini-grid i { display: grid; place-items: center; height: 22px; background: #fff; color: #14171c; font: 700 11px/1 var(--sans); font-style: normal; }
.mini-grid i.pen { background: #2a5ea5; color: #fff; }

/* Mobile banner: the same creative, tighter, with the whole banner as the button. */
@media (max-width: 779px) {
  .house { gap: 12px; padding: 0 14px; }
  .house:not(.house-tall) .house-logo { width: 48px; height: 48px; }
  .house-copy { font-size: .74rem; gap: 2px; }
  .house-copy b { font-size: 1.05rem; }
  .house:not(.house-tall) .house-cta { display: none; }
}
footer a { color: var(--text-2); text-underline-offset: 3px; }

/* ---- Narrow screens ---- */
@media (max-width: 720px) {
  header, main, footer { padding-left: 10px; padding-right: 10px; }
  .topbar { padding-top: 12px; padding-bottom: 8px; }
  h1 { font-size: 1.4rem; }
  .mark { width: 26px; height: 26px; }
  .stats { gap: 14px; }
  .how { font-size: .85rem; margin: 6px auto 14px; }
  .board { --gutter: 24px; gap: 6px 4px; }
  .card { padding: 5px 4px 3px; border-radius: 10px; margin-bottom: 2px; }
  .card svg.chart { height: 96px; }
  .card::after { content: "⤢"; position: absolute; top: 2px; right: 5px; font-size: .68rem; color: var(--muted); }  /* tap to open it large */
  .card svg.chart text, .card svg.chart .peak-tag { display: none; }   /* illegible this small; the caption gives the peak */
  .card svg.chart .line { stroke-width: 1.75; }
  .chart-caption { display: block; }
  /* Long words shrink to fit their column rather than breaking mid-word. */
  .guess-cell, .slot-cell { min-height: 40px; border-radius: 9px; font-size: clamp(7.5px, calc((100vw - 64px) / var(--cols, 4) / var(--len, 8) * 1.5), .74rem); overflow-wrap: normal; hyphens: manual; }
  .guess-cell { padding: 4px 2px; }
  .token { min-height: 34px; padding: 3px 0; border-radius: 8px; }
  .slot-cell.correct { gap: 3px; padding: 4px 2px; }
  .chip { font-size: .95rem; padding: 9px 14px; }
  .star, .delete-word { display: none; }    /* dev tools stay out of the way on phones */
  .words { gap: 8px; }
  .status-line { min-height: 3.4rem; }
  .status-line > * { font-size: .88rem; }
  .verdict { gap: 10px; padding: 8px 18px 8px 8px; }
  .verdict-badge { width: 34px; height: 34px; font-size: 1.1rem; }
  .verdict-text b { font-size: 1.15rem; }
  .verdict-text span { font-size: .8rem; }
  .hint { font-size: .74rem; }
  .panel { padding: 14px; }
}
@media (max-width: 480px) {
  /* No room for guess numbers: the score column alone stays. */
  .board { grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)) var(--gutter); }
  .row-n { display: none; }
  .card svg.chart { height: 88px; }
  .guess-cell, .slot-cell { min-height: 38px; letter-spacing: -.01em; }
  .chart-caption { font-size: .58rem; }
}
