/* edge-case — the whole game is a code editor.
   Tokens first, then chrome (title bar, tabs, status bar), then the editor, then moments. */

@font-face { font-family: "Plex"; src: url(/fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex"; src: url(/fonts/ibm-plex-mono-latin-400-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Plex"; src: url(/fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex"; src: url(/fonts/ibm-plex-mono-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Martian"; src: url(/fonts/martian-mono-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Martian"; src: url(/fonts/martian-mono-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Martian"; src: url(/fonts/martian-mono-latin-800-normal.woff2) format("woff2"); font-weight: 800; font-display: swap; }

:root {
  --font: "Plex", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --display: "Martian", "Plex", ui-monospace, monospace;

  /* type scale (mobile first) */
  --fs-xs: 11px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-prompt: clamp(22px, 6.2vw, 34px);
  --fs-big: clamp(34px, 11vw, 64px);

  --gutter-w: 34px;
  --pad: 16px;
  --radius: 6px;
  --ease-pop: cubic-bezier(.2, 1.6, .4, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  /* dark theme (default) */
  --bg: #0e1013;
  --bg-2: #13161b;
  --panel: #171a20;
  --line: #222730;
  --line-2: #2c323d;
  --hl: #1a1e25;
  --text: #dde2e8;
  --muted: #9aa3ae;
  --dim: #7f8893;
  --gutter: #4a525d;
  --comment: #8a93a0;
  --kw: #c9a6ff;
  --fn: #7fc1ff;
  --str: #ffab7d;
  --prop: #7ed9c3;
  --punct: #8e98a4;
  --accent: #7fc1ff;
  --danger: #ff7a7a;
  --warn: #ffb35c;
  --ok: #57d68d;

  --g0: #1b2028;
  --g1: #0e4429;
  --g2: #006d32;
  --g3: #26a641;
  --g4: #39d353;
  --gold: #f6c54a;
  --gold-2: #ffe08a;
  --gold-glow: rgba(246, 197, 74, .55);
  --gold-text: #f6c54a;
  --gold-text-2: #ffe08a;
  --green-text: #3fbf5d;
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f5f0;
    --bg-2: #f1eee7;
    --panel: #ebe7de;
    --line: #dfdacf;
    --line-2: #d2ccbf;
    --hl: #efebe2;
    --text: #1d2024;
    --muted: #59606a;
    --dim: #69707a;
    --gutter: #a39c8f;
    --comment: #6f6a60;
    --kw: #7a3fd1;
    --fn: #0a5fb8;
    --str: #b23f1f;
    --prop: #0b6f61;
    --punct: #6d6a63;
    --accent: #0a5fb8;
    --danger: #c42b2b;
    --warn: #b35f00;
    --ok: #18794e;

    --g0: #e4e0d6;
    --g1: #9be9a8;
    --g2: #40c463;
    --g3: #30a14e;
    --g4: #216e39;
    --gold: #e0a300;
    --gold-2: #ffcf4a;
    --gold-glow: rgba(224, 163, 0, .45);
    --gold-text: #8a6100;
    --gold-text-2: #c48a00;
    --green-text: #1f7a3a;
    --shadow: 0 10px 40px rgba(60, 50, 30, .16);
    color-scheme: light;
  }
}

@media (min-width: 760px) {
  :root { --fs-md: 16px; --gutter-w: 48px; --pad: 24px; }
}
@media (max-width: 600px) {
  .logo { padding: 0 10px; }
  .logo-text { display: none; }
  .tab { padding: 0 11px; gap: 5px; }
  .tab .ext { display: none; }
  .account .sign-label { display: none; }
  .account { padding: 6px 8px; }
  .icon-btn { width: 32px; }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-md)/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--fn); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* syntax colors */
.c { color: var(--comment); font-style: italic; }
.k { color: var(--kw); }
.f { color: var(--fn); }
.s { color: var(--str); }
.p { color: var(--punct); }
.pr { color: var(--prop); }
.m { color: var(--muted); }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }

/* ---------- app frame ---------- */
.app {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--vv-top, 0px);
  height: var(--app-h, 100dvh);
  display: flex;
  flex-direction: column;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.titlebar {
  display: flex;
  align-items: stretch;
  gap: 4px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-height: 44px;
  padding-top: env(safe-area-inset-top);
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 14px;
  font: 600 13px/1 var(--display);
  letter-spacing: -.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.logo b { color: var(--str); font-weight: 600; margin: 0 -.12em; }
.logo-mark { display: grid; grid-template-columns: repeat(2, 7px); gap: 2px; }
.logo-mark i { width: 7px; height: 7px; border-radius: 2px; background: var(--g2); }
.logo-mark i:nth-child(2) { background: var(--g4); }
.logo-mark i:nth-child(3) { background: var(--g1); }
.logo-mark i:nth-child(4) { background: var(--gold); box-shadow: 0 0 6px var(--gold-glow); }

.tabs { display: flex; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  white-space: nowrap;
  position: relative;
}
.tab:first-child { border-left: 1px solid var(--line); }
.tab[aria-selected="true"] { background: var(--bg); color: var(--text); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--str); }
.tab:hover { color: var(--text); }
.ext { font: 600 8px/1 var(--display); padding: 3px 3px 2px; border-radius: 3px; letter-spacing: .02em; }
.ext-ts { color: #3178c6; background: color-mix(in srgb, #3178c6 18%, transparent); }
.ext-md { color: var(--prop); background: color-mix(in srgb, var(--prop) 16%, transparent); }
.ext-todo { color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, transparent); font-size: 9px; }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text); opacity: 0; transition: opacity .2s; }
.tab .dot.on { opacity: .8; }

.actions { display: flex; align-items: center; gap: 2px; padding-right: 8px; }
.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--muted);
  font: 600 14px/1 var(--display);
}
.icon-btn:hover { background: var(--hl); color: var(--text); }
#sound-btn svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#sound-btn .spk { fill: currentColor; stroke: none; }
#sound-btn[aria-pressed="false"] .waves { display: none; }
#sound-btn[aria-pressed="true"] .mute { display: none; }
#sound-btn[aria-pressed="true"] { color: var(--str); }
.account {
  display: flex; align-items: center; gap: 8px;
  margin-left: 4px; padding: 5px 10px;
  border: 1px solid var(--line-2); border-radius: 6px;
  color: var(--text); text-decoration: none; font-size: var(--fs-sm); white-space: nowrap;
}
.account:hover { border-color: var(--muted); }
.account img { width: 20px; height: 20px; border-radius: 50%; }
.account svg { fill: currentColor; }

.crumbs {
  font-size: var(--fs-xs);
  color: var(--dim);
  padding: 5px var(--pad) 5px calc(var(--gutter-w) + 14px);
  border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.crumbs b { color: var(--muted); font-weight: 400; }
.crumbs i { font-style: normal; opacity: .55; margin: 0 6px; }

/* ---------- editor ---------- */
.editor {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0 24px;
  counter-reset: ln;
  scroll-behavior: smooth;
  outline: none;
}
.editor-inner { max-width: 920px; }
.editor.bottom { display: flex; flex-direction: column; }
.editor.bottom > .editor-inner { margin-top: auto; width: 100%; }
.ln {
  display: grid;
  grid-template-columns: var(--gutter-w) 1fr;
  gap: 14px;
  padding-right: var(--pad);
  min-height: 1.6em;
}
.ln::before {
  counter-increment: ln;
  content: counter(ln);
  color: var(--gutter);
  text-align: right;
  font-size: var(--fs-sm);
  line-height: inherit;
  padding-top: .1em;
  user-select: none;
}
.ln.nonum::before { content: ""; counter-increment: none; }
.ln > .code { min-width: 0; overflow-wrap: anywhere; }
.ln.hl { background: var(--hl); }
.ln.cur { background: var(--hl); box-shadow: inset 2px 0 0 var(--str); }
.indent { padding-left: 2ch; }

/* the prompt as a doc comment */
.doc { color: var(--comment); }
.doc .star { color: var(--comment); font-style: normal; opacity: .7; }
.prompt-line { padding-top: 2px; padding-bottom: 4px; }
.prompt-text {
  font-size: var(--fs-prompt);
  line-height: 1.18;
  font-weight: 500;
  color: var(--text);
  font-style: normal;
  letter-spacing: -.01em;
  display: block;
  margin: .05em 0 .1em;
  text-wrap: balance;
}
.prompt-hint { font-size: var(--fs-sm); color: var(--muted); font-style: italic; }
.prompt-hint .tag { color: var(--kw); font-style: normal; }
.timer {
  font: 600 var(--fs-lg)/1 var(--display);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  margin-left: .5ch;
}
.timer.low { color: var(--warn); }
.timer.crit { color: var(--danger); animation: tick 1s steps(1) infinite; }
@keyframes tick { 50% { opacity: .55; } }

/* completed prompt rows */
.row-call .sq { vertical-align: -3px; margin-right: .5ch; }
.row-result { display: flex; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.answer-str { color: var(--str); }
.answer-str.miss { color: var(--dim); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 70%, transparent); }
.tier-label { font-weight: 600; letter-spacing: .02em; }
.tier-intern, .tier-junior { color: var(--green-text); }
.tier-senior, .tier-principal { color: var(--g4); }
.tier-greybeard { color: var(--gold-text); text-shadow: 0 0 14px var(--gold-glow); }
.pts { font: 600 var(--fs-md)/1 var(--display); font-variant-numeric: tabular-nums; }
.feedback { color: var(--comment); font-style: italic; }

/* contribution squares */
.sq {
  --s: 14px;
  width: var(--s); height: var(--s);
  border-radius: 3px;
  background: var(--g0);
  display: inline-block;
  flex: none;
  outline: 1px solid color-mix(in srgb, var(--text) 6%, transparent);
  outline-offset: -1px;
}
.sq[data-tier="intern"] { background: var(--g1); }
.sq[data-tier="junior"] { background: var(--g2); }
.sq[data-tier="senior"] { background: var(--g3); }
.sq[data-tier="principal"] { background: var(--g4); }
.sq[data-tier="greybeard"] { background: var(--gold); box-shadow: 0 0 10px var(--gold-glow), 0 0 2px var(--gold-2) inset; outline-color: transparent; }
.sq[data-tier="miss"] { background: var(--g0); }
.sq[data-tier="pending"] { background: transparent; outline: 1px dashed var(--line-2); }
.sq[data-tier="active"] { background: transparent; outline: 1.5px solid var(--str); animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .45; } }
.sq.big { --s: 22px; border-radius: 4px; }
.sq.huge { --s: min(46px, calc((100vw - var(--gutter-w) - 14px - var(--pad) - 2ch - 42px) / 7)); border-radius: 6px; }

/* ---------- composer (the line you type on) ---------- */
.composer {
  position: relative;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom)) 0;
}
.composer .timebar {
  position: absolute; left: 0; top: -1px; height: 2px;
  background: var(--str);
  transform-origin: left; width: 100%;
}
.composer .timebar.low { background: var(--warn); }
.composer .timebar.crit { background: var(--danger); }
.input-line {
  display: grid;
  grid-template-columns: var(--gutter-w) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
}
.field-wrap { min-width: 0; }
.call-ctx { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.call-ctx .slot-mark { color: var(--str); opacity: .8; margin: 0 1px; }
.input-line .no { color: var(--gutter); text-align: right; font-size: var(--fs-sm); }
.field {
  display: flex; align-items: center; min-width: 0;
  font-size: var(--fs-lg);
  padding: 4px 0 2px;
  border-bottom: 1px solid var(--line-2);
}
.field:focus-within { border-bottom-color: var(--str); }
.field .fn-call { color: var(--fn); white-space: nowrap; }
.field .q { color: var(--str); }
.field input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  color: var(--str);
  font-size: max(18px, var(--fs-lg)); /* 16px+ stops iOS zooming */
  padding: 0;
  caret-color: var(--text);
}
.field input::placeholder { color: color-mix(in srgb, var(--str) 38%, transparent); font-style: italic; }
.field .tail { color: var(--punct); white-space: nowrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: transform .08s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { background: color-mix(in srgb, var(--text) 88%, var(--bg)); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1d1600; }
.btn .kbd { font-size: 10px; opacity: .65; border: 1px solid currentColor; border-radius: 3px; padding: 1px 4px; }
.btn.wide { width: 100%; height: 52px; font-size: var(--fs-md); }
.composer-actions { display: flex; gap: 8px; padding-left: calc(var(--gutter-w) + 14px); margin-top: 8px; flex-wrap: wrap; }
.composer-note { padding-left: calc(var(--gutter-w) + 14px); font-size: var(--fs-sm); color: var(--comment); font-style: italic; min-height: 1.4em; }
.suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.suggest .q-text { font-size: var(--fs-md); }

/* ---------- the reveal ---------- */
.reveal .sq { animation: pop .55s var(--ease-pop) both; }
.reveal .tier-label { animation: rise .35s var(--ease-out) .18s both; }
.reveal .pts { animation: rise .35s var(--ease-out) .26s both; }
.reveal .feedback { animation: fade .5s ease .5s both; }
@keyframes pop { 0% { transform: scale(0) rotate(-12deg); } 70% { transform: scale(1.35) rotate(3deg); } 100% { transform: scale(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.ln.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: color-mix(in srgb, var(--g3) 22%, transparent); } 100% { background: transparent; } }
.ln.flash-miss { animation: flashmiss 1s ease-out; }
@keyframes flashmiss { 0% { background: color-mix(in srgb, var(--danger) 14%, transparent); } 100% { background: transparent; } }

/* Greybeard: the rare celebration */
.ln.gb { animation: gbflash 2.4s ease-out; position: relative; }
@keyframes gbflash { 0% { background: color-mix(in srgb, var(--gold) 30%, transparent); } 100% { background: transparent; } }
.gb .sq[data-tier="greybeard"] { animation: pop .7s var(--ease-pop) both, glow 2.2s ease-in-out .7s 3; }
@keyframes glow { 50% { box-shadow: 0 0 22px 4px var(--gold-glow), 0 0 2px var(--gold-2) inset; } }
.gb .tier-label { letter-spacing: .14em; text-transform: uppercase; animation: rise .4s var(--ease-out) .3s both, shimmer 2.4s linear .7s 2; background: linear-gradient(90deg, var(--gold-text) 0%, var(--gold-text-2) 45%, var(--gold-text) 60%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; }
@keyframes shimmer { to { background-position: -200% 0; } }
.burst { position: absolute; pointer-events: none; width: 0; height: 0; }
.burst i {
  position: absolute; width: 7px; height: 7px; border-radius: 2px;
  background: var(--gold);
  animation: fly 1.1s var(--ease-out) forwards;
  opacity: 0;
}
.burst i:nth-child(3n) { background: var(--g4); }
.burst i:nth-child(4n) { background: var(--gold-2); }
@keyframes fly {
  0% { transform: translate(0, 0) scale(.4) rotate(0); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot)); opacity: 0; }
}
.gb-banner {
  font: 800 var(--fs-sm)/1 var(--display);
  letter-spacing: .3em;
  color: var(--gold-text);
  text-shadow: 0 0 18px var(--gold-glow);
  animation: rise .5s var(--ease-out) .5s both;
}

/* ---------- results ---------- */
.log-head { color: var(--str); }
.log-head .k { color: var(--gold-text); }
.score-big { font: 800 var(--fs-big)/1 var(--display); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.score-big small { font-size: .32em; color: var(--muted); font-weight: 400; letter-spacing: 0; margin-left: .4ch; }
.grid7 { display: flex; gap: 6px; margin: 6px 0 4px; }
.results-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.results-table td { padding: 6px 8px 6px 0; vertical-align: top; border-bottom: 1px dashed var(--line); }
.cta-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.countdown { font: 600 var(--fs-lg)/1 var(--display); font-variant-numeric: tabular-nums; color: var(--text); }
.others { font-size: var(--fs-sm); color: var(--muted); }
.others b { color: var(--text); font-weight: 500; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 8px 0 14px; max-width: 640px; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: var(--bg-2); }
.stat .v { font: 800 clamp(24px, 7vw, 34px)/1 var(--display); letter-spacing: -.03em; }
.stat .l { font-size: var(--fs-xs); color: var(--muted); margin-top: 6px; text-transform: uppercase; letter-spacing: .08em; }
.cal { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 11px); gap: 3px; overflow-x: auto; padding: 4px 0 8px; }
.cal .sq { --s: 11px; border-radius: 2px; }
.cal .sq.none { background: var(--g0); outline: none; opacity: .55; }
.bars { display: grid; gap: 6px; max-width: 520px; }
.bar { display: grid; grid-template-columns: 9ch 1fr 4ch; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.bar .track { height: 10px; background: var(--g0); border-radius: 3px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 3px; }

/* ideas */
.idea { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.vote {
  display: grid; justify-items: center; gap: 2px; min-width: 46px; padding: 6px 4px;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg-2);
  font: 600 var(--fs-sm)/1 var(--display);
}
.vote[aria-pressed="true"] { border-color: var(--g3); color: var(--g4); background: color-mix(in srgb, var(--g3) 12%, var(--bg-2)); }
.idea-text { font-size: var(--fs-md); }
.idea-meta { font-size: var(--fs-xs); color: var(--dim); }
.badge { font-size: 10px; padding: 1px 6px; border-radius: 999px; border: 1px solid currentColor; text-transform: uppercase; letter-spacing: .06em; }
.badge.ok { color: var(--ok); }
.form { display: grid; gap: 10px; max-width: 560px; margin: 8px 0 16px; }
.form label { font-size: var(--fs-sm); color: var(--muted); }
.form input, .form textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text);
  font-size: 16px;
}
.form input:focus, .form textarea:focus { border-color: var(--accent); outline: none; }

/* board */
.board { list-style: none; padding: 0; margin: 6px 0; max-width: 520px; }
.board li { display: grid; grid-template-columns: 3ch 24px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: var(--fs-sm); }
.board img { width: 24px; height: 24px; border-radius: 50%; background: var(--g0); }
.board .me { color: var(--str); }

/* ---------- onboarding demo ---------- */
.demo-skip { position: sticky; top: 0; float: right; margin-right: var(--pad); z-index: 2; }
.typing::after { content: "▌"; color: var(--text); animation: blink 1s steps(1) infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- states ---------- */
.state-msg { color: var(--comment); font-style: italic; }
.cursor-blink::after { content: "▌"; font-style: normal; color: var(--text); animation: blink 1s steps(1) infinite; }
.err { color: var(--danger); }
.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  font-size: var(--fs-sm); box-shadow: var(--shadow); z-index: 50;
  animation: rise .25s var(--ease-out);
  max-width: calc(100vw - 32px);
}

/* ---------- status bar ---------- */
.statusbar {
  display: flex; align-items: center; gap: 14px;
  min-height: 26px;
  padding: 3px 12px calc(3px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs);
  color: var(--muted);
  white-space: nowrap; overflow: hidden;
}
.composer:not([hidden]) ~ .statusbar { padding-bottom: 3px; }
.sb-item { display: inline-flex; align-items: center; gap: 6px; }
.sb-spacer { flex: 1; }
.sb-dim { color: var(--dim); }
.sb-squares { gap: 3px; }
.sb-squares .sq { --s: 9px; border-radius: 2px; }
.sb-streak .flame { color: var(--warn); }
.sb-wide { display: none; }
@media (min-width: 760px) { .sb-wide { display: inline-flex; } }
@media (max-width: 380px) { #sb-pos { display: none; } }

/* Keep the status bar out of the way while the keyboard is up on phones. */
.kb-open .statusbar { display: none; }
.kb-open .crumbs { display: none; }

/* ---------- desktop: an explorer sidebar ---------- */
@media (min-width: 1100px) {
  .editor { padding-top: 24px; }
  .editor-inner { margin-left: auto; margin-right: auto; width: 100%; max-width: 880px; }
  .composer .input-line, .composer .composer-actions, .composer .composer-note { max-width: 880px; margin-left: auto; margin-right: auto; }
  .composer .composer-actions { padding-left: calc(var(--gutter-w) + 14px); }
  .crumbs { padding-left: max(calc(var(--gutter-w) + 14px), calc((100vw - 880px) / 2 + var(--gutter-w) + 14px)); }
  .btn.wide { max-width: 420px; }
}

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .burst { display: none; }
}

/* scoring legend on the start screen */
.legend-row { display: grid; grid-template-columns: 14px 10ch 1fr auto; gap: 10px; align-items: center; max-width: 420px; font-size: var(--fs-sm); }
.legend-row .pts { font-size: var(--fs-sm); color: var(--muted); }

/* rejected attempts: the answer field shakes, a lint-style line appears under the prompt */
.ln.attempt { animation: rise .25s var(--ease-out); }
.attempt-text { font-size: var(--fs-sm); }
.field.nope { animation: nope .32s ease; border-bottom-color: var(--danger); }
@keyframes nope { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

/* answer key after finishing */
.btn.sm { height: 30px; padding: 0 10px; font-size: var(--fs-xs); border-radius: 6px; }
.key-toggle { color: var(--fn); }
.answer-key { padding: 4px var(--pad) 8px calc(var(--gutter-w) + 14px + 2ch); }
.key-wrap { border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); padding: 12px; max-width: 820px; }
.key-filter { width: 100%; height: 38px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--bg); color: var(--text); font-size: 16px; margin-bottom: 6px; }
.key-filter:focus { outline: none; border-color: var(--accent); }
.key-group { margin-top: 10px; }
.key-head { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); margin-bottom: 6px; }
.key-head .pts { font-size: var(--fs-sm); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; max-height: 260px; overflow-y: auto; }
.chip { font-size: var(--fs-xs); padding: 3px 7px; border-radius: 5px; border: 1px solid var(--line); background: var(--bg); color: var(--text); line-height: 1.4; }
.chip small { color: var(--dim); font-size: 10px; }
.chip.mine { border-color: var(--str); color: var(--str); }
.chip.more { color: var(--fn); cursor: pointer; }
.key-note { font-size: var(--fs-xs); margin: 10px 0 0; font-style: italic; color: var(--comment); }

/* Phones: drop the decorative lines, keep the game. Older one-liners hide; the newest stays. */
@media (max-width: 600px) {
  .ln.deco { display: none; }
  .slot.done:not(.latest) .ln.fb { display: none; }
  .prompt-hint { font-size: var(--fs-xs); }
  .ln.attempt ~ .ln.attempt ~ .ln.attempt { display: none; }
}

/* compact one-line version of a finished prompt (phones only) */
.ln.compact { display: none; }
.row-compact { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--fs-sm); }
.row-compact .answer-str { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row-compact .pts { margin-left: auto; font-size: var(--fs-sm); }
.row-compact .sq { --s: 12px; }

@media (max-width: 600px) {
  :root { --gutter-w: 24px; }
  .ln { gap: 10px; }
  /* older prompts: one line each; the newest one stays in full */
  .slot.done:not(.latest) .ln.full,
  .slot.done:not(.latest) .ln.fb { display: none; }
  .slot.done:not(.latest) .ln.compact { display: grid; }
  .slot.done.latest .ln.fb .feedback { font-size: var(--fs-sm); }
  .gb .tier-label { letter-spacing: .06em; }
  .prompt-text { font-size: clamp(22px, 6.4vw, 28px); }
  .doc .c.star { display: none; }
}
