/* ===========================================================================
   MAH BOI! — CD-i Quote Arena
   Retro-CRT styling. No webfonts, no CDNs, no images: the "pixel" typeface is
   assembled purely in CSS from the system monospace face plus disabled
   anti-aliasing, tight blocky metrics and hard (blur-0) phosphor shadows.
   =========================================================================== */

:root {
  --phosphor: #54ff8a;          /* primary phosphor green                     */
  --phosphor-dim: #1f7d45;
  --amber: #ffc247;             /* secondary amber phosphor                   */
  --amber-dim: #8a5f10;
  --bezel: #0b100c;
  --screen: #050a05;
  --ink: #051005;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #000;
  color: var(--phosphor);
  overflow-x: hidden;
}

body {
  /* Warm CRT glow behind everything. */
  background:
    radial-gradient(ellipse at 50% 40%, #0d2213 0%, #040804 55%, #000 100%);
  font-family: "Courier New", Courier, monospace;
  min-height: 100vh;
  padding: 1.5rem 1rem 3rem;
  display: flex;
  justify-content: center;
}

/* --- CSS-built pixel typeface -------------------------------------------- */
/* Monospace + no smoothing + integer letter-spacing + a 1px hard offset copy
   of every glyph gives the chunky, aliased look of an 8-bit bitmap font.     */
.pixel,
.pixel-title {
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  font-smooth: never;
  text-rendering: geometricPrecision;
  text-shadow: 1px 0 0 currentColor, 0 1px 0 currentColor;
}

/* --- CRT glass ------------------------------------------------------------ */
.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  /* Scanlines + aperture-grille + vignette, stacked. */
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.32) 0px,
      rgba(0, 0, 0, 0.32) 1px,
      rgba(0, 0, 0, 0) 1px,
      rgba(0, 0, 0, 0) 3px
    ),
    repeating-linear-gradient(
      to right,
      rgba(255, 0, 0, 0.05),
      rgba(0, 255, 0, 0.03) 1px,
      rgba(0, 0, 255, 0.05) 2px,
      rgba(0, 0, 0, 0) 3px
    ),
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.75) 100%);
}

/* Slow, subtle brightness wobble + a rolling refresh bar. */
.crt-flicker {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 59;
  background: linear-gradient(to bottom, rgba(84, 255, 138, 0.06), rgba(84, 255, 138, 0));
  background-size: 100% 22vh;
  background-repeat: no-repeat;
  animation: roll 7s linear infinite, flicker 3.2s steps(2, end) infinite;
  opacity: 0.55;
}

@keyframes roll {
  from { background-position: 0 -25vh; }
  to   { background-position: 0 115vh; }
}

@keyframes flicker {
  0%, 96%  { opacity: 0.5; }
  97%      { opacity: 0.75; }
  98%      { opacity: 0.35; }
  100%     { opacity: 0.55; }
}

/* Full-screen white/amber blast fired by the Squadala fanfare. */
.screen-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 58;
  background: radial-gradient(circle at 50% 45%, #fff 0%, var(--amber) 35%, rgba(255, 194, 71, 0) 72%);
  opacity: 0;
}
.screen-flash.fire { animation: blast 620ms ease-out 1; }
@keyframes blast {
  0%   { opacity: 0.95; }
  35%  { opacity: 0.45; }
  100% { opacity: 0; }
}

/* --- Layout --------------------------------------------------------------- */
.cabinet {
  position: relative;
  z-index: 10;
  width: min(880px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.masthead { text-align: center; }

.pixel-title {
  margin: 0;
  font-size: clamp(2rem, 8vw, 4.25rem);
  line-height: 1;
  color: var(--amber);
  /* Hard-edged multi-layer shadow = chunky "pixel bevel", no blur anywhere. */
  text-shadow:
    2px 0 0 var(--amber), 0 2px 0 var(--amber),
    4px 4px 0 var(--amber-dim),
    8px 8px 0 #2a1a02;
  animation: hum 4s ease-in-out infinite;
}
@keyframes hum {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.18); }
}

.subtitle {
  margin: 0.85rem 0 0;
  font-size: clamp(0.62rem, 2.2vw, 0.8rem);
  color: var(--phosphor-dim);
}

.stage {
  display: flex;
  justify-content: center;
}

#king {
  width: min(320px, 92vw);
  height: auto;
  image-rendering: pixelated;   /* keep the pixels crunchy when upscaled */
  border: 3px solid var(--phosphor-dim);
  border-radius: 6px;
  background: #030603;
  box-shadow: 0 0 24px rgba(84, 255, 138, 0.18), inset 0 0 40px rgba(0, 0, 0, 0.9);
}

/* --- Quote console -------------------------------------------------------- */
.console, .ticker {
  border: 3px solid var(--phosphor-dim);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(9, 24, 13, 0.9), rgba(3, 8, 4, 0.95));
  padding: 1rem;
  box-shadow: 0 0 18px rgba(84, 255, 138, 0.12);
}

.label {
  margin: 0 0 0.6rem;
  font-size: 0.66rem;
  color: var(--phosphor-dim);
}

.screen {
  min-height: 8.5rem;
  padding: 0.75rem;
  border: 1px dashed rgba(84, 255, 138, 0.25);
  background: rgba(0, 0, 0, 0.45);
}

.quote {
  margin: 0;
  font-size: clamp(1rem, 3.2vw, 1.45rem);
  line-height: 1.5;
  color: var(--phosphor);
  text-shadow: 0 0 8px rgba(84, 255, 138, 0.55);
  min-height: 3rem;
}

/* Blinking block cursor that trails the typewriter effect. */
.caret {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--phosphor);
  animation: blink 1s steps(1, end) infinite;
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.source {
  margin: 0.9rem 0 0;
  font-size: 0.75rem;
  color: var(--amber);
  min-height: 1rem;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn {
  flex: 1 1 12rem;
  cursor: pointer;
  padding: 0.85rem 1rem;
  font-size: clamp(0.7rem, 2.4vw, 0.92rem);
  color: var(--ink);
  background: var(--phosphor);
  border: 0;
  /* Hard offset "shadow" = chunky pixel button, no border-radius, no blur. */
  box-shadow: 4px 4px 0 var(--phosphor-dim);
  transition: transform 60ms linear, box-shadow 60ms linear, filter 120ms linear;
}
.btn:hover { filter: brightness(1.15); }
.btn:active,
.btn.pressed {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--phosphor-dim);
}
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.btn-amber {
  background: var(--amber);
  box-shadow: 4px 4px 0 var(--amber-dim);
}
.btn-amber:active,
.btn-amber.pressed { box-shadow: 0 0 0 var(--amber-dim); }

.key-hint { opacity: 0.65; }

.hint {
  margin: 0.9rem 0 0;
  font-size: 0.6rem;
  color: var(--phosphor-dim);
}
kbd {
  font-family: inherit;
  border: 1px solid var(--phosphor-dim);
  padding: 0 0.3em;
}

/* --- Quote bank ----------------------------------------------------------- */
.bank {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  max-height: 15rem;
  overflow-y: auto;
}
.bank li {
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--phosphor-dim);
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  border-left: 3px solid transparent;
}
.bank li:hover,
.bank li:focus-visible {
  color: var(--phosphor);
  border-left-color: var(--amber);
  background: rgba(84, 255, 138, 0.06);
  outline: none;
}
.bank li b { color: var(--amber); font-weight: 700; }

.footer {
  text-align: center;
  font-size: 0.62rem;
  color: var(--amber-dim);
  padding-top: 0.5rem;
}

/* Respect users who don't want motion: kill the loops, keep the look. */
@media (prefers-reduced-motion: reduce) {
  .crt-flicker, .pixel-title, .caret { animation: none; }
}
