/* Debug Paradox. Festival ticket stubs by day, string lights by night. */
:root {
  --bg: #f7efe0;
  --surface: #fffaf1;
  --ink: #1d1a33;
  --muted: #6c6479;
  --line: #e2d4bb;
  --marigold: #d98a00;
  --kumkum: #c2343f;
  --leaf: #1d7a58;
  --ghost: #0f8a6a;
  --ghost-bg: #e3f5ee;
  --dot: #e0cfae;
  --shadow: 0 1px 0 #e2d4bb, 0 12px 30px -18px #6b4a1a55;
  --display: "Unbounded", "Trebuchet MS", sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0d1c;
  --surface: #14172e;
  --ink: #f2e9d6;
  --muted: #a39db8;
  --line: #2a2e50;
  --marigold: #f6b73c;
  --kumkum: #ff6f6f;
  --leaf: #4fd1a0;
  --ghost: #7cffb2;
  --ghost-bg: #0f2a22;
  --dot: #1e2242;
  --shadow: 0 0 0 1px #2a2e50, 0 18px 40px -20px #000;
  color-scheme: dark;
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
/* The sidebar's scrollbar only appears while hovering it, so it doesn't sit beside the level list. */
.sidebar { scrollbar-color: transparent transparent; }
.sidebar:hover { scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--ink);
  font: 17px/1.6 var(--body);
  background:
    radial-gradient(circle at 20% -10%, color-mix(in srgb, var(--marigold) 22%, transparent), transparent 45%),
    radial-gradient(circle, var(--dot) 1.5px, transparent 1.6px) 0 0 / 22px 22px,
    var(--bg);
  min-height: 100vh;
}
a { color: var(--kumkum); }
code, pre, .mono { font-family: var(--mono); font-size: 0.88em; }
code { background: color-mix(in srgb, var(--marigold) 14%, transparent); padding: 0.1em 0.35em; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem 1rem; overflow-x: auto; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.06em; }
.eyebrow { font: 700 0.75rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 0 0 0.3rem; }
button, .button {
  font: 700 0.95rem var(--body);
  color: var(--bg);
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.15s, background 0.15s;
}
button:hover, .button:hover { transform: translateY(-1px); background: var(--kumkum); }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
input {
  font: 1rem var(--mono);
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  min-width: 0;
}

/* Top bar */
.topbar { display: flex; align-items: center; gap: 1.2rem; padding: 0.8rem max(16px, 4vw); border-bottom: 1px dashed var(--line); }
.topbar a { color: var(--ink); text-decoration: none; font-weight: 700; }
.brand { font: 800 1.1rem var(--display) !important; margin-right: auto; }
.brand span { color: var(--kumkum); }
.theme-toggle { background: transparent; color: var(--ink); border: 1px solid var(--line); padding: 0.3rem 0.7rem; font-size: 1.1rem; }

main { max-width: 820px; width: 100%; min-width: 0; padding: 1.5rem 16px 4rem; }

/* Layout: sidebar + content. Below 900px the sidebar becomes a collapsible "Levels" menu. */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 2rem; max-width: 1180px; margin: 0 auto; padding: 0 max(16px, 2vw); }
.sidebar { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; padding: 1.5rem 0 2rem; }
.side summary { display: none; }
.profile { display: flex; gap: 0.7rem; align-items: center; margin: 0 0 0.6rem; }
.profile small { display: block; color: var(--muted); font-size: 0.8rem; }
.sidebar progress { width: 100%; height: 6px; accent-color: var(--leaf); margin-bottom: 0.8rem; }
.side-act { font: 700 0.7rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 1rem 0 0.3rem; }
.side-levels { list-style: none; padding: 0; margin: 0; }
.side-level, .side-link { display: flex; gap: 0.6rem; align-items: center; padding: 0.35rem 0.6rem; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 0.93rem; }
.side-level:hover, .side-link:hover { background: color-mix(in srgb, var(--marigold) 14%, transparent); }
.side-level[aria-current], .side-link[aria-current] { background: var(--surface); box-shadow: var(--shadow); font-weight: 700; }
.side-level.locked { color: var(--muted); pointer-events: none; }
.side-level .mark { width: 1.4rem; height: 1.4rem; flex: none; display: grid; place-items: center; border-radius: 50%; font: 700 0.72rem var(--mono); border: 1.5px solid var(--line); }
.side-level.done .mark { background: var(--leaf); border-color: var(--leaf); color: var(--bg); }
.side-level.open .mark { border-color: var(--marigold); color: var(--marigold); }
.side-level.locked .mark { border: 0; font-size: 0.7rem; }
.avatar { --hue: 20; width: 2.2rem; height: 2.2rem; flex: none; border-radius: 50%; display: inline-grid; place-items: center; vertical-align: middle; font: 700 0.85rem var(--body); color: #fff; background: hsl(var(--hue) 55% 42%); }

/* Level page */
.level-head h1 { font-size: clamp(2rem, 6vw, 3.2rem); margin: 0.2rem 0 0.6rem; }
.skills { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; padding: 0; margin: 0; }
.skills li { font: 0.75rem var(--mono); border: 1px solid var(--line); border-radius: 999px; padding: 0.1rem 0.6rem; background: var(--surface); }
.mission { border: 2px dashed var(--kumkum); border-radius: 14px; padding: 0.4rem 1.1rem; }
.mission h2 { color: var(--kumkum); margin: 0.6rem 0 0; }
.stage { margin: 1.6rem 0; display: grid; gap: 1rem; }
.stage > * { min-width: 0; }
.hints details { border-bottom: 1px solid var(--line); padding: 0.4rem 0; }
.hints summary { cursor: pointer; font-weight: 700; }
.solve { margin-top: 2rem; padding: 1rem; background: var(--surface); border: 2px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow); }
.solve label { font-weight: 700; display: block; margin-bottom: 0.4rem; }
.solve .row { display: flex; gap: 0.5rem; }
.solve input { flex: 1; text-transform: uppercase; }
.solve output { display: block; margin-top: 0.4rem; min-height: 1.2em; }
.ok { color: var(--leaf); font-weight: 700; }
.bad { color: var(--kumkum); font-weight: 700; }
.warn { font-size: 0.9rem; color: var(--muted); }
.big { font: 800 2.4rem var(--display); margin: 0.2rem 0; }
.blink { color: var(--kumkum); }

/* Level props */
.kiosk { background: var(--ink); color: var(--bg); border-radius: 18px; padding: 1.4rem; max-width: 360px; box-shadow: var(--shadow); }
.kiosk-screen { background: #0a1f18; color: #7cffb2; font-family: var(--mono); border-radius: 10px; padding: 1rem; }
.kiosk-screen .eyebrow { color: #7cffb2aa; }
.slip, .wallet, .door, .spec { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.slip dt { font: 700 0.75rem var(--mono); text-transform: uppercase; color: var(--muted); margin-top: 0.6rem; }
.slip dd { margin: 0; }
.copy { cursor: copy; }
.projector { display: grid; place-items: center; height: 180px; background: #050608; color: #3cf; font: 700 1.1rem var(--mono); border-radius: 12px; box-shadow: inset 0 0 60px #3cf3; }
.flash { color: #fff; font-size: 2rem; text-shadow: 0 0 18px #3cf; }
.checks { list-style: none; padding: 0; font-family: var(--mono); }
.rig { height: 160px; display: grid; place-items: center; background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 40px), var(--surface); border-radius: 12px; overflow: hidden; }
.beam { width: 70%; height: 14px; border-radius: 7px; background: linear-gradient(90deg, transparent, var(--marigold), #fff6, var(--marigold), transparent); box-shadow: 0 0 24px var(--marigold); transition: transform 0.3s; }
.upload { display: inline-flex; gap: 0.5rem; align-items: center; font-weight: 700; margin-top: 0.5rem; }
.poster-wall { width: 360px; overflow: hidden; display: grid; grid-auto-rows: 200px; gap: 0; background: #2b2118; box-sizing: border-box; }
.poster { margin: 8px; padding: 1rem; display: flex; flex-direction: column; justify-content: flex-end; color: #fff; border-radius: 4px; transform: rotate(-1deg); }
.poster:nth-child(even) { transform: rotate(1.2deg); }
.poster b { font: 800 1.3rem/1.1 var(--display); }
.poster span { font: 0.8rem var(--mono); opacity: 0.85; }
.p0 { background: linear-gradient(135deg, #c2343f, #d98a00); }
.p1 { background: linear-gradient(135deg, #1d7a58, #0f3d4a); }
.p2 { background: linear-gradient(135deg, #3b2a6b, #c2343f); }
.p3 { background: linear-gradient(135deg, #d98a00, #f6d365); color: #1d1a33; }
.p4 { background: linear-gradient(135deg, #0b0d1c, #3cf); }
.p5 { background: repeating-linear-gradient(45deg, #1d1a33 0 12px, #2a2e50 12px 24px); }
.wall-stamp { position: sticky; bottom: 0; margin: 0; padding: 0.4rem; text-align: center; color: #7cffb2; font: 0.7rem var(--mono); background: #000a; }
.launch { font-size: 1.4rem; padding: 1rem 2rem; background: linear-gradient(135deg, var(--kumkum), var(--marigold)); color: #fff; }
main.locked { text-align: center; padding-top: 4rem; }
.story { display: grid; gap: 0.6rem; margin: 1.4rem 0; padding: 1rem 1.2rem; background: var(--surface); border-left: 4px solid var(--marigold); border-radius: 12px; box-shadow: var(--shadow); }
.story p { margin: 0; }
.story b:first-child { display: block; font: 700 0.7rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.ghost-line { color: var(--ghost); font-family: var(--mono); font-size: 0.9rem; padding-top: 0.6rem; border-top: 1px dashed var(--line); }
.ghost-line b:first-child { color: var(--ghost) !important; }
.use-it { border-left: 4px solid var(--leaf); padding: 0.2rem 1.1rem; background: color-mix(in srgb, var(--leaf) 7%, transparent); border-radius: 0 12px 12px 0; }
.use-it h2 { color: var(--leaf); margin: 0.6rem 0 0; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.4rem; font-weight: 700; }
.muted { color: var(--muted); font-weight: 400; }
.continue { display: block; margin: 1.4rem 0; padding: 1.2rem 1.4rem; border-radius: 14px; background: var(--surface); border: 2px solid var(--ink); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); transition: transform 0.15s; }
.continue:hover { transform: translateY(-2px); }
.continue h3 { font-size: 1.6rem; margin: 0.2rem 0 0.6rem; }
button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }

/* Dashboard */
.hero { padding: 2rem 0 1rem; }
.hero h1 { font-size: clamp(2rem, 8.5vw, 5.5rem); margin: 0; line-height: 0.95; }
.hero h1 span { color: var(--kumkum); }
.hero .tagline { font-size: 1.2rem; max-width: 560px; }
.prologue { background: var(--surface); border-radius: 14px; padding: 0.4rem 1.2rem; box-shadow: var(--shadow); }
.login { margin: 1.5rem 0; display: grid; gap: 0.6rem; justify-items: start; }
.login form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.badges { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; }
.badges li { border: 2px solid var(--line); border-radius: 999px; padding: 0.2rem 0.8rem; font-weight: 700; opacity: 0.45; filter: grayscale(1); }
.badges li.earned { opacity: 1; filter: none; border-color: var(--marigold); background: color-mix(in srgb, var(--marigold) 15%, transparent); }
.token-box { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.guide { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0.3rem 1.2rem; margin: 1rem 0; }
.guide summary { cursor: pointer; font: 700 1rem var(--display); padding: 0.6rem 0; }
.guide table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.guide td, .guide th { border-bottom: 1px solid var(--line); padding: 0.35rem 0.4rem; text-align: left; vertical-align: top; }
dialog.finale { max-width: 640px; width: calc(100% - 32px); border: 0; border-radius: 16px; background: #050608; color: #7cffb2; font-family: var(--mono); padding: 1.6rem; box-shadow: 0 0 80px #7cffb244; }
dialog.finale::backdrop { background: #000c; }
dialog.finale h2 { color: #fff; }
dialog.finale p { animation: rise 0.6s both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* Hall of Fame */
.hall-grid { width: 100%; border-collapse: collapse; }
.hall-grid th, .hall-grid td { padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--line); text-align: left; }
.progress { display: flex; gap: 2px; }
.progress i { width: 14px; height: 14px; border-radius: 3px; background: var(--line); }
.progress i.on { background: var(--leaf); }
.funnel { display: grid; gap: 0.3rem; }
.funnel div { display: grid; grid-template-columns: 11rem 1fr 3ch; gap: 0.6rem; align-items: center; font-size: 0.88rem; }
.funnel .bar { height: 12px; border-radius: 6px; background: var(--marigold); min-width: 2px; }
.scroll-x { overflow-x: auto; }

@media (max-width: 899px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidebar { position: static; max-height: none; padding: 0.8rem 0 0; }
  .side { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 0.2rem 0.9rem; }
  .side summary { display: list-item; cursor: pointer; font-weight: 700; padding: 0.5rem 0; }
  .side[open] { padding-bottom: 0.8rem; }
  main { padding-top: 0.5rem; }
}
@media (max-width: 560px) {
  .funnel div { grid-template-columns: 7rem 1fr 3ch; }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
