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

:root {
  --neon-cyan: #4dd0e1;
  --neon-pink: #ff4081;
  --neon-yellow: #ffd54f;
}

html, body {
  width: 100%; height: 100%;
  background: radial-gradient(ellipse at 50% 20%, #10141c 0%, #05070a 60%, #020304 100%);
  color: #e8f6ff;
  font-family: 'Orbitron', 'Courier New', monospace;
  overflow: hidden;
  user-select: none;
}

#app {
  width: 100vw; height: 100vh;
  display: flex; align-items: center; justify-content: center;
}

#arena {
  position: relative;
  /* exact px size is set by JS (resizeArena) to fill the viewport's shorter side */
  width: 100vmin;
  height: 100vmin;
  border-radius: 0;
  box-shadow:
    0 0 0 2px rgba(77, 208, 225, 0.35),
    0 0 30px rgba(77, 208, 225, 0.25),
    0 0 90px rgba(255, 64, 129, 0.12) inset;
  background: #05070a;
  overflow: hidden;
}

#game-canvas {
  width: 100%; height: 100%;
  display: block;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
  background: linear-gradient(to bottom, rgba(3,5,8,0.9), rgba(3,5,8,0));
  pointer-events: none;
}
#hud .hud-left, #hud .hud-right { display: flex; gap: 8px; pointer-events: auto; }
.hud-chip {
  background: rgba(10, 14, 20, 0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(77, 208, 225, 0.4);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  display: flex; gap: 6px; align-items: baseline;
  box-shadow: 0 0 8px rgba(77, 208, 225, 0.25) inset, 0 4px 12px rgba(0,0,0,0.35);
}
.hud-chip .label { color: #7fd8e8; font-size: 9px; opacity: 0.8; letter-spacing: 1px; }
.hud-chip .label.theme { color: var(--neon-yellow); opacity: 0.75; font-style: italic; margin-left: 2px; }
.hud-chip span:last-child { font-weight: 900; color: #fff; }

.hud-btn {
  background: rgba(10, 14, 20, 0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(77, 208, 225, 0.4);
  color: #fff;
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.hud-btn:hover { background: rgba(77, 208, 225, 0.25); box-shadow: 0 0 10px rgba(77, 208, 225, 0.5); transform: translateY(-1px); }
.hud-btn.small { font-size: 11px; padding: 6px 12px; }

.speed-switch {
  display: flex; align-items: center; gap: 5px;
  background: rgba(10, 14, 20, 0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(77, 208, 225, 0.4);
  border-radius: 8px;
  padding: 4px 6px;
  box-shadow: 0 0 8px rgba(77, 208, 225, 0.25) inset, 0 4px 12px rgba(0,0,0,0.35);
}
.speed-switch-label {
  color: #7fd8e8;
  font-size: 9px;
  letter-spacing: 1px;
  opacity: 0.85;
  padding-right: 2px;
  border-right: 1px solid rgba(77, 208, 225, 0.3);
  margin-right: 2px;
}
.speed-opt {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(77, 208, 225, 0.3);
  color: #9fb8c2;
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}
.speed-opt:hover { background: rgba(77, 208, 225, 0.22); color: #fff; }
.speed-opt.active {
  background: var(--neon-cyan);
  border-color: var(--neon-cyan);
  color: #04202a;
  box-shadow: 0 0 10px rgba(77, 208, 225, 0.8);
}

#player-bars {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(to top, rgba(3,5,8,0.9), rgba(3,5,8,0));
}
.pbar {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 11px;
  background: rgba(10,14,20,0.55);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  padding: 5px 12px;
  min-width: 110px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.pbar.p1 { border: 1px solid rgba(77, 208, 225, 0.5); box-shadow: 0 0 8px rgba(77, 208, 225, 0.25) inset; }
.pbar.p2 { border: 1px solid rgba(255, 64, 129, 0.5); box-shadow: 0 0 8px rgba(255, 64, 129, 0.25) inset; align-items: flex-end; }
.pname { font-weight: 900; letter-spacing: 1px; }
.pname em { font-style: normal; font-size: 9px; opacity: 0.7; margin-left: 4px; }
.pscore { font-weight: 700; font-size: 14px; color: var(--neon-yellow); text-shadow: 0 0 6px rgba(255,213,79,0.6); }
.p1 .plives { color: var(--neon-cyan); text-shadow: 0 0 6px rgba(77,208,225,0.7); letter-spacing: 2px; }
.p2 .plives { color: var(--neon-pink); text-shadow: 0 0 6px rgba(255,64,129,0.7); letter-spacing: 2px; }

/* ---------- Overlays ---------- */
.overlay {
  /* fixed (not absolute) so menu/pause/game-over content covers the full
     viewport instead of being clipped to the square arena - on tall narrow
     phones the arena is capped to the screen width, which is often shorter
     than this content needs. */
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at 50% 40%, rgba(10,16,26,0.92), rgba(2,3,5,0.97));
  backdrop-filter: blur(4px);
  text-align: center;
  padding: 20px;
  overflow-y: auto;
  z-index: 10;
}
#go-autorestart {
  color: var(--neon-cyan);
  font-size: 12px;
  letter-spacing: 1px;
  animation: flicker 1.6s infinite ease-in-out;
}
.hidden { display: none !important; }

.glow-title h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(28px, 6vmin, 52px);
  letter-spacing: 4px;
  color: #fff;
  text-shadow:
    0 0 8px var(--neon-cyan),
    0 0 22px var(--neon-cyan),
    0 0 46px rgba(77, 208, 225, 0.6);
  animation: flicker 3.2s infinite ease-in-out;
}
.glow-title h1 span {
  color: var(--neon-pink);
  text-shadow: 0 0 8px var(--neon-pink), 0 0 22px var(--neon-pink), 0 0 46px rgba(255,64,129,0.6);
}
.subtitle {
  margin-top: 10px;
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--neon-yellow);
  opacity: 0.85;
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  48% { opacity: 1; }
  50% { opacity: 0.85; }
  52% { opacity: 1; }
}

.menu-buttons {
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;
}
.menu-buttons.small { gap: 12px; }
.mode-btn {
  background: rgba(12, 18, 26, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(77, 208, 225, 0.45);
  border-radius: 10px;
  color: #fff;
  padding: 16px 20px;
  width: 240px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
  transition: all 0.18s;
  font-family: 'Orbitron', monospace;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.mode-btn:hover {
  border-color: var(--neon-pink);
  box-shadow: 0 0 20px rgba(255,64,129,0.35), 0 0 6px rgba(77,208,225,0.4) inset;
  transform: translateY(-2px);
}
.mode-icon { font-size: 22px; }
.mode-title { font-weight: 900; font-size: 13px; letter-spacing: 1px; color: var(--neon-cyan); }
.mode-desc { font-size: 10.5px; opacity: 0.75; line-height: 1.4; }

.menu-footer {
  display: flex; gap: 14px; align-items: center;
  font-size: 11px; color: var(--neon-yellow);
}
.hint { font-size: 10px; opacity: 0.55; letter-spacing: 0.5px; }

.overlay h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(20px, 4vmin, 34px);
  color: #fff;
  text-shadow: 0 0 10px var(--neon-cyan), 0 0 24px rgba(77,208,225,0.6);
}
.overlay h2.danger {
  color: #ff5252;
  text-shadow: 0 0 10px #ff5252, 0 0 26px rgba(255,82,82,0.7);
  animation: shake 0.4s ease-in-out;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.stats { font-size: 13px; line-height: 1.8; opacity: 0.9; }
.stats .hi { color: var(--neon-yellow); }

/* ---------- How to Play ---------- */
.howto-panel {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px;
  max-width: min(560px, 92vw);
  max-height: 88vh;
}
.howto-content {
  text-align: left;
  overflow-y: auto;
  padding: 4px 14px 4px 4px;
  max-height: 62vh;
  font-size: 12.5px;
  line-height: 1.55;
  color: #d6ecf3;
}
.howto-content::-webkit-scrollbar { width: 8px; }
.howto-content::-webkit-scrollbar-thumb { background: rgba(77, 208, 225, 0.4); border-radius: 4px; }
.howto-content::-webkit-scrollbar-track { background: rgba(255,255,255,0.04); }
.howto-content h3 {
  color: var(--neon-cyan);
  font-size: 13px;
  letter-spacing: 0.5px;
  margin: 16px 0 6px;
  text-shadow: 0 0 8px rgba(77, 208, 225, 0.5);
}
.howto-content h3:first-child { margin-top: 0; }
.howto-content p { margin: 0 0 6px; opacity: 0.92; }
.howto-content ul { margin: 0 0 6px; padding-left: 18px; }
.howto-content li { margin-bottom: 5px; opacity: 0.92; }
.howto-content b { color: #fff; }
.tag-friend { color: #39ff6a; font-weight: 700; text-shadow: 0 0 6px rgba(57,255,106,0.6); }
.tag-enemy { color: #ff3b3b; font-weight: 700; text-shadow: 0 0 6px rgba(255,59,59,0.6); }

@media (max-width: 520px) {
  .mode-btn { width: 90vw; }
  #player-bars { flex-direction: row; }
  .pbar { min-width: 90px; padding: 4px 8px; }

  /* Stage/Foes chips and Speed/Mute/Pause controls don't fit on one row at
     phone widths - wrap them onto two rows instead of clipping off-screen. */
  #hud { flex-wrap: wrap; row-gap: 6px; }
  #hud .hud-left, #hud .hud-right { flex: 1 1 100%; }
  #hud .hud-right { justify-content: flex-end; }
  .speed-switch { padding: 3px 5px; gap: 3px; }
  .speed-switch-label { display: none; }
  .speed-opt { padding: 3px 6px; font-size: 10px; }
}
