:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --shape: #38bdf8;
  --shape-recolor: #f59e0b;
  --ring: #fbbf24;
  --btn: #334155;
  --btn-on: #0ea5e9;
  --danger: #64748b;
  --spark: #38bdf8;
  --morph-size: 140px;
  --orbit-inset: -22px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, sans-serif;
  background: radial-gradient(circle at 50% 30%, #1e293b, var(--bg));
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem 1rem;
}

h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 650;
}

.meta, .coins, .hint {
  margin: 0;
  font-size: 1.1rem;
  color: var(--muted);
}

.hint {
  font-size: 0.95rem;
  max-width: 22rem;
  text-align: center;
  line-height: 1.35;
}

.coins {
  font-variant-numeric: tabular-nums;
  min-width: 16rem;
  text-align: center;
}

.combo-slot {
  display: inline-block;
  min-width: 7.5rem;
  text-align: left;
}

.coins strong, .meta strong {
  color: var(--accent);
  font-size: 1.4rem;
}

.stage {
  position: relative;
  width: 280px;
  height: 280px;
  display: grid;
  place-items: center;
}

.hit-zone, .ring, .spark-orbit {
  position: absolute;
  inset: var(--orbit-inset);
  pointer-events: none;
}

.hit-zone {
  border-radius: 50%;
  z-index: 2;
  background: conic-gradient(
    from 0deg,
    color-mix(in srgb, var(--accent) 55%, transparent) 0deg,
    color-mix(in srgb, var(--accent) 55%, transparent) var(--hit-span, 101deg),
    transparent var(--hit-span, 101deg)
  );
  mask: radial-gradient(farthest-side, transparent calc(100% - 11px), #000 calc(100% - 10px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 11px), #000 calc(100% - 10px));
  opacity: 0.8;
}

.hit-zone.active {
  opacity: 1;
  filter: brightness(1.35);
}

.morph, .shape {
  width: var(--morph-size);
  height: var(--morph-size);
}

.morph {
  position: relative;
  display: grid;
  place-items: center;
}

.shape {
  border-radius: 50%;
  background: var(--fill, var(--shape));
  box-shadow: 0 0 32px color-mix(in srgb, var(--fill, var(--shape)) 45%, transparent);
  transition: border-radius 0.35s ease, background 0.35s ease, box-shadow 0.35s ease;
}

.shape.square {
  border-radius: 8px;
}

.shape.recolor {
  --fill: var(--shape-recolor);
}

.ring {
  display: none;
  border: 5px solid var(--ring);
  border-top-color: transparent;
  border-radius: 50%;
}

.morph.has-ring .ring {
  display: block;
}

.spark {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  left: 50%;
  top: 0;
  border-radius: 50%;
  background: var(--spark);
  box-shadow: 0 0 12px var(--spark);
}

.shape.hit {
  filter: brightness(1.45);
}

.morph.pulse {
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: min(360px, 100%);
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  padding: 0.7rem 1.2rem;
  background: var(--btn);
  color: var(--text);
}

button:hover:not(:disabled) {
  filter: brightness(1.12);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  background: var(--danger);
}

#earn {
  background: var(--btn-on);
  font-weight: 650;
  min-width: 160px;
}

#next-level {
  width: 100%;
}

.upgrades {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  width: 100%;
}

.upgrades button {
  font-size: 0.9rem;
}
