:root {
  --bg: #05060b;

  /* Slightly different vibe for Centipede (green-forward) */
  --accent: #39ff14;
  --accent2: #ff2fd4;
  --accent3: #ffd54a;

  --text-main: #f5f5f5;
  --text-muted: #a3b0c2;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top, #101530 0, #020309 55%);
  font-family: "Roboto", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-main);
  height: 100%;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding-top: 56px;
}

.frame {
  width: 100%;
  max-width: 960px;
  padding: 1rem;
}

/* ----------------------------------------
   Cabinet strip (escape hatch)
-----------------------------------------*/
.cabinet-strip {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 999;

  background: linear-gradient(to bottom, rgba(5, 6, 11, 0.92), rgba(5, 6, 11, 0.55));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cabinet-strip__title {
  font-family: "Press Start 2P", system-ui;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-shadow: 0 0 8px rgba(57, 255, 20, 0.28);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

.cabinet-strip__dot {
  color: var(--accent2);
  opacity: 0.9;
}

.cabinet-strip__btn {
  font-family: "Press Start 2P", system-ui;
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;

  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(5, 6, 12, 0.85);
  color: var(--text-main);
  text-decoration: none;

  box-shadow: 0 0 10px rgba(0, 0, 0, 0.35);
}

.cabinet-strip__btn:hover {
  background: rgba(57, 255, 20, 0.12);
  border-color: rgba(57, 255, 20, 0.45);
}

.cabinet-strip__btn--primary {
  border-color: transparent;
  background: rgba(57, 255, 20, 0.16);
  color: var(--accent);
  box-shadow: 0 0 12px rgba(57, 255, 20, 0.18);
}

.cabinet-strip__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cabinet-strip__status {
  font-family: "Press Start 2P", system-ui;
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.9;
}

@media (max-width: 640px) {
  .cabinet-strip__status { display: none; }
}

@media (max-width: 640px) {
  body { padding-top: 60px; }
  .cabinet-strip { height: 56px; padding: 0 0.75rem; }
  .cabinet-strip__title { display: none; }
}

.crt-shell {
  position: relative;
  border-radius: 18px;
  padding: 0.75rem;
  background: radial-gradient(circle at top, #283a5b 0, #05060b 55%);
  box-shadow:
    0 0 18px rgba(0, 0, 0, 0.8),
    0 0 40px rgba(57, 255, 20, 0.25);
  border: 2px solid rgba(57, 255, 20, 0.22);
  overflow: hidden;
}

/* Scanlines */
.crt-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
    transparent 0,
    rgba(255, 255, 255, 0.06) 1px,
    transparent 2px
  );
  background-size: 100% 3px;
  opacity: 0.3;
  mix-blend-mode: screen;
  pointer-events: none;
  animation: scanWobble 4s infinite linear;
}

/* Vignette / CRT glow */
.crt-shell::after {
  content: "";
  position: absolute;
  inset: -10%;
  pointer-events: none;
  background:
    radial-gradient(circle at center, rgba(57,255,20,0.05) 0, transparent 40%),
    radial-gradient(circle at center, transparent 55%, rgba(0,0,0,0.5) 80%, rgba(0,0,0,0.9) 100%);
  mix-blend-mode: multiply;
}

canvas {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 640px;
  background: #020309;
  image-rendering: pixelated;
  position: relative;
  z-index: 1;
}

.hud-overlay {
  position: absolute;
  inset: 0.75rem;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: "Press Start 2P", system-ui;
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-main);
  z-index: 2;
}

.hud-row{
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.hud-col--center{
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
.hud-bottom { display: flex; justify-content: space-between; align-items: flex-end; }
.hud-col { display: flex; flex-direction: column; gap: 0.2rem; }
.hud-label { color: var(--text-muted); }
.hud-value { color: var(--accent3); }

.center-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 3;
}

.panel {
  background: rgba(1, 4, 10, 0.94);
  border: 1px solid rgba(57, 255, 20, .35);
  box-shadow:
    0 0 40px rgba(57, 255, 20, 0.18),
    0 0 80px rgba(0, 0, 0, 0.9);
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
}

/* Lighter attract-mode panel for the start screen */
.panel--start {
  background: radial-gradient(
    circle at top,
    rgba(57, 255, 20, 0.14),
    rgba(0, 20, 20, 0.85)
  );
  border: 1px solid rgba(57,255,20,0.28);
  box-shadow:
    0 0 22px rgba(57,255,20,0.18),
    0 0 42px rgba(57,255,20,0.12);
}

.panel h1 {
  font-family: "Press Start 2P", system-ui;
  font-size: 0.9rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 0.9rem;
}

#panelStart {
  max-width: 420px !important;
  width: 100%;
  padding: 26px 24px 22px !important;
  margin: 0 auto;
}

.panel p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 0.75rem;
}

.panel .highlight { color: var(--accent3); }

.panel small {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.45rem;
}

.hidden { display: none; }

.btn-inline {
  display: inline-block;
  margin-top: 0.8rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(5,6,12,0.95);
  color: var(--accent3);
  text-decoration: none;
  font-family: "Press Start 2P", system-ui;
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
}

.btn-inline:hover { background: rgba(57,255,20,0.12); }

/* Score table on attract screen */
.score-legend {
  margin: 0.75rem 0 0.5rem;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: radial-gradient(circle at top, rgba(57,255,20,0.10), rgba(2,3,10,0.9));
  font-family: "Press Start 2P", system-ui;
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: left;
}

.score-legend-title { text-align: center; color: var(--accent3); margin-bottom: 0.4rem; }
.score-line { display: flex; align-items: center; gap: 0.5rem; margin: 0.15rem 0; }
.score-icon { display: inline-block; width: 18px; text-align: center; }

.score-saucer::before { content: "≡"; color: #ff5555; }
.score-top::before    { content: "Λ"; color: #39ff14; }
.score-mid::before    { content: "Ξ"; color: #aaff00; }
.score-bottom::before { content: "Π"; color: #39ff14; }

.score-points { width: 38px; color: var(--accent3); }
.score-desc { flex: 1; color: var(--text-muted); }

.controls-line { margin-top: 0.75rem; }

/* Mobile controls */
.mobile-controls {
  position: absolute;
  left: 50%;
  bottom: 0.7rem;
  transform: translateX(-50%);
  width: calc(100% - 2rem);
  display: none;
  justify-content: space-between;
  align-items: center;
  z-index: 4;
  pointer-events: none;
}

.joystick {
  position: relative;
  width: 96px;
  height: 96px;
  pointer-events: auto;
  touch-action: none;
}
.joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at top,
    rgba(57, 255, 20, 0.22),
    rgba(3, 6, 14, 0.95)
  );
  border: 2px solid rgba(57, 255, 20, 0.55);
  box-shadow:
    0 0 12px rgba(57, 255, 20, 0.45),
    inset 0 0 10px rgba(0, 0, 0, 0.9);
}
.joystick-handle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at top, #ffffff, #ffd54a 35%, #b8860b 80%);
  box-shadow:
    0 0 10px rgba(255, 213, 74, 0.7),
    inset 0 0 6px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.7);
  transition: transform 60ms linear;
}
.joystick-handle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 24%;
  width: 40%;
  height: 2px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  border-radius: 999px;
}

.mobile-btn {
  min-width: 64px;
  min-height: 48px;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(5,6,12,0.95);
  color: var(--accent3);
  font-family: "Press Start 2P", system-ui;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
}

.mobile-btn.mobile-btn-fire { min-width: 74px; min-height: 74px; pointer-events: auto; }

/* Classic arcade fire button */
.mobile-btn-fire{
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 3px solid #2a0000;
  background: #b00000;
  position: relative;
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  box-shadow:
    inset 0 -6px 10px rgba(0,0,0,0.6),
    inset 0 4px 6px rgba(255,255,255,0.25),
    0 8px 14px rgba(0,0,0,0.6);
  transition: transform 0.05s ease, box-shadow 0.05s ease;
  -webkit-appearance: none;
  appearance: none;
}
.mobile-btn-fire::before{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ff6b6b, #b00000 60%, #5a0000 100%);
  display: block;
}
.mobile-btn-fire:active {
  transform: translateY(3px);
  box-shadow:
    inset 0 -2px 4px rgba(0,0,0,0.7),
    inset 0 2px 3px rgba(255,255,255,0.15),
    0 4px 8px rgba(0,0,0,0.6);
}
.mobile-btn-fire:active::before{ filter: brightness(0.92); }

.mobile-btn { -webkit-appearance: none; appearance: none; background-clip: padding-box; }
.mobile-btn:active { transform: translateY(1px); background: rgba(57,255,20,0.12); }

.initials-block {
  margin-top: 0.75rem;
  padding-top: 0.4rem;
  border-top: 1px dashed rgba(255,255,255,0.25);
  font-size: 0.7rem;
}
.initials-label { margin: 0 0 0.35rem; color: var(--text-muted); }
.initials-input-wrap { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-bottom: 0.3rem; }
.initials-input {
  width: 70px;
  padding: 0.25rem 0.4rem;
  text-align: center;
  font-family: "Press Start 2P", system-ui;
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.6);
  background: rgba(0,0,0,0.85);
  color: var(--accent3);
  outline: none;
}
.initials-input:focus { border-color: var(--accent3); box-shadow: 0 0 8px rgba(255,213,74,0.5); }
.initials-btn { font-size: 0.55rem; padding: 0.35rem 0.7rem; }
#initialsHint { display: block; margin-top: 0.1rem; font-size: 0.65rem; color: var(--text-muted); }

/* Show mobile controls only on small screens */
@media (max-width: 640px) {
  body { align-items: flex-start; }

  .mobile-controls {
    display: flex;
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0 0.75rem 0.75rem;
  }

  .hud-overlay { font-size: 0.5rem; }

  #panelStart {
    max-width: 340px !important;
    padding: 18px 16px 16px !important;
  }
  .panel h1 { font-size: 0.7rem; margin-bottom: 0.6rem; }
  .panel p { font-size: 0.65rem; line-height: 1.45; }
  .score-legend { font-size: 0.5rem; padding: 0.45rem 0.6rem; }
  .btn-inline { font-size: 0.5rem; padding: 0.4rem 0.75rem; }
}

/* Subtle scanline wobble */
@keyframes scanWobble {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(0.6px); }
}

/* --- Anti double-tap zoom / selection on mobile controls --- */
.mobile-controls,
.mobile-controls * ,
#joystick,
#btnFire,
.mobile-btn-fire {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* ==========================================
   Mobile: Start screen fills CRT (safe)
========================================== */
@media (max-width: 640px) {

  /* Start overlay should fill the entire CRT area */
  #panelStart{
    inset: 0;
    align-items: stretch;
    justify-content: stretch;
    padding: 0 !important;
    max-width: none !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
  }

  /* Panel becomes full CRT surface */
  #panelStart .panel{
    width: 100%;
    height: 100%;
    max-width: none !important;

    border-radius: 0;
    border: none;
    box-shadow: none;

    padding: 18px 16px 22px;

    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Slightly tighten typography for short screens */
  #panelStart .panel h1{
    margin: 0 0 0.6rem;
    font-size: 0.75rem;
  }
}
