:root {
  --ink: #fff7ec;
  --muted: #d9cbe8;
  --panel: rgba(23, 16, 38, 0.86);
  --line: rgba(255, 255, 255, 0.14);
  --accent: #ff8a1f;
  --accent-ink: #1d1206;
  --green: #00a862;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1d1530;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { display: block; }

#flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}

.badge {
  position: fixed;
  right: 12px;
  bottom: 12px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

#hud {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100vw - 24px);
}
#hud > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 14px;
  text-align: center;
  min-width: 72px;
}
#hud .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
#hud b { font-size: 20px; }
#who { max-width: 140px; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
#lives { color: #ff5a4f; letter-spacing: 2px; }

.panel {
  position: fixed;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: min(380px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 22px 20px;
  backdrop-filter: blur(6px);
}
.panel[hidden], #hud[hidden], .badge[hidden], [hidden] { display: none !important; }

h1, h2 { margin: 0 0 8px; line-height: 1.1; }
h1 { font-size: 30px; }
h2 { font-size: 26px; }
.hello { font-size: 18px; font-weight: 700; margin: 0 0 6px; }
.note { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 0 0 12px; }
.note a { color: #ffc27a; }

.rules { margin: 0 0 16px; padding-left: 18px; font-size: 14px; line-height: 1.6; }

.final { font-size: 18px; margin: 4px 0 8px; }
.final b { font-size: 44px; color: var(--accent); margin-right: 6px; }

.board { list-style: none; padding: 0; margin: 0 0 14px; }
.board li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.board li span:last-child { margin-left: auto; font-weight: 700; }
.board .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

button, .button {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 20px;
  min-height: 44px;
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
button:disabled { opacity: 0.5; cursor: wait; }
.button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button:focus-visible, .button:focus-visible { outline: 3px solid #ffd59e; outline-offset: 2px; }

@media (max-width: 480px) {
  #hud { flex-wrap: nowrap; gap: 6px; top: 8px; }
  #hud > div { padding: 4px 8px; min-width: 0; border-radius: 10px; }
  #hud .label { font-size: 9px; }
  #hud b { font-size: 16px; }
  #who { max-width: 72px; }
  #lives { letter-spacing: 0; font-size: 14px; white-space: nowrap; }
}

@media (max-width: 640px) {
  .panel {
    left: 50%;
    top: auto;
    bottom: 16px;
    transform: translateX(-50%);
  }
  h1 { font-size: 26px; }
}

/* ---------- juice: score bumps, combo, banner, floating text, mute ---------- */
#hud > div { transition: background 0.2s, border-color 0.2s; }
.bump { animation: bump 0.25s ease-out; }
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
#combo-box.hot { background: rgba(255, 138, 31, 0.28); border-color: var(--accent); }
#combo-box.hot b { color: #ffd59e; }
#time-box.hurry b { color: #ff5a4f; animation: pulse 0.5s ease-in-out infinite alternate; display: inline-block; }
@keyframes pulse { to { transform: scale(1.18); } }

.stat { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.stat b { color: var(--ink); }

.banner {
  position: fixed;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%) scale(0.6);
  font-size: clamp(34px, 8vw, 72px);
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #fff3e0;
  text-shadow: 0 4px 0 #b4440a, 0 8px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.25s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.banner.go { color: #b6ffcf; text-shadow: 0 4px 0 #00703f, 0 8px 24px rgba(0, 0, 0, 0.5); }
.banner.combo { color: #ffe08a; }

#pops { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 900;
  font-size: 26px;
  color: #ffd59e;
  text-shadow: 0 2px 0 #7a2d00, 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: rise 0.8s ease-out forwards;
  white-space: nowrap;
}
.pop.gold { color: #fff27a; font-size: 34px; }
.pop.bad { color: #ff8c84; text-shadow: 0 2px 0 #6b0000, 0 4px 12px rgba(0, 0, 0, 0.5); }
@keyframes rise {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -70%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -200%) scale(1); }
}

.mute {
  position: fixed;
  left: 12px;
  bottom: 12px;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--muted);
  border: 1px solid var(--line);
}

@media (prefers-reduced-motion: reduce) {
  .bump, #time-box.hurry b, .pop { animation-duration: 0.01s; }
  .banner { transition: none; }
}

@media (max-width: 480px) {
  #hud > div:first-child { display: none; } /* the player's name is on the start screen */
  .mute { left: auto; right: 8px; bottom: auto; top: 64px; min-height: 32px; padding: 4px 10px; font-size: 12px; }
  .badge { display: none; }
}
