:root {
  --bg-0: #0b0e1a;
  --bg-1: #131830;
  --accent: #ff7a18;
  --accent-2: #ffc94d;
  --cyan: #3ee6ff;
  --text: #e8ecff;
  --text-dim: #8b93b8;
  --panel: rgba(16, 20, 42, 0.88);
  --radius: 18px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  font-family: "Rajdhani", sans-serif;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: -50%;
  background:
    radial-gradient(ellipse 60% 50% at 20% 30%, rgba(62, 90, 255, 0.14), transparent 60%),
    radial-gradient(ellipse 50% 60% at 80% 70%, rgba(255, 122, 24, 0.10), transparent 60%),
    radial-gradient(ellipse 40% 40% at 60% 20%, rgba(62, 230, 255, 0.07), transparent 60%);
  animation: drift 26s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes drift {
  from { transform: translate(-2%, -2%) scale(1); }
  to   { transform: translate(2%, 3%) scale(1.06); }
}

#stage {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}

/* ---------- HUD ---------- */

#hud {
  width: min(92vw, 860px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--panel);
  border: 1px solid rgba(125, 140, 220, 0.18);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
}

#hud-title {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 4px;
  background: linear-gradient(180deg, #fff, #ffc94d 55%, #ff7a18);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 12px rgba(255, 150, 50, 0.35));
}

.hud-group { display: flex; gap: 14px; align-items: center; }

.hud-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 19px;
}

.hud-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
  font-weight: 600;
}

.hud-value {
  min-width: 20px;
  font-family: "Orbitron", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 10px rgba(120, 160, 255, 0.5);
}

.hud-value.wide { min-width: 52px; }

.hud-value.bump { animation: bump 0.3s ease; }
@keyframes bump {
  30% { transform: scale(1.45); color: var(--accent-2); }
}

.hud-icon { width: 18px; height: 18px; display: inline-block; border-radius: 50%; }
.hud-icon.heart {
  background: radial-gradient(circle at 35% 30%, #ff8d9d, #e3284b 70%);
  clip-path: path("M9 17 C2 11 0 7 2.5 4 C5 1.5 8 3 9 5.5 C10 3 13 1.5 15.5 4 C18 7 16 11 9 17 Z");
  border-radius: 0;
}
.hud-icon.bomb { background: radial-gradient(circle at 35% 30%, #6a7390, #181c2c 75%); box-shadow: 0 0 8px rgba(0,0,0,.6), inset 0 0 4px rgba(255,255,255,.18); }
.hud-icon.fire { background: radial-gradient(circle at 50% 65%, #ffd84d, #ff7a18 55%, #d3270f 90%); box-shadow: 0 0 10px rgba(255,130,30,.7); }
.hud-icon.speed { background: radial-gradient(circle at 35% 30%, #9af2ff, #18a6c8 75%); box-shadow: 0 0 10px rgba(62,230,255,.6); }
.hud-icon.enemy { background: radial-gradient(circle at 35% 30%, #d98cff, #7a2bd8 75%); box-shadow: 0 0 10px rgba(160,80,255,.55); }
.hud-icon.gold { background: radial-gradient(circle at 35% 30%, #ffe9a0, #e8a818 60%, #9a6606 95%); box-shadow: 0 0 10px rgba(255,200,60,.55), inset 0 0 3px rgba(120,70,0,.8); }

/* ---------- Board ---------- */

#board {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(125, 140, 220, 0.16),
    0 0 60px rgba(70, 90, 255, 0.08);
}

#game { display: block; background: var(--bg-1); }

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 100% 100% at 50% 50%, transparent 58%, rgba(5, 7, 16, 0.55) 100%);
  mix-blend-mode: multiply;
}

#foot {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-dim);
  opacity: 0.8;
}

/* ---------- Overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 22, 0.72);
  backdrop-filter: blur(10px) saturate(1.2);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s;
  z-index: 10;
}

.overlay.visible { opacity: 1; visibility: visible; }

.panel {
  text-align: center;
  padding: 42px 52px;
  border-radius: 24px;
  background: linear-gradient(170deg, rgba(30, 36, 70, 0.85), rgba(14, 17, 36, 0.92));
  border: 1px solid rgba(140, 156, 240, 0.22);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(10px) scale(0.97);
  transition: transform 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
  max-width: 480px;
}

.overlay.visible .panel { transform: translateY(0) scale(1); }

.logo {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 46px;
  letter-spacing: 6px;
  line-height: 1.05;
  background: linear-gradient(180deg, #ffffff, #ffd34d 50%, #ff6a18 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 24px rgba(255, 140, 40, 0.45));
}

.logo span { display: block; font-size: 26px; letter-spacing: 14px; color: transparent; }
.logo.small { font-size: 38px; letter-spacing: 8px; }

.tagline {
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1.5px;
}

.controls {
  margin: 26px 0 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.ctl { display: flex; align-items: center; gap: 12px; color: var(--text-dim); font-weight: 600; font-size: 14px; letter-spacing: 0.5px; }

.keys { display: flex; gap: 4px; }

kbd {
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  background: linear-gradient(180deg, #2b3258, #1a1f3c);
  border: 1px solid rgba(150, 165, 245, 0.3);
  border-bottom-width: 3px;
  border-radius: 6px;
  padding: 4px 8px;
  min-width: 26px;
  text-align: center;
}

kbd.space { padding: 4px 26px; }

.btn {
  margin-top: 24px;
  font-family: "Orbitron", sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #1a0e02;
  background: linear-gradient(180deg, #ffd34d, #ff7a18);
  border: none;
  border-radius: 12px;
  padding: 15px 40px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(255, 122, 24, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 32px rgba(255, 122, 24, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.5); filter: brightness(1.08); }
.btn:active { transform: translateY(1px) scale(0.98); }

.hint { margin-top: 18px; font-size: 13px; color: var(--text-dim); opacity: 0.75; letter-spacing: 0.5px; }

.end-stats {
  margin-top: 22px;
  display: flex;
  gap: 28px;
  justify-content: center;
}

.end-stat .v {
  font-family: "Orbitron", sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--accent-2);
  text-shadow: 0 0 16px rgba(255, 200, 80, 0.5);
}

.end-stat .k {
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: 2.5px;
  color: var(--text-dim);
  font-weight: 600;
}

/* ---------- Armory (upgrade shop) ---------- */

.panel.wide { max-width: 640px; }

.btn.ghost {
  display: block;
  margin: 12px auto 0;
  color: var(--text);
  background: linear-gradient(180deg, #2b3258, #1a1f3c);
  border: 1px solid rgba(150, 165, 245, 0.35);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.btn.ghost:hover { box-shadow: 0 8px 26px rgba(80, 110, 255, 0.3); }

.reset-link {
  margin-top: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: "Rajdhani", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-decoration: underline;
  opacity: 0.55;
  cursor: pointer;
}

.reset-link:hover { opacity: 1; color: #ff8d9d; }

.gold-banner {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 16px;
  padding: 8px 22px;
  border-radius: 999px;
  background: rgba(255, 200, 60, 0.08);
  border: 1px solid rgba(255, 200, 60, 0.3);
}

.gold-banner #shop-gold {
  font-family: "Orbitron", sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #ffd34d;
  text-shadow: 0 0 14px rgba(255, 200, 60, 0.5);
}

.gold-label { font-size: 11px; letter-spacing: 2.5px; color: var(--text-dim); font-weight: 600; }

.shop-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.shop-card {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 13px 15px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(140, 156, 240, 0.18);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.shop-card:hover { border-color: rgba(255, 200, 80, 0.4); background: rgba(255, 255, 255, 0.06); }
.shop-card.maxed { opacity: 0.55; }
.shop-card .hud-icon { width: 26px; height: 26px; flex-shrink: 0; }

.shop-info { flex: 1; min-width: 0; }

.shop-name {
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text);
}

.shop-desc { font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-top: 1px; }

.pips { display: flex; gap: 4px; margin-top: 6px; }

.pip {
  width: 16px; height: 5px;
  border-radius: 3px;
  background: rgba(140, 156, 240, 0.2);
}

.pip.on {
  background: linear-gradient(90deg, #ffd34d, #ff8c2e);
  box-shadow: 0 0 8px rgba(255, 180, 60, 0.6);
}

.shop-buy {
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #1a0e02;
  background: linear-gradient(180deg, #ffd34d, #ffa01e);
  border: none;
  border-radius: 9px;
  padding: 9px 13px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 12px rgba(255, 160, 30, 0.3);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.shop-buy:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.1); }
.shop-buy:active:not(:disabled) { transform: translateY(1px); }

.shop-buy:disabled {
  background: rgba(140, 156, 240, 0.15);
  color: var(--text-dim);
  cursor: not-allowed;
  box-shadow: none;
}

/* ---------- Touch controls (game.js adds .touch to <body> on coarse-pointer
   devices; desktop never sees any of this) ---------- */

#touch-controls, .touch-only { display: none; }

.touch .touch-only { display: flex; }
.touch .ctl:not(.touch-only), .touch #foot { display: none; }

.touch #touch-controls {
  position: fixed;
  left: 0; right: 0;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 30;
  pointer-events: none;
}

.touch.overlay-open #touch-controls { display: none; }

#touch-controls > * { pointer-events: auto; }

#dpad {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 30%;
  touch-action: none;
  background:
    linear-gradient(rgba(140, 156, 240, 0.1), rgba(140, 156, 240, 0.1)) center / 17% 76% no-repeat,
    linear-gradient(rgba(140, 156, 240, 0.1), rgba(140, 156, 240, 0.1)) center / 76% 17% no-repeat,
    radial-gradient(circle at 50% 35%, rgba(44, 52, 96, 0.55), rgba(14, 18, 38, 0.72));
  border: 1.5px solid rgba(140, 156, 240, 0.3);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
}

#dpad-stick {
  position: absolute;
  left: 50%; top: 50%;
  width: 56px; height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5a679f, #262c4e 75%);
  border: 1px solid rgba(160, 175, 250, 0.35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: transform 0.05s linear;
  pointer-events: none;
}

.tc-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

#btn-bomb-touch {
  width: 98px; height: 98px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 150, 60, 0.5);
  background: radial-gradient(circle at 35% 28%, #6a7390, #1c2134 62%, #11131f);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5), 0 0 26px rgba(255, 122, 24, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  touch-action: none;
  cursor: pointer;
}

#btn-bomb-touch span {
  font-family: "Orbitron", sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #ffd34d, #ff7a18);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 8px rgba(255, 140, 40, 0.5));
}

#btn-bomb-touch:active {
  transform: scale(0.92);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 40px rgba(255, 122, 24, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

#btn-pause-touch {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(140, 156, 240, 0.35);
  background: rgba(20, 25, 50, 0.7);
  color: var(--text-dim);
  font-size: 12px;
  touch-action: none;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

#btn-pause-touch:active { transform: scale(0.9); color: #fff; }

/* Compact layout on small screens. */
@media (max-width: 700px) {
  #stage { padding: 8px; gap: 8px; justify-content: flex-start; padding-top: 10px; }
  #hud { width: calc(100vw - 16px); padding: 7px 10px; border-radius: 13px; }
  #hud-title { display: none; }
  .hud-group { gap: 9px; }
  .hud-item { gap: 5px; }
  .hud-item[title="Score"] { display: none; }
  .hud-icon { width: 15px; height: 15px; }
  .hud-value { font-size: 13px; }
  .hud-value.wide { min-width: 38px; }
  .hud-label { font-size: 9px; letter-spacing: 1.5px; }

  .panel { padding: 26px 20px; max-width: calc(100vw - 28px); border-radius: 18px; }
  .logo { font-size: 33px; letter-spacing: 4px; }
  .logo span { font-size: 19px; letter-spacing: 9px; }
  .logo.small { font-size: 26px; letter-spacing: 5px; }
  .tagline { font-size: 14px; }
  .btn { padding: 13px 28px; font-size: 13px; }
  .shop-grid { grid-template-columns: 1fr; gap: 9px; }
  .shop-card { padding: 10px 12px; }
  .end-stats { gap: 18px; }
}

/* ---------- Nickname, shield, rankings ---------- */

.hud-icon.shield {
  background: radial-gradient(circle at 35% 30%, #b8f6ff, #1893c0 60%, #0a4a66 95%);
  box-shadow: 0 0 10px rgba(80, 220, 255, 0.6);
  clip-path: polygon(50% 0%, 100% 22%, 100% 60%, 50% 100%, 0% 60%, 0% 22%);
  border-radius: 0;
}

.nick-row {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.nick-row label {
  font-size: 11px;
  letter-spacing: 2.5px;
  font-weight: 600;
  color: var(--text-dim);
}

#nick-input {
  font-family: "Orbitron", sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
  text-align: center;
  text-transform: uppercase;
  background: rgba(10, 14, 32, 0.7);
  border: 1px solid rgba(150, 165, 245, 0.35);
  border-radius: 10px;
  padding: 10px 14px;
  width: 210px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#nick-input:focus {
  border-color: rgba(255, 200, 80, 0.7);
  box-shadow: 0 0 16px rgba(255, 170, 50, 0.25);
}

#nick-input::placeholder { color: rgba(139, 147, 184, 0.55); }

#nick-input.shake { animation: shake 0.45s ease; border-color: #ff5a6e; }

@keyframes shake {
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.rank-note {
  margin-top: 10px;
  min-height: 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ffd34d;
  text-shadow: 0 0 12px rgba(255, 200, 80, 0.35);
}

.board-tabs {
  margin-top: 18px;
  display: flex;
  gap: 7px;
  justify-content: center;
  flex-wrap: wrap;
}

.board-tab {
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(140, 156, 240, 0.22);
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.board-tab:hover { color: var(--text); border-color: rgba(140, 156, 240, 0.45); }

.board-tab.active {
  color: #1a0e02;
  background: linear-gradient(180deg, #ffd34d, #ffa01e);
  border-color: transparent;
  box-shadow: 0 3px 14px rgba(255, 160, 30, 0.35);
}

.board-list {
  margin-top: 14px;
  min-height: 200px;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
}

.board-status {
  padding: 40px 0;
  text-align: center;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 1px;
}

.board-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(140, 156, 240, 0.12);
}

.board-row.me {
  background: rgba(255, 200, 60, 0.1);
  border-color: rgba(255, 200, 60, 0.4);
}

.br-rank {
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 34px;
}

.board-row:nth-child(1) .br-rank { color: #ffd34d; }
.board-row:nth-child(2) .br-rank { color: #c9d4f5; }
.board-row:nth-child(3) .br-rank { color: #e0926a; }

.br-name {
  flex: 1;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 1px;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.br-time {
  font-family: "Orbitron", sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #7de8ff;
  text-shadow: 0 0 10px rgba(80, 220, 255, 0.35);
}

/* ---------- Locked upgrades + roomy shop ---------- */

.shop-grid { max-height: 46vh; overflow-y: auto; padding-right: 4px; }

.shop-card.locked { opacity: 0.55; }
.shop-card.locked .shop-name { color: var(--text-dim); }
.shop-card.locked .shop-desc { color: #c98a3e; }
.shop-card.locked:hover { border-color: rgba(140, 156, 240, 0.18); background: rgba(255, 255, 255, 0.04); }
