:root {
  --background: 230 45% 7%;
  --foreground: 190 100% 96%;
  --primary: 190 100% 58%;
  --secondary: 318 100% 62%;
  --muted: 219 24% 72%;
  --destructive: 346 100% 60%;
  --border: 190 75% 35%;
  --card: 232 40% 11%;
  --shadow-sm: 0 8px 22px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 18px 55px rgba(0, 0, 0, 0.36);
  --shadow-lg: 0 30px 90px rgba(0, 0, 0, 0.55);
  --transition-fast: 140ms ease;
  --transition-smooth: 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --radius-sm: 0.65rem;
  --radius-md: 1rem;
  --radius-lg: 1.4rem;
}

.dark {
  --background: 230 45% 7%;
  --foreground: 190 100% 96%;
  --primary: 190 100% 58%;
  --secondary: 318 100% 62%;
  --muted: 219 24% 72%;
  --destructive: 346 100% 60%;
  --border: 190 75% 35%;
  --card: 232 40% 11%;
}

* { box-sizing: border-box; }
html, body, #root { min-height: 100%; }
body {
  margin: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overscroll-behavior: none;
}
button, canvas { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }

.scanline {
  background:
    radial-gradient(circle at top left, hsl(var(--primary) / 0.18), transparent 32rem),
    radial-gradient(circle at 85% 20%, hsl(var(--secondary) / 0.18), transparent 28rem),
    linear-gradient(180deg, hsl(var(--background)), hsl(235 50% 5%));
  position: relative;
}
.scanline::after {
  content: '';
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,0.035) 0, rgba(255,255,255,0.035) 1px, transparent 1px, transparent 5px);
  mix-blend-mode: overlay;
  opacity: 0.32;
}
.panel {
  border: 1px solid hsl(var(--border) / 0.34);
  background: linear-gradient(145deg, hsl(var(--card) / 0.92), hsl(var(--card) / 0.62));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), inset 0 1px 0 hsl(var(--foreground) / 0.08);
  backdrop-filter: blur(18px);
}
.logo-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: hsl(var(--background));
  font-weight: 1000;
  letter-spacing: -0.08em;
  background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--secondary)));
  box-shadow: 0 0 28px hsl(var(--primary) / 0.42);
}
.btn-primary, .btn-ghost, .arena-card, .touch-controls button {
  border: 1px solid hsl(var(--border) / 0.4);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.btn-primary {
  color: hsl(var(--background));
  background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--secondary)));
  box-shadow: 0 0 26px hsl(var(--primary) / 0.35);
}
.btn-primary:active, .btn-ghost:active, .touch-controls button:active { transform: scale(0.97); }
@media (hover:hover) {
  .btn-primary:hover, .btn-ghost:hover, .arena-card:hover { transform: translateY(-2px); }
}
.btn-ghost {
  color: hsl(var(--foreground));
  background: hsl(var(--foreground) / 0.06);
}
.stat-card {
  min-height: 78px;
  border-radius: var(--radius-md);
  border: 1px solid hsl(var(--border) / 0.25);
  background: hsl(var(--background) / 0.42);
  padding: 0.9rem;
}
.stat-card span {
  display: block;
  font-size: 0.82rem;
  color: hsl(var(--muted));
  font-weight: 700;
}
.stat-card strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1rem;
  color: hsl(var(--foreground));
}
.arena-card {
  background: hsl(var(--background) / 0.36);
  color: hsl(var(--foreground));
}
.arena-card.is-active {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 28px hsl(var(--primary) / 0.18), inset 0 0 0 1px hsl(var(--primary) / 0.28);
  background: linear-gradient(135deg, hsl(var(--primary) / 0.14), hsl(var(--secondary) / 0.10));
}

.game-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: calc(env(safe-area-inset-top) + 0.65rem) 0.75rem calc(env(safe-area-inset-bottom) + 0.85rem);
  background: radial-gradient(circle at 50% 0%, hsl(var(--primary) / 0.18), transparent 30rem), hsl(var(--background));
}
.game-topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}
.hud-pill {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: var(--radius-md);
  border: 1px solid hsl(var(--border) / 0.34);
  background: hsl(var(--card) / 0.78);
  padding: 0 0.9rem;
  font-weight: 900;
  color: hsl(var(--foreground));
  box-shadow: var(--shadow-sm);
}
.hud-pill.danger { color: hsl(var(--destructive)); }
.game-frame {
  position: relative;
  flex: 1;
  min-height: 420px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid hsl(var(--border) / 0.38);
  background: hsl(var(--card));
  box-shadow: var(--shadow-lg);
}
.game-canvas {
  width: 100%;
  height: 100%;
  min-height: 420px;
  display: block;
  touch-action: manipulation;
  cursor: crosshair;
}
.message-strip {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  top: 0.75rem;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid hsl(var(--border) / 0.3);
  background: hsl(var(--background) / 0.62);
  color: hsl(var(--foreground));
  font-weight: 900;
  text-align: center;
  padding: 0.45rem 0.75rem;
  backdrop-filter: blur(12px);
}
.mini-wrap {
  position: absolute;
  right: 0.75rem;
  top: 4.25rem;
  width: 150px;
  border-radius: var(--radius-md);
  border: 1px solid hsl(var(--primary) / 0.42);
  background: hsl(var(--background) / 0.74);
  padding: 0.55rem;
  box-shadow: 0 0 30px hsl(var(--primary) / 0.18);
  backdrop-filter: blur(12px);
}
.mini-wrap p {
  margin: 0 0 0.35rem;
  color: hsl(var(--primary));
  font-size: 0.74rem;
  font-weight: 1000;
  letter-spacing: 0.12em;
}
.mini-canvas {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  border-radius: 0.7rem;
}
.legend {
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  font-size: 0.74rem;
  color: hsl(var(--muted));
  font-weight: 800;
}
.blue-dot, .red-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
}
.blue-dot { background: hsl(207 100% 60%); }
.red-dot { background: hsl(var(--destructive)); }
.touch-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.control-cluster {
  display: grid;
  gap: 0.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid hsl(var(--border) / 0.25);
  background: hsl(var(--card) / 0.72);
  padding: 0.55rem;
}
.touch-controls button {
  min-width: 48px;
  min-height: 48px;
  border-radius: var(--radius-md);
  color: hsl(var(--foreground));
  background: hsl(var(--foreground) / 0.08);
  font-size: 1.1rem;
  font-weight: 1000;
}
.touch-controls .shoot-btn {
  min-height: 58px;
  color: hsl(var(--background));
  background: linear-gradient(135deg, hsl(var(--destructive)), hsl(var(--secondary)));
  box-shadow: 0 0 28px hsl(var(--destructive) / 0.34);
  letter-spacing: 0.16em;
}
@media (min-width: 768px) {
  .game-shell { padding-inline: 1.25rem; }
  .game-frame { min-height: 620px; }
  .game-canvas { min-height: 620px; }
  .mini-wrap { width: 180px; }
  .touch-controls { max-width: 620px; margin-inline: auto; }
}
@media (min-width: 1024px) {
  .touch-controls { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 1rem); transform: translateX(-50%); opacity: 0.9; }
}
