:root {
  --bg-0: #0b0716;
  --bg-1: #191233;
  --bubble: #8fd8ff;
  --green: #6fe08a;
  --pink: #ff9ad5;
  --yellow: #ffd23d;
  --orange: #ff9d2e;
  --red: #ff5d75;
  --text: #efe8ff;
  --dim: #9a8fc4;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: radial-gradient(1200px 700px at 50% -10%, #2c2058 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

#stage {
  position: relative;
  width: min(100vw - 20px, calc((100vh - 70px) * 3 / 2), 1080px);
  aspect-ratio: 3 / 2;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(143, 216, 255, 0.28),
    0 0 40px rgba(143, 216, 255, 0.14),
    0 24px 80px rgba(0, 0, 0, 0.6);
  background: #141031;
}

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

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 5;
}

.hud-col { display: flex; flex-direction: column; gap: 6px; }
.hud-col.hud-right { align-items: flex-end; }
.hud-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; }

.hud-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(10, 6, 28, 0.55);
  border: 1px solid rgba(143, 216, 255, 0.22);
  border-radius: 10px;
  padding: 4px 12px;
  min-width: 84px;
  backdrop-filter: blur(2px);
}

.hud-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--dim);
}

.hud-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.hud-level-val { color: var(--yellow); }
.hud-lives { font-size: 14px; letter-spacing: 2px; }
.hud-power-val { color: var(--pink); font-size: 13px; min-height: 15px; }

#hud-phase {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--bubble);
  text-shadow: 0 0 12px rgba(143, 216, 255, 0.6);
}

#hud-phase.hurry {
  color: var(--red);
  text-shadow: 0 0 14px rgba(255, 93, 117, 0.8);
  animation: blink 0.5s steps(2) infinite;
}

@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- top bar ---------- */
#topbar {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  z-index: 8;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(143, 216, 255, 0.3);
  background: rgba(10, 6, 28, 0.6);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  display: grid;
  place-items: center;
  text-decoration: none;
  line-height: 1;
}
.icon-btn:hover { background: rgba(143, 216, 255, 0.18); }

/* ---------- overlays ---------- */
#overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 20px;
  background: rgba(9, 5, 24, 0.82);
  border: 1px solid rgba(143, 216, 255, 0.25);
  border-radius: 16px;
  box-shadow: 0 0 60px rgba(143, 216, 255, 0.12);
  max-width: 88%;
  pointer-events: auto;
}

.logo {
  font-size: clamp(28px, 5vw, 46px);
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--bubble);
  text-shadow: 0 0 24px rgba(143, 216, 255, 0.55);
}
.logo span { color: var(--pink); text-shadow: 0 0 24px rgba(255, 154, 213, 0.55); }

.tagline { color: var(--dim); font-size: 14px; }
.big { font-size: clamp(24px, 4vw, 38px); font-weight: 900; letter-spacing: 3px; }
.over-title { color: var(--red); text-shadow: 0 0 20px rgba(255, 93, 117, 0.6); }
.win-title { color: var(--yellow); text-shadow: 0 0 20px rgba(255, 210, 61, 0.6); }

.btn {
  font: inherit;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 10px 26px;
  border-radius: 10px;
  border: 1px solid rgba(143, 216, 255, 0.35);
  background: rgba(143, 216, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.06s ease, background 0.12s ease;
}
.btn:hover { background: rgba(143, 216, 255, 0.2); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, #7cd4ff, #3d9be0);
  border-color: #b8e6ff;
  color: #06121f;
  font-size: 16px;
}
.btn-primary:hover { background: linear-gradient(180deg, #98e0ff, #55aef0); }

.btn-row { display: flex; gap: 10px; }

.final-score { font-size: 18px; color: var(--text); }
.final-score span { color: var(--yellow); font-weight: 800; }
.win-bonus-line { font-size: 13px; color: var(--dim); }
.win-bonus-line span { color: var(--green); font-weight: 700; }
.new-record {
  color: var(--yellow);
  font-weight: 800;
  letter-spacing: 2px;
  animation: blink 0.7s steps(2) infinite;
}

.entry-label { font-size: 13px; color: var(--dim); }
#hs-form, #win-form { display: flex; gap: 8px; }
#hs-form input, #win-form input {
  font: inherit;
  font-weight: 800;
  letter-spacing: 6px;
  width: 90px;
  text-align: center;
  text-transform: uppercase;
  padding: 9px 6px;
  border-radius: 8px;
  border: 1px solid rgba(143, 216, 255, 0.4);
  background: rgba(0, 0, 0, 0.4);
  color: var(--yellow);
  outline: none;
}

.hint { font-size: 12px; color: var(--dim); max-width: 480px; line-height: 1.5; }
.back-link { color: var(--dim); font-size: 12px; text-decoration: none; }
.back-link:hover { color: var(--bubble); }

.hud-power-box { min-width: 110px; }

#footer {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 1px;
}

.hidden { display: none !important; }

/* ---------- high score list ---------- */
.hs-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  min-width: 240px;
}

.hs-title {
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--dim);
}

.hs-list {
  list-style: none;
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.hs-list li { padding: 2px 0; }
.hs-list li b { color: var(--pink); }
