:root {
  --bg: #0f1115;
  --gold-1: #f6e27a;
  --gold-2: #d4a017;
  --gold-3: #8a6a12;
  --text: #f2ead0;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(circle at 50% 30%, #1a1d24, var(--bg));
  color: var(--text);
  font-family: 'Georgia', 'Times New Roman', serif;
  overflow: hidden;
}

.stage {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  perspective: 1200px;
}

.coin-wrap {
  width: min(70vw, 300px);
  aspect-ratio: 1 / 1;
}

.coin {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  cursor: pointer;
  filter: drop-shadow(0 0 18px rgba(212, 160, 23, 0.35));
}

.coin-wrap[data-milestone="true"] .coin {
  filter: drop-shadow(0 0 40px rgba(246, 226, 122, 0.85));
}

.coin.spin-once {
  animation: spin-normal 1.4s ease-out 1;
}

.coin-wrap[data-milestone="true"] .coin.spin-once {
  animation: spin-milestone 2.6s cubic-bezier(0.2, 0.8, 0.2, 1) 1;
}

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  background:
    radial-gradient(circle at 35% 30%, var(--gold-1), var(--gold-2) 55%, var(--gold-3) 100%);
  border: 6px solid var(--gold-3);
  box-shadow:
    inset 0 0 0 4px rgba(255, 245, 210, 0.5),
    inset 0 0 25px rgba(0, 0, 0, 0.35);
}

.coin-back {
  transform: rotateY(180deg);
}

.coin-ring {
  position: absolute;
  inset: 14px;
  border: 2px dashed rgba(90, 60, 10, 0.55);
  border-radius: 50%;
}

.coin-text-top,
.coin-text-bottom {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(0.55rem, 2.2vw, 0.75rem);
  letter-spacing: 0.12em;
  color: #4a3306;
  font-weight: bold;
  white-space: nowrap;
}

.coin-text-top {
  top: 14%;
}

.coin-text-bottom {
  bottom: 14%;
}

.coin-number {
  font-size: clamp(3rem, 16vw, 5rem);
  font-weight: bold;
  color: #4a3306;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.coin-label {
  font-size: clamp(0.7rem, 3vw, 0.95rem);
  letter-spacing: 0.3em;
  color: #4a3306;
  margin-top: 0.25rem;
}

.coin-star {
  font-size: clamp(3rem, 14vw, 4.5rem);
  color: #4a3306;
}

@keyframes spin-normal {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}

@keyframes spin-milestone {
  from { transform: rotateY(0deg) scale(0.9); }
  60% { transform: rotateY(1080deg) scale(1.08); }
  to { transform: rotateY(1440deg) scale(1); }
}

.celebration-message {
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  text-align: center;
  color: var(--gold-1);
  text-shadow: 0 0 12px rgba(246, 226, 122, 0.6);
  opacity: 0;
  min-height: 2.4em;
  padding: 0 1rem;
}

.celebration-message.show {
  animation: fade-in 0.8s ease-out forwards;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

#confettiCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
}
