:root {
  --bg: #0c0c11;
  --ink: #e9e6dc;
  --ink-soft: #bdb8aa;
  --muted: #8a8578;
  --line: rgba(233, 230, 220, 0.16);
  --line-2: rgba(233, 230, 220, 0.24);
  --hair: rgba(233, 230, 220, 0.1);
  --card: #17161d;
  --accent: #f3d27a;
  --jam: #f3d27a;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: var(--sans); overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ── top bar ── */
.bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.brand { font-family: var(--mono); letter-spacing: 0.12em; font-size: 12px; color: var(--muted); }
.about-pill {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-2); background: rgba(12, 12, 17, 0.6);
  border-radius: 999px; padding: 4px 11px 4px 8px; font-size: 12px; color: var(--ink-soft); text-decoration: none;
  backdrop-filter: blur(6px);
}
.about-pill:hover { color: var(--ink); border-color: var(--ink); }
.about-pill [aria-hidden] { font-size: 14px; line-height: 1; }
.lenses {
  display: flex; gap: 4px; margin-left: auto; flex-wrap: nowrap;
  min-width: 0; overflow-x: auto; scrollbar-width: none; /* safety net: if the bar still can't fit it scrolls, never clips */
}
.lenses::-webkit-scrollbar { display: none; }
.lens, .restart, .brand, .about-pill { flex: none; white-space: nowrap; }
/* compact mode is switched on by lenses.slice.js when the full bar doesn't fit, whatever the width */
#app.compact-bar .bar:has(.lenses:not([hidden])) .brand,
#app.compact-bar .bar:has(.lenses:not([hidden])) .about-pill .word { display: none; }
#app.compact-bar .bar:has(.lenses:not([hidden])) .about-pill { padding: 4px 8px; }
#app.compact-bar .bar { gap: 6px; }
#app.compact-bar .lens, #app.compact-bar .restart { padding: 5px 9px; }
#app.compact-bar .lens:not(.on) .full { display: none; }
#app.compact-bar .lens:not(.on) .short { display: inline; min-width: 1.2em; text-align: center; }
.lens .short { display: none; }
.lens, .restart {
  appearance: none; border: 1px solid var(--line); background: rgba(12, 12, 17, 0.6);
  border-radius: 999px; padding: 5px 11px; font-size: 12px; cursor: pointer; color: var(--ink-soft);
  backdrop-filter: blur(6px);
}
.lens.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.restart { margin-left: 4px; }
.lenses[hidden] + .restart { margin-left: auto; }
.restart.armed { color: var(--accent); border-color: var(--accent); }

/* ── stage ── */
.stage { position: relative; flex: 1; min-height: 0; }
.flat, .fx, .depth { position: absolute; inset: 0; width: 100%; height: 100%; }
.fx { z-index: 15; pointer-events: none; }
.depth { touch-action: none; }
.depth canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.real-cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1.6s ease; background: #000; }
.real-cam.on { opacity: 1; }

/* the ring you hold the light in */
.reticle {
  --p: 0; position: fixed; z-index: 26; left: 50%; top: 50%; width: 92px; height: 92px; margin: -46px 0 0 -46px;
  border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--accent) calc(var(--p) * 1turn), rgba(233, 230, 220, 0.28) 0);
  -webkit-mask: radial-gradient(circle, transparent 41px, #000 42px);
  mask: radial-gradient(circle, transparent 41px, #000 42px);
  transition: transform 0.4s, opacity 0.6s;
}
.reticle.done { transform: scale(1.6); opacity: 0; }
.echo-arrow {
  position: fixed; z-index: 26; left: 50%; top: 50%; color: var(--accent); font-size: 26px; pointer-events: none;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.7); animation: nudge 1s ease-in-out infinite;
}
@keyframes nudge { 50% { opacity: 0.55; } }

/* ── words ── */
.words {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  max-width: 720px; margin: 0 auto; padding: 56px 16px max(16px, env(safe-area-inset-bottom));
  font-family: var(--mono); font-size: 16px; line-height: 1.55;
}
.log { flex: 1; overflow-y: auto; padding: 8px 8px 16px; scrollbar-width: thin; }
.log p { margin: 0; min-height: 1.55em; white-space: pre-wrap; animation: appear 0.5s ease both; }
.log p.me { color: var(--accent); margin-top: 0.8em; }
.log p.dim { color: var(--muted); }
.log p.title { letter-spacing: 0.12em; font-size: 22px; margin: 0.6em 0 0.4em; }
@keyframes appear { from { opacity: 0; transform: translateY(3px); } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0; }
.chips button {
  appearance: none; border: 1px solid var(--line-2); background: transparent; border-radius: 6px;
  padding: 6px 10px; font-family: var(--mono); font-size: 13px; color: var(--ink-soft); cursor: pointer;
}
.chips button:hover { border-color: var(--ink); color: var(--ink); }
.ask { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 10px; color: var(--accent); }
.ask input {
  flex: 1; appearance: none; border: none; background: transparent; outline: none;
  font: inherit; color: var(--ink); caret-color: var(--accent); padding: 6px 0;
}
@media (max-width: 520px) { .words { font-size: 14px; } }

/* ── level 0: bits ── */
/* fit rules for short and wide screens are at the end of this block */
.bits { position: absolute; inset: 0; font-family: var(--mono); overflow: hidden; background: #000401; --accent: #3ccf62; --jam: #3ccf62; }
.bits-rain { position: absolute; inset: 0; width: 100%; height: 100%; }
/* an old green monitor: faint scanlines over everything in level 0 */
.bits::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, 0.22) 2px 3px);
}
.bits-stage { position: absolute; inset: 0; display: grid; place-items: center; padding: 64px 16px max(24px, env(safe-area-inset-bottom)); }
.bits-echo { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 48px 64px; border-radius: 50%; background: radial-gradient(closest-side, rgba(0, 4, 1, 0.92) 60%, rgba(0, 4, 1, 0)); }
.bits-slots { display: flex; gap: 16px; font-size: 44px; color: var(--muted); }
.bits-slots span { width: 1ch; text-align: center; transition: color 0.2s, text-shadow 0.2s; }
.bits-slots span.on, .bits-slots.glow span { color: var(--accent); text-shadow: 0 0 18px rgba(60, 207, 98, 0.6); }
.bits-slots.shake, .riddle.shake { animation: shake 0.35s; }
.bits-note { margin: 0; min-height: 1.4em; color: var(--ink-soft); font-size: 16px; text-align: center; }
.bits-again { appearance: none; border: none; background: none; color: var(--muted); font-family: var(--mono); font-size: 14px; cursor: pointer; padding: 8px; }
.bits-pad { display: flex; gap: 14px; margin-top: 18px; }
.bits-pad button {
  width: 92px; height: 92px; border-radius: 18px; border: 1px solid rgba(60, 207, 98, 0.35); background: rgba(2, 10, 5, 0.88);
  font-family: var(--mono); font-size: 34px; color: var(--ink); cursor: pointer; touch-action: manipulation; user-select: none;
}
.bits-pad button:active { background: var(--accent); color: var(--bg); }
.bits-decode { width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.l-word { display: flex; gap: 14px; font-size: 34px; color: var(--line-2); letter-spacing: 0.05em; }
.l-word span.on { color: var(--accent); text-shadow: 0 0 14px rgba(60, 207, 98, 0.45); animation: appear 0.4s ease both; }
.l-word.glow span { text-shadow: 0 0 26px rgba(60, 207, 98, 0.9); }
.lesson {
  width: 100%; background: rgba(2, 10, 5, 0.9); box-shadow: 0 0 40px rgba(0, 0, 0, 0.8); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 14px 14px; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.l-text { margin: 0 0 10px; min-height: 2.9em; font-size: 16px; line-height: 1.45; color: var(--ink-soft); text-align: center; }
.l-grid { display: grid; grid-template-columns: repeat(8, 2.1ch); justify-content: center; text-align: center; }
.l-byte { font-size: 26px; }
.l-byte .pre { color: var(--ink); transition: color 0.8s; }
.explained .l-byte .pre { color: var(--line-2); }
.l-byte .one { transition: color 0.5s, text-shadow 0.5s; }
.show-vals .l-byte .one { color: var(--accent); text-shadow: 0 0 12px rgba(60, 207, 98, 0.5); }
.l-ruler, .l-vals { font-size: 26px; }
.l-ruler span, .l-vals span { font-size: 11px; transition: opacity 0.6s, transform 0.6s; opacity: 0; }
.l-ruler span { color: var(--muted); }
.show-ruler .l-ruler span { opacity: 1; }
.l-vals span { color: var(--accent); font-size: 14px; transform: translateY(-8px); }
.show-vals .l-vals span { opacity: 1; transform: none; }
.l-sum { margin: 8px 0 4px; min-height: 1.4em; font-size: 17px; color: var(--ink); text-align: center; }
.l-alpha { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; width: 100%; margin-top: 8px; }
.l-alpha button {
  appearance: none; border: 1px solid var(--line-2); background: transparent; border-radius: 8px; padding: 6px 0 4px;
  color: var(--ink); font-family: var(--mono); cursor: pointer; display: flex; flex-direction: column; align-items: center; line-height: 1.1;
}
.l-alpha button b { font-size: 16px; font-weight: 500; }
.l-alpha button small { font-size: 10px; color: var(--muted); }
.l-alpha button:active { background: var(--accent); color: var(--bg); }
.l-row { display: flex; gap: 10px; align-items: center; margin-top: 8px; min-height: 36px; }
.l-back { appearance: none; border: none; background: none; color: var(--muted); font-family: var(--mono); font-size: 14px; cursor: pointer; padding: 7px 10px; }
.reviewing .lesson { border-style: dashed; }
.lesson { touch-action: pan-y; }
.l-next { appearance: none; border: 1px solid var(--accent); background: transparent; color: var(--accent); border-radius: 999px; padding: 7px 16px; font-family: var(--mono); cursor: pointer; }
.lesson.shake { animation: shake 0.35s; }
.bits-hint { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-2); background: transparent; color: var(--ink-soft); font-family: var(--mono); cursor: pointer; }
.bits-skip { position: absolute; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); appearance: none; border: none; background: none; color: var(--muted); font-family: var(--mono); font-size: 12px; cursor: pointer; }
.fall { animation: fall 1.6s cubic-bezier(.5, 0, .9, .4) var(--d, 0s) forwards; }
/* Wide screens (Galaxy Fold inner, tablets): the alphabet in two rows of 13 */
@media (min-width: 600px) {
  .bits-decode { max-width: 760px; }
  .l-alpha { grid-template-columns: repeat(13, 1fr); }
}
/* Short screens: tighter, so the whole alphabet and the next row stay on screen */
@media (max-height: 560px) {
  .bits-stage { padding: 48px 16px 12px; }
  .bits-echo { padding: 16px 32px; gap: 10px; }
  .bits-slots { font-size: 34px; }
  .bits-pad { margin-top: 8px; }
  .bits-pad button { width: 64px; height: 56px; font-size: 28px; }
  .bits-decode { gap: 6px; }
  .l-word { font-size: 24px; }
  .lesson { padding: 8px 12px 8px; gap: 2px; }
  .l-text { margin: 0 0 4px; min-height: 2.4em; font-size: 14px; line-height: 1.3; }
  .l-byte, .l-ruler, .l-vals { font-size: 20px; }
  .l-ruler span { font-size: 10px; }
  .l-vals span { font-size: 12px; transform: none; }
  .l-sum { margin: 2px 0; min-height: 1.2em; font-size: 14px; }
  .l-alpha { gap: 3px; margin-top: 2px; }
  .l-alpha button { padding: 3px 0 2px; border-radius: 6px; }
  .l-alpha button b { font-size: 14px; }
  .l-alpha button small { font-size: 9px; }
  .l-row { margin-top: 2px; min-height: 32px; }
  .bits-hint { width: 32px; height: 32px; }
  .l-next { padding: 5px 14px; }
  .bits-skip { bottom: 4px; }
}
/* very short: the lesson card's text and ruler get a landscape-style squeeze */
@media (max-height: 460px) {
  .bits-stage { padding-top: 44px; }
  .l-word { font-size: 20px; }
  .l-text { min-height: 2.2em; font-size: 13px; }
  .l-byte, .l-ruler, .l-vals { font-size: 17px; }
  .l-alpha button b { font-size: 13px; }
}
@keyframes fall { to { transform: translateY(70vh) rotate(var(--r, 40deg)); opacity: 0; } }
.waking .lesson { border-color: transparent; background: transparent; transition: border-color 1s, background 1s; }
.waking .l-word span { animation: wake 2.4s ease 0.4s forwards; }
@keyframes wake { 40% { transform: scale(1.4); text-shadow: 0 0 30px rgba(60, 207, 98, 0.9); } 100% { transform: scale(1.4); opacity: 0; } }

/* ── overlays on the drawn lenses ── */
.goal, .caption, .keys {
  position: absolute; left: 16px; right: 16px; margin: 0 auto; max-width: 560px; text-align: center; z-index: 12;
  pointer-events: none;
}
.goal { top: max(50px, calc(env(safe-area-inset-top) + 44px)); font-size: 13px; color: var(--ink-soft); text-shadow: 0 1px 4px #000; }
.caption {
  bottom: 120px; padding: 10px 14px; border-radius: 10px; background: rgba(12, 12, 17, 0.82);
  border: 1px solid var(--line); font-size: 14px; line-height: 1.45;
  opacity: 0; transform: translateY(6px); transition: opacity 0.3s, transform 0.3s;
}
.caption.on { opacity: 1; transform: none; }
.keys { bottom: 14px; font-size: 11px; color: var(--muted); }
#app[data-lens="1"] .goal, #app[data-lens="1"] .caption, #app[data-lens="1"] .keys,
#app[data-lens="0"] .goal, #app[data-lens="0"] .caption, #app[data-lens="0"] .keys { display: none; }
@media (pointer: coarse) { .keys { display: none; } .caption { bottom: 222px; } }

/* ── the popups take each era's look ── */
/* Shapes: flat vector. A thick outline, square-ish, a hard offset shape for a shadow, no blur. */
#app[data-lens="2"] .caption {
  background: var(--bg); border: 2px solid var(--ink); border-radius: 4px;
  box-shadow: 5px 5px 0 rgba(233, 230, 220, 0.22); font-family: var(--sans); letter-spacing: 0.01em;
  opacity: 0; transform: translate(-4px, -4px) scale(0.96); transition: opacity 0.18s, transform 0.18s cubic-bezier(.3, 1.6, .5, 1);
}
#app[data-lens="2"] .caption.on { opacity: 1; transform: none; }
#app[data-lens="2"] .goal { font-family: var(--sans); font-weight: 600; letter-spacing: 0.04em; text-transform: lowercase; color: var(--ink); text-shadow: none; }
#app[data-lens="2"] .goal::before { content: "△ "; color: var(--accent); }

/* Pixels: a 16-bit text box. Stepped corners, a two-tone border, chunky mono, a hard 2px shadow, no easing. */
#app[data-lens="3"] .caption {
  border: none; border-radius: 0; background: #1b1525; color: #f4f1e8;
  font-family: var(--mono); font-size: 13px; line-height: 1.6; letter-spacing: 0.06em; text-transform: uppercase;
  text-shadow: 2px 2px 0 #000; image-rendering: pixelated;
  box-shadow: 0 -4px 0 #1b1525, 0 4px 0 #1b1525, -4px 0 0 #1b1525, 4px 0 0 #1b1525,
    0 -8px 0 #f4f1e8, 0 8px 0 #f4f1e8, -8px 0 0 #f4f1e8, 8px 0 0 #f4f1e8,
    -4px -4px 0 #f4f1e8, 4px -4px 0 #f4f1e8, -4px 4px 0 #f4f1e8, 4px 4px 0 #f4f1e8,
    0 12px 0 #000, 8px 8px 0 #000, 12px 0 0 #000;
  transition: opacity 0s steps(1), transform 0s; transform: none;
}
#app[data-lens="3"] .caption.on { animation: px-pop 0.24s steps(3) both; }
@keyframes px-pop { from { clip-path: inset(-16px -16px 100% -16px); } to { clip-path: inset(-16px); } }
#app[data-lens="3"] .goal { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; color: #f7d154; text-shadow: 2px 2px 0 #000; }
#app[data-lens="3"] .goal::before { content: "▶ "; }

/* Depth: the world has light now. Frosted glass over the sky, soft depth shadow, a gentle rise. */
#app[data-lens="4"] .caption {
  background: rgba(255, 255, 255, 0.62); color: #14202e; border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 18px; backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 18px 40px -12px rgba(10, 30, 60, 0.45), 0 2px 6px rgba(10, 30, 60, 0.15);
  transform: perspective(600px) translateY(14px) rotateX(18deg); transition: opacity 0.45s, transform 0.6s cubic-bezier(.2, .8, .2, 1);
}
#app[data-lens="4"] .caption.on { transform: perspective(600px) translateY(0) rotateX(0); }
#app[data-lens="4"] .goal {
  width: fit-content; padding: 6px 14px; border-radius: 999px; color: #14202e; text-shadow: none; font-weight: 500;
  background: rgba(255, 255, 255, 0.6); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 20px -8px rgba(10, 30, 60, 0.4);
}
#app[data-lens="4"] .goal:empty { display: none; }

/* Real: an AR label over the camera. Dark glass, a small live dot, crisp system type. */
#app[data-lens="5"] .caption {
  background: rgba(0, 0, 0, 0.5); color: #fff; border: none; border-radius: 999px; padding: 10px 18px 10px 30px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); font-size: 15px; font-weight: 500; width: fit-content;
}
#app[data-lens="5"] .caption::before {
  content: ""; position: absolute; left: 14px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px;
  border-radius: 50%; background: #ff453a; box-shadow: 0 0 0 3px rgba(255, 69, 58, 0.3);
}
#app[data-lens="5"] .goal { color: #fff; font-weight: 600; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7); }

/* ── touch pad ── */
.pad {
  position: fixed; z-index: 25; left: 16px; bottom: max(56px, calc(env(safe-area-inset-bottom) + 48px));
  display: grid; grid-template: repeat(3, 46px) / repeat(3, 46px); gap: 4px; touch-action: none;
}
.pad button {
  appearance: none; border: 1px solid var(--line-2); background: rgba(12, 12, 17, 0.55); border-radius: 12px;
  color: var(--ink-soft); font-size: 14px; user-select: none; -webkit-user-select: none; touch-action: none;
  backdrop-filter: blur(4px);
}
.pad button:active { background: rgba(233, 230, 220, 0.25); }
.pad .up { grid-area: 1 / 2; } .pad .left { grid-area: 2 / 1; } .pad .right { grid-area: 2 / 3; } .pad .down { grid-area: 3 / 2; }
@media (pointer: fine) { .pad { display: none; } }

.act {
  position: fixed; z-index: 25; right: 16px; bottom: max(110px, calc(env(safe-area-inset-bottom) + 100px));
  appearance: none; border: 1px solid var(--accent); background: rgba(12, 12, 17, 0.7); color: var(--accent);
  border-radius: 999px; padding: 12px 18px; font-size: 15px; cursor: pointer;
}

/* the question covers the bottom of the screen: the action button rides above it */
#app.asking .act { bottom: calc(var(--riddle-h, 0px) + max(24px, env(safe-area-inset-bottom)) + 12px); }

/* ── music box ── */
.musicbox {
  position: fixed; inset: 0; z-index: 35; display: grid; place-items: end center;
  padding: 16px 16px max(20px, env(safe-area-inset-bottom)); background: rgba(8, 8, 12, 0.5);
  opacity: 0; transition: opacity 0.25s;
}
.musicbox.open { opacity: 1; }
.mb-card {
  width: 100%; max-width: 460px; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 16px 14px; font-family: var(--mono);
}
.mb-head { display: flex; align-items: center; justify-content: space-between; }
.mb-title { letter-spacing: 0.25em; text-transform: uppercase; font-size: 12px; color: var(--muted); }
.mb-x { appearance: none; border: none; background: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px; }
.mb-status { margin: 10px 0 6px; min-height: 1.4em; color: var(--ink-soft); font-size: 14px; }
.mb-letters { display: flex; gap: 10px; justify-content: center; margin: 4px 0 14px; font-size: 22px; letter-spacing: 0.05em; color: var(--line-2); }
.mb-letters span.on { color: var(--accent); animation: appear 0.4s ease both; }
.mb-keys { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; touch-action: none; }
.mb-key {
  appearance: none; height: 116px; border-radius: 0 0 9px 9px; border: 1px solid #c9c3b4; background: linear-gradient(#f4f1e8, #e4dfd2);
  color: #4a463e; font-family: var(--mono); font-size: 13px; display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 10px; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none;
  transition: background 0.08s, transform 0.08s;
}
.mb-key.lit { background: linear-gradient(#fff3c4, var(--accent)); transform: translateY(2px); }
.musicbox.playing .mb-key { cursor: default; }
.mb-row { display: flex; justify-content: center; margin-top: 12px; }
.mb-listen { appearance: none; border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: 7px 14px; font-family: var(--mono); font-size: 12px; color: var(--ink-soft); cursor: pointer; }

/* ── the radio (Morse) ── */
.mo-tape { text-align: center; font-size: 22px; letter-spacing: 0.1em; min-height: 1.4em; color: var(--ink); margin: 2px 0 8px; }
.mo-keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; touch-action: none; }
.mo-key {
  appearance: none; height: 96px; border-radius: 14px; border: 1px solid #c9c3b4; background: linear-gradient(#f4f1e8, #e4dfd2);
  color: #3b372f; font-family: var(--mono); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none; transition: background 0.08s, transform 0.08s;
}
.mo-key b { font-size: 38px; line-height: 1; }
.mo-key small { font-size: 11px; color: #6f695d; }
.mo-key.lit { background: linear-gradient(#fff3c4, var(--accent)); transform: translateY(2px); }
.mo-card { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.mo-card b { color: var(--ink-soft); font-weight: 600; margin-right: 2px; }

/* ── episodes on the ending card ── */
.episodes { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.episodes .episode {
  appearance: none; border: 1px solid var(--line-2); background: transparent; color: var(--ink-soft); border-radius: 999px;
  padding: 7px 12px; font-size: 13px; cursor: pointer;
}
.episodes .episode.here { border-style: dashed; cursor: default; }
.episodes .episode:not(.here) { border-color: var(--accent); color: var(--accent); }

/* ── the light's question ── */
.riddle {
  position: fixed; z-index: 28; left: 16px; right: 16px; bottom: max(24px, env(safe-area-inset-bottom)); margin: 0 auto; max-width: 440px;
  background: rgba(23, 22, 29, 0.92); border: 1px solid var(--accent); border-radius: 16px; padding: 16px; backdrop-filter: blur(6px);
  max-height: calc(100dvh - 70px - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain;
}
.riddle-q { margin: 0 0 6px; font-size: 15px; }
.riddle-hint { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.riddle-row { display: flex; gap: 8px; }
.riddle-row input {
  flex: 1; min-width: 0; appearance: none; border: 1px solid var(--line-2); background: transparent; border-radius: 10px;
  padding: 10px 12px; color: var(--ink); font-family: var(--mono); font-size: 16px; text-transform: uppercase; letter-spacing: 0.15em;
}
.riddle-row button { appearance: none; border: none; background: var(--accent); color: var(--bg); border-radius: 10px; padding: 0 16px; font-weight: 600; cursor: pointer; }
.riddle-no { margin: 8px 0 0; min-height: 1.2em; font-size: 13px; color: var(--accent); }
.riddle.shake { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ── ending ── */
.ending {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center;
  box-sizing: border-box;
  /* clear the top bar (its padding + lens buttons ≈ 50px) and the safe areas; the card scrolls inside what is left */
  padding: calc(max(10px, env(safe-area-inset-top)) + 46px) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: linear-gradient(transparent 40%, rgba(8, 8, 12, 0.6));
}
.ending .card {
  width: 100%; max-width: 440px; max-height: 100%; box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px 22px 18px;
  animation: appear 0.8s ease both;
}
.ending h2 { margin: 0 0 10px; font-weight: 600; letter-spacing: 0.02em; }
.ending .bin { font-family: var(--mono); font-size: 12px; color: #3ccf62; white-space: normal; word-break: break-word; }
.ending ol { padding-left: 20px; margin: 0 0 12px; line-height: 1.6; color: var(--ink-soft); }
.ending p { color: var(--ink-soft); line-height: 1.5; font-size: 14px; }
.ending .row { display: flex; gap: 8px; justify-content: flex-end; }
.ending .row button { appearance: none; border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.ending .row .keep { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.ending .row { flex-wrap: wrap; }
.ending .row .tell { margin-right: auto; border-color: var(--accent); color: var(--accent); }

/* ── start notice ── */
.notice {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(8, 8, 12, 0.72);
}
.notice .card {
  max-width: 420px; max-height: 100%; box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px 22px 18px;
  animation: appear 0.6s ease both; color: var(--ink);
}
.notice p { color: var(--ink-soft); line-height: 1.5; font-size: 15px; margin: 0 0 12px; }
.notice .big { color: var(--ink); font-size: 19px; font-weight: 600; }
.notice .url { color: var(--ink); font-family: var(--mono); font-weight: 400; word-break: break-all; }
.notice .row { display: flex; justify-content: flex-end; }
.notice .go { appearance: none; border: 1px solid var(--ink); background: var(--ink); color: var(--bg); border-radius: 999px; padding: 9px 16px; font: inherit; cursor: pointer; }

.ending .about-link { color: var(--ink); text-underline-offset: 3px; }

/* ── short screens (a phone on its side): less air, so less scrolling ── */
@media (max-height: 520px) {
  .ending { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .ending .card { padding: 12px 16px 12px; }
  .ending h2 { margin: 0 0 4px; font-size: 18px; }
  .ending ol { margin: 0 0 6px; line-height: 1.35; font-size: 14px; }
  .episodes { margin: 2px 0 8px; }
  .episodes .episode { padding: 5px 10px; font-size: 12px; }
  .ending p { line-height: 1.35; font-size: 13px; margin: 0 0 6px; }
  .ending .row button { padding: 6px 12px; }
  .notice .card { padding: 14px 18px 12px; }
  .notice p { line-height: 1.35; font-size: 14px; margin: 0 0 8px; }
  .notice .big { font-size: 17px; }
  .riddle { bottom: max(10px, env(safe-area-inset-bottom)); padding: 10px 14px; max-height: calc(100dvh - 60px - env(safe-area-inset-bottom)); }
  .riddle-hint { margin-bottom: 6px; }
  .riddle-no { margin-top: 4px; }
}

/* ── Bits, once awake: where you stand, as bytes ── */
.bits-world {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: max(64px, calc(env(safe-area-inset-top) + 56px)) 16px 24px; overflow-y: auto; text-align: center;
}
.bw-head, .bw-foot { margin: 0; font-size: 12px; letter-spacing: 0.12em; color: var(--muted); }
.bw-bytes {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 8px; max-width: 640px;
  padding: 14px; background: rgba(0, 4, 1, 0.82); border: 1px solid rgba(60, 207, 98, 0.25); border-radius: 4px;
}
.bw-byte { display: flex; flex-direction: column; align-items: center; animation: appear 0.3s ease var(--d, 0s) both; }
.bw-byte b { font-weight: 400; font-size: 11px; letter-spacing: 0.04em; color: #1c9e3c; }
.bw-byte i { font-style: normal; font-size: 17px; color: var(--accent); text-shadow: 0 0 10px rgba(60, 207, 98, 0.55); }
.bw-byte.space i { color: rgba(60, 207, 98, 0.35); }
.bw-plain { margin: 0; max-width: 560px; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
