:root {
  --bg: #05060f;
  --panel: rgba(13, 15, 34, 0.78);
  --line: rgba(120, 140, 255, 0.28);
  --text: #e8ecff;
  --muted: #8d94bd;
  --cyan: #22e8ff;
  --magenta: #ff2fd0;
  --violet: #8b5cff;
  --lime: #7dff5c;
  --amber: #ffc23d;
  --red: #ff4d6d;
  --font: "Eurostile", "Bank Gothic", "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(60vw 50vh at 15% 0%, rgba(139, 92, 255, 0.16), transparent 70%),
    radial-gradient(60vw 50vh at 90% 100%, rgba(34, 232, 255, 0.11), transparent 70%),
    var(--bg);
}

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

/* ---------- HUD ---------- */
.hud {
  flex: none;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
}

.hud-group { display: flex; align-items: center; gap: 22px; }
.hud-buttons { gap: 8px; }

.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.stat-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-score {
  font-size: 24px;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(34, 232, 255, 0.75);
}

.stat-combo { opacity: 0; transition: opacity 0.15s; }
.stat-combo.is-active { opacity: 1; }
.stat-combo .stat-value { color: var(--magenta); text-shadow: 0 0 12px rgba(255, 47, 208, 0.8); }

.lives { display: flex; gap: 5px; height: 22px; align-items: center; }

.life-pip {
  width: 18px;
  height: 6px;
  border-radius: 3px;
  background: var(--magenta);
  box-shadow: 0 0 8px var(--magenta), 0 0 2px #fff inset;
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 14px;
  color: var(--text);
  background: rgba(20, 24, 54, 0.8);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, color 0.15s;
}

.icon-btn:hover { border-color: var(--cyan); box-shadow: 0 0 12px rgba(34, 232, 255, 0.45); }
.icon-btn.is-off { color: var(--muted); text-decoration: line-through; }

button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- Play area ---------- */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.playfield {
  position: relative;
  border-radius: 10px;
  box-shadow:
    0 0 0 1px rgba(34, 232, 255, 0.55),
    0 0 26px rgba(34, 232, 255, 0.28),
    0 0 70px rgba(139, 92, 255, 0.22);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  touch-action: none;
}

body.is-playing #game-canvas { cursor: none; }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow-y: auto;
  border-radius: 10px;
  background: rgba(4, 5, 14, 0.56);
  animation: overlay-in 0.25s ease-out;
}

.overlay[hidden] { display: none; }

.card {
  width: min(460px, 100%);
  margin: auto;
  padding: clamp(16px, 4vmin, 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.logo {
  margin: 0;
  font-size: clamp(32px, 8vmin, 56px);
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.05;
  text-transform: uppercase;
}

.logo-a {
  color: #bff8ff;
  text-shadow: 0 0 8px var(--cyan), 0 0 26px var(--cyan), 0 0 54px rgba(34, 232, 255, 0.55);
  animation: flicker 5.5s linear infinite;
}

.logo-b {
  color: #ffd4f5;
  text-shadow: 0 0 8px var(--magenta), 0 0 26px var(--magenta), 0 0 54px rgba(255, 47, 208, 0.55);
}

.tagline { margin: 0; color: var(--muted); font-size: 14px; letter-spacing: 0.04em; }

.headline {
  margin: 0;
  font-size: clamp(28px, 7vmin, 44px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d9f9ff;
  text-shadow: 0 0 10px var(--cyan), 0 0 30px var(--cyan);
}

.headline-danger { color: #ffd9e0; text-shadow: 0 0 10px var(--red), 0 0 30px var(--red); }
.headline-win { color: #e2ffd9; text-shadow: 0 0 10px var(--lime), 0 0 30px var(--lime); }

.final-score {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(30px, 7vmin, 44px);
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(34, 232, 255, 0.8);
}

.new-best {
  margin: 0;
  color: var(--amber);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(255, 194, 61, 0.8);
}

.summary { margin: 0; color: var(--muted); font-size: 14px; }

.btn {
  min-width: 190px;
  min-height: 44px;
  padding: 10px 26px;
  font: 700 15px var(--font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(20, 24, 54, 0.85);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s;
}

.btn:hover { transform: translateY(-1px); border-color: var(--cyan); box-shadow: 0 0 16px rgba(34, 232, 255, 0.5); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  color: #04121a;
  background: linear-gradient(100deg, var(--cyan), #9ef6ff);
  border-color: transparent;
  box-shadow: 0 0 18px rgba(34, 232, 255, 0.6);
}

.btn-primary:hover { box-shadow: 0 0 30px rgba(34, 232, 255, 0.95); }

.controls { margin: 4px 0 0; width: 100%; font-size: 13px; }
.controls > div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px solid rgba(120, 140, 255, 0.14); }
.controls dt { color: var(--muted); }
.controls dd { margin: 0; text-align: right; }

.powerup-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--muted);
}

.powerup-legend li { display: flex; align-items: center; gap: 6px; }

.powerup-chip {
  width: 22px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 10px var(--mono);
  color: #05060f;
  background: var(--chip);
  border-radius: 7px;
  box-shadow: 0 0 8px var(--chip);
}

.noscript { position: fixed; inset: auto 0 20px; text-align: center; }

@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

@keyframes flicker {
  0%, 91%, 94%, 97%, 100% { opacity: 1; }
  92%, 96% { opacity: 0.55; }
}

/* ---------- Small screens ---------- */
@media (max-width: 620px) {
  .hud-group { gap: 12px; }
  .stat-best, .stat-combo { display: none; }
  .stat-score { font-size: 20px; }
  .stat-value { font-size: 15px; }
  .icon-btn { width: 34px; height: 34px; }
  .life-pip { width: 12px; }
}

@media (max-height: 520px) {
  .controls, .powerup-legend, .tagline { display: none; }
  .app { gap: 6px; padding-top: 6px; padding-bottom: 6px; }
  .icon-btn { width: 32px; height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .logo-a, .overlay { animation: none; }
  .btn, .icon-btn { transition: none; }
}
