:root {
  --bg: #000;
  --fg: #f4f4f4;
  --accent: #ffcc33;
  --ui: rgba(10, 10, 14, 0.72);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overflow: hidden; }
body { font-family: Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }

#app { position: fixed; inset: 0; display: grid; place-items: center; }
#stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  background: #000;
  container-type: size;
  overflow: hidden;
}
#stage:fullscreen { width: 100vw; height: 100vh; }
#screen { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- boot / end overlays ---------- */
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: radial-gradient(ellipse at center, #10131a 0%, #000 70%);
  z-index: 5; transition: opacity .8s ease;
}
.overlay.fade { opacity: 0; pointer-events: none; }
#endcard { background: transparent; place-items: end center; padding-bottom: 7cqh; }
.boot-inner { text-align: center; display: grid; gap: 3.2cqh; justify-items: center; padding: 0 16px; }
.logo h1 {
  font-family: 'Press Start 2P', monospace; font-weight: 400;
  font-size: clamp(22px, 5.2cqw, 72px); margin: 0; letter-spacing: .06em;
  color: #fff; text-shadow: 0 0 18px rgba(255,255,255,.55), 0.12em 0.12em 0 #ff2e63;
}
.logo-dot {
  display: inline-block; width: 1.4cqw; height: 1.4cqw; min-width: 10px; min-height: 10px;
  background: #fff; box-shadow: 0 0 20px #fff; margin-bottom: 2.4cqh;
  animation: bounce 1.4s cubic-bezier(.4,0,.6,1) infinite;
}
@keyframes bounce { 0%,100% { transform: translate(-10cqw, 0); } 50% { transform: translate(10cqw, 0); } }
.tagline { font-family: VT323, monospace; font-size: clamp(16px, 2.2cqw, 30px); color: #9fb3c8; margin: 1.6cqh 0 0; letter-spacing: .08em; }
#loader { width: min(420px, 60cqw); }
.bar { height: 10px; border: 2px solid #fff; padding: 2px; }
.bar span { display: block; height: 100%; width: 0%; background: #fff; transition: width .2s; }
#loadtext { font-family: VT323, monospace; font-size: clamp(14px, 1.8cqw, 24px); color: #8b9; letter-spacing: .1em; }
#start, #replay {
  font-family: 'Press Start 2P', monospace; font-size: clamp(14px, 2cqw, 26px);
  color: #fff; background: transparent; border: 3px solid #fff; padding: 1em 1.6em;
  cursor: pointer; box-shadow: 0 0 24px rgba(255,255,255,.25), inset 0 0 24px rgba(255,255,255,.08);
  transition: transform .15s, background .15s, color .15s;
}
#start:hover, #start:focus-visible, #replay:hover, #replay:focus-visible { background: #fff; color: #000; transform: scale(1.04); outline: none; }
.blink { animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.hint { font-family: VT323, monospace; color: #667; font-size: clamp(13px, 1.6cqw, 20px); margin: 0; letter-spacing: .06em; }

/* ---------- controls ---------- */
#controls {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  width: min(920px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px; background: var(--ui);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  z-index: 10; transition: opacity .5s ease, transform .5s ease;
  font-family: VT323, monospace; font-size: 18px;
}
#controls.idle { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }
#controls button {
  background: none; border: 0; color: #fff; font-size: 18px; cursor: pointer;
  width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
}
#controls button:hover, #controls button:focus-visible { background: rgba(255,255,255,.12); outline: none; }
#clock { white-space: nowrap; color: #ccd; min-width: 92px; text-align: right; }
#scrub { position: relative; flex: 1; height: 34px; cursor: pointer; touch-action: none; }
#track { position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; background: rgba(255,255,255,.18); border-radius: 2px; }
#progress { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #fff, var(--accent)); border-radius: 2px; }
#head { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #fff; box-shadow: 0 0 10px rgba(255,255,255,.7); left: 0; }
#chapters { position: absolute; inset: 0; pointer-events: none; }
#chapters i { position: absolute; top: 50%; width: 2px; height: 10px; margin-top: -5px; background: rgba(255,255,255,.55); }
#tooltip {
  position: absolute; bottom: 38px; transform: translateX(-50%); white-space: nowrap;
  background: rgba(0,0,0,.85); padding: 4px 8px; border-radius: 6px; font-size: 16px; color: #fff;
  opacity: 0; transition: opacity .15s; pointer-events: none;
}
#scrub:hover #tooltip { opacity: 1; }
@media (max-width: 560px) {
  #controls { gap: 6px; padding: 8px; bottom: 8px; }
  #clock { display: none; }
}

/* ---------- captions ---------- */
#captions { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.cap {
  position: absolute; left: 50%; bottom: 11cqh; transform: translateX(-50%);
  text-align: center; white-space: nowrap; opacity: 0;
  transition: opacity .6s ease, transform .8s cubic-bezier(.2,.8,.2,1), filter .6s;
}
.cap .y, .cap .t { display: block; }
.cap.show { opacity: 1; }
.cap.top { bottom: auto; top: 10cqh; }

/* 1972: blocky white, phosphor glow */
.cap.pong { font-family: VT323, monospace; color: #fff; text-shadow: 0 0 10px #fff, 0 0 26px rgba(255,255,255,.6); transition: opacity .05s steps(1); }
.cap.pong .y { font-size: 7cqh; letter-spacing: .3em; }
.cap.pong .t { font-size: 4.6cqh; letter-spacing: .25em; text-transform: uppercase; }

/* 1978: arcade attract-mode */
.cap.arcade { font-family: 'Press Start 2P', monospace; transition: opacity .05s steps(1); }
.cap.arcade .y { color: #ff3c6e; font-size: 4.6cqh; margin-bottom: 1.6cqh; text-shadow: 0 0 12px #ff3c6e; }
.cap.arcade .t { color: #6bff6b; font-size: 2.8cqh; text-shadow: 0 0 10px #3f3; }

/* 1980: vector glow */
.cap.vector { font-family: Orbitron, sans-serif; font-weight: 500; color: transparent; -webkit-text-stroke: 1px #7dff9a; text-shadow: 0 0 12px rgba(80,255,140,.9); letter-spacing: .3em; }
.cap.vector .y { font-size: 7cqh; }
.cap.vector .t { font-size: 3cqh; color: #b8ffc8; -webkit-text-stroke: 0; text-transform: uppercase; }
.cap.vector:not(.show) { filter: blur(6px); }

/* 1985 & 1991: pixel titles */
.cap.pixel, .cap.pixel16 { font-family: 'Press Start 2P', monospace; transition: opacity .1s steps(1), transform .5s steps(6); }
.cap.pixel .y { font-size: 5cqh; color: #fff; text-shadow: .5cqh .5cqh 0 #000; margin-bottom: 1.8cqh; }
.cap.pixel .t { font-size: 2.8cqh; color: #fcd8a8; text-shadow: .4cqh .4cqh 0 #000; }
.cap.pixel16 .y { font-size: 5.6cqh; background: linear-gradient(#fff6c0 0%, #ffd23c 45%, #ff7a1a 55%, #c2410c 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(.45cqh .45cqh 0 #301040); margin-bottom: 1.8cqh; }
.cap.pixel16 .t { font-size: 2.6cqh; color: #fff; text-shadow: .35cqh .35cqh 0 #301040; }
.cap.pixel:not(.show), .cap.pixel16:not(.show) { transform: translate(-50%, 4cqh); }

/* 1993: chrome polygon logo */
.cap.poly { font-family: Orbitron, sans-serif; font-weight: 800; font-style: italic; }
.cap.poly .y { font-size: 7.5cqh; background: linear-gradient(180deg, #fff 0%, #9cc8ff 48%, #1b2f7a 52%, #8fd0ff 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 .5cqh 0 #0a1440); }
.cap.poly .t { font-size: 3cqh; color: #ffe14d; text-transform: uppercase; letter-spacing: .12em; text-shadow: 0 .3cqh 0 #7a2b00; }
.cap.poly:not(.show) { transform: translate(-50%, 0) perspective(400px) rotateX(70deg); }

/* 1996 */
.cap.ps1 { font-family: Inter, sans-serif; font-weight: 700; font-style: italic; }
.cap.ps1 .y { font-size: 7cqh; color: #e8eef8; letter-spacing: .04em; text-shadow: .3cqh .3cqh 0 #0b1f5c, 0 0 2cqh rgba(80,140,255,.5); }
.cap.ps1 .t { font-size: 3cqh; color: #9fc3ff; text-transform: uppercase; letter-spacing: .3em; font-style: normal; }

/* 2001 */
.cap.ps2 { font-family: Inter, sans-serif; font-weight: 200; color: #dfe8ff; text-shadow: 0 0 2.5cqh rgba(120,170,255,.8); }
.cap.ps2 .y { font-size: 8cqh; letter-spacing: .5em; margin-right: -.5em; }
.cap.ps2 .t { font-size: 2.6cqh; letter-spacing: .6em; text-transform: uppercase; }
.cap.ps2:not(.show) { letter-spacing: .4em; filter: blur(4px); }

/* 2007 */
.cap.hd { font-family: Inter, sans-serif; font-weight: 700; text-transform: uppercase; color: #f1e6d0; text-align: left; left: 8cqw; transform: none; }
.cap.hd .y { font-size: 6cqh; letter-spacing: .1em; border-left: .6cqw solid #c8a050; padding-left: 1.2cqw; }
.cap.hd .t { font-size: 2.4cqh; letter-spacing: .35em; padding-left: 1.8cqw; color: #c9b896; margin-top: .8cqh; }
.cap.hd:not(.show) { transform: translateX(-3cqw); }

/* 2020s */
.cap.modern { font-family: Inter, sans-serif; font-weight: 200; color: #fff; text-shadow: 0 0 3cqh rgba(0,0,0,.45); transition: opacity 1.4s ease, transform 2.4s cubic-bezier(.2,.8,.2,1), letter-spacing 2.4s ease; }
.cap.modern .y { font-size: 2.6cqh; letter-spacing: .8em; margin-right: -.8em; font-weight: 400; opacity: .85; }
.cap.modern .t { font-size: 6cqh; letter-spacing: .18em; margin-top: 1.4cqh; }
.cap.modern .t::after { content: ''; display: block; height: 1px; width: 40%; margin: 2cqh auto 0; background: linear-gradient(90deg, transparent, #fff, transparent); }
.cap.modern:not(.show) { transform: translate(-50%, 2cqh); letter-spacing: .05em; }

/* outro titles */
.cap.outro { font-family: Inter, sans-serif; font-weight: 200; color: #fff; bottom: auto; top: 58cqh; letter-spacing: .3em; transition: opacity 1.2s ease; }
.cap.outro .y { font-size: 3cqh; }
.cap.outro .t { font-family: 'Press Start 2P', monospace; font-size: 4.2cqh; letter-spacing: .1em; margin-top: 3cqh; text-shadow: 0 0 2cqh rgba(255,255,255,.6); }
.cap.intro { font-family: VT323, monospace; color: #fff; bottom: auto; top: 60cqh; font-size: 4.2cqh; letter-spacing: .2em; text-shadow: 0 0 10px #fff; transition: opacity 1s ease; }
