:root {
  --bg-deep: #0a0a12;
  --bg-panel: rgba(255, 255, 255, 0.05);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --text-primary: #f0f0f5;
  --text-muted: #8888a0;
  --accent-cyan: #00e5ff;
  --accent-pink: #ec4899;
  --font: 'Outfit', system-ui, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#game-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
  touch-action: none;
}

/* ---- Back link / mute ---- */
.back-link {
  position: fixed;
  top: 1.2rem;
  left: 1.4rem;
  z-index: 5;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  border-radius: 100px;
  background: rgba(10, 10, 18, 0.5);
  backdrop-filter: blur(6px);
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--accent-cyan);
}

.mute-btn {
  position: fixed;
  top: 1.1rem;
  left: 9.5rem;
  z-index: 5;
  font-size: 1rem;
  line-height: 1;
  padding: 0.45rem 0.6rem;
  border-radius: 100px;
  border: 1px solid var(--border-subtle);
  background: rgba(10, 10, 18, 0.5);
  color: var(--text-primary);
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.mute-btn:hover {
  border-color: var(--accent-cyan);
}

/* ---- HUD ---- */
.hud {
  position: fixed;
  top: 1.2rem;
  right: 1.4rem;
  z-index: 5;
  display: flex;
  gap: 0.7rem;
}

.hud-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 76px;
  padding: 0.55rem 0.9rem;
  background: rgba(10, 10, 18, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  backdrop-filter: blur(6px);
}

.hud-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hud-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
  font-variant-numeric: tabular-nums;
}

/* ---- Next-ball queue ---- */
.hud-panel--queue {
  min-width: 108px;
}

.queue {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  height: 34px;
  margin-top: 0.15rem;
}

.chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fdfdff;
  text-shadow: 0 1px 3px rgba(6, 8, 16, 0.6);
}

/* The upcoming balls after the next one — smaller and dimmer. */
.chip--small {
  width: 21px;
  height: 21px;
  font-size: 0.56rem;
  opacity: 0.62;
}

/* ---- Chain badge ---- */
.combo {
  position: fixed;
  bottom: 1.6rem;
  left: 1.6rem;
  z-index: 5;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffd24a;
  text-shadow: 0 0 14px rgba(255, 210, 74, 0.7);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
}

.combo--on {
  opacity: 1;
  transform: scale(1);
}

/* ---- Overlays ---- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 6, 12, 0.72);
  backdrop-filter: blur(5px);
  transition: opacity 0.25s;
}

.overlay--hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay--pause {
  background: rgba(6, 6, 12, 0.55);
}

.overlay-content {
  max-width: 460px;
  padding: 2.4rem 2.6rem;
  text-align: center;
  background: rgba(14, 14, 24, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  box-shadow: 0 0 60px rgba(0, 229, 255, 0.12);
}

.overlay-content h2 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-pink));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.8rem;
}

.overlay-content p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  margin-bottom: 1.4rem;
}

.hint-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-bottom: 1.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

kbd {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  margin-right: 0.2rem;
}

.end-stats {
  display: flex;
  justify-content: center;
  gap: 1.8rem;
  margin-bottom: 1.6rem;
}

.end-stat {
  display: flex;
  flex-direction: column;
}

.end-stat__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
}

.end-stat__label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.overlay-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.8rem;
}

.btn-start {
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 700;
  color: #061014;
  padding: 0.75rem 2.2rem;
  border: none;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--accent-cyan), #4dd0ff);
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.45);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 34px rgba(0, 229, 255, 0.65);
}

.tool-btn {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 0.7rem 1.5rem;
  border: 1px solid var(--border-subtle);
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.tool-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
}

.is-hidden {
  display: none;
}

/* ---- Small screens ---- */
@media (max-width: 720px) {
  .hud {
    top: auto;
    bottom: 0.8rem;
    right: 0.7rem;
    left: 0.7rem;
    gap: 0.4rem;
    justify-content: space-between;
  }

  .hud-panel {
    min-width: 0;
    flex: 1;
    padding: 0.4rem 0.5rem;
  }

  .hud-value {
    font-size: 1rem;
  }

  .hud-panel--queue {
    flex: 1.3;
  }

  .queue {
    height: 28px;
  }

  .chip {
    width: 26px;
    height: 26px;
    font-size: 0.62rem;
  }

  .chip--small {
    width: 18px;
    height: 18px;
    font-size: 0.5rem;
  }

  .combo {
    bottom: 5.4rem;
    left: 0.9rem;
    font-size: 0.95rem;
  }

  .overlay-content {
    margin: 1rem;
    padding: 1.8rem 1.5rem;
  }
}
