:root {
  --navy: #0b1230;
  --ink: #eef0ff;
  --muted: #a9b0d8;
  --gold: #ffd23f;
  --blue: #3f8cff;
  --pixel: "Press Start 2P", monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--navy); color: var(--ink); font-family: var(--sans); }

/* the letterbox around the stage matches the scene background */
.bg {
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 12% 20%, rgba(120, 140, 230, .10) 0 9%, transparent 9.5%),
    radial-gradient(circle at 88% 75%, rgba(120, 140, 230, .08) 0 12%, transparent 12.5%),
    radial-gradient(circle at 80% 12%, rgba(160, 120, 230, .07) 0 7%, transparent 7.5%),
    linear-gradient(180deg, #0c1436 0%, #151040 60%, #0b0f2a 100%);
}
#stage {
  position: fixed; image-rendering: pixelated; image-rendering: crisp-edges;
  transition: filter .5s ease;
}
body.carding #stage { filter: blur(3px) brightness(.55) saturate(.9); }

.ov { position: fixed; pointer-events: none; }
.ov-labels span, .ov-hud span {
  position: absolute; white-space: nowrap; font-family: var(--pixel);
  text-shadow: 2px 0 #000, -2px 0 #000, 0 2px #000, 0 -2px #000, 2px 2px #000;
  transition: opacity .5s ease, transform .5s ease;
}
.ov-labels span { font-size: clamp(6px, 1.05vw, 11px); color: var(--ink); opacity: 0; transform: translate(-50%, -50%) translateY(4px); }
.ov-labels span.on { opacity: 1; transform: translate(-50%, -50%); }
.ov-labels span.l { transform: translate(0, -50%) translateY(4px); }
.ov-labels span.l.on { transform: translate(0, -50%); }
.ov-labels span.r { transform: translate(-100%, -50%) translateY(4px); }
.ov-labels span.r.on { transform: translate(-100%, -50%); }
.ov-labels span::before { content: ""; display: inline-block; width: .6em; height: .6em; margin-right: .5em; background: var(--gold); box-shadow: 1px 1px 0 #000; vertical-align: .05em; }
.ov-hud span { font-size: clamp(12px, 2.6vw, 30px); color: var(--gold); transform: translate(-50%, -50%); }
.ov-hud span.r { transform: translate(-100%, -50%); }
.ov-hud span.l { transform: translate(0, -50%); }
.ov-hud span.small { font-size: clamp(8px, 1.3vw, 14px); color: var(--ink); }
.ov-hud span.na { color: #ffd23f; } .ov-hud span.k { color: #6fd0ff; } .ov-hud span.pink { color: #ff7aa6; }

.top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: 12px 14px; z-index: 5; }
.back, .fs {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center; text-decoration: none;
  color: var(--ink); font-size: 18px; background: rgba(10, 12, 40, .55); border: 2px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(4px); cursor: pointer; font-family: var(--sans);
}
.bars { flex: 1; display: flex; gap: 4px; }
.bars i { flex: 1; height: 4px; background: rgba(255, 255, 255, .18); position: relative; overflow: hidden; }
.bars i b { position: absolute; inset: 0; width: 0; background: var(--ink); }
.bars i.done b { width: 100%; }

.title {
  position: fixed; top: 58px; left: 50%; transform: translateX(-50%); margin: 0; z-index: 4;
  font-family: var(--pixel); font-weight: 400; font-size: clamp(12px, 2.4vw, 26px); letter-spacing: 1px;
  color: #fff8e0; text-align: center; padding: 8px 12px; background: rgba(5, 6, 20, .72); pointer-events: none;
  text-shadow: 2px 2px 0 #000;
}

.cap {
  position: fixed; left: 18px; bottom: 18px; z-index: 4; max-width: min(330px, calc(100vw - 110px));
  padding: 12px 14px; background: rgba(8, 10, 34, .58); border: 2px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(6px); box-shadow: 4px 4px 0 rgba(0, 0, 0, .45);
  font-size: 15px; line-height: 1.45; min-height: 3.2em; transition: opacity .35s;
}
.cap.swap { opacity: 0; }
.cap b, .card b { color: var(--gold); font-weight: 600; }
body.carding .cap { opacity: 0; }

.card {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -48%); z-index: 6; width: min(600px, calc(100vw - 32px));
  max-height: calc(100vh - 150px); overflow: auto; padding: 22px 24px;
  background: rgba(10, 12, 40, .78); border: 2px solid rgba(255, 255, 255, .16); backdrop-filter: blur(10px);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, .5); opacity: 0; transition: opacity .4s, transform .4s;
}
body.carding .card { opacity: 1; transform: translate(-50%, -50%); }
.card-k { font-family: var(--pixel); font-size: 9px; color: #7fb2ff; margin: 0 0 10px; letter-spacing: 1px; }
.card h2 { font-family: var(--pixel); font-weight: 400; font-size: clamp(13px, 2vw, 18px); line-height: 1.5; margin: 0 0 14px; color: #fff8e0; }
.card ul { margin: 0; padding-left: 20px; }
.card li { margin: 0 0 9px; line-height: 1.5; font-size: 15.5px; }
.card p { margin: 0 0 10px; line-height: 1.55; }
.card a { color: #7fb2ff; font-weight: 600; text-decoration: none; }
.card .note { color: var(--muted); font-size: 13.5px; }

.ctrl { position: fixed; right: 18px; bottom: 18px; display: flex; gap: 10px; z-index: 7; }
.nav {
  width: 52px; height: 52px; border: 2px solid rgba(255, 255, 255, .2); background: rgba(10, 12, 40, .6);
  color: var(--ink); font-size: 22px; cursor: pointer; backdrop-filter: blur(4px); box-shadow: 4px 4px 0 rgba(0, 0, 0, .45);
}
.nav.next { width: 64px; background: var(--blue); border-color: var(--blue); }
.nav.next.ready { animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(4px); box-shadow: 4px 4px 0 rgba(0,0,0,.45), 0 0 18px rgba(63,140,255,.8); } }
.nav:disabled { opacity: .3; cursor: default; }
.nav:focus-visible, .back:focus-visible, .fs:focus-visible { outline: 2px dashed var(--gold); outline-offset: 3px; }

.rotate { display: none; position: fixed; left: 50%; transform: translateX(-50%); top: 104px; z-index: 4; margin: 0;
  font-size: 12px; color: var(--muted); background: rgba(10, 12, 40, .6); padding: 4px 10px; }
@media (orientation: portrait) and (max-width: 700px) {
  .rotate { display: block; }
  .cap { left: 12px; right: 12px; bottom: 82px; max-width: none; }
  .ctrl { right: 12px; bottom: 14px; }
  .title { top: 54px; }
}
@media (prefers-reduced-motion: reduce) { .nav.next.ready { animation: none; } }

/* ---------- interactive labs ---------- */
.controls {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 6;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px;
  max-width: min(640px, calc(100vw - 200px)); padding: 10px 14px;
  background: rgba(8, 10, 34, .66); border: 2px solid rgba(255, 255, 255, .14); backdrop-filter: blur(6px); box-shadow: 4px 4px 0 rgba(0, 0, 0, .45);
}
.controls[hidden] { display: none; }
body.carding .controls { opacity: 0; pointer-events: none; }
.ctl { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.ctl span { font-family: var(--pixel); font-size: 8px; letter-spacing: .5px; }
.ctl output { min-width: 3.5em; font-family: var(--pixel); font-size: 9px; color: var(--gold); }
.ctl input[type=range] { width: 120px; accent-color: var(--gold); }
.ctl.seg button, .ctl-btn {
  font: 600 13px var(--sans); color: var(--ink); background: rgba(255, 255, 255, .06); border: 2px solid rgba(255, 255, 255, .18);
  padding: 6px 10px; cursor: pointer;
}
.ctl.seg button + button { border-left: none; }
.ctl.seg button.on { background: var(--blue); border-color: var(--blue); }
.ctl-btn { background: var(--gold); color: #1a1405; border-color: var(--gold); box-shadow: 3px 3px 0 rgba(0, 0, 0, .45); }
.ctl-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0, 0, 0, .45); }
body.lab .cap { top: 104px; bottom: auto; max-width: min(300px, calc(100vw - 40px)); }
@media (orientation: portrait) and (max-width: 700px) {
  .controls { left: 12px; right: 12px; transform: none; max-width: none; bottom: 82px; }
  body.lab .cap { top: 130px; }
}
