  @font-face {
    font-family: 'Press Start 2P';
    src: url('assets/fonts/press-start-2p.woff2') format('woff2');
    font-display: block;
  }
  :root {
    --ink: #0a0a0a;
    --bone: #ebe6dc;
    --blood: #b8231c;
    --pixel: 'Press Start 2P', monospace;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  html, body {
    height: 100%;
    background: var(--ink);
    color: var(--bone);
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
  }
  body {
    user-select: none;
  }
  #stage {
    position: relative;
    width: 100vw;
    height: 100dvh;
    background: #000;
    overflow: hidden;
  }
  canvas {
    width: 100%;
    height: 100%;
    display: block;
  }
  .hud {
    position: absolute;
    inset: 0;
    z-index: 3;   /* above the game canvas — score/labels never hide behind bars */
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 18px 20px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    mix-blend-mode: difference;
    color: var(--bone);
  }
  .top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    font-size: 11px;
  }
  .score {
    font-family: var(--pixel);
    font-size: 40px;
    line-height: 1;
    letter-spacing: 0;
    font-weight: 400;
  }
  .score.pop { animation: score-pop 140ms ease; }
  @keyframes score-pop {
    50% { transform: scale(1.14); }
  }
  @media (prefers-reduced-motion: reduce) {
    .score.pop { animation: none; }
  }
  .bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 10px;
    opacity: 0.65;
  }
  /* Narrow screens: tighten the HUD so nothing collides. */
  @media (max-width: 560px) {
    .top { font-size: 9px; letter-spacing: 0.08em; gap: 8px; }
    .score { font-size: 28px; }
    .ego-track { width: 64px; }
  }
  .overlay {
    position: absolute;
    inset: 0;
    z-index: 5;   /* above the game canvas (z1) — text never hides behind bars */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
    pointer-events: auto;
    cursor: pointer;
    transition: opacity 200ms ease;
  }
  .overlay.hidden {
    opacity: 0;
    pointer-events: none;
  }
  .title {
    font-size: 44px;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 0.9;
    color: var(--bone);
    text-transform: uppercase;
  }
  .title .red { color: var(--blood); }
  .tagline {
    margin-top: 12px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.5em;
    opacity: 0.75;
    text-transform: uppercase;
  }
  .now-line {
    margin-top: 12px;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.32em;
    color: var(--era-accent, var(--bone));
    text-transform: uppercase;
    transition: color 600ms ease;
  }
  .onboard {
    margin-top: 14px;
    font-family: var(--pixel);
    font-size: 10px;
    letter-spacing: 0.08em;
    color: #f0c33c;
  }
  .sub {
    margin-top: 18px;
    font-family: var(--pixel);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.85;
  }
  .meta {
    margin-top: 28px;
    font-size: 9px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    opacity: 0.4;
    max-width: 70%;
    line-height: 1.6;
  }
  /* Era title card — the typography moment at each room boundary. */
  .era-card {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
    z-index: 4;
    color: var(--era-accent, var(--bone));
    text-shadow: 0 2px 24px rgba(0,0,0,0.55);
    opacity: 1;
    transition: opacity 300ms ease;
  }
  .era-card.hidden { opacity: 0; }
  .ec-roman {
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 0.6em;
    opacity: 0.85;
  }
  .ec-album {
    font-size: clamp(34px, 9vw, 120px);
    font-weight: 900;
    line-height: 0.95;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    max-width: 92vw;
    animation: ec-tighten 1.6s ease both;
  }
  .ec-meta {
    margin-top: 14px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.5em;
    opacity: 0.7;
    text-transform: uppercase;
  }
  @keyframes ec-tighten {
    from { letter-spacing: 0.22em; }
    to   { letter-spacing: 0.02em; }
  }
  @media (prefers-reduced-motion: reduce) {
    .ec-album { animation: none; }
  }

  .credit {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--bone);
    opacity: 0.35;
    font-size: 9px;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    mix-blend-mode: difference;
    pointer-events: none;
    z-index: 3;
  }
  /* Death moment: context, era quote, attribution, stats. */
  .death-block { margin-top: 16px; max-width: 82vw; }
  .death-context {
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.4em;
    color: var(--era-accent, var(--blood));
    text-transform: uppercase;
  }
  .death-quote {
    margin-top: 10px;
    font-size: clamp(18px, 3.4vw, 30px);
    font-weight: 900;
    font-style: italic;
    line-height: 1.2;
    text-transform: uppercase;
    color: var(--bone);
  }
  .death-attr {
    margin-top: 6px;
    font-size: 10px;
    letter-spacing: 0.3em;
    opacity: 0.55;
  }
  .death-stats {
    margin-top: 14px;
    font-family: var(--pixel);
    font-size: 11px;
    letter-spacing: 0.08em;
    opacity: 0.9;
  }

  /* Ego meter: hairline gold bar under the score + the ×2 chip. */
  .ego-wrap { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
  .ego-track { width: 92px; height: 4px; background: rgba(235,230,220,0.18); }
  .ego-bar { width: 0%; height: 100%; background: #f0c33c; }
  .ego-chip {
    font-family: var(--pixel);
    font-size: 9px;
    color: #f0c33c;
    visibility: hidden;
  }
  .ego-chip.on { visibility: visible; }

  /* Discography progress dots on the title screen. */
  .era-dots { display: flex; gap: 8px; margin-top: 18px; }
  .era-dot {
    width: 9px;
    height: 9px;
    background: rgba(235,230,220,0.16);
  }
  .era-dot.filled { background: var(--bone); }
  .era-dot.filled.goat { background: #ffd700; }

  /* Toast: short center-screen flash ("THE EGO HAS LANDED" etc). */
  .toast {
    position: absolute;
    left: 50%;
    top: 26%;
    transform: translateX(-50%);
    font-weight: 900;
    font-size: clamp(16px, 3vw, 26px);
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--era-accent, var(--bone));
    mix-blend-mode: difference;
    z-index: 4;
    pointer-events: none;
    transition: opacity 250ms ease;
  }
  .toast.hidden { opacity: 0; }

  /* Yeezus takeover: the HUD itself tears for a third of a second. */
  .hud.glitch { animation: hud-tear 0.36s steps(3) both; }
  @keyframes hud-tear {
    0%   { transform: translate(3px, -2px); clip-path: inset(0 0 12% 0); }
    50%  { transform: translate(-4px, 1px); clip-path: inset(8% 0 0 0); }
    100% { transform: translate(0, 0); clip-path: none; }
  }
  @media (prefers-reduced-motion: reduce) {
    .hud.glitch { animation: none; }
  }
.mute-btn {
  background: transparent;
  border: 1px solid var(--era-accent, rgba(235,230,220,0.4));
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  padding: 4px 10px;
  cursor: pointer;
  pointer-events: auto;
  text-transform: uppercase;
}
.mute-btn:hover { border-color: var(--bone); }
#stage canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}
#bg { z-index: 0; }
#game {
  z-index: 1;
  background: transparent;
  image-rendering: pixelated;   /* hi-bit: crisp nearest-neighbor upscale */
}

/* Honest degradation when WebGL is unavailable: static Turrell-ish gradient. */
.no-webgl #stage { background: radial-gradient(120% 90% at 50% 55%, #6e2bd1 0%, #1a0d2a 75%); }
.no-webgl #bg { display: none; }
