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

:root {
  --ink: #14141a;
  --gold: #ffd23f;
  --red: #ff3b3b;
  --cyan: #00e5ff;
  --white: #f7f7fa;
  --muted: #8b95b0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0e14;
  font-family: "Outfit", system-ui, sans-serif;
  color: var(--white);
  user-select: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  position: fixed;
  inset: 0;
}

.hidden { display: none !important; }

/* ── Overlays ── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  background: radial-gradient(120% 90% at 50% 40%, rgba(12, 16, 28, 0.35), rgba(12, 16, 28, 0.88));
  backdrop-filter: blur(4px);
}

.title {
  font-family: "Bungee", sans-serif;
  font-size: clamp(2.4rem, 10vw, 4.5rem);
  line-height: 0.95;
  color: var(--gold);
  text-shadow: 0 5px 0 #b8860b, 0 10px 24px rgba(0, 0, 0, 0.45);
  letter-spacing: 1px;
}

.title .red {
  color: var(--red);
  text-shadow: 0 5px 0 #8e1f1f, 0 10px 24px rgba(0, 0, 0, 0.45);
}

.tagline {
  margin: 1rem 0 1.2rem;
  font-size: clamp(0.95rem, 2.8vw, 1.15rem);
  font-weight: 600;
  color: rgba(247, 247, 250, 0.9);
  max-width: 420px;
  line-height: 1.45;
}

.tagline b { color: var(--gold); }
.tagline i { color: var(--red); font-style: normal; }

.best-line {
  font-family: "Bungee", sans-serif;
  font-size: 0.95rem;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 1.4rem;
}

.btn {
  font-family: "Bungee", sans-serif;
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  color: var(--ink);
  background: var(--gold);
  border: none;
  border-radius: 14px;
  padding: 0.9rem 2.4rem;
  cursor: pointer;
  letter-spacing: 1px;
  box-shadow: 0 7px 0 #b8860b, 0 12px 26px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 9px 0 #b8860b, 0 14px 30px rgba(0, 0, 0, 0.45);
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #b8860b;
}

.hint {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.over-title {
  font-family: "Bungee", sans-serif;
  font-size: clamp(2.2rem, 9vw, 4rem);
  color: var(--red);
  text-shadow: 0 5px 0 #8e1f1f, 0 10px 22px rgba(0, 0, 0, 0.45);
}

.badge {
  font-family: "Bungee", sans-serif;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--gold);
  border-radius: 8px;
  padding: 0.35rem 0.85rem;
  margin: 0.8rem 0 0.4rem;
  letter-spacing: 1px;
  animation: pop 0.45s ease;
}

@keyframes pop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}

.score-row {
  display: flex;
  gap: 2.5rem;
  margin: 1.2rem 0 1.6rem;
}

.score-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-cell .lab {
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: var(--muted);
  font-weight: 600;
}

.score-cell .val {
  font-family: "Bungee", sans-serif;
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  color: var(--white);
}

.score-cell.best .val { color: var(--gold); }

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

.top-hud {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.6rem;
}

.stat {
  background: rgba(10, 14, 26, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.4rem 0.9rem;
  min-width: 88px;
  text-align: center;
  backdrop-filter: blur(10px);
}

.stat .lab {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}

#score, #combo, #lives {
  font-family: "JetBrains Mono", "Bungee", monospace;
  font-size: 1.25rem;
  font-weight: 600;
}

#score { color: var(--gold); }
#combo { color: var(--cyan); }
#lives { color: var(--red); font-size: 1rem; letter-spacing: 0.1em; }

.bottom-hud {
  position: absolute;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.speedo {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  background: rgba(8, 12, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 0.45rem 1.1rem;
  backdrop-filter: blur(10px);
}

#speed {
  font-family: "JetBrains Mono", monospace;
  font-size: 1.7rem;
  color: var(--cyan);
  min-width: 3ch;
  text-align: right;
}

.unit {
  font-size: 0.8rem;
  color: var(--muted);
}

.hints {
  font-size: 0.72rem;
  color: var(--muted);
}

.hints kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.68rem;
  color: var(--white);
}

#popup-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.float-score {
  position: absolute;
  font-family: "Bungee", sans-serif;
  font-size: 1.3rem;
  color: var(--gold);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  animation: floatUp 0.85s ease forwards;
  white-space: nowrap;
}

.float-score.big {
  font-size: 1.7rem;
  color: #ff8a5c;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, 0) scale(0.7); }
  20% { transform: translate(-50%, -12px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(1); }
}

#toast {
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  font-family: "Bungee", sans-serif;
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  color: #fff;
  text-shadow: 0 0 20px rgba(255, 61, 110, 0.7), 0 4px 12px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  letter-spacing: 0.06em;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.08);
}

@media (max-width: 640px) {
  .hints { display: none; }
  .top-hud { gap: 0.35rem; }
  .stat { min-width: 72px; padding: 0.35rem 0.55rem; }
}
