* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #070a1c;
}

body {
  background: #0a0710;
  font-family: 'Press Start 2P', monospace;
  color: #fff;
  user-select: none;
}

/* CRT overlay: scanlines, faint RGB aperture stripes, vignette and a
   subtle flicker. Sits above everything (HUD included) so the whole
   screen reads as one tube. Pure CSS, no rendering cost. */
:root {
  --tube-inset: 2.6vmin;   /* picture inset from the window edge */
  --tube-radius: 4vmin;    /* corner rounding of the picture */
  --bezel: #1b1209;        /* vintage dark cabinet color */
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  clip-path: inset(var(--tube-inset) round var(--tube-radius));
}

#crt {
  position: fixed;
  inset: var(--tube-inset);
  z-index: 40;
  pointer-events: none;
  border-radius: var(--tube-radius);
  background:
    radial-gradient(120% 90% at 28% 18%,
      rgba(255, 255, 255, 0.055), transparent 55%),
    repeating-linear-gradient(0deg,
      rgba(0, 0, 0, 0.24) 0px, rgba(0, 0, 0, 0.24) 1px,
      transparent 1px, transparent 3px),
    repeating-linear-gradient(90deg,
      rgba(255, 60, 60, 0.035) 0px, rgba(255, 60, 60, 0.035) 1px,
      rgba(60, 255, 60, 0.035) 1px, rgba(60, 255, 60, 0.035) 2px,
      rgba(60, 60, 255, 0.035) 2px, rgba(60, 60, 255, 0.035) 3px);
  box-shadow:
    inset 0 0 11vmax rgba(2, 4, 14, 0.65),
    0 0 0 3px rgba(255, 255, 255, 0.05),
    0 0 0 calc(var(--tube-inset) + 1vmin) var(--bezel);
  animation: crtflicker 0.14s steps(2) infinite;
}

@keyframes crtflicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.94; }
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.score {
  position: absolute;
  top: calc(var(--tube-inset) + 16px);
  font-size: 30px;
  text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.55);
}
.score.p1 { left: calc(var(--tube-inset) + 22px); color: #ff6b64; }
.score.p2 { right: calc(var(--tube-inset) + 22px); color: #5aff8f; }
.score.flash { animation: pop 0.35s; }
@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.7); }
  100% { transform: scale(1); }
}

#timer {
  position: absolute;
  top: calc(var(--tube-inset) + 16px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  color: #ffe08a;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.55);
}
#timer.low {
  color: #ff5a5a;
  animation: pulse 0.5s infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }

#msg {
  position: absolute;
  top: 36%;
  width: 100%;
  text-align: center;
  font-size: clamp(18px, 3.4vw, 36px);
  color: #fff;
  text-shadow: 4px 4px 0 rgba(15, 20, 60, 0.85);
}

/* ---------- Player tags (snow dots + charge bar) ---------- */

.ptag {
  position: fixed;
  left: 0;
  top: 0;
  margin-left: -60px;
  width: 120px;
  z-index: 6;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.dots { display: flex; gap: 3px; }
.dots i {
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.16);
}
.ptag.p1 .dots i.on { background: #ff6b64; }
.ptag.p2 .dots i.on { background: #5aff8f; }

.chargewrap {
  width: 72px;
  height: 9px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.4);
}
.charge {
  height: 100%;
  width: 0%;
  background: #ffe08a;
}

/* ---------- Power-up icon pop ---------- */

.pop {
  position: fixed;
  z-index: 20;
  width: 44px;
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.7));
  animation: popfly 1.1s ease-out forwards;
}
.pop svg { display: block; width: 100%; }

@keyframes popfly {
  0%   { transform: translate(-50%, 0) scale(0.2); opacity: 0; }
  25%  { transform: translate(-50%, -16px) scale(1.25); opacity: 1; }
  60%  { transform: translate(-50%, -28px) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -44px) scale(0.9); opacity: 0; }
}

/* ---------- Overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background: rgba(7, 10, 28, 0.84);
  text-align: center;
}

.hidden { display: none !important; }

/* Menus and HUD live inside the tube; nothing paints over the frame. */
.overlay, #hud {
  clip-path: inset(var(--tube-inset) round var(--tube-radius));
}

#menu h1 {
  font-size: clamp(22px, 5vw, 42px);
  line-height: 1.5;
  color: #ffe08a;
  text-shadow: 5px 5px 0 #8a3030;
}

#menu .sub {
  font-size: clamp(9px, 1.4vw, 12px);
  color: #9fd7ff;
  letter-spacing: 3px;
}

.controls {
  font-size: clamp(9px, 1.3vw, 12px);
  line-height: 2.4;
  color: #dfe8ff;
}
.controls .p1c { color: #ff6b64; }
.controls .p2c { color: #5aff8f; }

.controls .mkbd {
  margin-top: 8px;
  font-size: clamp(8px, 1.1vw, 10px);
  color: #8a95c0;
}

.blink {
  font-size: clamp(10px, 1.5vw, 14px);
  color: #fff;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

#winner { font-size: clamp(16px, 3vw, 30px); }
#finalscore { font-size: clamp(12px, 2vw, 18px); color: #ffe08a; }

kbd {
  display: inline-block;
  border: 2px solid #55608a;
  border-bottom-width: 4px;
  border-radius: 4px;
  padding: 3px 6px;
  margin: 0 2px;
  background: #161d3d;
  font: inherit;
  font-size: 0.9em;
}
