/* kanootti: a lake at dusk. Ink-teal, glacier mist, cloudberry gold. */
:root {
  --bg: #e8f0f1; --bg2: #d6e5e7; --fg: #0e2a33; --muted: #455f67; --card: #ffffff; --line: #c3d6d9;
  --ink: #0e2f3a; --accent: #0a6a70; --accent-fg: #ffffff; --gold: #f0a92b; --gold-fg: #3a2600; --bad: #b7324a; --good: #167a52;
  --o0: #c23e18; --o1: #0b7a72; --o2: #7a5cb5; --o3: #8f6400;
  --on-c: #ffffff; /* text on option colours and on --bad/--good fills */
  --shadow: 0 1px 0 rgba(14,42,51,.06), 0 10px 28px -14px rgba(14,42,51,.35);
  --wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 12'%3E%3Cpath d='M0 6q15-8 30 0t30 0 30 0 30 0V12H0z' fill='%23ffffff' fill-opacity='.14'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0a1b22; --bg2: #0f2830; --fg: #e6f1f2; --muted: #93b0b7; --card: #11303a; --line: #1f4551;
    --ink: #04141a; --accent: #4fc6cc; --accent-fg: #03191d; --gold: #f4b942; --gold-fg: #2b1c00; --bad: #ff7d92; --good: #5fd6a0;
    --o0: #ff7a52; --o1: #36c7bb; --o2: #a98ae6; --o3: #e8ae2e; --on-c: #03191d; --shadow: 0 10px 28px -14px rgba(0,0,0,.7); color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--fg); font: 18px/1.45 "Avenir Next", "Segoe UI", system-ui, sans-serif; display: flex; flex-direction: column; min-height: 100vh; }
h1, h2, .display { font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif; letter-spacing: -.02em; text-wrap: balance; }
h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); line-height: 1.1; margin: .3em 0 .4em; font-weight: 800; }
h2 { font-size: 1.05rem; margin: 1.4em 0 .5em; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
a { color: var(--accent); }

/* ---- top bar ---- */
.top { background: var(--ink); color: #e8f1f2; }
.top .in { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top::after { content: ""; display: block; height: 12px; background: var(--wave) repeat-x 0 0 / 120px 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 800; letter-spacing: -.02em; font-size: 1.25rem; }
.boat { display: inline-block; width: 2.4em; height: 1.04em; background: currentColor;
  -webkit-mask: url(/static/img/boat.svg) center / contain no-repeat; mask: url(/static/img/boat.svg) center / contain no-repeat; }
.brand .boat { color: var(--gold); font-size: 1.25rem; }
.top a.small { color: #bcd3d6; font-size: .9rem; }
main { flex: 1; width: 100%; max-width: 680px; margin: 0 auto; padding: 18px 16px 28px; }
main.wide { max-width: 1100px; }
footer { padding: 14px 16px 20px; text-align: center; color: var(--muted); font-size: .85rem; }

/* ---- hero (home) ---- */
.hero { text-align: center; padding: 18px 0 6px; color: var(--ink); }
@media (prefers-color-scheme: dark) { .hero { color: var(--fg); } }
.hero .boat { font-size: clamp(5rem, 26vw, 9rem); color: var(--accent); }
.hero .word { font-size: clamp(2.4rem, 11vw, 4rem); font-weight: 800; letter-spacing: -.04em; line-height: 1; display: block; margin-top: -.1em; }
.hero p { color: var(--muted); margin: .4em 0 0; }
.codebox { background: var(--card); border-radius: 22px; padding: 18px; margin-top: 22px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.codebox input { font-size: 2rem; text-align: center; letter-spacing: .3em; font-weight: 800; text-transform: uppercase; }

/* ---- form controls ---- */
button, input, select, textarea { font: inherit; color: inherit; }
input[type=text], textarea, select { width: 100%; padding: 13px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); }
select { width: auto; }
input:focus, textarea:focus, button:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button.primary, button.secondary, button.danger { border: 0; border-radius: 14px; padding: 13px 20px; font-weight: 800; cursor: pointer; letter-spacing: -.01em; transition: transform .08s; }
button.primary { background: var(--accent); color: var(--accent-fg); box-shadow: 0 4px 0 rgba(0,0,0,.22); }
button.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.22); }
button.secondary { background: var(--card); border: 2px solid var(--line); }
button.danger { background: var(--bad); color: var(--on-c); }
button:disabled { opacity: .5; cursor: default; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 2px 6px; }
button.link.active { font-weight: 800; text-decoration: underline; }
.wide-btn { width: 100%; margin-top: 10px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin: 14px 0; box-shadow: var(--shadow); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.error { color: var(--bad); font-weight: 700; min-height: 1.4em; }
.center { text-align: center; }
.pill { display: inline-block; padding: 3px 12px; border-radius: 999px; background: var(--bg2); color: var(--fg); font-size: .85rem; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 8px 0; }
.chips li { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; font-weight: 600; animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.overlay { position: fixed; inset: 0; background: rgba(4, 20, 26, .86); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 700; z-index: 10; text-align: center; padding: 24px; }
.overlay[hidden] { display: none; }

/* ---- join code ---- */
.huge-code { font-size: clamp(2.4rem, 12vw, 5.5rem); font-weight: 800; letter-spacing: .14em; font-variant-numeric: tabular-nums; color: var(--accent); }
.qr { width: min(60vw, 260px); height: auto; background: #fff; border-radius: 14px; padding: 8px; border: 1px solid var(--line); }

/* ---- countdown ring ---- */
.ring { --frac: 1; width: min(62vw, 340px); aspect-ratio: 1; margin: 18px auto; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--gold) calc(var(--frac) * 360deg), var(--bg2) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 12%; border-radius: 50%; background: var(--bg); }
.ring .num { position: relative; font-size: clamp(5rem, 30vw, 11rem); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.screen .ring { width: min(60vh, 520px); }

/* ---- river timer: the boat paddles across as time runs out ---- */
.river { --frac: 1; position: relative; height: 34px; margin: 10px 0 14px; }
.river::before { content: ""; position: absolute; left: 0; right: 0; bottom: 6px; height: 8px; border-radius: 4px; background: var(--bg2); }
.river .fill { position: absolute; left: 0; bottom: 6px; height: 8px; border-radius: 4px; width: calc((1 - var(--frac)) * 100%); background: var(--accent); }
.river .boat { position: absolute; bottom: 5px; left: calc((1 - var(--frac)) * (100% - 3em)); font-size: 1.35rem; color: var(--accent); width: 3em; height: 1.3em; }

/* ---- answer options ---- */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.opt { --c: var(--o0); position: relative; display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer;
  background: var(--card); border: 2px solid var(--line); border-bottom: 5px solid var(--c); border-radius: 18px; padding: 14px; min-height: 92px; font-weight: 700; box-shadow: var(--shadow); }
.opt.i0 { --c: var(--o0); } .opt.i1 { --c: var(--o1); } .opt.i2 { --c: var(--o2); } .opt.i3 { --c: var(--o3); }
.badge { flex: none; width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--c); display: grid; place-items: center; color: var(--on-c); font-size: 1.2rem; line-height: 1; }
.opt .txt { min-width: 0; overflow-wrap: anywhere; }
.opt.chosen { background: var(--c); color: var(--on-c); border-color: var(--c); }
.opt.chosen .badge { background: #fff; color: var(--c); }
.opt.dim { opacity: .4; }
.opt.right { border-color: var(--good); border-bottom-color: var(--good); box-shadow: 0 0 0 3px var(--good); }
.opt.right::after { content: "✓"; position: absolute; top: -10px; right: -6px; width: 28px; height: 28px; border-radius: 50%; background: var(--good); color: var(--on-c); display: grid; place-items: center; font-weight: 800; }
.opt.phone-only { justify-content: center; min-height: 26vh; background: var(--c); border-color: var(--c); color: var(--on-c); border-radius: 26px; }
.opt.phone-only .badge { width: 5rem; height: 5rem; font-size: 2.8rem; background: rgba(255,255,255,.2); color: inherit; }
.opt.phone-only.chosen { outline: 6px solid var(--fg); outline-offset: 3px; }
button.opt:disabled { opacity: 1; }
button.opt.dim:disabled { opacity: .4; }

/* ---- verdict ---- */
.verdict { display: inline-flex; align-items: center; gap: 10px; font-size: 1.8rem; font-weight: 800; padding: 6px 20px; border-radius: 999px; margin: 4px 0; }
.verdict.right { background: var(--good); color: var(--on-c); } .verdict.wrong { background: var(--bad); color: var(--on-c); }
.verdict.none { background: var(--bg2); color: var(--fg); }

/* ---- charts ---- */
.chart-title { margin-top: 1.2em; }
.pts { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 10px; }
.pts li { display: grid; grid-template-columns: 2.2rem minmax(0, 9rem) 1fr; align-items: center; gap: 10px; }
.screen .pts li { grid-template-columns: 3rem minmax(0, 14rem) 1fr; font-size: 1.4rem; }
.pts .rk { font-weight: 800; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.pts .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pts .track { position: relative; height: 2.1rem; background: var(--bg2); border-radius: 10px; overflow: hidden; }
.pts .seg { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 10px 0 0 10px; transition: width .9s cubic-bezier(.2,.8,.2,1); width: 0; }
.pts .base { background: var(--accent); }
.pts .gain { background: var(--gold); border-radius: 0 10px 10px 0; transition-delay: .5s; }
.pts .val { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); padding: 0 9px; line-height: 1.5; border-radius: 8px; background: var(--card); font-weight: 800; font-variant-numeric: tabular-nums; color: var(--fg); }
.pts li.me .nm { color: var(--accent); } .pts li.me .nm::after { content: " ●"; font-size: .7em; }
.pts li.gap { display: block; text-align: center; color: var(--muted); letter-spacing: .3em; line-height: .8; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 2px; }
  .legend i.a { background: var(--accent); } .legend i.g { background: var(--gold); }
.legend i { display: inline-block; width: .8em; height: .8em; border-radius: 3px; margin-right: 5px; vertical-align: -.05em; }
.dist { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; height: 150px; margin: 14px 0 4px; }
.dist .col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; }
.dist .bar { width: 100%; border-radius: 10px 10px 4px 4px; background: var(--c); height: calc(var(--h, 0) * 100% - 0px); min-height: 6px; opacity: .45; transition: height .8s cubic-bezier(.2,.8,.2,1); }
.dist .col.right .bar { opacity: 1; box-shadow: 0 0 0 3px var(--good); }
.dist .n { font-weight: 800; font-variant-numeric: tabular-nums; }
.dist .badge { width: 2.1rem; height: 2.1rem; font-size: 1rem; }
.dist .col.i0 { --c: var(--o0); } .dist .col.i1 { --c: var(--o1); } .dist .col.i2 { --c: var(--o2); } .dist .col.i3 { --c: var(--o3); }
.dist .col.right .badge::after { content: "✓"; position: absolute; transform: translate(1.2rem, -1rem); background: var(--good); width: 1.3rem; height: 1.3rem; font-size: .8rem; border-radius: 50%; display: grid; place-items: center; }
.dist .col .badge { position: relative; }
.screen .dist { height: 24vh; }

.legend i.a { background: var(--accent); } .legend i.g { background: var(--gold); }

/* ---- podium ---- */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 10px; margin: 18px auto 8px; max-width: 520px; height: 230px; }
.podium .step { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.podium .who { font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .sc { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; margin-bottom: 4px; }
.podium .blk { width: 100%; border-radius: 14px 14px 0 0; background: var(--accent); color: var(--accent-fg); font-weight: 800; font-size: 2rem; display: grid; place-items: start center; padding-top: 6px; height: 0; transition: height .9s cubic-bezier(.2,.8,.2,1); }
.podium .p1 .blk { background: var(--gold); color: var(--gold-fg); }
.podium .step.me .who { color: var(--accent); }
.screen .podium { max-width: 900px; height: 36vh; }

/* ---- screen (projector) ---- */
.screen main { max-width: none; padding: 22px 4vw; }
.screen .qtext { font-size: clamp(1.8rem, 4.6vw, 4rem); font-weight: 800; line-height: 1.1; margin: .2em 0 .5em; text-wrap: balance; letter-spacing: -.02em; }
.screen .opt { min-height: 16vh; font-size: clamp(1.2rem, 2.8vw, 2.4rem); }
.screen .badge { width: clamp(2.6rem, 5vw, 4rem); height: clamp(2.6rem, 5vw, 4rem); font-size: clamp(1.2rem, 2.4vw, 2rem); }
.screen .count { font-size: 1.5rem; font-weight: 700; text-align: center; }
.screen .top .in { max-width: none; padding-inline: 4vw; }
.joinline { font-size: clamp(1rem, 2.2vw, 1.8rem); color: var(--muted); }
.joinline b { color: var(--fg); }

/* ---- editor / lists ---- */
.qrow { border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin: 14px 0; background: var(--card); box-shadow: var(--shadow); }
.qrow .opts { display: grid; gap: 8px; margin-top: 10px; }
.qrow .opt-row { display: flex; gap: 10px; align-items: center; }
.qrow .opt-row .badge { width: 2rem; height: 2rem; font-size: .9rem; background: var(--c); }
.qrow .opt-row:nth-child(1) { --c: var(--o0); } .qrow .opt-row:nth-child(2) { --c: var(--o1); }
.qrow .opt-row:nth-child(3) { --c: var(--o2); } .qrow .opt-row:nth-child(4) { --c: var(--o3); }
.qrow input[type=radio] { width: 1.3rem; height: 1.3rem; accent-color: var(--good); flex: none; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--line); }
/* account page: AI assistant connect URL and one-time token */
#mcp-url, #tok-secret { flex: 1; min-width: 12ch; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }
.tokenbox { border-color: var(--accent); }
.row select { max-width: 100%; padding: 13px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); }
form.row input[type=text] { flex: 1 1 14ch; width: auto; }
.qcard h2 { text-transform: none; letter-spacing: -.01em; color: var(--fg); font-size: 1.25rem; margin: 0 0 .2em; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media (max-width: 420px) { .options { gap: 8px; } .opt { padding: 10px; min-height: 84px; } .pts li { grid-template-columns: 1.8rem minmax(0, 6.5rem) 1fr; } }

/* legal pages */
main.legal { line-height: 1.55; }
main.legal h1 { font-size: 1.6rem; }
main.legal h3 { margin-top: 1.4em; }
main.legal ul, main.legal ol { padding-left: 1.3em; }
main.legal li { margin: .35em 0; }
main.legal a { color: var(--link, inherit); }

/* question images */
.qimg { display: block; max-width: 100%; max-height: 38vh; margin: 8px auto 14px; border-radius: 14px; object-fit: contain; }
.qimg[hidden] { display: none; }
.screen-body .qimg, body.screen .qimg { max-height: 44vh; }
.qimg.thumb { max-height: 90px; margin: 0; }
.mediarow { margin: 6px 0 10px; }

/* ---- editor layout, preview, validation badges ---- */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
main.editor-page { max-width: 1100px; }
.editor { display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 18px; align-items: start; }
.editor .side { position: sticky; top: 8px; display: grid; gap: 8px; }
.outline { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.oitem { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.oitem a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); text-decoration: none; }
.oitem.dragging { opacity: .5; } .oitem.over { outline: 3px dashed var(--accent); outline-offset: 1px; }
.handle { cursor: grab; color: var(--muted); user-select: none; }
.qbadge { font-weight: 700; } .qbadge.small { color: var(--bad); } .qbadge[hidden] { display: none; }
.counter { font-size: .8rem; white-space: nowrap; }
.banner { border-color: var(--gold); border-width: 2px; }
.hostbox { display: grid; gap: 6px; margin-top: 10px; }
.preview { margin-top: 10px; padding: 12px; border: 2px dashed var(--line); border-radius: 14px; background: var(--bg); }
.preview .qtext { font-size: 1.25rem; font-weight: 800; margin: .3em 0; }
.preview .options { margin-top: 6px; }
.preview .opt { cursor: default; min-height: 56px; }
.preview .opt.phone-only { min-height: 80px; }
.qrow .opt-row input[type=text] { flex: 1; min-width: 0; }
button.link[aria-pressed=true] { font-weight: 800; text-decoration: underline; }
button.link[aria-disabled=true] { opacity: .6; }
@media (max-width: 760px) { .editor { grid-template-columns: 1fr; } .editor .side { position: static; } }
@media (forced-colors: active) { button:focus-visible, input:focus, textarea:focus, select:focus-visible, a:focus-visible { outline: 3px solid Highlight; } }

.devbanner { background: #b00020; color: #fff; text-align: center; padding: 6px 12px; font-weight: 700; }

/* layout fixes */
.editor > * { min-width: 0; }
ul.plain > li.card { padding: 14px 16px; border-bottom: 1px solid var(--line); }
ul.plain > li.card .row { flex-wrap: wrap; gap: 6px 12px; }
.editor .side > * { min-width: 0; max-width: 100%; }
.editor .side input, .editor .side select, .editor .side button { width: 100%; box-sizing: border-box; }
.row.center { justify-content: center; }
.qcard .row { gap: 8px 12px; }
.qcard .row select { flex: 1 1 14rem; }
.outline { grid-template-columns: minmax(0, 1fr); }
.oitem { min-width: 0; }
.mediarow { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.error:empty { display: none; }
