:root {
  --cyan: #22e3ff;
  --magenta: #ff2ea6;
  --lime: #b6ff3c;
  --gold: #ffd23c;
  --bg: #05060a;
  --panel: rgba(12, 16, 28, 0.82);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Rajdhani', 'Segoe UI', sans-serif;
  color: #eaf6ff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#canvas {
  position: absolute;
  inset: 0;
  display: block;
  cursor: crosshair;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 16px clamp(12px, 4vw, 40px);
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat.center { align-items: center; }
.stat.right { align-items: flex-end; }

.stat-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  letter-spacing: 3px;
  color: rgba(180, 210, 235, 0.6);
}

.stat-value {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: clamp(20px, 5vw, 30px);
  line-height: 1;
  text-shadow: 0 0 12px var(--cyan);
}

.bars {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-wrap {
  position: relative;
  height: 16px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  transform-origin: left;
  transition: width 0.18s ease-out;
  border-radius: 10px;
}

.bar-wrap.hp .bar-fill {
  background: linear-gradient(90deg, #ff2e5e, #ff8b3c);
  box-shadow: 0 0 14px rgba(255, 60, 90, 0.7);
}

.bar-wrap.xp { height: 10px; }
.bar-wrap.xp .bar-fill {
  background: linear-gradient(90deg, var(--cyan), var(--lime));
  box-shadow: 0 0 14px rgba(34, 227, 255, 0.7);
}

.bar-text {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'Orbitron', sans-serif;
  font-size: 9px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.combo {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(18px, 6vw, 34px);
  color: var(--gold);
  text-shadow: 0 0 18px var(--gold);
  opacity: 0;
  transition: opacity 0.2s;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(5, 6, 10, 0.72), rgba(5, 6, 10, 0.94));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 10;
  animation: fade 0.35s ease;
}

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

.panel {
  text-align: center;
  padding: clamp(24px, 5vw, 44px);
  max-width: 92vw;
}

.title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(38px, 12vw, 82px);
  line-height: 0.92;
  letter-spacing: 2px;
  color: var(--cyan);
  text-shadow: 0 0 24px rgba(34, 227, 255, 0.75), 0 0 60px rgba(34, 227, 255, 0.35);
}
.title span {
  display: block;
  color: var(--magenta);
  text-shadow: 0 0 24px rgba(255, 46, 166, 0.75), 0 0 60px rgba(255, 46, 166, 0.35);
}

.subtitle {
  font-family: 'Rajdhani', sans-serif;
  letter-spacing: 8px;
  font-size: clamp(12px, 3.5vw, 16px);
  color: rgba(200, 225, 245, 0.7);
  margin: 14px 0 22px;
}

.desc {
  font-size: clamp(14px, 4vw, 18px);
  line-height: 1.7;
  color: rgba(210, 230, 245, 0.86);
  margin-bottom: 30px;
}

.btn {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: clamp(18px, 5vw, 24px);
  letter-spacing: 3px;
  color: #05060a;
  background: linear-gradient(120deg, var(--cyan), var(--lime));
  border: none;
  border-radius: 14px;
  padding: 16px 44px;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(34, 227, 255, 0.55);
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.btn:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 0 40px rgba(34, 227, 255, 0.8); }
.btn:active { transform: scale(0.97); }

/* ---------- Difficulty selector ---------- */
.difficulty { margin-bottom: 28px; }
.diff-label {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  letter-spacing: 4px;
  color: rgba(180, 210, 235, 0.6);
  margin-bottom: 12px;
}
.diff-btns { display: flex; gap: 10px; justify-content: center; }
.diff-btn {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: clamp(12px, 3.4vw, 15px);
  letter-spacing: 2px;
  color: rgba(210, 230, 245, 0.7);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 12px clamp(14px, 4vw, 26px);
  cursor: pointer;
  transition: all 0.15s ease;
}
.diff-btn:hover { border-color: rgba(34, 227, 255, 0.6); color: #eaf6ff; }
.diff-btn.active {
  color: #05060a;
  background: linear-gradient(120deg, var(--cyan), var(--magenta));
  border-color: transparent;
  box-shadow: 0 0 20px rgba(34, 227, 255, 0.5);
}

/* ---------- Mute button ---------- */
#mute-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(12, 16, 28, 0.7);
  color: #eaf6ff;
  font-size: 20px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: transform 0.12s ease, border-color 0.2s;
}
#mute-btn:hover { transform: scale(1.08); border-color: var(--cyan); }
#mute-btn.off { opacity: 0.55; }

.controls {
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: rgba(190, 215, 235, 0.6);
}
.controls b { color: var(--lime); letter-spacing: 1px; }

/* ---------- Level up ---------- */
.levelup-panel { max-width: 720px; }
.lv-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(28px, 8vw, 48px);
  color: var(--lime);
  text-shadow: 0 0 24px rgba(182, 255, 60, 0.7);
}
.lv-sub { color: rgba(210, 230, 245, 0.75); margin: 8px 0 26px; letter-spacing: 2px; }

.cards { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

.card {
  width: 180px;
  padding: 22px 16px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid rgba(34, 227, 255, 0.35);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.2s, box-shadow 0.2s;
}
.card:hover {
  transform: translateY(-6px);
  border-color: var(--cyan);
  box-shadow: 0 0 30px rgba(34, 227, 255, 0.4);
}
.card-icon { font-size: 40px; margin-bottom: 12px; }
.card-name {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--cyan);
  margin-bottom: 8px;
}
.card-desc { font-size: 14px; color: rgba(215, 232, 245, 0.8); line-height: 1.5; }

@media (max-width: 420px) {
  .card { width: 44vw; padding: 16px 10px; }
  .card-icon { font-size: 32px; }
}

/* ---------- Ghost button ---------- */
.btn.ghost {
  background: transparent;
  color: var(--cyan);
  border: 1px solid rgba(34, 227, 255, 0.5);
  box-shadow: none;
  margin-top: 12px;
  font-size: clamp(14px, 4vw, 18px);
  padding: 12px 30px;
}
.btn.ghost:hover { background: rgba(34, 227, 255, 0.1); box-shadow: 0 0 20px rgba(34, 227, 255, 0.3); }
.btn.small { font-size: 16px; padding: 12px 24px; }

/* ---------- Name entry ---------- */
.name-entry {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 6px 0 6px;
}
#name-input {
  font-family: 'Orbitron', sans-serif;
  font-size: 16px;
  letter-spacing: 2px;
  text-align: center;
  color: #eaf6ff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(34, 227, 255, 0.4);
  border-radius: 12px;
  padding: 12px 14px;
  width: 190px;
  outline: none;
}
#name-input:focus { border-color: var(--cyan); box-shadow: 0 0 16px rgba(34, 227, 255, 0.35); }
#name-input::placeholder { color: rgba(180, 210, 235, 0.45); letter-spacing: 1px; }

.submit-msg {
  min-height: 20px;
  font-size: 14px;
  letter-spacing: 1px;
  color: var(--lime);
  margin-bottom: 8px;
}

/* ---------- Leaderboard ---------- */
.leaderboard {
  width: min(360px, 84vw);
  margin: 0 auto 22px;
  max-height: 42vh;
  overflow-y: auto;
}
.lb-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  margin-bottom: 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  font-family: 'Rajdhani', sans-serif;
}
.lb-row.top { background: rgba(255, 210, 60, 0.08); }
.lb-row.me {
  background: rgba(34, 227, 255, 0.15);
  border: 1px solid var(--cyan);
  box-shadow: 0 0 16px rgba(34, 227, 255, 0.3);
}
.lb-rank {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  color: rgba(200, 225, 245, 0.75);
}
.lb-name {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 1px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-score {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--lime);
}
.lb-empty, .lb-loading {
  padding: 20px;
  color: rgba(190, 215, 235, 0.55);
  letter-spacing: 1px;
  font-size: 15px;
}
.rank-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(26px, 8vw, 44px);
  color: var(--gold);
  text-shadow: 0 0 22px rgba(255, 210, 60, 0.6);
  margin-bottom: 6px;
}
.rank-source {
  font-size: 12px;
  letter-spacing: 2px;
  color: rgba(180, 210, 235, 0.5);
  margin-bottom: 18px;
}

/* ---------- Game over ---------- */
.go-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(30px, 9vw, 56px);
  color: var(--magenta);
  text-shadow: 0 0 24px rgba(255, 46, 166, 0.7);
  margin-bottom: 24px;
}
.result {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 30px;
  min-width: min(320px, 80vw);
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-family: 'Rajdhani', sans-serif;
  letter-spacing: 2px;
}
.result-row span { color: rgba(190, 215, 235, 0.7); font-size: 14px; }
.result-row b { font-family: 'Orbitron', sans-serif; font-size: 22px; }
.result-row.best { border: 1px solid var(--gold); }
.result-row.best b { color: var(--gold); text-shadow: 0 0 14px rgba(255, 210, 60, 0.6); }
