/* ── Retro arcade cabinet theme ── */
:root {
  --bg-deep: #070014;
  --bg-panel: #12082a;
  --neon-pink: #ff2a6d;
  --neon-cyan: #05d9e8;
  --neon-yellow: #f9f002;
  --neon-green: #39ff14;
  --neon-orange: #ff6b2b;
  --lcd-bg: #0a1f0a;
  --lcd-green: #33ff66;
  --lcd-dim: #1a5c2e;
  --player-red: #ff3864;
  --cpu-blue: #05d9e8;
  --font-pixel: "Press Start 2P", "Courier New", monospace;
  --font-lcd: "VT323", "Courier New", monospace;
  --bezel: #1a1035;
  --bezel-highlight: #3d2a6b;
}

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

body {
  min-height: 100vh;
  font-family: var(--font-lcd);
  font-size: 1.15rem;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 42, 109, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 20% 80%, rgba(5, 217, 232, 0.1) 0%, transparent 45%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255, 255, 255, 0.015) 2px,
      rgba(255, 255, 255, 0.015) 4px
    ),
    var(--bg-deep);
  color: #e8f4ff;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem 1rem 1.5rem;
  touch-action: manipulation;
}

#app.cabinet {
  width: min(100%, 1100px);
  padding: 0.85rem;
  border: 4px solid var(--bezel-highlight);
  border-radius: 6px;
  background: linear-gradient(180deg, #1a0a35 0%, var(--bg-panel) 8%, var(--bg-panel) 92%, #0d0520 100%);
  box-shadow:
    0 0 0 2px #000,
    0 0 30px rgba(255, 42, 109, 0.25),
    0 0 60px rgba(5, 217, 232, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ── Marquee ── */
.marquee {
  position: relative;
  margin-bottom: 0.75rem;
  padding: 0.85rem 1rem;
  border: 3px solid var(--neon-pink);
  background: linear-gradient(180deg, #2a0845 0%, #150528 100%);
  box-shadow:
    0 0 12px rgba(255, 42, 109, 0.5),
    inset 0 0 20px rgba(255, 42, 109, 0.15);
  overflow: hidden;
  animation: marquee-glow 2.4s ease-in-out infinite;
}

.marquee-lights {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 18px,
    rgba(249, 240, 2, 0.06) 18px,
    rgba(249, 240, 2, 0.06) 20px
  );
  pointer-events: none;
}

.marquee-inner {
  position: relative;
  text-align: center;
}

.marquee h1 {
  font-family: var(--font-pixel);
  font-size: clamp(0.85rem, 3.2vw, 1.35rem);
  color: var(--neon-yellow);
  text-shadow:
    0 0 8px rgba(249, 240, 2, 0.8),
    2px 2px 0 var(--neon-pink);
  letter-spacing: 0.12em;
  line-height: 1.6;
}

.marquee-sub {
  font-family: var(--font-pixel);
  font-size: clamp(0.45rem, 1.8vw, 0.62rem);
  color: var(--neon-cyan);
  letter-spacing: 0.2em;
  margin-top: 0.35rem;
  text-shadow: 0 0 6px rgba(5, 217, 232, 0.7);
}

@keyframes marquee-glow {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 42, 109, 0.5), inset 0 0 20px rgba(255, 42, 109, 0.15); }
  50% { box-shadow: 0 0 22px rgba(255, 42, 109, 0.75), inset 0 0 28px rgba(255, 42, 109, 0.22); }
}

/* ── Arcade panels ── */
.arcade-panel {
  border: 2px solid rgba(5, 217, 232, 0.35);
  background: rgba(0, 0, 0, 0.35);
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.55rem;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.5);
}

header.arcade-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.badge.lcd {
  font-family: var(--font-pixel);
  font-size: clamp(0.42rem, 1.6vw, 0.55rem);
  letter-spacing: 0.08em;
  padding: 0.45rem 0.65rem;
  border: 2px solid var(--lcd-dim);
  background: var(--lcd-bg);
  color: var(--lcd-green);
  text-shadow: 0 0 6px rgba(51, 255, 102, 0.6);
  box-shadow: inset 0 0 8px rgba(51, 255, 102, 0.12);
}

.badge.goal-flash-red {
  border-color: var(--player-red);
  color: #ff8fa8;
  text-shadow: 0 0 10px rgba(255, 56, 100, 0.8);
  animation: lcd-flash 0.35s step-end 3;
}

.badge.goal-flash-blue {
  border-color: var(--cpu-blue);
  color: var(--cpu-blue);
  text-shadow: 0 0 10px rgba(5, 217, 232, 0.8);
  animation: lcd-flash 0.35s step-end 3;
}

@keyframes lcd-flash {
  50% { opacity: 0.35; }
}

/* ── Score LCD ── */
#scoreboard.score-lcd {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem;
  background: var(--lcd-bg);
  border: 3px solid #1a3d1a;
  box-shadow:
    inset 0 0 16px rgba(51, 255, 102, 0.08),
    0 0 8px rgba(51, 255, 102, 0.15);
}

.score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 3.5rem;
}

.score-label {
  font-family: var(--font-pixel);
  font-size: 0.45rem;
  letter-spacing: 0.06em;
  opacity: 0.7;
}

.score-block.red .score-label { color: var(--player-red); }
.score-block.blue .score-label { color: var(--cpu-blue); }

.score-block strong {
  display: inline-block;
  font-family: var(--font-lcd);
  font-size: 2.4rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

.score-block.red strong {
  color: var(--player-red);
  text-shadow: 0 0 10px rgba(255, 56, 100, 0.7);
}

.score-block.blue strong {
  color: var(--cpu-blue);
  text-shadow: 0 0 10px rgba(5, 217, 232, 0.7);
}

.divider {
  font-family: var(--font-lcd);
  font-size: 2rem;
  color: var(--lcd-dim);
  opacity: 0.8;
  padding-bottom: 0.2rem;
}

/* ── Rod select ── */
.rod-panel {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.rod-bar-label {
  font-family: var(--font-pixel);
  font-size: 0.45rem;
  letter-spacing: 0.1em;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px rgba(5, 217, 232, 0.5);
}

#rod-pills {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.rod-pill {
  font-family: var(--font-pixel);
  font-size: clamp(0.38rem, 1.4vw, 0.48rem);
  letter-spacing: 0.04em;
  border: 2px solid #4a3a6b;
  border-top-color: #6b5a8b;
  border-left-color: #6b5a8b;
  background: linear-gradient(180deg, #2a1a4a 0%, #1a1030 100%);
  color: #b8a8d8;
  border-radius: 2px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.15s, color 0.15s;
  box-shadow: 0 3px 0 #0a0618;
}

.rod-pill:hover {
  color: #fff;
  border-color: var(--neon-cyan);
  box-shadow: 0 3px 0 #0a0618, 0 0 8px rgba(5, 217, 232, 0.35);
}

.rod-pill:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0a0618;
}

.rod-pill.active {
  background: linear-gradient(180deg, #4a1020 0%, #2a0810 100%);
  border-color: var(--player-red);
  border-top-color: #ff8fa8;
  color: #ffb8cc;
  text-shadow: 0 0 6px rgba(255, 56, 100, 0.6);
  box-shadow: 0 3px 0 #1a0410, 0 0 12px rgba(255, 56, 100, 0.35);
}

.rod-pill:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

/* ── CRT bezel + canvas ── */
#canvas-wrap.crt-bezel {
  position: relative;
  width: 100%;
  padding: 10px;
  border-radius: 4px;
  background: linear-gradient(180deg, #2a1848 0%, #12082a 50%, #0a0618 100%);
  border: 4px solid #3d2a6b;
  box-shadow:
    inset 0 0 30px rgba(0, 0, 0, 0.6),
    0 8px 24px rgba(0, 0, 0, 0.55),
    0 0 28px rgba(5, 217, 232, 0.15);
  overflow: hidden;
}

.crt-scanlines {
  position: absolute;
  inset: 10px;
  pointer-events: none;
  z-index: 4;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.08) 3px,
    rgba(0, 0, 0, 0.08) 5px
  );
  mix-blend-mode: multiply;
  opacity: 0.65;
}

@keyframes scanline-drift {
  from { background-position: 0 0; }
  to { background-position: 0 40px; }
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1100 / 620;
  background: #12082a;
  cursor: crosshair;
  touch-action: none;
  border: 2px solid #4a6080;
  box-shadow:
    inset 0 0 50px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(5, 217, 232, 0.15);
}

canvas:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

#scoreboard.scoreboard-flash {
  animation: scoreboard-pulse 0.45s step-end 6;
}

.score-block.score-pop strong {
  animation: score-pop 0.35s ease-out 4;
}

@keyframes scoreboard-pulse {
  50% {
    box-shadow:
      inset 0 0 16px rgba(51, 255, 102, 0.08),
      0 0 24px rgba(249, 240, 2, 0.55);
    border-color: var(--neon-yellow);
  }
}

@keyframes score-pop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.35); }
}

/* ── Goal toast ── */
#toast {
  position: absolute;
  top: 6%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  font-family: var(--font-pixel);
  font-size: clamp(0.65rem, 2.8vw, 1rem);
  letter-spacing: 0.12em;
  pointer-events: none;
  z-index: 7;
  border: 4px solid;
  animation: toast-pop 0.25s ease-out, toast-blink 0.4s step-end 8;
}

#toast.goal-you {
  background: #2a0010;
  border-color: var(--player-red);
  color: #fff;
  text-shadow: 0 0 8px rgba(255, 56, 100, 0.9);
  box-shadow: 0 0 20px rgba(255, 56, 100, 0.5);
}

#toast.goal-cpu {
  background: #001a22;
  border-color: var(--cpu-blue);
  color: #fff;
  text-shadow: 0 0 8px rgba(5, 217, 232, 0.9);
  box-shadow: 0 0 20px rgba(5, 217, 232, 0.5);
}

#toast.hidden {
  display: none;
}

@keyframes toast-pop {
  from { opacity: 0; transform: translateX(-50%) scale(0.7); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}

@keyframes toast-blink {
  50% { opacity: 0.45; }
}

/* ── Goal pause banner ── */
#goal-banner {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  animation: goal-dim-in 0.2s ease-out;
  cursor: pointer;
}

#goal-banner.hidden {
  display: none;
}

#goal-banner-card {
  width: min(94%, 520px);
  padding: 1.75rem 1.25rem 1.5rem;
  text-align: center;
  border: 5px solid;
  animation: goal-banner-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), goal-banner-shake 0.5s ease-in-out 0.2s;
}

#goal-banner.player #goal-banner-card {
  background: linear-gradient(180deg, #3a0018 0%, #120008 100%);
  border-color: var(--player-red);
  box-shadow:
    0 0 40px rgba(255, 56, 100, 0.65),
    inset 0 0 30px rgba(255, 56, 100, 0.12);
}

#goal-banner.cpu #goal-banner-card {
  background: linear-gradient(180deg, #001828 0%, #000810 100%);
  border-color: var(--cpu-blue);
  box-shadow:
    0 0 40px rgba(5, 217, 232, 0.65),
    inset 0 0 30px rgba(5, 217, 232, 0.12);
}

.goal-banner-tag {
  font-family: var(--font-pixel);
  font-size: clamp(0.55rem, 2.2vw, 0.85rem);
  letter-spacing: 0.2em;
  color: var(--neon-yellow);
  text-shadow: 0 0 10px rgba(249, 240, 2, 0.8);
  margin-bottom: 0.85rem;
  animation: blink 0.55s step-end infinite;
}

#goal-banner-title {
  font-family: var(--font-pixel);
  font-size: clamp(0.75rem, 3.5vw, 1.35rem);
  line-height: 1.7;
  letter-spacing: 0.08em;
  margin-bottom: 0.65rem;
}

#goal-banner.player #goal-banner-title {
  color: #fff;
  text-shadow: 0 0 16px rgba(255, 56, 100, 0.9);
}

#goal-banner.cpu #goal-banner-title {
  color: #fff;
  text-shadow: 0 0 16px rgba(5, 217, 232, 0.9);
}

.goal-banner-score {
  font-family: var(--font-lcd);
  font-size: clamp(2rem, 8vw, 3.2rem);
  letter-spacing: 0.08em;
  color: var(--neon-yellow);
  text-shadow: 0 0 12px rgba(249, 240, 2, 0.6);
  margin-bottom: 0.85rem;
}

.goal-banner-hint {
  font-family: var(--font-pixel);
  font-size: clamp(0.38rem, 1.5vw, 0.48rem);
  letter-spacing: 0.06em;
  color: rgba(200, 232, 255, 0.75);
  animation: blink 1.1s step-end infinite;
}

@keyframes goal-dim-in {
  from { background: rgba(0, 0, 0, 0); }
  to { background: rgba(0, 0, 0, 0.72); }
}

@keyframes goal-banner-pop {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes goal-banner-shake {
  0%, 100% { transform: translateX(0) scale(1); }
  20% { transform: translateX(-6px) scale(1.02); }
  40% { transform: translateX(6px) scale(1.02); }
  60% { transform: translateX(-4px) scale(1); }
  80% { transform: translateX(4px) scale(1); }
}

/* ── Overlay ── */
#overlay {
  position: absolute;
  inset: 10px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.82);
  z-index: 6;
}

#overlay.hidden {
  display: none;
}

#overlay-card {
  width: min(92%, 440px);
  padding: 1.5rem 1.25rem;
  text-align: center;
  border: 4px solid var(--neon-pink);
  background: linear-gradient(180deg, #1a0828 0%, #0d0418 100%);
  box-shadow:
    0 0 24px rgba(255, 42, 109, 0.45),
    inset 0 0 30px rgba(255, 42, 109, 0.08);
}

.overlay-tag {
  font-family: var(--font-pixel);
  font-size: 0.42rem;
  color: var(--neon-cyan);
  letter-spacing: 0.15em;
  margin-bottom: 0.75rem;
  text-shadow: 0 0 6px rgba(5, 217, 232, 0.6);
}

#overlay-card h2 {
  font-family: var(--font-pixel);
  font-size: clamp(0.65rem, 2.5vw, 0.95rem);
  color: var(--neon-yellow);
  margin-bottom: 0.85rem;
  line-height: 1.7;
  text-shadow: 2px 2px 0 var(--neon-pink);
}

#overlay-text {
  font-family: var(--font-lcd);
  font-size: 1.35rem;
  line-height: 1.45;
  color: #c8e8ff;
  margin-bottom: 1.15rem;
  white-space: pre-line;
}

#overlay-btn {
  font-family: var(--font-pixel);
  font-size: clamp(0.45rem, 1.8vw, 0.58rem);
  letter-spacing: 0.06em;
  border: none;
  border-radius: 2px;
  padding: 0.85rem 1.4rem;
  cursor: pointer;
  color: #000;
  background: linear-gradient(180deg, var(--neon-yellow) 0%, var(--neon-orange) 100%);
  border-bottom: 4px solid #a03000;
  box-shadow: 0 0 16px rgba(249, 240, 2, 0.4);
  transition: transform 0.08s, filter 0.15s;
}

#overlay-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 22px rgba(249, 240, 2, 0.55);
}

#overlay-btn:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

#overlay-btn:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 3px;
}

/* ── Mobile touch controls ── */
#mobile-controls {
  display: none;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.45rem;
}

.touch-btn {
  font-family: var(--font-pixel);
  font-size: clamp(0.42rem, 1.6vw, 0.52rem);
  letter-spacing: 0.04em;
  border: 2px solid #4a3a6b;
  border-top-color: #7a6a9b;
  background: linear-gradient(180deg, #2a1a4a 0%, #12082a 100%);
  color: #e8f4ff;
  border-radius: 2px;
  padding: 0.9rem 0.5rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  box-shadow: 0 4px 0 #0a0618;
}

.touch-btn.kick {
  background: linear-gradient(180deg, #5a1020 0%, #2a0810 100%);
  border-color: var(--neon-pink);
  color: #ffb8cc;
  box-shadow: 0 4px 0 #1a0410, 0 0 10px rgba(255, 42, 109, 0.25);
}

.touch-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0a0618;
}

/* ── HUD footer ── */
.hud-panel {
  margin-top: 0.55rem;
  margin-bottom: 0;
  line-height: 1.55;
  color: #98b8d8;
}

.controls-line {
  font-family: var(--font-lcd);
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px rgba(5, 217, 232, 0.3);
}

.blink {
  animation: blink 1s step-end infinite;
  color: var(--neon-yellow);
}

@keyframes blink {
  50% { opacity: 0; }
}

.muted {
  font-family: var(--font-lcd);
  font-size: 1.05rem;
  opacity: 0.55;
  margin-top: 0.25rem;
}

.cheat {
  font-family: var(--font-pixel);
  font-size: clamp(0.38rem, 1.4vw, 0.48rem);
  color: var(--neon-green);
  text-shadow: 0 0 8px rgba(57, 255, 20, 0.6);
  margin-top: 0.35rem;
  line-height: 1.8;
}

.credit-line {
  font-family: var(--font-pixel);
  font-size: 0.38rem;
  letter-spacing: 0.1em;
  text-align: center;
  color: rgba(152, 184, 216, 0.45);
  margin-top: 0.65rem;
}

.hidden {
  display: none !important;
}

/* ── Responsive ── */
@media (max-width: 720px) {
  body {
    padding: 0.5rem;
  }

  #app.cabinet {
    padding: 0.55rem;
  }

  #mobile-controls {
    display: grid;
  }

  #rod-pills {
    width: 100%;
  }

  .rod-pill {
    flex: 1 1 calc(50% - 0.35rem);
    text-align: center;
  }

  .score-block strong {
    font-size: 2rem;
  }
}

@media (hover: none) and (pointer: coarse) {
  #mobile-controls {
    display: grid;
  }
}
