:root {
  --bg: #05060f;
  --panel: rgba(10, 14, 34, 0.78);
  --panel-border: rgba(96, 160, 255, 0.25);
  --text: #e8ecff;
  --muted: #8a93b8;
  --accent: #4de3ff;
  --accent2: #b06bff;
  --danger: #ff4d6d;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }

#score-panel {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 10px 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(6px);
}

#score-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(77, 227, 255, 0.6);
}

/* Combo & multiplier chip */
#combo-chip {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#combo-chip.hidden { display: none; }
#combo-mult {
  font-size: 22px;
  font-weight: 900;
  color: #ffd75e;
  text-shadow: 0 0 12px rgba(255, 200, 60, 0.7);
  animation: combo-pop 0.25s ease-out;
}
#combo-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--muted);
}
#combo-bar {
  flex: 1 1 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
#combo-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ffd75e, #ff8a3d);
  transition: width 0.1s linear;
}
#combo-chip.fire #combo-mult {
  color: #ff8a3d;
  text-shadow: 0 0 16px rgba(255, 120, 40, 0.9);
  animation: combo-fire 0.5s ease-in-out infinite alternate;
}
#combo-chip.fire #combo-fill { background: linear-gradient(90deg, #ff8a3d, #ff3d6d); }
@keyframes combo-pop { from { transform: scale(1.5); } to { transform: scale(1); } }
@keyframes combo-fire { from { transform: scale(1); } to { transform: scale(1.12); } }

.hud-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
}

#leaderboard {
  position: absolute;
  top: 16px;
  right: 16px;
  min-width: 190px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(6px);
}

#leaderboard-list {
  margin-top: 6px;
  list-style: none;
  counter-reset: rank;
}

#leaderboard-list li {
  counter-increment: rank;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  padding: 2px 0;
  color: var(--text);
}

#leaderboard-list li::before {
  content: counter(rank) ".";
  color: var(--muted);
  margin-right: 6px;
}

#leaderboard-list li.me {
  color: var(--accent);
  font-weight: 700;
  text-shadow: 0 0 8px rgba(77, 227, 255, 0.5);
}

#leaderboard-list li .lb-score { color: var(--muted); font-variant-numeric: tabular-nums; }
#leaderboard-list li.me .lb-score { color: var(--accent); }

#effects {
  position: absolute;
  top: 96px;
  left: 16px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 230px;
}

.fx-chip {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

.fx-chip.tier {
  color: var(--accent);
  letter-spacing: 1px;
  text-transform: uppercase;
}

#evolve-banner {
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 8px;
  white-space: nowrap;
  color: #ffd75e;
  text-shadow: 0 0 24px rgba(255, 215, 94, 0.8);
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

#evolve-banner.show {
  opacity: 1;
  transform: translateX(-50%) scale(1.05);
}

#toast {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 3px;
  white-space: nowrap;
  color: var(--accent);
  text-shadow: 0 0 16px rgba(77, 227, 255, 0.6);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#toast.show { opacity: 1; }

#boss-bar {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px;
  background: rgba(40, 8, 16, 0.8);
  border: 1px solid rgba(255, 77, 109, 0.5);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 20px rgba(255, 77, 109, 0.25);
}

.boss-name {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ff8fa3;
}

.boss-hp { font-size: 16px; color: #ff4d6d; letter-spacing: 2px; }
.boss-hp .dim { color: rgba(255, 77, 109, 0.25); }

#skin-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  min-height: 15px;
  letter-spacing: 0.5px;
}

.skin-swatch.locked {
  filter: grayscale(0.8) brightness(0.5);
  position: relative;
}

.skin-swatch.locked::after {
  content: "🔒";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  filter: none;
}

#level-card {
  margin-top: 18px;
  padding: 12px 16px;
  text-align: left;
  background: rgba(5, 7, 18, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
}

#level-card .hud-label b { color: var(--accent); font-size: 13px; }
#level-title { color: var(--text); text-transform: none; letter-spacing: 0.5px; }

#level-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #ffd75e, var(--accent2));
  transition: width 0.4s ease;
}

#difficulty-block {
  margin-top: 14px;
  text-align: left;
}

#difficulty-seg {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  padding: 3px;
  background: rgba(5, 7, 18, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
}

#difficulty-seg button {
  flex: 1;
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#difficulty-seg button.on {
  color: #04121a;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

#difficulty-desc {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--muted);
  min-height: 14px;
}

#daily-card {
  margin-top: 14px;
  padding: 12px 16px;
  text-align: left;
  background: rgba(5, 7, 18, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
}

.daily-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

#daily-status { font-size: 11px; color: var(--accent); font-variant-numeric: tabular-nums; }
#daily-desc { margin: 6px 0 8px; font-size: 13px; color: var(--text); }

.daily-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(96, 160, 255, 0.15);
  overflow: hidden;
}

#daily-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.4s ease;
}

#minimap {
  position: absolute;
  bottom: 16px;
  right: 16px;
  border-radius: 50%;
  background: rgba(10, 14, 34, 0.6);
  border: 1px solid var(--panel-border);
}

#boost-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
}

#boost-btn {
  position: absolute;
  bottom: 28px;
  left: 24px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--panel-border);
  background: var(--panel);
  color: var(--accent);
  font-size: 30px;
  pointer-events: auto;
  display: none;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

#boost-btn:active {
  background: rgba(77, 227, 255, 0.25);
  box-shadow: 0 0 24px rgba(77, 227, 255, 0.5);
}

body.touch #boost-btn { display: flex; }
body.touch #boost-hint { display: none; }

#spectate-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 10px;
}

#spectate-bar button {
  padding: 13px 26px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #e8ecff;
  background: rgba(10, 14, 34, 0.85);
  border: 2px solid rgba(207, 227, 255, 0.5);
  border-radius: 999px;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 18px rgba(207, 227, 255, 0.25);
  -webkit-tap-highlight-color: transparent;
}

#spectate-play {
  color: #04121a !important;
  background: linear-gradient(90deg, var(--accent), var(--accent2)) !important;
  border-color: transparent !important;
}

#spectate-bar button:active { filter: brightness(1.15); }

#hud.spectate #spectate-bar { display: flex; }
#hud.spectate #boost-hint,
#hud.spectate #boost-btn,
#hud.spectate #effects { display: none; }

#hud-tools {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

#hud-tools button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(6px);
  -webkit-tap-highlight-color: transparent;
}

#hud-tools button:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 14px rgba(77, 227, 255, 0.3);
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(9, 12, 30, 0.55) 0%, rgba(4, 5, 14, 0.92) 100%);
  z-index: 10;
}

.menu-card {
  width: min(420px, 92vw);
  max-height: 94vh;
  overflow-y: auto;
  padding: 32px 30px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 60px rgba(77, 227, 255, 0.08), 0 20px 60px rgba(0, 0, 0, 0.6);
}

.logo {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--text);
  cursor: pointer;
  animation: logo-pulse 3.4s ease-in-out infinite;
}

@keyframes logo-pulse {
  0%, 100% { text-shadow: 0 0 16px rgba(77, 227, 255, 0.45); }
  50% { text-shadow: 0 0 26px rgba(77, 227, 255, 0.85), 0 0 44px rgba(176, 107, 255, 0.35); }
}

.logo span {
  display: block;
  font-size: 26px;
  letter-spacing: 10px;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--accent));
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: logo-flow 5s linear infinite;
}

@keyframes logo-flow {
  to { background-position: 220% center; }
}

@media (prefers-reduced-motion: reduce) {
  .logo, .logo span { animation: none; }
}

.tagline { margin: 10px 0 6px; font-size: 14px; color: var(--muted); }

.welcome {
  margin: 0 0 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  min-height: 16px;
  text-shadow: 0 0 10px rgba(77, 227, 255, 0.3);
}

#nickname {
  width: 100%;
  padding: 13px 16px;
  font-size: 16px;
  text-align: center;
  color: var(--text);
  background: rgba(5, 7, 18, 0.8);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  outline: none;
}

#nickname:focus {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(77, 227, 255, 0.3);
}

.skin-picker { margin: 20px 0 6px; }

#skin-list {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.skin-swatch {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.skin-swatch:hover { transform: scale(1.12); }

.skin-swatch.selected {
  border-color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 18px var(--glow, rgba(255, 255, 255, 0.6));
}

.primary-btn {
  width: 100%;
  margin-top: 22px;
  padding: 15px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #04121a;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(77, 227, 255, 0.35);
}

.ghost-btn {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  cursor: pointer;
}

.ghost-btn:hover { color: var(--text); border-color: var(--muted); }

.ghost-btn.accent { color: var(--accent); border-color: rgba(77, 227, 255, 0.4); }
.ghost-btn.accent:hover { box-shadow: 0 0 16px rgba(77, 227, 255, 0.25); }

.menu-links {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.ghost-btn.small {
  flex: 1;
  margin-top: 0;
  padding: 9px 4px;
  font-size: 11px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.menu-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(96, 160, 255, 0.12);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
  text-decoration: underline;
  cursor: pointer;
}

.link-btn:hover { color: var(--danger); }

.link-btn.version { text-decoration: none; color: var(--muted); }
.link-btn.version:hover { color: var(--accent); }

#update-pill {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #04121a;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(77, 227, 255, 0.45);
  animation: pill-pulse 1.6s ease-in-out infinite;
}

@keyframes pill-pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  #update-pill { animation: none; }
}

/* ---------- Tutorial / About ---------- */
.overlay.top { z-index: 20; }

.menu-card.wide {
  width: min(520px, 94vw);
  text-align: left;
}

.overlay-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 4px;
  text-align: center;
  color: var(--text);
  text-shadow: 0 0 14px rgba(77, 227, 255, 0.45);
  margin-bottom: 18px;
}

.tut-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 9px 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
  border-bottom: 1px solid rgba(96, 160, 255, 0.08);
}

.tut-step span { font-size: 20px; line-height: 1.3; }
.tut-step b { color: var(--text); }

.about-text {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--muted);
}

.about-text b { color: var(--text); }
.about-text.small { margin-top: 14px; font-size: 11px; letter-spacing: 1px; }
.about-sub { margin: 16px 0 6px; }

.diff-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--muted);
}

.diff-list b { color: var(--text); }

#run-chart {
  width: 100%;
  height: 110px;
  margin-top: 4px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(5, 7, 18, 0.6);
}

.how-to {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin-top: 22px;
  font-size: 12px;
  color: var(--muted);
  text-align: left;
}

.how-to b { color: var(--text); }

.best { margin-top: 18px; font-size: 13px; color: var(--accent); min-height: 16px; }

.shard-chip {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #c9a8ff;
  text-shadow: 0 0 10px rgba(160, 110, 255, 0.5);
}

/* Challenges ladder */
.challenge-chip {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #67e8f9;
  background: rgba(103, 232, 249, 0.08);
  border: 1px solid rgba(103, 232, 249, 0.35);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.challenge-chip:hover { background: rgba(103, 232, 249, 0.16); }
.challenge-chip:active { transform: scale(0.97); }

.challenge-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 8px 0 4px;
  text-align: left;
}
.challenge-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  opacity: 0.62;
}
.challenge-row.done {
  opacity: 1;
  border-color: rgba(103, 232, 249, 0.5);
  background: rgba(103, 232, 249, 0.08);
}
.challenge-row .ch-icon { font-size: 20px; width: 24px; text-align: center; flex: none; }
.challenge-row .ch-desc { flex: 1; font-size: 14px; color: var(--text); }
.challenge-row .ch-check { font-size: 18px; font-weight: 700; color: var(--muted); flex: none; }
.challenge-row.done .ch-check { color: #67e8f9; text-shadow: 0 0 10px rgba(103, 232, 249, 0.6); }

@media (min-width: 720px) {
  .challenge-list { grid-template-columns: 1fr 1fr; }
}

/* Buy Me a Coffee — BMC brand yellow, tasteful */
.coffee-btn {
  display: block;
  margin: 16px auto 0;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-align: center;
  text-decoration: none;
  color: #12100a;
  background: #ffdd00;
  border-radius: 12px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.coffee-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 221, 0, 0.35);
}

.coffee-btn.small {
  margin-top: 12px;
  padding: 9px 14px;
  font-size: 12.5px;
  background: transparent;
  color: #ffdd00;
  border: 1px solid rgba(255, 221, 0, 0.5);
}

#new-best-badge {
  margin: 10px auto 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #12100a;
  background: linear-gradient(90deg, #ffd75e, #ffb84d);
  border-radius: 999px;
  box-shadow: 0 0 20px rgba(255, 215, 94, 0.5);
  animation: nb-pulse 1.3s ease-in-out infinite;
}

@keyframes nb-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }

/* ---------- Rank / tier ladder badge ---------- */
.rank-badge {
  --rank: #cd7f32;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 300px;
  margin: 12px auto 0;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(13, 19, 48, 0.7);
  border: 1px solid color-mix(in srgb, var(--rank) 55%, transparent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--rank) 25%, transparent);
}
.rank-badge:empty { display: none; }
.rank-badge .rank-emblem { font-size: 22px; line-height: 1; flex: none; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--rank) 60%, transparent)); }
.rank-badge .rank-body { flex: 1; min-width: 0; text-align: left; }
.rank-badge .rank-name {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--rank);
  text-shadow: 0 0 10px color-mix(in srgb, var(--rank) 45%, transparent);
}
.rank-badge .rank-bar {
  height: 5px;
  margin-top: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.rank-badge .rank-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--rank);
  box-shadow: 0 0 8px var(--rank);
  transition: width 0.4s ease;
}
.rank-badge .rank-next { font-size: 11px; font-weight: 700; color: var(--muted); flex: none; white-space: nowrap; }

#rank-up-badge {
  --rank: #ffd75e;
  margin: 10px auto 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #12100a;
  background: var(--rank);
  border-radius: 999px;
  box-shadow: 0 0 22px color-mix(in srgb, var(--rank) 60%, transparent);
  animation: nb-pulse 1.3s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) { #rank-up-badge { animation: none; } }

#hud-version {
  position: absolute;
  bottom: 5px;
  left: 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: rgba(138, 147, 184, 0.45);
  pointer-events: none;
}

body.touch #hud-version { bottom: 5px; left: 108px; }

@media (prefers-reduced-motion: reduce) { #new-best-badge { animation: none; } }

/* ---------- Death screen ---------- */
.death-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--danger);
  text-shadow: 0 0 20px rgba(255, 77, 109, 0.6);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 22px 0 6px;
}

.stat {
  padding: 12px;
  background: rgba(5, 7, 18, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
}

.stat-num {
  margin-top: 4px;
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}

/* ---------- Tablets: large touch screens get a scaled-up UI ---------- */
@media (pointer: coarse) and (min-width: 640px) {
  .menu-card { width: min(600px, 90vw); padding: 44px 46px; border-radius: 26px; }
  .menu-card.wide { width: min(680px, 92vw); }
  .logo { font-size: 54px; }
  .logo span { font-size: 36px; letter-spacing: 13px; }
  .tagline { font-size: 17px; }

  #nickname { padding: 19px 20px; font-size: 21px; border-radius: 16px; }
  .hud-label { font-size: 13px; }
  .skin-swatch { width: 58px; height: 58px; }
  .skin-swatch.locked::after { font-size: 21px; }
  #skin-hint { font-size: 15px; }

  .primary-btn { padding: 20px; font-size: 20px; border-radius: 16px; }
  .ghost-btn { padding: 16px; font-size: 16px; }
  .ghost-btn.small { padding: 12px 6px; font-size: 14px; }
  .link-btn, .menu-footer { font-size: 14px; }

  #level-card, #daily-card { padding: 16px 20px; }
  #daily-desc { font-size: 16px; }
  #daily-status { font-size: 13px; }
  .daily-track { height: 8px; }
  #difficulty-seg button { padding: 12px 4px; font-size: 15px; }
  #difficulty-desc { font-size: 14px; }
  .welcome { font-size: 15px; }

  .how-to { font-size: 15px; gap: 10px 20px; }
  .best { font-size: 16px; }

  .overlay-title { font-size: 28px; }
  .tut-step { font-size: 16.5px; padding: 12px 0; }
  .tut-step span { font-size: 26px; }
  .about-text, .diff-list { font-size: 16px; }

  .death-title { font-size: 38px; }
  .stat-num { font-size: 30px; }
  #run-chart { height: 140px; }

  /* HUD */
  #score-panel { padding: 14px 24px; }
  #score-value { font-size: 36px; }
  #effects { top: 118px; max-width: 300px; }
  .fx-chip { font-size: 15px; padding: 6px 14px; }
  #leaderboard { min-width: 240px; padding: 16px 20px; }
  #leaderboard-list li { font-size: 16px; padding: 3px 0; }
  #minimap { width: 180px; height: 180px; }
  #hud-tools { gap: 12px; }
  #hud-tools button { width: 54px; height: 54px; font-size: 23px; }
  #boost-btn { width: 96px; height: 96px; font-size: 40px; bottom: 40px; left: 36px; }
  #boost-hint { font-size: 15px; }
  #spectate-bar { bottom: 34px; }
  #spectate-bar button { font-size: 16px; padding: 16px 34px; }
  #boss-bar { top: 84px; padding: 10px 24px; }
  .boss-name { font-size: 16px; }
  .boss-hp { font-size: 19px; }
  #evolve-banner { font-size: 44px; }
  #toast { font-size: 21px; }
  #update-pill { font-size: 15px; padding: 13px 26px; bottom: 100px; }
}

/* Large screens (tablet landscape / desktop): use the width — the menu
   becomes a proper wide page, not a tall narrow popup. Placed AFTER the
   tablet tier so its card width wins while touch-target sizes are kept. */
@media (min-width: 860px) {
  .menu-card { width: min(900px, 94vw); padding: 40px 52px; }
  .menu-card.wide { width: min(760px, 92vw); }
  #menu-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: start;
    margin-top: 18px;
  }
  #menu-stats > * { margin-top: 0; }
  /* In the narrow 3-up columns the stat headers must not wrap awkwardly:
     tighten the label so "Level N · Tier" + "XP" and "Daily challenge" +
     "0 / N" each stay on one line (ellipsis an unusually long tier name). */
  #menu-stats .hud-label { font-size: 11px; letter-spacing: 0.5px; }
  #menu-stats .daily-head { gap: 8px; }
  #level-card .daily-head > .hud-label:first-child {
    min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #daily-card .daily-head > .hud-label { white-space: nowrap; }
  .how-to { max-width: 700px; margin-left: auto; margin-right: auto; }
  .menu-links { max-width: 700px; margin-left: auto; margin-right: auto; }
}

@media (max-width: 600px) {
  #leaderboard { min-width: 150px; padding: 8px 12px; }
  #leaderboard-list li { font-size: 11px; }
  #minimap { width: 100px; height: 100px; }
  #score-value { font-size: 22px; }
  .logo { font-size: 32px; }
}

/* Short viewports — chiefly landscape phones (e.g. 844x390). The oversized
   logo + tagline + welcome would otherwise eat the whole height and bury the
   skins and the ENTER THE ARENA button below the fold. Compress the header so
   the CTA is reachable with little or no scrolling. Placed last so it wins for
   short screens regardless of width; heights this small never hit a tablet. */
@media (max-height: 560px) {
  .menu-card { padding: 16px 26px; border-radius: 16px; }
  .logo { font-size: 26px; letter-spacing: 2px; animation: none; }
  .logo span { font-size: 17px; letter-spacing: 6px; }
  .tagline { display: none; }
  .welcome { margin: 2px 0 10px; font-size: 12px; min-height: 0; }
  #nickname { padding: 10px 14px; font-size: 16px; margin: 0; }
  .skin-picker { margin: 10px 0 4px; }
  .skin-swatch { width: 42px; height: 42px; }
  #skin-list { gap: 8px; margin-top: 6px; }
  #menu-stats { margin-top: 10px; }
  .primary-btn { padding: 14px; font-size: 17px; }
}
