/* Gambit — base layout & components. Theme tokens live in themes.css. */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font-family: var(--font-body); color: var(--ink); background: var(--bg); background-attachment: fixed;
  line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--link, var(--accent)); text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: .5rem; z-index: 200; padding: .6rem 1rem; background: var(--accent); color: var(--accent-ink); border-radius: var(--radius-sm); font-weight: 700; }
.skip:focus { left: .75rem; }
.only-news, .only-neon, .only-marble, .only-wood { display: none; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: clamp(.5rem, 1.6vw, 1.25rem);
  padding: .55rem clamp(.75rem, 3vw, 2rem); background: var(--header-bg); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.logo { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-size: 1.55rem; font-weight: 700; letter-spacing: .01em; flex: none; }
.logo-mark { width: 34px; height: 34px; fill: var(--accent); transition: transform .4s cubic-bezier(.3, 1.6, .5, 1); }
.logo-mark circle { fill: var(--bg-solid); }
.logo:hover .logo-mark { transform: translate(6px, -10px) rotate(-8deg); }
.logo:active .logo-mark { transform: translate(10px, -4px); }
.masthead { margin: 0; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
.main-nav { display: flex; align-items: center; gap: .2rem; margin-left: auto; flex-wrap: wrap; }
.nav-btn, .nav-link {
  border: 1px solid transparent; background: transparent; color: var(--ink); padding: .45rem .8rem; border-radius: 999px; cursor: pointer;
  font-weight: 600; font-size: .92rem; text-decoration: none; transition: background .2s, color .2s, transform .15s;
}
.nav-btn:hover, .nav-link:hover { background: var(--hover); }
.nav-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.header-tools { display: flex; gap: .35rem; flex: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; height: 40px; min-width: 40px; padding: 0 .6rem;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--btn-bg); color: var(--ink); cursor: pointer; transition: transform .15s, background .2s;
}
.icon-btn:hover { background: var(--hover); transform: translateY(-1px); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .snd-off { display: none; }
body.muted .icon-btn .snd-on { display: none; }
body.muted .icon-btn .snd-off { display: inline; }
.tool-label { font-size: .82rem; font-weight: 600; white-space: nowrap; }
.menu-btn { display: none; }

/* ---------- stage ---------- */
.stage {
  --board: max(290px, min(calc(100vh - 235px), calc(100vw - 500px), 860px));
  display: grid; grid-template-columns: var(--board) minmax(300px, 400px); gap: clamp(1rem, 2.5vw, 2.4rem);
  justify-content: center; align-items: start; padding: clamp(.75rem, 2.2vw, 1.75rem) clamp(.75rem, 3vw, 2rem) 2.5rem;
}
.board-col { width: 100%; min-width: 0; }
.board-row { display: flex; gap: 10px; align-items: stretch; padding: var(--frame-w, 0px); }
.board-wrap { position: relative; flex: 1; min-width: 0; }
#board { width: 100%; }
.strip { display: flex; align-items: center; gap: .6rem; padding: .35rem .15rem; min-height: 50px; }
.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 1.2rem; line-height: 1;
  background: var(--btn-bg); border: 1px solid var(--line); transition: box-shadow .3s;
}
.strip.to-move .avatar { box-shadow: 0 0 0 3px var(--accent); }
.strip.thinking .avatar { animation: think 1.1s ease-in-out infinite; }
.who { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.pname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psub { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray { display: flex; flex-wrap: wrap; align-items: center; min-width: 0; flex: 1; padding-left: .2rem; }
.tray .cap { width: 19px; height: 19px; margin-right: -6px; }
.diff { font-size: .8rem; font-weight: 800; color: var(--muted); min-width: 1.5em; }
.clock {
  margin-left: auto; flex: none; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.2rem; font-weight: 700;
  padding: .2rem .6rem; border-radius: var(--radius-sm); background: var(--btn-bg); border: 1px solid var(--line); min-width: 5.4ch; text-align: center; transition: background .2s, color .2s;
}
.clock.running { background: var(--accent); color: var(--accent-ink); }
.clock.low.running { background: var(--danger); color: #fff; animation: pulse 1s ease-in-out infinite; }
.board-tools { display: flex; gap: .35rem; justify-content: center; align-items: center; margin-top: .55rem; flex-wrap: wrap; }
.tool {
  min-width: 46px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--btn-bg); cursor: pointer;
  font-size: 1rem; transition: transform .12s, background .2s;
}
.tool:hover:not(:disabled) { background: var(--hover); transform: translateY(-1px); }
.tool:active:not(:disabled) { transform: translateY(1px); }
.tool:disabled { opacity: .4; cursor: default; }
.tool-sep { width: 1px; height: 26px; background: var(--line); margin: 0 .2rem; }
.diagram-caption { margin: .4rem 0 0; text-align: center; font-style: italic; font-size: .9rem; }

/* ---------- side panel ---------- */
.side {
  display: flex; flex-direction: column; gap: 1rem; background: var(--panel); border: var(--panel-border, 1px solid var(--line));
  border-radius: var(--radius); padding: clamp(1rem, 2vw, 1.35rem); box-shadow: var(--shadow); min-width: 0;
}
.kicker { margin: 0; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.mode-title { margin: .1rem 0 .2rem; font-family: var(--font-display); font-size: clamp(1.6rem, 2.4vw, 2.1rem); line-height: 1.1; }
.status { margin: 0; min-height: 3em; font-size: .95rem; }
.panel { display: flex; flex-direction: column; gap: .75rem; animation: fadeUp .3s ease-out; }
.panel-note { margin: 0; color: var(--muted); font-size: .9rem; }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.btn {
  position: relative; font-weight: 650; font-size: .92rem; padding: .62rem .9rem; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--btn-bg); color: var(--ink); cursor: pointer; text-align: center; line-height: 1.2;
  transition: transform .12s ease, background .2s, box-shadow .2s, color .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--btn-hover-shadow, 0 6px 16px rgba(0,0,0,.18)); background: var(--hover); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.armed { background: var(--danger); color: #fff; border-color: transparent; animation: wiggle .35s; }
.btn.small { padding: .35rem .65rem; font-size: .82rem; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.switch { display: flex; gap: .65rem; align-items: center; cursor: pointer; font-size: .9rem; }
.switch input {
  -webkit-appearance: none; appearance: none; width: 42px; height: 24px; flex: none; border-radius: 99px; background: var(--line); position: relative; margin: 0; cursor: pointer; transition: background .2s;
}
.switch input::before { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--knob, #fff); box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .22s cubic-bezier(.3, 1.4, .5, 1); }
.switch input:checked { background: var(--accent); }
.switch input:checked::before { transform: translateX(18px); }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 600; }
.field span { display: flex; justify-content: space-between; gap: .5rem; }
.field input[type="text"], .field select, .field textarea {
  font: inherit; font-weight: 400; font-size: .9rem; padding: .55rem .7rem; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--input-bg); color: var(--ink); width: 100%; min-width: 0;
}
.field textarea { font-family: var(--font-mono); font-size: .8rem; resize: vertical; }
.field input[type="range"] { accent-color: var(--accent); width: 100%; }
.field select option { background: var(--panel-solid); color: var(--ink); }
.opp-card { display: flex; gap: .8rem; align-items: center; padding: .7rem .8rem; border-radius: var(--radius-sm); background: var(--btn-bg); border: 1px solid var(--line); }
.opp-emoji { font-size: 2.2rem; line-height: 1; animation: bob 3s ease-in-out infinite; }
.opp-name { margin: 0; font-weight: 800; }
.opp-blurb { margin: .1rem 0 0; font-size: .82rem; color: var(--muted); }
.pz-head { display: flex; flex-direction: column; }
.pz-title { margin: 0; font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; }
.pz-info { margin: 0; color: var(--muted); font-size: .88rem; }
.pz-msg { margin: 0; padding: .6rem .75rem; border-radius: var(--radius-sm); background: var(--btn-bg); border: 1px dashed var(--line); font-size: .9rem; min-height: 3.1em; }
.pz-msg.good { color: var(--good); border-style: solid; animation: pop .3s; }
.pz-msg.bad { color: var(--bad); border-style: solid; animation: wiggle .35s; }
.pz-progress { margin: 0; font-weight: 700; font-size: .88rem; }
.pz-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .35rem; }
.pz-cell {
  aspect-ratio: 1 / 1; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--btn-bg); cursor: pointer; font-weight: 800;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; transition: transform .15s, background .2s;
}
.pz-cell small { font-size: .62rem; font-weight: 600; color: var(--muted); margin-top: 2px; }
.pz-cell:hover { transform: translateY(-2px); }
.pz-cell.solved { background: var(--accent); color: var(--accent-ink); }
.pz-cell.solved small { color: inherit; opacity: .75; }
.pz-cell.cur { box-shadow: 0 0 0 2px var(--ink); }
.an-readout { display: flex; align-items: baseline; gap: .75rem; }
.an-eval { font-family: var(--font-mono); font-size: 2rem; font-weight: 800; }
.an-depth { color: var(--muted); font-size: .85rem; }
.an-pv { margin: 0; font-family: var(--font-mono); font-size: .85rem; padding: .55rem .7rem; border-radius: var(--radius-sm); background: var(--btn-bg); border: 1px solid var(--line); min-height: 3em; word-spacing: .1em; }
.moves-wrap { display: flex; flex-direction: column; min-width: 0; }
.moves-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; border-bottom: 1px solid var(--line); padding-bottom: .35rem; margin-bottom: .35rem; }
.moves-head h2 { margin: 0; font-size: .82rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.opening { font-size: .8rem; font-style: italic; color: var(--accent); text-align: right; }
.move-list { list-style: none; margin: 0; padding: 0; max-height: 230px; overflow-y: auto; position: relative; font-family: var(--font-mono); font-size: .9rem; scrollbar-width: thin; }
.move-list li { display: grid; grid-template-columns: 3.4ch 1fr 1fr; gap: .2rem; align-items: center; padding: .05rem .2rem; border-radius: 4px; }
.move-list li:nth-child(odd) { background: var(--row-alt); }
.move-list .mn { color: var(--muted); font-size: .8rem; }
.move-list .mv { font: inherit; text-align: left; border: 0; background: transparent; color: var(--ink); padding: .18rem .45rem; border-radius: 4px; cursor: pointer; }
.move-list .mv.ph { color: var(--muted); cursor: default; }
.move-list button.mv:hover { background: var(--hover); }
.move-list .mv.cur { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.move-list .res-li { display: block; text-align: center; font-weight: 800; padding: .3rem; }
.empty { color: var(--muted); font-size: .88rem; font-style: italic; margin: .3rem 0; }
.move-form { display: flex; gap: .4rem; margin-top: .6rem; }
.move-form input { flex: 1; min-width: 0; font: inherit; font-size: .9rem; padding: .45rem .65rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--input-bg); color: var(--ink); }
.joke { margin: 0; font-style: italic; color: var(--muted); font-size: .85rem; transition: opacity .35s, transform .35s; }
.joke::before { content: '♞ '; font-style: normal; color: var(--accent); }
.joke.swap { opacity: 0; transform: translateY(4px); }

/* ---------- sections ---------- */
.section { scroll-margin-top: 64px; padding: clamp(2.2rem, 6vw, 4.5rem) clamp(1rem, 4vw, 2rem); border-top: 1px solid var(--line); }
.section-inner { max-width: 1120px; margin: 0 auto; }
.section h2 { font-family: var(--font-display); font-size: clamp(1.6rem, 3.4vw, 2.5rem); margin: .2rem 0 1.2rem; line-height: 1.15; }
.section h3 { font-family: var(--font-display); font-size: 1.15rem; margin: 1.6rem 0 .7rem; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; }
.stat-card { display: flex; flex-direction: column; padding: 1rem 1.1rem; border-radius: var(--radius); background: var(--panel); border: var(--panel-border, 1px solid var(--line)); box-shadow: var(--shadow); }
.stat-card.big { grid-column: span 2; }
.stat-num { font-family: var(--font-display); font-size: clamp(1.8rem, 3.5vw, 2.6rem); font-weight: 800; line-height: 1.05; }
.stat-lbl { font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; }
.stat-extra { font-size: .82rem; color: var(--accent); margin-top: .2rem; }
.stats-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; margin-top: 1rem; }
.chart-card, .table-card { margin: 0; padding: 1rem 1.1rem; border-radius: var(--radius); background: var(--panel); border: var(--panel-border, 1px solid var(--line)); box-shadow: var(--shadow); min-width: 0; }
.chart-card figcaption, .table-card h3 { margin: 0 0 .6rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; font-family: var(--font-body); }
.rating-chart svg { width: 100%; height: auto; display: block; }
.rating-chart .area { fill: var(--accent); opacity: .16; }
.rating-chart .ln { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.rating-chart .dot { fill: var(--accent); stroke: var(--bg-solid); stroke-width: 2; }
.rating-chart text { fill: var(--muted); font-size: 11px; font-family: var(--font-mono); }
.level-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.level-table th, .level-table td { padding: .4rem .3rem; border-bottom: 1px solid var(--line); text-align: center; }
.level-table th[scope="row"], .level-table thead th:first-child { text-align: left; font-weight: 600; }
.level-table small { color: var(--muted); }
.recent { list-style: none; margin: 0 0 1.2rem; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.recent li { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; padding: .6rem .8rem; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--line); }
.recent li.empty { display: block; }
.rg-main { flex: 1 1 220px; }
.rg-main small { display: block; color: var(--muted); }
.rg-delta { font-family: var(--font-mono); font-weight: 700; }
.rg-date { font-size: .78rem; color: var(--muted); }
.badge { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding: .2rem .55rem; border-radius: 99px; background: var(--btn-bg); border: 1px solid var(--line); }
.badge.w { background: var(--good); color: var(--bg-solid); border-color: transparent; }
.badge.l { background: var(--danger); color: #fff; border-color: transparent; }
.about-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: clamp(1.2rem, 4vw, 3rem); align-items: start; }
.about p { max-width: 65ch; }
.quip { font-family: var(--font-display); font-style: italic; font-size: 1.2rem; color: var(--accent); }
.credit-card { padding: 1.4rem; border-radius: var(--radius); background: var(--panel); border: var(--panel-border, 1px solid var(--line)); box-shadow: var(--shadow); }
.credit-title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; margin: 0 0 .7rem; }
.credit-links { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.credit-links a { display: inline-block; padding: .4rem .8rem; border-radius: 99px; border: 1px solid var(--line); text-decoration: none; font-weight: 600; transition: transform .15s, background .2s; }
.credit-links a:hover { transform: translateY(-2px); background: var(--hover); }
.more-link { font-weight: 700; }
.keys { font-size: .85rem; color: var(--muted); margin-bottom: 0; }
.site-footer { text-align: center; padding: 1.8rem 1rem 2.4rem; border-top: 1px solid var(--line); font-size: .9rem; }
.site-footer p { margin: .3rem 0; }
.gratitude { font-style: italic; font-size: .85rem; color: var(--muted); }

/* ---------- dialogs ---------- */
.dlg {
  border: var(--panel-border, 1px solid var(--line)); padding: 0; border-radius: var(--radius); background: var(--panel-solid); color: var(--ink);
  width: min(760px, 94vw); max-width: 94vw; box-shadow: 0 30px 90px rgba(0,0,0,.45);
}
.dlg::backdrop { background: rgba(10, 8, 6, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dlg[open] { animation: dlgIn .28s cubic-bezier(.2, .9, .3, 1.15); }
.dlg-body { padding: clamp(1rem, 3vw, 1.75rem); max-height: 88vh; overflow: auto; }
.dlg h2 { font-family: var(--font-display); margin: 0 0 1rem; font-size: 1.6rem; }
.dlg fieldset { border: 0; padding: 0; margin: 0 0 1.1rem; min-width: 0; }
.dlg legend { font-weight: 800; margin-bottom: .5rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); padding: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; padding: 3px; background: var(--btn-bg); }
.seg label { position: relative; cursor: pointer; }
.seg input, .chip input, .level-card input, .theme-card input, .set-card input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: .4rem 1rem; border-radius: 99px; font-weight: 600; transition: background .2s, color .2s; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); }
.level-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .55rem; }
.level-card, .theme-card, .set-card {
  position: relative; display: grid; grid-template-columns: auto 1fr; column-gap: .65rem; align-items: center; padding: .7rem .8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--btn-bg); cursor: pointer; transition: transform .15s, border-color .2s, box-shadow .2s;
}
.level-card:hover, .theme-card:hover, .set-card:hover { transform: translateY(-2px); }
.level-card:has(input:checked), .theme-card:has(input:checked), .set-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.level-card:focus-within, .theme-card:focus-within, .set-card:focus-within, .chip:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.lc-emoji { grid-row: span 3; font-size: 1.9rem; }
.lc-name, .tc-name { font-weight: 800; }
.level-card input:checked ~ .lc-name { color: var(--accent); }
.lc-tag { font-size: .75rem; color: var(--muted); font-weight: 700; }
.lc-blurb, .tc-blurb { font-size: .78rem; color: var(--muted); grid-column: 2; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { position: relative; cursor: pointer; }
.chip span { display: flex; flex-direction: column; align-items: center; padding: .4rem .8rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--btn-bg); line-height: 1.15; transition: background .2s, color .2s; }
.chip small { font-size: .7rem; color: var(--muted); }
.chip input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip input:checked + span small { color: inherit; opacity: .8; }
.theme-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.theme-card .mini { grid-row: span 2; display: grid; grid-template-columns: repeat(3, 14px); grid-template-rows: repeat(3, 14px); border-radius: 3px; overflow: hidden; }
.theme-card .tc-name { align-self: end; }
.theme-card .tc-blurb { align-self: start; }
.set-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; }
.set-card { grid-template-columns: 1fr; text-align: center; justify-items: center; }
.set-prev { display: flex; justify-content: center; gap: 2px; padding: 6px; border-radius: 6px; background: linear-gradient(135deg, #d9c9a8, #9c7a52); margin-bottom: .4rem; }
.set-prev .piece-static { width: 34px; height: 34px; }
.set-card .tc-blurb { grid-column: 1; }
.toggles { display: grid; gap: .6rem; }
.io-msg { min-height: 1.4em; font-size: .88rem; margin: .5rem 0 0; }
.io-msg.bad { color: var(--bad); }
.io-msg.good { color: var(--good); }
.dlg .field { margin-bottom: .6rem; }
.result .dlg-body { text-align: center; }
.result .dlg-actions { justify-content: center; }
.res-stamp { display: inline-block; font-size: 4.2rem; line-height: 1; animation: stampIn .6s cubic-bezier(.2, 1.6, .4, 1) both; }
.result.win h2 { color: var(--good); }
.result.lose h2 { color: var(--bad); }
.res-reason { font-weight: 700; margin: 0 0 .3rem; }
.res-rating { font-family: var(--font-mono); font-size: .9rem; color: var(--accent); margin: 0 0 .6rem; }
.res-joke { font-style: italic; color: var(--muted); max-width: 46ch; margin: 0 auto; }

/* ---------- toasts & fx ---------- */
.toasts { position: fixed; left: 50%; bottom: clamp(.75rem, 3vh, 1.5rem); transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: .45rem; align-items: center; width: min(560px, 92vw); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; gap: .8rem; align-items: center; background: var(--toast-bg); color: var(--toast-ink); padding: .7rem 1rem; border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.35); font-size: .9rem; animation: toastIn .35s cubic-bezier(.2, 1.2, .4, 1); transition: opacity .3s, transform .3s; border: 1px solid var(--line);
}
.toast.bad { border-left: 4px solid var(--danger); }
.toast.out { opacity: 0; transform: translateY(10px); }
.toast-act { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: .3rem .7rem; font-weight: 700; cursor: pointer; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 130; }
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

/* ---------- keyframes ---------- */
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes think { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg) scale(1.05); } 75% { transform: rotate(10deg) scale(1.05); } }
@keyframes pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }
@keyframes wiggle { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes dlgIn { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes stampIn { from { transform: scale(2.4) rotate(-20deg); opacity: 0; } to { transform: scale(1) rotate(-6deg); opacity: 1; } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .menu-btn { display: inline-flex; }
  .main-nav {
    position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: .25rem; padding: .75rem;
    background: var(--panel-solid); border-bottom: 1px solid var(--line); box-shadow: 0 20px 40px rgba(0,0,0,.25); display: none; margin: 0;
  }
  .main-nav.open { display: flex; animation: fadeUp .2s ease-out; }
  .nav-btn, .nav-link { text-align: left; border-radius: var(--radius-sm); padding: .7rem .9rem; }
  .header-tools { margin-left: auto; }
  .masthead { display: none !important; }
}
@media (max-width: 920px) {
  .stage { --board: min(calc(100vw - 1.5rem), 640px); grid-template-columns: minmax(0, var(--board)); }
  .side { width: 100%; }
  .stats-grid, .about-grid { grid-template-columns: 1fr; }
  .move-list { max-height: 190px; }
}
@media (max-width: 560px) {
  .tool-label { display: none; }
  .logo { font-size: 1.3rem; }
  .logo-mark { width: 28px; height: 28px; }
  .stage { --board: calc(100vw - 1rem); padding-left: .5rem; padding-right: .5rem; }
  .board-row { gap: 6px; }
  .strip { gap: .45rem; min-height: 44px; }
  .avatar { width: 32px; height: 32px; font-size: 1rem; }
  .clock { font-size: 1.05rem; padding: .15rem .45rem; }
  .tray .cap { width: 15px; height: 15px; }
  .stat-card.big { grid-column: 1 / -1; }
  .theme-cards, .set-cards { grid-template-columns: 1fr; }
  .set-card { grid-template-columns: auto 1fr; text-align: left; justify-items: start; }
  .set-card .set-prev { grid-row: span 2; margin: 0; }
  .set-card .tc-blurb { grid-column: 2; }
  .btn { padding: .6rem .6rem; }
}
@media (min-width: 1800px) {
  html { font-size: 18px; }
  .stage { --board: min(calc(100vh - 260px), calc(100vw - 640px), 1120px); grid-template-columns: var(--board) minmax(380px, 500px); }
  .move-list { max-height: 360px; }
}
@media (min-width: 2600px) { html { font-size: 22px; } .stage { --board: min(calc(100vh - 300px), 1500px); } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
html[data-motion="off"] { scroll-behavior: auto; }

.noscript { margin: 1rem auto; max-width: 640px; padding: 1rem; text-align: center; border: 1px solid var(--line); border-radius: var(--radius-sm); }
