/* House style from the Blood game (GTAC colours, Figtree, eggshell page, cobalt buttons). */
:root {
  --ax-mem: #4f5d73; --ax-cyt: #a9b6c8;
  --eggshell: #F9F6E7; --sodium-flame: #FF6D3A; --cadmium-yellow: #FFCD1F;
  --chlorophyll-green: #00BC74; --aquamarine: #6BE7BE; --lavender: #C0ADFF;
  --cobalt-blue: #4C34E5; --onyx: #272A24; --panel: #FFFFFF;
  --line: rgba(39, 42, 36, 0.12); --touch: 48px;
  --mem: #7d4f86; --cyt: #d6acd5; --nuc: #6a3f8a; --signal: #FFCD1F;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; touch-action: manipulation; }
body {
  font-family: 'Figtree', system-ui, sans-serif; background: var(--eggshell); color: var(--onyx);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; touch-action: manipulation; }
h2 { margin: 0; line-height: 1.15; border-left: 5px solid var(--chlorophyll-green); padding-left: 10px; font-size: 1.5rem; }
h3 { margin: 0 0 6px; font-size: 1.05rem; }

.top {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 4px solid var(--sodium-flame); background: var(--eggshell);
}
.top .gtac { height: 34px; width: auto; }
.wordmark { color: var(--cobalt-blue); font-weight: 700; font-size: 1.8rem; letter-spacing: .04em; margin: 0; }

main { max-width: 1240px; margin: 0 auto; padding: 12px 12px max(16px, env(safe-area-inset-bottom)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-top: 6px solid var(--cobalt-blue);
  border-radius: 16px; padding: 14px 16px; box-shadow: 0 3px 10px rgba(0,0,0,.08);
}
.act-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pill {
  display: inline-block; font-weight: 700; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase;
  background: var(--cobalt-blue); color: #fff; border-radius: 999px; padding: 4px 12px;
}
.steps { margin-left: auto; display: flex; gap: 6px; }
.steps button { width: 26px; height: 26px; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; position: relative; }
.steps button::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--line); }
.steps button.done::after { background: var(--chlorophyll-green); }
.steps button.on::after { background: var(--sodium-flame); inset: 5px; }

.act-body { display: grid; gap: 14px; margin-top: 12px; }
@media (min-width: 820px) and (orientation: landscape) { .act-body:not(.wide) { grid-template-columns: 1.35fr 1fr; align-items: start; } }
.act-body.wide .side { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.act-body.wide .tip { flex: 1 1 360px; margin: 0; }
.act-body.wide #side { flex: 1 1 320px; }
.act-body.wide .next-row { flex: 0 0 auto; }

.stage { position: relative; background: #fff7f3; border: 2px solid var(--line); border-radius: 16px; padding: 6px; overflow: hidden; }
.stage > svg { display: block; width: 100%; height: auto; max-height: calc(100dvh - 245px); touch-action: none; border-radius: 10px; }
.wide .stage > svg { max-height: calc(100dvh - 425px); }
@media (orientation: portrait), (max-width: 819px) { .stage > svg { max-height: 56dvh; } }

.tip { background: var(--cadmium-yellow); border-radius: 12px; padding: 12px 14px; font-weight: 700; font-size: 1.12rem; line-height: 1.35; margin: 0 0 12px; }
.tip.pop { animation: tip-pop .35s ease-out; }
@keyframes tip-pop { from { transform: scale(.96); opacity: .4; } }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--touch); padding: 0 16px; border-radius: 12px;
  border: 2px solid var(--cobalt-blue); background: #fff; color: var(--cobalt-blue);
  font-weight: 700; cursor: pointer;
}
button.primary { background: var(--cobalt-blue); color: var(--eggshell); }
button:active, .btn:active { transform: scale(.97); }
button:disabled { opacity: .4; cursor: default; transform: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.next-row button { min-width: 220px; min-height: 56px; font-size: 1.1rem; width: 100%; }
.hidden { display: none !important; }
.muted { opacity: .7; }

/* ---- info card ---- */
.info { background: var(--eggshell); border: 2px solid var(--aquamarine); border-radius: 14px; padding: 12px 16px; line-height: 1.45; font-size: 1.05rem; }
.info ul { margin: 6px 0 0; padding-left: 1.2em; }
.info li { margin: 4px 0; }
.info b { color: var(--cobalt-blue); }

/* ---- tracing ---- */
.ink { fill: none; stroke: var(--chlorophyll-green); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; opacity: .85; pointer-events: none; }
.ink.closed { fill: rgba(0, 188, 116, .22); }
.ink.b { stroke: var(--cobalt-blue); }
.ink.b.closed { fill: rgba(76, 52, 229, .18); }
.ink.o { stroke: var(--sodium-flame); }
.ink.o.closed { fill: rgba(255, 109, 58, .18); }
.end-dot { fill: var(--sodium-flame); pointer-events: none; }
.end-ring { fill: none; stroke: var(--sodium-flame); stroke-width: 4; pointer-events: none; transform-box: fill-box; transform-origin: center; animation: ping 1.2s ease-out infinite; }
.start-dot { fill: #fff; stroke: var(--chlorophyll-green); stroke-width: 3; pointer-events: none; }
.start-dot.ready { fill: var(--chlorophyll-green); stroke: #fff; }
@keyframes ping { from { scale: .8; opacity: 1; } to { scale: 2; opacity: 0; } }
.scalebar rect { fill: rgba(255,255,255,.85); }
.scalebar line { stroke: var(--onyx); }
.scalebar text { font-weight: 700; font-family: Figtree, sans-serif; fill: var(--onyx); }
.upload { position: absolute; top: 14px; right: 14px; min-height: 40px; font-size: .9rem; opacity: .9; }
.meter { background: var(--eggshell); border: 2px solid var(--aquamarine); border-radius: 14px; padding: 12px 16px; margin-bottom: 4px; }
.meter .lab { font-weight: 700; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
.meter .big { font-size: 3rem; font-weight: 700; color: var(--cobalt-blue); font-variant-numeric: tabular-nums; line-height: 1.05; }
.meter .big small { font-size: 1.3rem; color: var(--onyx); opacity: .7; margin-left: 4px; }
.meter .sub { font-size: 1.02rem; margin-top: 4px; min-height: 1.4em; }
.meter.done { border-color: var(--chlorophyll-green); }
.scale-row { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-weight: 700; font-size: .95rem; }
.scale-row input { width: 90px; min-height: 40px; border-radius: 10px; border: 2px solid var(--line); padding: 0 8px; font-size: 16px; -webkit-user-select: text; user-select: text; }
table { width: 100%; border-collapse: collapse; font-size: 1rem; margin-top: 6px; }
th, td { border-bottom: 1px solid var(--line); padding: 6px; text-align: center; }
td:first-child { text-align: left; font-weight: 700; }
th small { font-weight: 400; opacity: .7; }
td .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.cmp-label { font: 700 20px Figtree, sans-serif; fill: var(--onyx); }

.badge { display: grid; grid-template-columns: 2.2em 1fr; gap: 8px; background: var(--eggshell); border: 2px solid var(--chlorophyll-green); border-radius: 12px; padding: 10px 12px; line-height: 1.3; margin-bottom: 10px; animation: badge-in .5s cubic-bezier(.2,.9,.3,1.3); }
.badge .ic { font-size: 1.7rem; text-align: center; }
.badge b { display: block; color: #00875a; }
@keyframes badge-in { from { transform: scale(.6); opacity: 0; } }

/* ---- neuron drawings ---- */
.n-mem, .n-cyt { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.n-mem { stroke: var(--mem); }
.n-mem circle { fill: var(--mem); stroke: none; }
.n-cyt { stroke: var(--cyt); }
.n-cyt circle { fill: var(--cyt); stroke: none; }
/* the axon is blue-grey, so it's easy to tell apart from the dendrites */
.n-mem .ax { stroke: var(--ax-mem); }
.n-mem circle.ax { fill: var(--ax-mem); stroke: none; }
.n-cyt .ax { stroke: var(--ax-cyt); }
.n-cyt circle.ax { fill: var(--ax-cyt); stroke: none; }
.n-soma { fill: var(--cyt); stroke: var(--mem); stroke-width: 4; transition: fill 1.5s ease-out; }
.n-nuc { fill: var(--nuc); }
.neuron.firing .n-soma { fill: var(--signal); transition: fill .2s; }
.sig { fill: none; stroke: var(--signal); stroke-linecap: round; opacity: 0; pointer-events: none; }
.bulb-sig { fill: var(--signal); opacity: 0; transition: opacity 1.5s ease-in; pointer-events: none; }
.neuron.out .bulb-sig { opacity: 1; transition: opacity .2s; }
.n-somag.pulse { transform-box: fill-box; transform-origin: center; animation: pulse 1.4s ease-in-out infinite; }
.n-somag.pulse .n-soma { stroke: var(--sodium-flame); stroke-width: 6; }
@keyframes pulse { 50% { scale: 1.14; } }
.ping-ring { fill: none; stroke: var(--sodium-flame); stroke-width: 5; pointer-events: none; transform-box: fill-box; transform-origin: center; animation: ping 1.4s ease-out infinite; }
.nt { fill: var(--sodium-flame); stroke: #fff; stroke-width: 1; pointer-events: none; }
.nt.caught { fill: var(--chlorophyll-green); }
.nt.fine { stroke-width: .4; }
.part-label text { font: 700 28px Figtree, sans-serif; fill: var(--onyx); }
.part-label rect { fill: #fff; stroke: var(--cobalt-blue); stroke-width: 3; }
.part-label.tap { cursor: pointer; }
.part-label.tap rect { fill: #fff; stroke-dasharray: 6 4; }
.part-label.on rect { fill: var(--chlorophyll-green); stroke: var(--chlorophyll-green); stroke-dasharray: none; }
.part-label.on text { fill: #fff; }
.part-label.wrong { animation: shake .4s; }
.part-label .num { fill: var(--sodium-flame); }
.part-label .num-t { font-size: 18px; fill: #fff; }
@keyframes shake { 25% { translate: -6px 0; } 75% { translate: 6px 0; } }
.flow-arrow { fill: none; stroke: var(--sodium-flame); stroke-width: 5; stroke-dasharray: 14 10; animation: flow 0.8s linear infinite; pointer-events: none; }
.flow-head { fill: var(--sodium-flame); }
@keyframes flow { to { stroke-dashoffset: -24; } }
.thr-bg { fill: none; stroke: rgba(39,42,36,.15); }
.thr { fill: none; stroke: var(--chlorophyll-green); stroke-linecap: round; transition: stroke-dasharray .2s; }
.thr-text { font: 700 22px Figtree, sans-serif; fill: var(--onyx); }
.demo-title { font: 700 26px Figtree, sans-serif; fill: var(--onyx); }
.result-text { font: 700 24px Figtree, sans-serif; }
.result-text.yes { fill: #00875a; }
.result-text.no { fill: var(--sodium-flame); }

/* ---- explain ---- */
.explain textarea {
  width: 100%; min-height: 220px; border-radius: 12px; border: 2px solid var(--line); padding: 12px;
  font-size: 18px; line-height: 1.45; resize: vertical; background: #fff;
  -webkit-user-select: text; user-select: text;
}
.explain textarea:focus { outline: none; border-color: var(--cobalt-blue); }
.kw { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.kw span { border: 2px dashed var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: .95rem; }
.kw span.used { border-style: solid; border-color: var(--chlorophyll-green); background: var(--chlorophyll-green); color: #fff; }
.wordcount { margin-top: 8px; font-size: .95rem; }

/* ---- chain + network ---- */
.speed { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.speed input { flex: 1; min-width: 160px; accent-color: var(--cobalt-blue); height: 32px; }
.zoom-cap { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: var(--onyx); color: #fff; font-weight: 700; padding: 6px 14px; border-radius: 999px; font-size: 1rem; pointer-events: none; transition: opacity .3s; opacity: 0; }
.zoom-cap.on { opacity: .9; }
.hit { fill: transparent; cursor: pointer; }
.start-tag circle { fill: var(--cobalt-blue); stroke: #fff; stroke-width: 3; }
.start-tag text { font: 700 20px Figtree, sans-serif; fill: #fff; }
.start-tag { cursor: pointer; }
.start-tag .hit { fill: transparent; stroke: none; }
.start-tag.pred circle { fill: var(--sodium-flame); }
.net-soma { fill: var(--cyt); stroke: var(--mem); stroke-width: 3; transition: fill 1.5s ease-out; }
.net-node.lit .net-soma { transition: fill .08s; }
.net-node.lit .net-soma { fill: var(--signal); }
.net-node.dead .net-soma { fill: #ccc; }
.net-dend { stroke: var(--mem); stroke-width: 5; stroke-linecap: round; fill: none; }
.net-axon { stroke: var(--ax-mem); stroke-width: 3; fill: none; stroke-linecap: round; opacity: .75; }
.net-bulb { fill: var(--ax-mem); }
.net-ring { fill: none; stroke: var(--mem); stroke-width: 2.5; }
.net-count { font: 700 13px Figtree, sans-serif; fill: var(--onyx); }
.target-star { font-size: 26px; }
.choice { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.choice button { min-width: 56px; font-size: 1.1rem; }
.choice button.on { background: var(--sodium-flame); border-color: var(--sodium-flame); color: #fff; }
.tally { display: flex; gap: 6px; margin-top: 10px; font-size: .95rem; flex-wrap: wrap; }
.tally span { border: 2px solid var(--line); border-radius: 10px; padding: 4px 10px; font-weight: 700; }
.tally span.has { border-color: var(--cobalt-blue); }

/* ---- annotator (from the plant scavenger hunt) ---- */
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 42px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--cobalt-blue); color: var(--cobalt-blue); background: #fff; touch-action: none; }
.chip.on { background: var(--cobalt-blue); color: #fff; }
.chip.own { border-style: dashed; }
.chip-ghost { position: fixed; z-index: 50; pointer-events: none; transform: translate(-50%, -130%); background: var(--cobalt-blue); color: #fff; font-weight: 700; padding: 8px 14px; border-radius: 999px; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.ann { display: grid; gap: 8px; }
.ann-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ann-bar button { min-height: 44px; padding: 0 12px; font-size: .95rem; }
.ann-bar button.on { background: var(--cobalt-blue); color: var(--eggshell); }
.ann-sws { display: inline-flex; gap: 6px; margin-left: auto; }
.sw { width: 36px; height: 36px; min-height: 0 !important; padding: 0 !important; border-radius: 50% !important; border: 2px solid var(--line) !important; }
.sw.on { outline: 3px solid var(--cobalt-blue); outline-offset: 1px; }
.ann-hint { margin: 0; font-size: .9rem; opacity: .7; min-height: 1.2em; }
.ann-host { width: 100%; }
.ann-wrap { position: relative; display: inline-block; line-height: 0; justify-self: center; }
.ann canvas { display: block; max-width: 100%; max-height: calc(100dvh - 355px); min-height: 200px; touch-action: none; border-radius: 10px; background: #000; cursor: crosshair; }
.ann textarea.ann-ta { position: absolute; display: none; margin: 0; resize: none; overflow: auto; min-height: 0; font-weight: 600; line-height: 1.2; border: 2px solid var(--cobalt-blue); border-radius: 6px; padding: 3px 6px; background: rgba(255,255,255,.94); color: #111; -webkit-user-select: text; user-select: text; }
.final-img { display: block; max-width: 100%; max-height: calc(100dvh - 315px); margin: 0 auto; border-radius: 10px; }
.quote { background: #fff; border-left: 5px solid var(--cobalt-blue); border-radius: 8px; padding: 10px 12px; font-size: 1rem; line-height: 1.45; white-space: pre-wrap; }

@media (prefers-reduced-motion: reduce) {
  .end-ring, .tip.pop, .badge, .n-somag.pulse, .ping-ring, .flow-arrow { animation: none; }
}
.finds { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.finds li { border: 2px dashed var(--line); border-radius: 999px; padding: 4px 10px; font-weight: 700; font-size: .88rem; }
.finds li::before { content: "○ "; opacity: .5; }
.finds li.got { border: 2px solid var(--chlorophyll-green); background: var(--eggshell); animation: badge-in .5s cubic-bezier(.2,.9,.3,1.3); }
.finds li.got::before { content: "✓ "; color: #00875a; opacity: 1; }
.net-node .hit { cursor: pointer; }
/* ---- wire up real neurons (drawn on a dark micrograph) ---- */
.wn-body path { fill: none; stroke: #6BE7BE; stroke-linecap: round; opacity: .9; }
.wn-body circle { fill: #6BE7BE; }
.wn-body .ax { stroke: var(--ax-cyt); }
.wn-body circle.ax { fill: var(--ax-cyt); }
.wn-soma { fill: rgba(107, 231, 190, .25); stroke: #6BE7BE; transition: fill .25s; }
.wn.lit .wn-soma { fill: var(--signal); }
.wn.draft { opacity: .6; }
.wl-syn-ring { fill: none; stroke: #fff; stroke-dasharray: 3 2; opacity: .9; }
.wl-snap { fill: none; stroke: var(--signal); animation: tip-pop .6s ease-in-out infinite alternate; }
@media (min-width: 820px) and (orientation: landscape) { .act-body.photo { grid-template-columns: 1.9fr 1fr; } }

/* ---- tab bar, name, join, reset ---- */
.who { margin-left: auto; font-weight: 700; font-size: 1.05rem; }
.tabs { display: flex; gap: 6px; padding: 8px 12px 0; max-width: 1240px; margin: 0 auto; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabs button { flex: 0 0 auto; min-height: 44px; border-radius: 12px 12px 0 0; border-width: 2px 2px 0; background: #fff; font-size: .95rem; padding: 0 14px; }
.tabs button.on { background: var(--cobalt-blue); color: #fff; }
.tabs button.done:not(.on) { border-color: var(--chlorophyll-green); color: #00875a; }
.tabs + main { padding-top: 0; }
.tabs + main .card { border-top-left-radius: 0; }
.join { max-width: 560px; margin: 40px auto; }
.join .lead { font-size: 1.1rem; line-height: 1.45; }
.join form { display: grid; gap: 8px; margin-top: 14px; }
.join label { font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.join input { min-height: var(--touch); padding: 0 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 1.2rem; font-weight: 700; -webkit-user-select: text; user-select: text; }
.join input:focus { outline: none; border-color: var(--cobalt-blue); }
.error { color: var(--sodium-flame); font-weight: 700; min-height: 1.4em; }
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(39,42,36,.45); display: grid; place-items: center; padding: 16px; }
button.danger { background: var(--sodium-flame); border-color: var(--sodium-flame); }
