:root {
  --bg-0: #03030c;
  --bg-1: #0b0620;
  --cyan: #4dd8ff;
  --purple: #9d4dff;
  --amber: #ff9d2e;
  --yellow: #ffe14d;
  --green: #3dff8f;
  --red: #ff4d6d;
  --text: #eaf6ff;
  --dim: #8b93b8;
}

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

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

body {
  background: radial-gradient(1200px 700px at 50% -10%, #17103a 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 / 4), 520px);
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(157, 77, 255, 0.25),
    0 0 40px rgba(157, 77, 255, 0.15),
    0 24px 80px rgba(0, 0, 0, 0.6);
  background: #070516;
}

#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; }

/* keep HUD clear of the 3-button topbar */
#hud .hud-col.hud-right { margin-right: 124px; }
.hud-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; }

.hud-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
  padding: 3px 10px;
  border-radius: 8px;
  background: rgba(5, 6, 20, 0.55);
  border: 1px solid rgba(157, 77, 255, 0.2);
}

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

.hud-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(77, 216, 255, 0.7);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.hud-lives-val { color: var(--amber); text-shadow: 0 0 10px rgba(255, 157, 46, 0.7); }

.hud-weapon {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--yellow);
  text-shadow: 0 0 8px rgba(255, 225, 77, 0.6);
  padding: 6px 0;
}

.hud-combo {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--yellow);
  text-shadow: 0 0 12px rgba(255, 225, 77, 0.9);
  animation: pulse 0.5s ease-in-out infinite alternate;
}

/* ---------- Boss bar ---------- */
#boss-bar {
  position: absolute;
  top: 64px;
  left: 24px;
  right: 24px;
  z-index: 5;
  pointer-events: none;
}

.boss-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--red);
  text-shadow: 0 0 8px rgba(255, 77, 109, 0.8);
  display: block;
  margin-bottom: 3px;
}

.boss-track {
  height: 7px;
  border-radius: 4px;
  background: rgba(5, 6, 20, 0.7);
  border: 1px solid rgba(255, 77, 109, 0.4);
  overflow: hidden;
}

.boss-fill {
  height: 100%;
  width: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #ff2d55, #ff7a9d);
  box-shadow: 0 0 10px rgba(255, 45, 85, 0.8);
  transition: width 0.15s ease;
}

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

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid rgba(157, 77, 255, 0.3);
  background: rgba(5, 6, 20, 0.6);
  color: var(--cyan);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: rgba(157, 77, 255, 0.2);
  box-shadow: 0 0 14px rgba(157, 77, 255, 0.4);
}

.icon-btn.muted { color: var(--dim); text-decoration: line-through; }

.back-link {
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 1px;
  text-decoration: none;
  cursor: pointer;
}

.back-link:hover { color: var(--text); }

/* ---------- Bomb button ---------- */
.bomb-btn {
  position: absolute;
  bottom: 14px;
  right: 14px;
  z-index: 6;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--yellow);
  background: rgba(10, 8, 24, 0.75);
  border: 1px solid rgba(255, 225, 77, 0.45);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-shadow: 0 0 8px rgba(255, 225, 77, 0.5);
}

.bomb-btn:hover {
  border-color: var(--yellow);
  box-shadow: 0 0 18px rgba(255, 225, 77, 0.4);
  transform: translateY(-1px);
}

/* ---------- Overlays ---------- */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(4, 5, 15, 0.72);
  backdrop-filter: blur(4px);
}

#overlay.hidden { display: none; }

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  max-width: 380px;
}

.screen.hidden { display: none; }

.logo {
  font-size: 54px;
  font-weight: 900;
  letter-spacing: 8px;
  line-height: 0.95;
  color: var(--cyan);
  text-shadow:
    0 0 8px rgba(77, 216, 255, 0.9),
    0 0 30px rgba(77, 216, 255, 0.5);
}

.logo span {
  display: block;
  color: var(--purple);
  text-shadow:
    0 0 8px rgba(157, 77, 255, 0.9),
    0 0 30px rgba(157, 77, 255, 0.5);
}

.tagline { color: var(--dim); font-size: 14px; letter-spacing: 1px; }

.big {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 4px;
}

.over-title {
  color: var(--red);
  text-shadow: 0 0 12px rgba(255, 77, 109, 0.8);
}

.win-title {
  color: var(--green);
  text-shadow: 0 0 12px rgba(61, 255, 143, 0.8);
}

.level-title {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--amber);
  text-shadow: 0 0 14px rgba(255, 157, 46, 0.7);
}

.level-name {
  font-size: 18px;
  letter-spacing: 3px;
  color: var(--text);
  text-transform: uppercase;
}

.final-score { font-size: 18px; color: var(--dim); }
.final-score span { color: var(--cyan); font-weight: 700; font-size: 22px; }

.new-record {
  color: var(--yellow);
  font-weight: 700;
  letter-spacing: 2px;
  animation: pulse 0.8s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.6; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1.03); }
}

/* ---------- Buttons ---------- */
.btn {
  padding: 12px 34px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
  background: rgba(10, 12, 30, 0.8);
  border: 1px solid rgba(157, 77, 255, 0.4);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:hover {
  border-color: var(--purple);
  box-shadow: 0 0 18px rgba(157, 77, 255, 0.4);
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(77, 216, 255, 0.2), rgba(255, 157, 46, 0.18));
  border-color: var(--cyan);
  color: #fff;
  box-shadow: 0 0 18px rgba(77, 216, 255, 0.25);
}

.btn-primary:hover { box-shadow: 0 0 28px rgba(77, 216, 255, 0.5); }

.btn-row { display: flex; gap: 12px; margin-top: 4px; }

/* ---------- Highscores ---------- */
.hs-wrap { width: 100%; max-width: 280px; }

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

.hs-list {
  list-style: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hs-list li {
  display: flex;
  justify-content: space-between;
  padding: 5px 12px;
  font-size: 14px;
  border-radius: 6px;
  background: rgba(10, 12, 30, 0.5);
  border: 1px solid rgba(157, 77, 255, 0.1);
  font-variant-numeric: tabular-nums;
}

.hs-list li .pos { color: var(--dim); margin-right: 10px; }
.hs-list li .ini { color: var(--amber); font-weight: 700; letter-spacing: 2px; }
.hs-list li .pts { color: var(--cyan); font-weight: 700; }
.hs-list li.empty { justify-content: center; color: var(--dim); }

/* ---------- Initials entry ---------- */
#hs-form { display: flex; gap: 8px; }

#hs-input, #win-input {
  width: 84px;
  padding: 10px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 8px;
  text-align: center;
  text-transform: uppercase;
  color: var(--yellow);
  background: rgba(5, 6, 20, 0.8);
  border: 1px solid rgba(255, 225, 77, 0.4);
  border-radius: 10px;
  outline: none;
}

#hs-input:focus, #win-input:focus { box-shadow: 0 0 16px rgba(255, 225, 77, 0.35); }

.entry-label { color: var(--dim); font-size: 13px; letter-spacing: 1px; }

/* ---------- Misc ---------- */
.hint { color: var(--dim); font-size: 12px; letter-spacing: 1px; }

#footer {
  color: #3a4066;
  font-size: 11px;
  letter-spacing: 1px;
  text-align: center;
}

.hidden { display: none !important; }

@media (max-width: 560px) {
  .logo { font-size: 40px; }
  .big { font-size: 28px; }
  .level-title { font-size: 32px; }
  .hud-value { font-size: 15px; }
  #stage { width: min(100vw, calc((100vh - 60px) * 3 / 4)); border-radius: 0; }
}
