/* =========================================================
   Retro Pong — CRT arcade styling
   ========================================================= */

:root {
  --bg: #040805;
  --crt: #050d07;
  --green: #4dff88;
  --green-dim: #2f8f52;
  --green-soft: #8fffb4;
  --ink: #eafff2;
  --muted: #5f9c78;
  --panel-bg: rgba(5, 18, 10, 0.94);
}

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

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  background-color: var(--bg);
  background-image: radial-gradient(
    1100px 650px at 50% 18%,
    rgba(20, 60, 35, 0.55),
    rgba(0, 0, 0, 0) 70%
  );
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 14px;
}

button {
  -webkit-tap-highlight-color: transparent;
}

/* ------------------------- Cabinet / marquee ------------------------- */

.cabinet {
  width: min(880px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.marquee {
  text-align: center;
  padding: 4px 0 0;
}

.coin {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  animation: blink 1.6s steps(2, start) infinite;
}

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

.title {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--ink);
  text-shadow:
    0 0 10px rgba(77, 255, 136, 0.9),
    0 0 34px rgba(77, 255, 136, 0.45);
}

.subtitle {
  margin-top: 8px;
  font-size: 0.8rem;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: var(--muted);
}

/* ------------------------- CRT screen ------------------------- */

.screen {
  position: relative;
  background: var(--crt);
  border: 3px solid #173823;
  border-radius: 14px;
  padding: 14px;
  box-shadow:
    0 0 55px rgba(77, 255, 136, 0.1),
    inset 0 0 60px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  animation: crt-flicker 5s infinite;
}

@keyframes crt-flicker {
  0%,
  91%,
  93.5%,
  100% {
    opacity: 1;
  }
  92% {
    opacity: 0.965;
  }
}

/* Scanlines */
.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  border-radius: inherit;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.18) 3px,
    rgba(0, 0, 0, 0.18) 4px
  );
}

/* Vignette */
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 21;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(
    120% 90% at 50% 45%,
    rgba(0, 0, 0, 0) 60%,
    rgba(0, 0, 0, 0.4) 100%
  );
}

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

.hud {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 2px 8px 12px;
}

.score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
}

.score {
  font-size: clamp(2.6rem, 9vw, 4.2rem);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  text-shadow:
    0 0 12px rgba(77, 255, 136, 0.85),
    0 0 30px rgba(77, 255, 136, 0.35);
  font-variant-numeric: tabular-nums;
}

.score-label {
  margin-top: 6px;
  font-size: 0.72rem;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--muted);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-bottom: 8px;
}

.status {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--green-soft);
  text-shadow: 0 0 8px rgba(77, 255, 136, 0.5);
}

.mode-tag {
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  color: var(--muted);
}

/* ------------------------- Stage / canvas ------------------------- */

.stage {
  position: relative;
  z-index: 5;
  line-height: 0;
  user-select: none;
}

#game {
  display: block;
  width: 100%;
  aspect-ratio: 8 / 5;
  background: #06110a;
  touch-action: none;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.noscript {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  letter-spacing: 0.2em;
}

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

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(2, 7, 3, 0.82);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.16s ease,
    visibility 0.16s;
}

.overlay.active {
  opacity: 1;
  visibility: visible;
}

.panel {
  display: none;
  border: 3px solid var(--green);
  background: var(--panel-bg);
  box-shadow:
    0 0 28px rgba(77, 255, 136, 0.28),
    inset 0 0 22px rgba(77, 255, 136, 0.07);
  padding: 22px 30px 24px;
  text-align: center;
  max-width: min(480px, 100%);
}

.panel.active {
  display: block;
}

.panel-title {
  font-size: 1.25rem;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--ink);
  text-shadow: 0 0 10px rgba(77, 255, 136, 0.6);
}

.panel-sub {
  margin-top: 6px;
  font-size: 0.9rem;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.panel-note {
  margin-top: 16px;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  color: var(--muted);
}

.field {
  margin: 16px 0 0;
}

.field-label {
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--muted);
  margin-bottom: 8px;
}

.toggle-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.toggle-group.disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* ------------------------- Buttons ------------------------- */

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  font-size: 0.85rem;
  color: var(--green-soft);
  background: #0a1a10;
  border: 2px solid var(--green-dim);
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  transition:
    background 0.12s ease,
    color 0.12s ease,
    box-shadow 0.12s ease,
    transform 0.05s ease;
}

.btn:hover {
  background: #16351f;
  color: var(--ink);
  box-shadow: 0 0 16px rgba(77, 255, 136, 0.25);
}

.btn:active {
  transform: translateY(2px);
}

.btn:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.btn-primary {
  border-color: var(--green);
  background: #123524;
  color: var(--ink);
}

.btn-primary:hover {
  background: var(--green);
  color: #04140a;
  box-shadow: 0 0 22px rgba(77, 255, 136, 0.5);
}

.toggle {
  padding: 8px 14px;
  font-size: 0.78rem;
}

.toggle[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green);
  color: #04140a;
  box-shadow: 0 0 14px rgba(77, 255, 136, 0.45);
}

.btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

/* ------------------------- Controls bar ------------------------- */

.controls-bar {
  position: relative;
  z-index: 5;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 14px 8px 2px;
}

.btn-small {
  padding: 8px 14px;
  font-size: 0.75rem;
}

/* ------------------------- Legend ------------------------- */

.legend {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  padding: 2px 0 8px;
}

.legend p {
  display: flex;
  align-items: center;
  gap: 5px;
}

kbd {
  font: inherit;
  font-size: 0.72rem;
  color: var(--green-soft);
  background: #0a1810;
  border: 1px solid #2c5c3c;
  border-bottom-width: 3px;
  border-radius: 4px;
  padding: 1px 6px;
}

/* ------------------------- Motion preference ------------------------- */

@media (prefers-reduced-motion: reduce) {
  .screen {
    animation: none;
  }
  .coin {
    animation: none;
  }
  .overlay {
    transition: none;
  }
}
