:root {
  --bg: #07060b;
  --bg-raise: #14111a;
  --ink: #f7f1f4;
  --muted: #d7c9d2;
  --faint: #b3a3ad;
  --pink: #ff4d8d;
  --red: #ff2d55;
  --hot: #ff1744;
  --real: #9ec1ff;
  --real-ink: #07101f;
  --ok: #8dff78;
  --warn: #ffd60a;
  --panel: rgba(16, 12, 20, 0.9);
  --line: rgba(255, 77, 141, 0.4);
  --real-line: rgba(158, 193, 255, 0.45);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --sans: "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
p { line-height: 1.45; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 80;
  background: var(--real);
  color: var(--real-ink);
  padding: 8px 12px;
  border-radius: 8px;
}
.skip:focus { top: 12px; }

.app-frame {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background:
    radial-gradient(900px 480px at 8% -10%, rgba(255, 45, 85, 0.28), transparent 55%),
    radial-gradient(700px 420px at 110% 0%, rgba(158, 90, 255, 0.2), transparent 50%),
    linear-gradient(180deg, #140910 0%, #07060b 42%, #0a1020 100%);
}
.orb, .scanlines { pointer-events: none; }
.orb {
  position: fixed;
  width: 38vw;
  height: 38vw;
  min-width: 220px;
  min-height: 220px;
  border-radius: 50%;
  filter: blur(36px);
  opacity: 0.45;
  z-index: 0;
}
.orb-a { background: #ff2d55; top: -8vw; left: -8vw; animation: drift 16s ease-in-out infinite alternate; }
.orb-b { background: #6d4bff; right: -10vw; bottom: -12vw; animation: drift 20s ease-in-out infinite alternate-reverse; }
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 4px);
  mix-blend-mode: soft-light;
  opacity: 0.35;
}
.realbar, .stage, .narrator-dock, .toast-stack, .overlay { position: relative; z-index: 2; }

.realbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px calc(10px + env(safe-area-inset-top));
  background: rgba(8, 12, 22, 0.92);
  border-bottom: 1px solid var(--real-line);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}
.realbar-brand, .realbar-actions, .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.realbar-brand strong { display: block; letter-spacing: 0.04em; }
.realbar-note, .fictional-tag, .flavor, .goal-line, .progress-note { color: var(--muted); }
.realbar-note, .fictional-tag { margin: 0; font-size: 0.78rem; }
.real-badge, .honest-tag, .sim-tag, .level-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.real-badge { background: var(--real); color: var(--real-ink); }
.honest-tag { background: var(--ok); color: #06210a; }
.sim-tag { background: var(--warn); color: #2a2100; }
.level-pill { border: 1px solid var(--line); color: var(--pink); }

.meter { min-width: min(280px, 100%); flex: 1; }
.meter-label { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.78rem; }
.meter-track {
  height: 10px;
  border-radius: 999px;
  background: #241820;
  border: 1px solid rgba(255, 45, 85, 0.45);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffd60a, #ff2d55 70%, #ff4d8d);
}

.stage {
  flex: 1;
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 22px 16px 28px;
}
.narrator-dock {
  position: sticky;
  bottom: 0;
  z-index: 4;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(10, 8, 14, 0.94);
  border-top: 1px solid var(--line);
}
.narrator-kicker {
  margin: 0;
  color: var(--pink);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
}
.narrator-line, .hint-line { margin: 4px 0 0; min-height: 1.3em; }
.narrator-line { font-size: 1.05rem; }
.hint-line { color: var(--ok); font-family: var(--mono); font-size: 0.92rem; }
.is-speaking { animation: rise 0.35s ease; }

.window {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pixel-edge { box-shadow: var(--shadow), 6px 6px 0 #3a1024; }
.titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(90deg, #2a1020, #1a1428);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.titlebar h1, .titlebar span { margin: 0; }
.dots { display: inline-flex; gap: 6px; }
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #6e6470;
  border: 0;
  padding: 0;
}
.dot-close { background: #ff5f57; }
.window-body { padding: 18px; }
.instruction {
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin: 0 0 6px;
  letter-spacing: -0.03em;
}
.goal-line { margin-top: 0; }
.honest-status { min-height: 1.3em; color: var(--ok); font-family: var(--mono); }
.honest-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(141, 255, 120, 0.08);
  border: 1px solid rgba(141, 255, 120, 0.35);
}

.btn {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #2a2230;
  padding: 10px 14px;
}
.btn:hover { border-color: var(--pink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-danger {
  background: linear-gradient(180deg, #ff4d6d, #c81040);
  border-color: transparent;
  color: white;
  font-weight: 700;
}
.btn-real { background: #1b2740; border-color: var(--real-line); }
.btn-ghost { background: transparent; }
.btn-tiny { min-height: 40px; padding: 8px 10px; font-size: 0.92rem; }
.btn-block { width: 100%; }
.btn.is-selected, .tile.is-on, .level-card.is-done { outline: 2px solid var(--ok); }
.inline-trap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  margin: 0 2px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px dashed rgba(255, 77, 141, 0.7);
  background: transparent;
  color: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 4px;
  font: inherit;
}
:focus-visible { outline: 2px solid var(--real); outline-offset: 3px; }

.glitch { position: relative; display: inline-block; font-size: clamp(3rem, 8vw, 5.4rem); line-height: 0.95; margin: 0; letter-spacing: -0.05em; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.glitch::before { color: #7cf7ff; clip-path: inset(8% 0 58% 0); transform: translate(3px, 0); animation: glitch-a 2.2s infinite linear; }
.glitch::after { color: var(--red); clip-path: inset(48% 0 12% 0); transform: translate(-3px, 0); animation: glitch-b 1.7s infinite linear; }
.kicker { margin: 0; color: var(--pink); font-family: var(--mono); letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.78rem; }
.menu-blurb { max-width: 62ch; }
.menu-actions, .stack { display: grid; gap: 10px; }
.menu-hero .window-body { padding-bottom: 28px; }

.boot-log { min-height: 9rem; font-family: var(--mono); margin: 16px 0; }
.boot-line { margin: 0 0 6px; }
.boot-line::before { content: "> "; color: var(--pink); }

.level-grid, .achieve-grid, .captcha-grid, .error-grid, .choice-row, .door-row {
  display: grid;
  gap: 10px;
}
.level-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.level-card, .achieve-card, .error-card, .paint-btn, .door, .tile {
  text-align: left;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #1a1520;
  padding: 12px;
}
.level-card { display: grid; gap: 4px; min-height: 104px; }
.level-index { font-family: var(--mono); color: var(--pink); }
.achieve-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.achieve-card.is-locked { opacity: 0.55; }
.achieve-card h2, .error-card header { font-size: 1rem; margin: 0 0 6px; }

.dialog, .password-box, .terms, .captcha, .volume-box, .alarm-wrap, .boss-start {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.dodge-bounds, .dodge-arena, .still-arena {
  position: relative;
  min-height: 190px;
  border-radius: 16px;
  border: 1px dashed rgba(255, 77, 141, 0.45);
  background: rgba(0, 0, 0, 0.25);
  padding: 12px;
  touch-action: none;
}
.dodge-arena.is-compact, .boss-arena.is-compact {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.catch-btn, .color-btn { min-width: min(100%, 220px); min-height: 64px; font-weight: 800; letter-spacing: 0.08em; }
.dodger { transition: left 0.12s linear, top 0.12s linear; }
.color-btn {
  width: min(100%, 320px);
  min-height: 110px;
  border: 0;
  border-radius: 18px;
  font-size: 1.4rem;
  margin: 12px auto;
  display: block;
}
.history { display: flex; gap: 6px; flex-wrap: wrap; min-height: 32px; }
.chip { padding: 4px 8px; border-radius: 999px; font-family: var(--mono); font-size: 0.75rem; }

.fake-timer { text-align: center; }
.timer-digits {
  font-family: var(--mono);
  font-size: clamp(3rem, 10vw, 6rem);
  letter-spacing: 0.08em;
  color: var(--pink);
  text-shadow: 0 0 18px rgba(255, 45, 85, 0.45);
}
.log {
  font-family: var(--mono);
  font-size: 0.86rem;
  background: #09070c;
  border-radius: 12px;
  padding: 10px 12px;
  max-height: 180px;
  overflow: auto;
}
.log-line { margin: 0 0 4px; }
.is-kernel { color: var(--ok); }
.is-ui { color: var(--faint); }
.kbd {
  min-width: 64px;
  min-height: 56px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #221821;
  font-family: var(--mono);
  font-size: 1.3rem;
}

.rules { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.rule-exception { color: var(--ok); }
.field, .setting-row, .check-row { display: grid; gap: 6px; }
.field input, .code-form input, .setting-row input[type="range"] { width: 100%; }
.field input, .code-form input {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #0d0b10;
  padding: 8px 10px;
}
.field-error { min-height: 1.3em; color: var(--warn); margin: 0; }
.code-form { display: flex; gap: 8px; flex-wrap: wrap; }
.code-form input { flex: 1; min-width: 140px; }

.choice-row, .door-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.paint-btn { min-height: 150px; display: grid; align-content: space-between; gap: 12px; }
.swatch {
  display: block;
  height: 72px;
  border-radius: 10px;
  background: var(--paint, #888);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25);
}
.nameplate { font-size: 1.2rem; font-weight: 800; }
.door { min-height: 210px; display: grid; align-content: end; gap: 6px; position: relative; overflow: hidden; }
.door-index { font-family: var(--mono); color: var(--pink); }
.door.scorch { background: linear-gradient(#2a2018, #1a1210); box-shadow: inset 0 0 0 8px #3a2418; }
.door.wet { background: linear-gradient(#14202a, #101820); }
.door.mat { background: linear-gradient(#1d1830, #141018); }
.door.mat::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  height: 16px;
  border-radius: 6px;
  background: repeating-linear-gradient(90deg, #6b3a3a 0 10px, #d7c3a2 10px 20px);
}
.lie-banner {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 45, 85, 0.12);
  border: 1px solid var(--line);
  font-weight: 700;
}
.wall-note {
  max-width: 280px;
  padding: 12px;
  background: #efe3a4;
  color: #241c08;
  transform: rotate(-1.5deg);
  border-radius: 2px;
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.25);
}
.wall-note p { margin: 8px 0 0; font-family: "Segoe Print", "Comic Sans MS", var(--sans); font-size: 1.15rem; }

.captcha-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile { min-height: 112px; display: grid; align-content: center; justify-items: center; gap: 6px; }
.tile-emoji { font-size: 2rem; }
.error-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.error-card header { display: flex; justify-content: space-between; gap: 8px; }
.error-card.is-honest { border-color: rgba(141, 255, 120, 0.5); }

.popup-layer { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.popup { border-radius: 12px; padding: 12px; background: #241820; border: 1px solid transparent; }
.tone-notice { border-color: #7eb6ff; }
.tone-warn { border-color: var(--warn); }
.tone-error { border-color: var(--red); }
.popup header { font-family: var(--mono); letter-spacing: 0.08em; }

.terms-body {
  max-height: 240px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 12px;
  background: #0c0a10;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.terms-title { margin: 0; }
.terms-line { margin: 0 0 10px; }
.speaker { display: flex; align-items: end; gap: 4px; height: 64px; }
.bar { width: 12px; height: 8px; border-radius: 3px; background: #3a3140; }
.bar.on { background: var(--ok); }
.bar:nth-child(1).on { height: 10px; }
.bar:nth-child(2).on { height: 16px; }
.bar:nth-child(3).on { height: 22px; }
.bar:nth-child(4).on { height: 28px; }
.bar:nth-child(5).on { height: 34px; }
.bar:nth-child(6).on { height: 40px; }
.bar:nth-child(7).on { height: 46px; }
.bar:nth-child(8).on { height: 52px; }
.bar:nth-child(9).on { height: 58px; }
.bar:nth-child(10).on { height: 64px; }
.slider { padding: 12px 0; }
.slider-track {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ok), #ffd60a 40%, var(--red));
}
.slider-thumb {
  position: absolute;
  top: 50%;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.alarm-unit {
  border-radius: 18px;
  padding: 14px;
  background: #1a0d14;
  border: 2px solid #ff2d55;
}
.alarm-lights { display: flex; gap: 8px; }
.alarm-lights span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--red);
  animation: blink 0.8s steps(2, end) infinite;
}
.alarm-lights span:nth-child(2) { animation-delay: 0.2s; }
.alarm-face-title { font-family: var(--mono); letter-spacing: 0.12em; }
.alarm-status { font-weight: 800; }
.alarm-unit[data-flipped="false"] .alarm-back,
.alarm-unit[data-flipped="true"] .alarm-front { display: none; }
.alarm-unit[data-cut="true"] { border-color: var(--ok); }
.decoy-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.liar-stamp {
  font-family: var(--mono);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--red);
  border: 3px solid var(--red);
  display: inline-block;
  padding: 8px 10px;
  transform: rotate(-6deg);
}
.still-arena { display: grid; place-items: center; align-content: center; gap: 16px; }

.prereq-list { padding-left: 18px; }
.prereq.is-done { color: var(--ok); text-decoration: line-through; }
.fake-win {
  margin: 10px 0;
  padding: 14px;
  border-radius: 16px;
  background:
    linear-gradient(rgba(255, 214, 10, 0.08), rgba(255, 214, 10, 0.08)),
    repeating-linear-gradient(-45deg, transparent, transparent 8px, rgba(255, 214, 10, 0.12) 8px 16px);
  border: 2px dashed var(--warn);
}
.fake-win h3 { margin: 0; font-size: 2rem; letter-spacing: 0.12em; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.62);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal {
  width: min(480px, 100%);
  background: #16131c;
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: var(--shadow);
}
.modal-real { border-color: var(--real-line); }
.complete-stats { padding-left: 18px; }
.end-cert {
  border: 1px dashed var(--pink);
  border-radius: 14px;
  padding: 12px 14px;
  font-family: var(--mono);
}
.help { margin-top: 16px; color: var(--muted); }
.toast-stack {
  position: fixed;
  right: 12px;
  bottom: 108px;
  z-index: 8;
  display: grid;
  gap: 8px;
  width: min(320px, calc(100% - 24px));
}
.toast {
  background: #201823;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.toast-sim { border-style: dashed; }
.toast p { margin: 4px 0 8px; }
.is-shaking { animation: shake 0.35s linear; }
.is-wrong { box-shadow: inset 0 0 0 2px var(--red); }

@keyframes drift { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(30px, 20px, 0); } }
@keyframes rise { from { transform: translateY(6px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
@keyframes glitch-a {
  0%, 80% { transform: translate(2px, 0); }
  82% { transform: translate(-3px, 1px); }
  86% { transform: translate(3px, -1px); }
  90% { transform: translate(2px, 0); }
}
@keyframes glitch-b {
  0%, 70% { transform: translate(-2px, 0); }
  74% { transform: translate(3px, 1px); }
  78% { transform: translate(-4px, 0); }
  84% { transform: translate(-2px, 0); }
}
@keyframes blink { from { opacity: 1; } to { opacity: 0.25; } }

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  animation: none !important;
  transition: none !important;
}
.no-flash .alarm-lights span,
.no-flash .glitch::before,
.no-flash .glitch::after,
.is-steady .alarm-lights span {
  animation: none !important;
  opacity: 1 !important;
}

@media (max-width: 800px) {
  .choice-row, .door-row { grid-template-columns: 1fr; }
  .door { min-height: 140px; }
  .captcha-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .glitch { font-size: 3rem; }
  .realbar-note { display: none; }
  .toast-stack { left: 12px; right: 12px; width: auto; bottom: 132px; }
}
@media (max-width: 420px) {
  .captcha-grid { grid-template-columns: 1fr 1fr; }
}
