* { box-sizing: border-box; margin: 0; }

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 30% 20%, #2b2f4a, #12131c 70%);
  color: #eef0ff;
}

.card {
  text-align: center;
  padding: 2.5rem 3rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

h1 {
  font-size: 1.4rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.stage {
  perspective: 800px;
  margin: 2rem auto 1.5rem;
  width: 140px;
  height: 140px;
}

.coin {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.coin.spinning {
  animation: toss 1.2s cubic-bezier(0.3, 0.7, 0.4, 1) forwards;
}

.face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 3.5rem;
  font-weight: 800;
  backface-visibility: hidden;
  color: #6b4a00;
  background: radial-gradient(circle at 35% 30%, #fff3b0, #f5c542 45%, #c8901a);
  box-shadow: inset 0 0 0 8px rgba(160, 110, 10, 0.55), 0 8px 20px rgba(0, 0, 0, 0.45);
}

.tails {
  transform: rotateY(180deg);
  color: #3d4250;
  background: radial-gradient(circle at 35% 30%, #ffffff, #c9ced8 45%, #8a92a3);
  box-shadow: inset 0 0 0 8px rgba(90, 98, 115, 0.55), 0 8px 20px rgba(0, 0, 0, 0.45);
}

@keyframes toss {
  0%   { transform: translateY(0) rotateY(var(--from)); }
  45%  { transform: translateY(-70px) rotateY(calc((var(--from) + var(--to)) / 2)); }
  100% { transform: translateY(0) rotateY(var(--to)); }
}

.result {
  font-size: 1.5rem;
  font-weight: 700;
  min-height: 2rem;
  margin-bottom: 1.25rem;
}

button {
  font: inherit;
  font-weight: 600;
  padding: 0.8rem 2rem;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  color: #1a1400;
  background: linear-gradient(180deg, #ffd85e, #f0b429);
  box-shadow: 0 6px 18px rgba(240, 180, 41, 0.35);
  transition: transform 0.1s, filter 0.2s;
}

button:hover { filter: brightness(1.08); }
button:active { transform: scale(0.96); }
button:disabled { opacity: 0.6; cursor: default; }

.tally {
  margin-top: 1.25rem;
  font-size: 0.85rem;
  opacity: 0.6;
}

@media (prefers-reduced-motion: reduce) {
  .coin.spinning { animation-duration: 0.01s; }
}
