/* ============ Star Defender — design tokens ============ */
:root {
  --bg: #05070f;
  --bg-2: #0b1226;
  --panel: rgba(15, 23, 42, .72);
  --panel-line: rgba(148, 190, 255, .14);
  --fg: #eaf2ff;
  --muted: #8ea3c4;
  --red: #dc2626;
  --red-glow: #ff5470;
  --blue: #2563eb;
  --cyan: #22d3ee;
  --green: #22c55e;
  --amber: #fbbf24;
  --violet: #a78bfa;
  --radius: 18px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, .9);
  --font-display: 'Orbitron', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1200px 700px at 50% -10%, #16224a 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 110%, #2a1140 0%, transparent 55%),
    var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  display: grid;
  place-items: center;
  padding: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.stage {
  width: min(1080px, 100%);
  height: min(760px, calc(100vh - 28px));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============ HUD ============ */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(20, 30, 58, .8), rgba(10, 16, 34, .72));
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, .8);
}

.hud-group { display: flex; align-items: center; gap: 18px; }
.hud-group.right { gap: 12px; }

.stat { display: flex; flex-direction: column; line-height: 1.1; }

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

.stat-value {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.accent-blue { color: var(--cyan); text-shadow: 0 0 14px rgba(34, 211, 238, .6); }
.accent-green { color: var(--green); text-shadow: 0 0 14px rgba(34, 197, 94, .5); }

.brand {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 15px;
  letter-spacing: .16em;
  color: #cfe0ff;
  display: flex;
  align-items: center;
  gap: 9px;
  text-shadow: 0 0 18px rgba(120, 170, 255, .45);
}

.brand span { color: var(--red); text-shadow: 0 0 18px rgba(220, 38, 38, .8); }

.brand-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.7); }
}

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--panel-line);
  border-radius: 11px;
  color: var(--fg);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.icon-btn:hover { background: rgba(34, 211, 238, .12); border-color: rgba(34, 211, 238, .5); transform: translateY(-2px); }
.icon-btn svg { width: 17px; height: 17px; }

/* ============ Playfield ============ */
.playfield {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--panel-line);
  background: #04060f;
  box-shadow: var(--shadow), inset 0 0 90px rgba(37, 99, 235, .1);
  touch-action: none;
}

#game { display: block; width: 100%; height: 100%; cursor: crosshair; }

.lives {
  position: absolute;
  left: 14px; bottom: 12px;
  display: flex; gap: 6px;
  z-index: 3;
  pointer-events: none;
}

.lives svg {
  width: 16px; height: 16px;
  fill: var(--red-glow);
  stroke: var(--red-glow);
  filter: drop-shadow(0 0 8px rgba(255, 84, 112, .9));
  animation: pop .3s ease;
}

@keyframes pop {
  from { transform: scale(.2); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.powerbar {
  position: absolute;
  right: 14px; bottom: 12px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  z-index: 3;
  pointer-events: none;
}

.power {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: rgba(4, 6, 15, .6);
  backdrop-filter: blur(6px);
  animation: slideIn .25s ease;
}
.power svg { width: 12px; height: 12px; }
.power.p-triple { color: var(--violet); }
.power.p-rapid { color: var(--amber); }
.power.p-shield { color: var(--cyan); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: none; }
}

/* ============ Overlays & panels ============ */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 18px;
  background: radial-gradient(900px 500px at 50% 40%, rgba(15, 23, 42, .6), rgba(3, 5, 12, .88));
  backdrop-filter: blur(7px);
  animation: fadeIn .25s ease;
  overflow: auto;
}

.overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: min(620px, 100%);
  padding: 30px 30px 26px;
  text-align: center;
  border-radius: 22px;
  border: 1px solid rgba(148, 190, 255, .18);
  background: linear-gradient(165deg, rgba(23, 34, 64, .86), rgba(8, 12, 26, .9));
  box-shadow: 0 30px 80px -30px #000, inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(16px);
  animation: rise .35s cubic-bezier(.2, .8, .2, 1);
}

.panel.compact { width: min(440px, 100%); padding: 26px 24px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  font-size: 9.5px;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 12px;
}

.panel h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(30px, 6vw, 52px);
  letter-spacing: .04em;
  margin: 0 0 14px;
  color: #eaf2ff;
  text-shadow: 0 0 34px rgba(37, 99, 235, .75);
}
.panel h1 span { color: var(--red); text-shadow: 0 0 34px rgba(220, 38, 38, .9); }

.panel h2 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(22px, 4vw, 32px);
  letter-spacing: .05em;
  margin: 0 0 10px;
}

.lede { color: var(--muted); font-size: 12.5px; line-height: 1.75; margin: 0 0 18px; }

/* ============ Controls list ============ */
.controls {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 8px;
  text-align: left;
}

.controls li {
  display: grid;
  grid-template-columns: 26px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 190, 255, .1);
  background: rgba(255, 255, 255, .025);
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}
.controls li:hover {
  transform: translateY(-2px);
  border-color: rgba(34, 211, 238, .4);
  background: rgba(34, 211, 238, .06);
}

.controls svg { grid-row: 1 / 3; width: 18px; height: 18px; color: var(--cyan); }
.controls b { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #dbe7ff; }
.controls span { font-size: 10.5px; color: var(--muted); line-height: 1.5; }

/* ============ Buttons ============ */
.btn {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 13px 26px;
  border-radius: 12px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: linear-gradient(135deg, var(--red), #ff5470);
  color: #fff;
  box-shadow: 0 12px 30px -12px rgba(220, 38, 38, .95), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -14px rgba(255, 84, 112, 1); }

.btn-ghost {
  background: rgba(255, 255, 255, .04);
  border-color: var(--panel-line);
  color: var(--fg);
}
.btn-ghost:hover { transform: translateY(-2px); background: rgba(37, 99, 235, .18); border-color: rgba(37, 99, 235, .6); }

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

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

.hint { font-size: 10px; color: #6f83a5; margin: 16px 0 0; letter-spacing: .04em; }
.hint b { color: #a9bde0; font-weight: 500; }

/* ============ Results & toast ============ */
.finals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.final {
  padding: 14px 8px;
  border-radius: 14px;
  border: 1px solid rgba(148, 190, 255, .12);
  background: rgba(255, 255, 255, .03);
}

.final span {
  display: block;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(20px, 4vw, 28px);
  font-variant-numeric: tabular-nums;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(34, 211, 238, .55);
}
.final:last-child span { color: var(--green); text-shadow: 0 0 18px rgba(34, 197, 94, .55); }
.final small { font-size: 9px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }

.toast {
  position: absolute;
  top: 16px; left: 50%;
  transform: translate(-50%, -18px);
  z-index: 4;
  padding: 9px 20px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #dff7ff;
  background: rgba(6, 12, 26, .82);
  border: 1px solid rgba(34, 211, 238, .45);
  box-shadow: 0 0 34px -6px rgba(34, 211, 238, .7);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.danger { border-color: rgba(255, 84, 112, .6); color: #ffe0e6; box-shadow: 0 0 34px -6px rgba(255, 84, 112, .8); }

/* ============ Footer ============ */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 9.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #5d7092;
  padding-bottom: 2px;
}
.footer .sep { color: #31405c; }

/* ============ Responsive ============ */
@media (max-width: 760px) {
  body { padding: 8px; }
  .stage { height: calc(100vh - 16px); gap: 8px; }
  .brand { display: none; }
  .hud { padding: 8px 11px; border-radius: 12px; }
  .stat-value { font-size: 16px; }
  .controls { grid-template-columns: 1fr; }
  .controls li:nth-child(n + 3) { display: none; }
  .panel { padding: 24px 18px 22px; border-radius: 18px; }
  .footer span:nth-child(n + 2) { display: none; }
  .btn { padding: 12px 20px; font-size: 11.5px; }
}

@media (max-height: 560px) {
  .panel h1 { font-size: 26px; margin-bottom: 8px; }
  .lede { margin-bottom: 10px; }
  .controls { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ============ power chip timer ============ */
.power .pw-t {
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  opacity: .75;
  min-width: 26px;
  text-align: right;
}
