:root {
  --neon-cyan: #37f2ff;
  --neon-mag: #ff3df0;
  --bg0: #05060f;
  --bg1: #0b1030;
  --ink: #cfe9ff;
  font-family: "Segoe UI", system-ui, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 700px at 50% -10%, #12183f 0%, var(--bg0) 60%);
}

#game {
  display: block;
  image-rendering: pixelated;
  box-shadow: 0 0 60px rgba(55, 242, 255, 0.15), 0 0 120px rgba(255, 61, 240, 0.08);
}

/* ---- CSS post overlays sit over the canvas but under UI ---- */
.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.16) 3px,
    rgba(0, 0, 0, 0.16) 4px
  );
  mix-blend-mode: multiply;
  opacity: 0.6;
}
.vignette {
  background: radial-gradient(120% 120% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.65) 100%);
}

/* ---- HUD ---- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  padding: 14px 18px;
  pointer-events: none;
}
#hud .chip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin-right: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: var(--ink);
  background: rgba(10, 16, 48, 0.55);
  border: 1px solid rgba(55, 242, 255, 0.35);
  border-radius: 999px;
  backdrop-filter: blur(4px);
  text-shadow: 0 0 8px rgba(55, 242, 255, 0.6);
  box-shadow: 0 0 12px rgba(55, 242, 255, 0.15);
}
#hud .chip .ico { filter: drop-shadow(0 0 4px currentColor); }
#hud .chip .sep { opacity: 0.5; }
#hud .lives { border-color: rgba(255, 61, 240, 0.45); text-shadow: 0 0 8px rgba(255,61,240,0.7); }
#hud .kills { border-color: rgba(255, 176, 61, 0.5); text-shadow: 0 0 8px rgba(255,176,61,0.7); }
#hud .btn { cursor: pointer; font-size: 16px; }
#hud .btn.muted { opacity: 0.45; text-decoration: line-through; }

/* ---- Screens ---- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 24px;
  overflow-y: auto;
  background: radial-gradient(80% 80% at 50% 45%, rgba(6, 9, 28, 0.55), rgba(3, 4, 12, 0.9));
  backdrop-filter: blur(2px);
  animation: fade 0.35s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.logo {
  font-size: clamp(34px, 8vw, 78px);
  font-weight: 900;
  letter-spacing: 4px;
  color: #eafcff;
  text-shadow:
    0 0 10px var(--neon-cyan),
    0 0 28px var(--neon-cyan),
    0 0 46px rgba(55, 242, 255, 0.55);
  animation: flicker 4s infinite;
}
.logo.small { font-size: clamp(28px, 6vw, 52px); }
.logo.dead {
  color: #ffe1f6;
  text-shadow:
    0 0 10px var(--neon-mag),
    0 0 28px var(--neon-mag),
    0 0 46px rgba(255, 61, 240, 0.55);
}
.logo .sub {
  display: block;
  font-size: clamp(13px, 2.4vw, 22px);
  letter-spacing: 8px;
  margin-top: 8px;
  color: #ffd9fb;
  text-shadow: 0 0 10px var(--neon-mag), 0 0 26px var(--neon-mag);
}
@keyframes flicker {
  0%, 18%, 22%, 100% { opacity: 1; }
  20% { opacity: 0.72; }
  60% { opacity: 0.95; }
}

.tag { font-size: clamp(13px, 2.6vw, 18px); color: #9fd6ff; letter-spacing: 1px; }
.credit { font-size: 14px; opacity: 0.85; }
.credit a { color: var(--neon-mag); text-decoration: none; text-shadow: 0 0 8px var(--neon-mag); }

.neonBtn {
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 2px;
  color: #eafcff;
  padding: 14px 34px;
  background: rgba(55, 242, 255, 0.08);
  border: 2px solid var(--neon-cyan);
  border-radius: 12px;
  text-shadow: 0 0 8px var(--neon-cyan);
  box-shadow: 0 0 14px rgba(55, 242, 255, 0.35), inset 0 0 14px rgba(55, 242, 255, 0.12);
  transition: transform 0.08s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.neonBtn:hover { transform: translateY(-2px); box-shadow: 0 0 26px rgba(55, 242, 255, 0.6), inset 0 0 20px rgba(55,242,255,0.2); background: rgba(55,242,255,0.16); }
.neonBtn:active { transform: translateY(0); }
.neonBtn.ghost { border-color: var(--neon-mag); text-shadow: 0 0 8px var(--neon-mag); box-shadow: 0 0 14px rgba(255,61,240,0.3); }

.controls { list-style: none; margin-top: 8px; font-size: 14px; line-height: 1.9; color: #a9c9e8; }
.controls b { color: #eafcff; text-shadow: 0 0 6px var(--neon-cyan); }

/* ---- Leaderboard ---- */
.boardWrap {
  width: min(380px, 88vw);
  padding: 14px 16px;
  border: 1px solid rgba(55, 242, 255, 0.25);
  border-radius: 14px;
  background: rgba(8, 12, 34, 0.5);
  box-shadow: 0 0 18px rgba(55, 242, 255, 0.12), inset 0 0 22px rgba(55, 242, 255, 0.05);
}
.board-title {
  font-weight: 800;
  letter-spacing: 3px;
  font-size: 14px;
  color: #eafcff;
  text-shadow: 0 0 10px var(--neon-cyan);
  margin-bottom: 10px;
}
.board { width: 100%; border-collapse: collapse; font-size: 14px; }
.board th {
  font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  color: #8fb8d8; font-weight: 700; padding: 0 8px 6px;
  border-bottom: 1px solid rgba(55, 242, 255, 0.25);
}
.board td { padding: 7px 8px; border-bottom: 1px solid rgba(55, 242, 255, 0.08); }
.board tr:last-child td { border-bottom: none; }
.board th.rank, .board td.rank { text-align: center; width: 30px; }
.board td.rank { color: var(--neon-cyan); font-weight: 800; text-shadow: 0 0 8px var(--neon-cyan); }
.board td.nm { text-align: left; color: #eafcff; font-weight: 700; overflow: hidden; text-overflow: ellipsis; max-width: 150px; white-space: nowrap; }
.board th.tm, .board td.tm { text-align: right; color: #bfe9ff; font-variant-numeric: tabular-nums; }
.board th.kl, .board td.kl { text-align: right; width: 52px; color: #ffb0e8; }
.board th.dt, .board td.dt { text-align: right; width: 56px; color: #9fd0ff; }
.board tr.me td { background: rgba(255, 61, 240, 0.14); }
.board tr.me td.rank { color: var(--neon-mag); text-shadow: 0 0 8px var(--neon-mag); }
.board-msg { font-size: 13px; color: #9fd6ff; opacity: 0.85; margin-top: 8px; }
.board-msg.err { color: #ff9ab0; }

.saveRow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.nameInput {
  font: inherit; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  color: #eafcff; background: rgba(55, 242, 255, 0.06);
  border: 2px solid var(--neon-cyan); border-radius: 10px;
  padding: 12px 16px; width: 210px; text-align: center;
  text-shadow: 0 0 6px var(--neon-cyan); outline: none;
  transition: box-shadow 0.2s ease;
}
.nameInput::placeholder { color: #6fa8c8; letter-spacing: 2px; }
.nameInput:focus { box-shadow: 0 0 16px rgba(55, 242, 255, 0.5); }
.saveRow .neonBtn { padding: 12px 24px; font-size: 16px; }

.hidden { display: none !important; }

/* ---- Achievement toasts (Steam-style) ---- */
#achievements {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none; /* never blocks clicks on the game/screens */
}
.ach {
  --accent: 55, 242, 255;
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(360px, 92vw);
  padding: 12px 16px 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(var(--accent), 0.55);
  background: linear-gradient(180deg, rgba(10, 16, 44, 0.96), rgba(6, 9, 26, 0.96));
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.55),
    0 0 26px rgba(var(--accent), 0.3),
    inset 0 0 20px rgba(var(--accent), 0.06);
  /* start below the corner, hidden; .show slides it up into view */
  transform: translateY(150%);
  opacity: 0;
  transition: transform 0.56s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.56s ease;
}
.ach.show { transform: none; opacity: 1; }
.ach-icon {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  font-size: 28px;
  line-height: 1;
  border-radius: 12px;
  background: radial-gradient(circle at 50% 40%, rgba(var(--accent), 0.32), rgba(0, 0, 0, 0.35));
  border: 1px solid rgba(var(--accent), 0.6);
  box-shadow: inset 0 0 14px rgba(var(--accent), 0.25), 0 0 16px rgba(var(--accent), 0.35);
  filter: drop-shadow(0 0 5px rgba(var(--accent), 0.6));
}
.ach-body { min-width: 0; }
.ach-label {
  font-size: 10px;
  letter-spacing: 2.5px;
  font-weight: 800;
  color: rgb(var(--accent));
  text-shadow: 0 0 10px rgba(var(--accent), 0.9);
  margin-bottom: 3px;
}
.ach-title {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1.15;
  color: #eafcff;
  text-shadow: 0 0 10px rgba(var(--accent), 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ach-desc {
  font-size: 12.5px;
  color: #a9c9e8;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (prefers-reduced-motion: reduce) {
  .ach { transition: opacity 0.3s ease; transform: none; }
}
