/* Layout: a split stage (words left, pixels right) is the hero; the challenge editor and the making-of follow. */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --fg: #0d1a38;
  --muted: #56627f;
  --line: #d9deea;
  --accent: #d9661a;
  --bad: #d9361a;
  --pix-b: #0b1a3d; --pix-d: #55628a; --pix-l: #b7bfd6; --pix-w: #f7f8fb; --pix-empty: #d6dbe7;
  --font-display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --font-body: "Literata", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0a1024; --surface: #111a36; --fg: #e9edf7; --muted: #9aa5c4; --line: #26305a; --accent: #f59a4a; --bad: #ff6b4a; color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.6 var(--font-body); }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.mono, code { font-family: var(--font-mono); }
code { font-size: 0.86em; }
.wrap { max-width: 78rem; margin: 0 auto; padding-inline: 16px; }
@media (min-width: 700px) { .wrap { padding-inline: 32px; } }
[hidden] { display: none !important; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-block: 1rem; }
.brand { font: 800 1.35rem/1 var(--font-display); letter-spacing: 0.04em; text-transform: uppercase; text-decoration: none; }
.nav { display: flex; gap: 1.25rem; font: 0.8rem var(--font-mono); }
.nav a { text-decoration: none; color: var(--muted); } .nav a:hover { color: var(--fg); }

/* hero */
.hero { display: grid; gap: 1rem; padding-block: 0.5rem 3rem; }
.intro { max-width: 48rem; }
h1 { font: 800 clamp(2.2rem, 5.5vw, 4rem)/0.95 var(--font-display); text-transform: uppercase; margin: 0.25rem 0 0.75rem; text-wrap: balance; letter-spacing: 0.01em; }
.lede { font-size: clamp(1.05rem, 2vw, 1.2rem); margin: 0; max-width: 44rem; }
.shared-note { margin: 0.75rem 0 0; padding: 0.6rem 0.9rem; border-left: 3px solid var(--accent); background: var(--surface); }

.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; font-size: 0.9rem; align-items: center; }
.legend .item { display: inline-flex; align-items: center; gap: 0.45rem; }
.legend .sw { width: 1.05rem; height: 1.05rem; border: 1px solid var(--line); flex: none; }
.legend .ex { font: 0.78rem var(--font-mono); color: var(--muted); }

.stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: stretch; }
@media (max-width: 760px) {
  .stage { gap: 0.5rem; }
  .typed { height: 62vh; padding: 0.6rem 0.6rem 1.5rem; font-size: 0.8rem; line-height: 1.7; }
  .pane-head { padding: 0.45rem 0.5rem; font-size: 0.66rem; }
  .now { display: none; }
  .now-m { display: block; }
  .stage .pix-pane .canvas-wrap { padding: 0.4rem; place-items: start center; }
  .nav { display: none; }
}
.pane { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; overflow: hidden; }
.pane-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--line); font: 0.75rem var(--font-mono); color: var(--muted); }
.pane-head .label { letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.now { text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now b { color: var(--fg); font-weight: 600; }
.typed { height: clamp(24rem, calc(100vh - 21rem), 46rem); overflow-y: auto; padding: 0.9rem 1rem 2rem; font-size: 1rem; line-height: 1.85; overscroll-behavior: contain; }
.typed .row-mark { display: block; margin-top: 0.4rem; font: 0.66rem var(--font-mono); letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.typed .row-mark:first-child { margin-top: 0; }
.typed .zone { color: var(--accent); }
.w { padding: 0 0.08em; border-radius: 2px; box-shadow: inset 0 -0.28em 0 var(--sh, transparent); }
/* underline weight follows pixel darkness: white words get no bar, black words the heaviest */
.w.s0 { --sh: transparent; }
.w.s1 { --sh: var(--pix-l); }
.w.s2 { --sh: var(--pix-d); }
.w.s3 { --sh: var(--pix-b); }
@media (prefers-color-scheme: dark) {
  .w.s1 { --sh: color-mix(in srgb, var(--pix-l) 30%, transparent); }
  .w.s2 { --sh: color-mix(in srgb, var(--pix-l) 60%, transparent); }
  .w.s3 { --sh: var(--pix-w); }
}
.w.cur, .w.hit { background: var(--accent); color: #fff; box-shadow: none; }
@media (prefers-color-scheme: dark) { .w.cur, .w.hit { color: #0a1024; } }
.now-m { display: none; margin: 0; font-size: 0.75rem; color: var(--muted); min-height: 1.4em; }
.now-m b { color: var(--fg); }
.hint .warn { color: var(--bad); }
.canvas-wrap { background: var(--pix-w); line-height: 0; }
.pix-pane .canvas-wrap { flex: 1; display: grid; place-items: center; padding: 0.75rem; }
#pix { width: 100%; max-width: calc(clamp(24rem, calc(100vh - 21rem), 46rem) * 0.78); height: auto; image-rendering: pixelated; cursor: crosshair; transition: filter 300ms; }
#pix.squint, #edpix.squint { filter: blur(3px) contrast(1.15); }
.count { font-variant-numeric: tabular-nums; }

.controls { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.btn { font: 600 0.8rem/1 var(--font-mono); letter-spacing: 0.02em; padding: 0.65rem 0.95rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface); flex-wrap: wrap; }
.seg button { font: 600 0.78rem/1 var(--font-mono); border: 0; background: transparent; color: var(--fg); padding: 0.55rem 0.8rem; border-radius: 999px; cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--accent); color: #fff; }
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, .typed:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* sections */
.challenge, .how { padding-block: 3rem; border-top: 1px solid var(--line); }
.section-head { max-width: 48rem; margin-bottom: 1.75rem; }
.eyebrow { font: 600 0.75rem var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin: 0; }
h2 { font: 800 clamp(1.9rem, 4.5vw, 3rem)/1 var(--font-display); text-transform: uppercase; margin: 0.35rem 0 0.75rem; text-wrap: balance; }
h3 { font: 800 1.3rem/1.1 var(--font-display); text-transform: uppercase; letter-spacing: 0.02em; margin: 1.5rem 0 0.4rem; }
h3:first-child { margin-top: 0; }
.sub { margin: 0 0 1rem; font-size: 1.05rem; }
.rules { margin: 0; padding-left: 1.3rem; display: grid; gap: 0.3rem; }

.editor { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.75rem; align-items: start; }
@media (max-width: 860px) { .editor { grid-template-columns: minmax(0, 1fr); } .ed-right { order: -1; } }
.ed-left, .ed-right { display: grid; gap: 0.85rem; min-width: 0; }
.field-row { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: end; }
.field { display: grid; gap: 0.3rem; min-width: 0; flex: 1 1 12rem; }
label, .field-label { font: 0.72rem var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.check { display: inline-flex; gap: 0.4rem; align-items: center; padding-bottom: 0.5rem; }
select, input[type="file"] { font: 0.9rem var(--font-body); padding: 0.5rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); max-width: 100%; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
textarea { width: 100%; min-height: 18rem; resize: vertical; font: 1rem/1.7 var(--font-body); padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); }
.hint { font-size: 0.95rem; min-height: 1.6em; }
.hint .need { display: inline-block; width: 0.9em; height: 0.9em; border: 1px solid var(--line); vertical-align: -0.1em; margin-right: 0.3em; }
.suggest { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.suggest button { font: 0.8rem var(--font-mono); padding: 0.3rem 0.55rem; border-radius: 4px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; }
.suggest button:hover { border-color: var(--accent); }
.misses { display: grid; gap: 0.25rem; font-size: 0.88rem; color: var(--muted); }
.misses button { all: unset; cursor: pointer; color: var(--fg); text-decoration: underline; text-decoration-color: var(--bad); text-underline-offset: 3px; }
.misses button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ed-stats { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.ed-stats div { display: grid; }
.ed-stats .k { font: 0.7rem var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.ed-stats .v { font: 800 1.6rem/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.ed-canvas { border: 1px solid var(--line); border-radius: 6px; padding: 0.75rem; display: grid; place-items: center; }
#edpix { width: 100%; max-width: 32rem; height: auto; image-rendering: pixelated; }
.caption { font-size: 0.85rem; color: var(--muted); margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.toast { min-height: 1.4em; margin: 0; font: 0.85rem var(--font-mono); color: var(--accent); }

.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: 1rem 3rem; }
.how-grid p { margin: 0 0 0.75rem; max-width: 38rem; }
.foot { border-top: 1px solid var(--line); padding-block: 1.5rem 3rem; font-size: 0.85rem; color: var(--muted); }
.foot p { margin: 0 0 0.4rem; max-width: 52rem; }
@media (prefers-reduced-motion: reduce) { #pix, #edpix { transition: none; } }
