:root {
  --bg-1: #0f1226;
  --bg-2: #1a1f3a;
  --bg-3: #232a4c;
  --fg: #e8ecff;
  --muted: #9aa3c7;
  --accent: #ffd166;
  --accent-2: #ff6b6b;
  --good: #51cf66;
  --paddle: #4dabf7;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  color: var(--fg);
  background: radial-gradient(
      1200px 600px at 20% -10%,
      #2a3170 0%,
      transparent 60%
    ),
    radial-gradient(900px 500px at 110% 20%, #5b2470 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 18px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.logo {
  margin: 0;
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  letter-spacing: 0.5px;
  font-weight: 800;
  background: linear-gradient(120deg, #ffd166, #ff6b6b 50%, #c084fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

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

.stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 10px;
  min-width: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.stat .value {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 2px;
}

.stat.best .value {
  color: var(--accent);
}

.stage {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, #0c0f25 0%, #161b3a 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

#game {
  display: block;
  width: 100%;
  height: auto;
  background: radial-gradient(
      600px 280px at 50% 0%,
      rgba(255, 255, 255, 0.05) 0%,
      transparent 70%
    ),
    linear-gradient(180deg, #0c1130 0%, #181f44 100%);
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 26, 0.78);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  padding: 16px;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.overlay-card {
  width: min(440px, 92%);
  background: linear-gradient(180deg, #1b2150 0%, #2a3170 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.overlay-card h2 {
  margin: 0 0 8px;
  font-size: 1.6rem;
  background: linear-gradient(120deg, #ffd166, #ff6b6b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.overlay-card p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

.controls-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  text-align: left;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.controls-list kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  color: var(--fg);
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 9px 18px;
  transition: transform 0.05s ease, background 0.15s ease,
    border-color 0.15s ease;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  background: linear-gradient(135deg, #ff6b6b, #ffd166);
  color: #1a1a2e;
  border: none;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 11px 22px;
  box-shadow: 0 8px 20px rgba(255, 107, 107, 0.35);
}

button.primary:hover {
  filter: brightness(1.05);
}

button.ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
}

button.ghost:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.18);
}

.bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.chip {
  width: 16px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  margin-left: 8px;
}

.chip-red { background: #ff6b6b; }
.chip-orange { background: #ffa94d; }
.chip-yellow { background: #ffd43b; }
.chip-green { background: #51cf66; }
.chip-blue { background: #4dabf7; }

.actions {
  display: flex;
  gap: 8px;
}

@media (max-width: 520px) {
  .hud .stat {
    min-width: 56px;
    padding: 6px 8px;
  }
  .stat .value {
    font-size: 1rem;
  }
  .overlay-card h2 {
    font-size: 1.3rem;
  }
}
