:root {
  --void: #070418;
  --deep: #120a33;
  --star: #f4f1ff;
  --gold: #f6d58a;
  --gold-glow: #f6d58a88;
  --cyan: #8fe3ff;
  --violet: #b89cff;
  --muted: #a99fd6;
  --line: #ffffff2a;
  --radius: 24px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background: var(--void);
  color: var(--star);
  font-family: "Cinzel", Georgia, serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.nebula {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 30% at 20% 25%, #5b2fb066, transparent 70%),
    radial-gradient(35% 28% at 80% 20%, #1e5fa855, transparent 70%),
    radial-gradient(45% 35% at 70% 85%, #8a2b8a44, transparent 70%),
    radial-gradient(60% 50% at 50% 50%, var(--deep), transparent 80%);
  animation: drift 60s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) rotate(0deg); }
  to   { transform: translate3d(2%, 1%, 0) rotate(4deg); }
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 16px 48px;
}

h1 {
  margin: 0 0 10px;
  text-align: center;
  font-family: "Cinzel Decorative", "Cinzel", Georgia, serif;
  font-weight: 700;
  font-size: clamp(38px, 10vw, 68px);
  line-height: 1.05;
  /* Solid colour plus a dark outline and glow. A gradient clipped to text
     rendered dim in some browsers (Opera), so the title stays solid. */
  color: #fbe3a6;
  -webkit-text-stroke: 1px #3a2410;
  paint-order: stroke fill;
  text-shadow:
    0 2px 0 #2a1708,
    0 0 6px #000a,
    0 0 22px #f6d58a66;
}

.tagline {
  margin: 0 0 32px;
  text-align: center;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: clamp(18px, 4.5vw, 24px);
  color: var(--star);
  opacity: .85;
  text-shadow: 0 1px 6px #000a;
}

/* ── Constellation cards ── */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (min-width: 680px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

.card {
  position: relative;
  padding: 14px 10px 16px;
  text-align: center;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff0b, #ffffff04);
  border: 1px solid #ffffff1a;
  backdrop-filter: blur(4px);
  transition: border-color .4s, box-shadow .4s;
}

.card.lit {
  border-color: #f6d58a66;
  box-shadow: 0 0 30px #f6d58a22, inset 0 0 30px #b89cff14;
}

.shape {
  position: relative;
  display: block;
  width: 110px;
  height: 110px;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.shape svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  display: block;
}

.shape .edge {
  stroke: var(--line);
  stroke-width: 1;
  fill: none;
  stroke-linecap: round;
  transition: stroke .5s;
}

.shape .star {
  fill: var(--star);
  filter: url(#glow);
  transform-box: fill-box;
  transform-origin: center;
  animation: twinkle var(--tw, 3s) ease-in-out var(--td, 0s) infinite;
}

.card.lit .edge { stroke: #f6d58aaa; }
.card.lit .star { fill: #fff6dc; }

@keyframes twinkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.7); }
}

.name {
  margin: 4px 0 10px;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color .4s;
}

.card.lit .name { color: var(--gold); }

.counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.step {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #ffffff30;
  background: #ffffff0d;
  color: var(--star);
  font: 400 22px/1 system-ui, sans-serif;
  cursor: pointer;
  transition: background .2s, box-shadow .2s, transform .1s;
}

.step:hover { background: #ffffff1c; box-shadow: 0 0 14px #b89cff55; }
.step:active { transform: scale(.9); }

.step.plus {
  border-color: #f6d58a88;
  color: var(--gold);
}

.step.plus:hover { box-shadow: 0 0 16px var(--gold-glow); }

.count {
  min-width: 2ch;
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: "Cinzel", Georgia, serif;
}

/* ── Particles ── */
.spark {
  position: absolute;
  left: 50%;
  top: 70px;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, #fff 0%, var(--c, var(--gold)) 40%, transparent 70%);
  box-shadow: 0 0 8px var(--c, var(--gold));
}

/* ── Buttons ── */
.actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
}

.btn {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .2em;
  text-transform: uppercase;
  padding: 15px 34px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .1s, box-shadow .3s, opacity .3s;
}

.btn:active { transform: scale(.97); }

.btn.primary {
  color: #1a1030;
  border: 0;
  background: linear-gradient(180deg, #fff3cf, var(--gold) 50%, #d9a94f);
  box-shadow: 0 0 24px #f6d58a66, 0 0 60px #b89cff33;
}

.btn.primary:not(:disabled):hover { box-shadow: 0 0 34px #f6d58a99, 0 0 80px #b89cff55; }

.btn.primary:disabled {
  opacity: .3;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.ghost {
  color: var(--star);
  background: transparent;
  border: 1px solid #ffffff35;
  font-size: 14px;
  padding: 11px 26px;
}

.btn.ghost:hover { background: #ffffff10; }

.icon-btn {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid #ffffff30;
  background: #ffffff0a;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s, background .2s;
}

.icon-btn:hover { color: var(--star); background: #ffffff18; }

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mute {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  width: 42px;
  height: 42px;
}

.mute .off { display: none; }
.mute[aria-pressed="true"] .on { display: none; }
.mute[aria-pressed="true"] .off { display: inline; }

.btn:focus-visible, .step:focus-visible, .icon-btn:focus-visible, .shape:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 4px;
  border-radius: 999px;
}

/* ── Fortune ── */
.fortune {
  margin-top: 44px;
  text-align: center;
}

.scroll {
  position: relative;
  padding: 38px 30px;
  margin-bottom: 18px;
  border-radius: 18px;
  background:
    radial-gradient(120% 100% at 50% 0%, #2a1a5e 0%, #120a33 70%);
  border: 1px solid #f6d58a55;
  box-shadow: 0 0 50px #b89cff33, inset 0 0 40px #f6d58a14;
  overflow: hidden;
}

.scroll::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid #f6d58a33;
  border-radius: 12px;
  pointer-events: none;
}

.fortune-text {
  position: relative;
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: clamp(24px, 5.6vw, 32px);
  line-height: 1.3;
  color: #fff8e6;
  text-shadow: 0 0 18px #f6d58a55;
}

.fortune-text .w {
  display: inline-block;
  opacity: 0;
  filter: blur(6px);
  transform: translateY(8px);
  animation: appear .7s ease forwards;
}

@keyframes appear {
  to { opacity: 1; filter: blur(0); transform: none; }
}

.toast {
  min-height: 1.4em;
  margin: 12px 0 0;
  font-size: 14px;
  letter-spacing: .1em;
  color: var(--gold);
  opacity: 0;
  transition: opacity .2s;
}

.toast.on { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .nebula, .shape .star { animation: none; }
  .fortune-text .w { animation-duration: .01s; }
}
