:root { --bg: #070b1a; --panel: rgba(10, 16, 36, 0.82); --line: rgba(120, 170, 255, 0.25); --text: #e8f0ff;
  --dim: #8aa0c8; --blue: #58a6ff; --green: #3fe08a; --red: #ff5c6c; --gold: #ffd166; --purple: #b388ff; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif; user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; font-size: 28px; color: var(--dim); }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hudTL { position: absolute; left: 22px; top: 18px; }
#score { font-size: 46px; font-weight: 900; letter-spacing: -1px; text-shadow: 0 0 18px rgba(88,166,255,.7); }
#combo { font-size: 24px; font-weight: 800; color: var(--gold); min-height: 30px; }
#mult { display: inline-block; transition: transform .1s; }
#mult.pulse { transform: scale(1.5); }
#comboN { color: var(--dim); font-size: 16px; }
#dist { color: var(--dim); font-size: 17px; font-weight: 700; }
#hudTR { position: absolute; right: 22px; top: 18px; text-align: right; }
#hearts { font-size: 30px; letter-spacing: 4px; }
#starsHud { font-size: 26px; font-weight: 900; color: var(--gold); margin-top: 2px; }
#branchBadge { display: inline-block; margin-top: 8px; padding: 6px 14px; border-radius: 99px; background: var(--panel);
  border: 2px solid var(--blue); font: 700 18px ui-monospace, Menlo, monospace; }
#files { position: absolute; left: 22px; top: 150px; display: flex; flex-direction: column; gap: 5px; }
.chip { font: 700 15px ui-monospace, Menlo, monospace; padding: 4px 10px; border-radius: 8px; background: var(--panel); width: max-content; }
.chip.m { border-left: 5px solid var(--red); color: #ffb0b8; }
.chip.s { border-left: 5px solid var(--green); color: #b6ffd5; }
#progress { position: absolute; left: 50%; top: 14px; width: 300px; margin-left: -150px; height: 8px; border-radius: 8px; background: rgba(255,255,255,.1); overflow: hidden; }
#progressFill { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--green)); }

#question { position: absolute; left: 50%; top: 34px; transform: translateX(-50%); width: min(820px, 94vw);
  background: var(--panel); border: 3px solid var(--gold); border-radius: 22px; padding: 16px 22px; text-align: center;
  box-shadow: 0 0 40px rgba(255, 209, 102, .35); animation: drop .3s ease-out; }
#qText { font-size: 30px; font-weight: 900; line-height: 1.2; }
#qOpts { display: flex; gap: 10px; margin-top: 12px; justify-content: center; }
#qOpts div { flex: 1; font: 700 18px ui-monospace, Menlo, monospace; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.07); }
#qOpts div b { color: var(--gold); }
@keyframes drop { from { transform: translate(-50%, -30px); opacity: 0; } }

#toasts { position: absolute; left: 50%; top: 210px; transform: translateX(-50%); width: min(760px, 92vw);
  display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 10px 18px; font-size: 21px;
  font-weight: 700; text-align: center; animation: pop .25s ease-out; line-height: 1.3; }
.toast.good { border-color: var(--green); } .toast.bad { border-color: var(--red); } .toast.new { border-color: var(--gold); }
.toast.tip { border-color: var(--blue); }
.toast small { display: block; font-size: 16px; color: var(--dim); font-weight: 600; margin-top: 3px; }
.toast code { color: var(--gold); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

#terminal { position: absolute; left: 18px; bottom: 18px; width: min(470px, 46vw); background: rgba(5, 8, 18, .88);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 10px; font: 15px/1.45 ui-monospace, Menlo, monospace; }
.termTitle { color: #56658a; font: 700 12px ui-monospace, Menlo, monospace; margin-bottom: 4px; }
#termLines div { white-space: pre-wrap; word-break: break-all; }
#termLines .cmd { color: #7ee787; } #termLines .cmd::before { content: '$ '; color: #56658a; }
#termLines .out { color: #b9c6e4; } #termLines .note { color: #8aa0c8; font-style: italic; }
#graphBox { position: absolute; right: 18px; bottom: 18px; background: rgba(5, 8, 18, .88); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 10px; }
#graph { display: block; width: 360px; height: 150px; }
#pops { position: absolute; inset: 0; }
.popTxt { position: absolute; font-weight: 900; font-size: 26px; color: var(--gold); text-shadow: 0 2px 10px #000; animation: rise .9s ease-out forwards; white-space: nowrap; transform: translateX(-50%); }
@keyframes rise { to { transform: translate(-50%, -70px); opacity: 0; } }
#help { position: fixed; bottom: 6px; left: 50%; transform: translateX(-50%); color: #56658a; font-size: 13px; pointer-events: none; }

/* Screens */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(7,11,26,.55), rgba(7,11,26,.92)); padding: 24px; }
.screen.clear { background: none; pointer-events: none; }
.card { background: var(--panel); border: 2px solid var(--line); border-radius: 26px; padding: 28px 34px; width: min(920px, 96vw);
  box-shadow: 0 20px 80px rgba(0,0,0,.5); animation: pop .25s ease-out; max-height: 94vh; overflow-y: auto; }
h1 { font-size: 54px; font-weight: 900; letter-spacing: -1.5px; line-height: 1; }
h1 span { background: linear-gradient(90deg, var(--blue), var(--green)); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { font-size: 34px; font-weight: 900; margin-bottom: 10px; }
.sub { color: var(--dim); font-size: 19px; margin: 8px 0 18px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.stat { background: rgba(255,255,255,.06); border-radius: 14px; padding: 10px 16px; font-size: 17px; color: var(--dim); }
.stat b { display: block; font-size: 26px; color: var(--text); }
.btn { pointer-events: auto; cursor: pointer; border: 2px solid var(--line); background: rgba(255,255,255,.06); color: var(--text);
  font: 800 20px inherit; font-family: inherit; padding: 12px 22px; border-radius: 14px; transition: transform .08s, background .1s; }
.btn:hover, .btn.sel { background: rgba(88,166,255,.22); border-color: var(--blue); transform: translateY(-2px); }
.btn.primary { background: linear-gradient(90deg, #2f81f7, #2ea043); border-color: transparent; }
.btn.primary.sel { outline: 3px solid #fff; }
.btn:disabled { opacity: .35; cursor: default; }
.key { display: inline-block; font: 700 14px ui-monospace, Menlo, monospace; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line); color: var(--dim); margin-left: 6px; }
.chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.ch { pointer-events: auto; cursor: pointer; border-radius: 16px; padding: 14px; background: rgba(255,255,255,.05); border: 2px solid transparent; min-height: 104px; }
.ch.sel { border-color: #fff; background: rgba(88,166,255,.18); transform: translateY(-2px); }
.ch.locked { opacity: .35; }
.ch .n { font-size: 14px; color: var(--dim); font-weight: 800; } .ch .t { font-size: 19px; font-weight: 900; margin: 4px 0; }
.ch .s { color: var(--gold); font-size: 20px; letter-spacing: 2px; }
.brief li { font-size: 22px; line-height: 1.4; margin: 0 0 12px 24px; }
.xpbar { height: 12px; background: rgba(255,255,255,.08); border-radius: 8px; overflow: hidden; margin-top: 6px; }
.xpbar div { height: 100%; background: linear-gradient(90deg, var(--gold), #ff9f43); }
.codex { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin: 14px 0; }
.cx { background: rgba(255,255,255,.05); border-radius: 12px; padding: 10px 12px; }
.cx code { color: var(--green); font-size: 15px; font-weight: 700; } .cx p { color: var(--dim); font-size: 15px; margin-top: 4px; }
.cx.lock code { color: #56658a; } .cx.lock p { color: #3e4b6b; }
.review { margin-top: 12px; } .review div { background: rgba(255,92,108,.08); border-left: 4px solid var(--red); padding: 8px 12px; border-radius: 8px; margin-bottom: 8px; font-size: 17px; }
.review b { color: var(--green); }
.skins { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.skin { pointer-events: auto; cursor: pointer; border-radius: 16px; padding: 14px; text-align: center; background: rgba(255,255,255,.05); border: 2px solid transparent; }
.skin.sel { border-color: #fff; } .skin .dot { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 8px; }
.big { font-size: 80px; font-weight: 900; line-height: 1; }
.gold { color: var(--gold); } .green { color: var(--green); } .red { color: var(--red); } .dim { color: var(--dim); }
@media (max-width: 1000px) { #question { top: 120px; } #toasts { top: 300px; } }
@media (max-width: 760px) {
  #terminal { width: 58vw; font-size: 11px; } #graphBox { display: none; } #score { font-size: 32px; }
  #qText { font-size: 20px; } #qOpts div { font-size: 13px; } h1 { font-size: 36px; } .toast { font-size: 16px; }
}
