:root { color-scheme: dark; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: #05060a;
  font-family: Inter, system-ui, sans-serif;
  color: #dce9ef;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#game-root {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(0, 229, 255, 0.1), transparent 55%),
    radial-gradient(ellipse 50% 40% at 85% 15%, rgba(168, 85, 247, 0.16), transparent 50%),
    #05060a;
}
#game {
  display: block;
  width: min(100vw, calc(100dvh * 9 / 16));
  height: min(100dvh, calc(100vw * 16 / 9));
  max-width: 480px;
  background: #05060a;
  border-radius: 12px;
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.12), 0 0 80px rgba(168, 85, 247, 0.08);
}
#hud {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw, 480px);
  padding: 0.85rem 1rem 0;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 5;
}
#hud.hidden { display: none; }
.hud-label {
  font-family: Orbitron, system-ui, sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  color: rgba(0, 229, 255, 0.7);
}
#score, #best {
  font-family: Orbitron, system-ui, sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: #e8fbff;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.45);
}
.hud-right { text-align: right; }
.flavor {
  position: absolute;
  top: 3.4rem;
  left: 0;
  right: 0;
  text-align: center;
  font-family: Orbitron, system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: #e9d5ff;
  text-shadow: 0 0 16px rgba(168, 85, 247, 0.6);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.flavor.show { opacity: 1; }
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 10, 0.72);
  backdrop-filter: blur(6px);
  z-index: 10;
  padding: 1rem;
}
.overlay.hidden { display: none; }
.panel {
  width: min(92vw, 380px);
  border: 1px solid rgba(0, 229, 255, 0.28);
  border-radius: 18px;
  padding: 1.5rem 1.35rem 1.25rem;
  background: rgba(8, 12, 20, 0.92);
  box-shadow: 0 0 32px rgba(0, 229, 255, 0.1), inset 0 0 40px rgba(168, 85, 247, 0.05);
  text-align: center;
}
.eyebrow {
  font-family: Orbitron, system-ui, sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  color: rgba(0, 229, 255, 0.65);
  margin-bottom: 0.55rem;
}
.panel h1 {
  font-family: Orbitron, system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(1.8rem, 8vw, 2.6rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e8fbff;
  text-shadow:
    0 0 12px rgba(0, 229, 255, 0.55),
    0 0 40px rgba(168, 85, 247, 0.3);
  margin-bottom: 0.55rem;
}
.tagline {
  font-size: 0.9rem;
  color: rgba(220, 233, 239, 0.75);
  margin-bottom: 1.1rem;
  line-height: 1.4;
}
.controls {
  text-align: left;
  font-size: 0.78rem;
  color: rgba(220, 233, 239, 0.65);
  margin: 0 auto 1.2rem;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.controls span {
  color: #67e8f9;
  font-family: Orbitron, system-ui, sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  display: inline-block;
  min-width: 11.5rem;
}
.cta {
  font-family: Orbitron, system-ui, sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid rgba(0, 229, 255, 0.6);
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.2), rgba(168, 85, 247, 0.28));
  color: #e8fbff;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.2);
  transition: filter 0.15s ease, transform 0.15s ease;
}
.cta:hover { filter: brightness(1.15); transform: translateY(-1px); }
.last-score {
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: #e9d5ff;
  min-height: 1.2em;
}
.back {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.75rem;
  color: rgba(0, 229, 255, 0.75);
  text-decoration: none;
  letter-spacing: 0.06em;
}
.back:hover { text-decoration: underline; }
.game-footer {
  position: absolute;
  bottom: 0.45rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: rgba(220, 233, 239, 0.35);
  pointer-events: none;
  z-index: 6;
  padding: 0 0.5rem;
}

/* —— Leaderboard —— */
.leaderboard {
  margin-top: 1.1rem;
  padding: 0.75rem 0.7rem 0.55rem;
  border-radius: 12px;
  border: 1px solid rgba(168, 85, 247, 0.35);
  background:
    linear-gradient(180deg, rgba(0, 229, 255, 0.06), transparent 40%),
    rgba(6, 10, 18, 0.85);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.12), inset 0 0 24px rgba(0, 229, 255, 0.04);
  text-align: left;
}
.lb-title {
  font-family: Orbitron, system-ui, sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-align: center;
  color: #e9d5ff;
  text-shadow: 0 0 14px rgba(168, 85, 247, 0.65);
  margin-bottom: 0.55rem;
}
.lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  max-height: 11.5rem;
  overflow-y: auto;
}
.lb-list.hidden,
.lb-empty.hidden { display: none; }
.lb-row {
  display: grid;
  grid-template-columns: 1.6rem 1fr auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.28rem 0.4rem;
  border-radius: 8px;
  font-size: 0.74rem;
  color: rgba(220, 233, 239, 0.85);
}
.lb-row:nth-child(odd) {
  background: rgba(0, 229, 255, 0.04);
}
.lb-row.lb-top1 {
  background: rgba(0, 229, 255, 0.1);
  box-shadow: inset 0 0 12px rgba(0, 229, 255, 0.08);
}
.lb-row.lb-top2,
.lb-row.lb-top3 {
  background: rgba(168, 85, 247, 0.08);
}
.lb-rank {
  font-family: Orbitron, system-ui, sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: rgba(0, 229, 255, 0.75);
}
.lb-top1 .lb-rank { color: #67e8f9; text-shadow: 0 0 8px rgba(0, 229, 255, 0.5); }
.lb-name {
  font-family: Orbitron, system-ui, sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: #e8fbff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-score {
  font-family: Orbitron, system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: #e9d5ff;
  text-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}
.lb-empty {
  text-align: center;
  font-size: 0.72rem;
  color: rgba(220, 233, 239, 0.45);
  margin: 0.15rem 0 0.1rem;
}

/* —— Name prompt —— */
.name-prompt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 10, 0.82);
  backdrop-filter: blur(8px);
  z-index: 20;
  padding: 1rem;
}
.name-prompt.hidden { display: none; }
.name-prompt-card {
  width: min(92vw, 340px);
  border: 1px solid rgba(0, 229, 255, 0.35);
  border-radius: 18px;
  padding: 1.35rem 1.25rem 1.15rem;
  background: rgba(8, 12, 20, 0.95);
  box-shadow: 0 0 36px rgba(0, 229, 255, 0.14), 0 0 60px rgba(168, 85, 247, 0.12);
  text-align: center;
}
.name-prompt-card h2 {
  font-family: Orbitron, system-ui, sans-serif;
  font-size: 1.15rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #e8fbff;
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.45);
  margin-bottom: 0.35rem;
}
.name-prompt-score {
  font-size: 0.85rem;
  color: #e9d5ff;
  margin-bottom: 0.9rem;
}
.name-label {
  display: block;
  font-family: Orbitron, system-ui, sans-serif;
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  color: rgba(0, 229, 255, 0.7);
  text-align: left;
  margin-bottom: 0.35rem;
}
.name-input {
  width: 100%;
  font-family: Orbitron, system-ui, sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: #e8fbff;
  background: rgba(0, 229, 255, 0.06);
  border: 1px solid rgba(0, 229, 255, 0.4);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  outline: none;
  margin-bottom: 0.95rem;
  box-shadow: inset 0 0 16px rgba(0, 229, 255, 0.06);
}
.name-input:focus {
  border-color: rgba(168, 85, 247, 0.7);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.25);
}
.name-input::placeholder { color: rgba(220, 233, 239, 0.35); }
.name-actions {
  display: flex;
  gap: 0.55rem;
  justify-content: center;
}
.name-actions .cta { flex: 1; padding: 0.7rem 0.8rem; }
.cta-ghost {
  background: transparent;
  border-color: rgba(220, 233, 239, 0.25);
  box-shadow: none;
  color: rgba(220, 233, 239, 0.75);
}
.cta-ghost:hover { filter: brightness(1.2); }

@media (max-height: 720px) {
  .lb-list { max-height: 7.5rem; }
  .controls { margin-bottom: 0.7rem; }
  .panel { padding: 1.15rem 1.1rem 1rem; }
}
