.coin-btn {
  all: unset;
  cursor: pointer;
  touch-action: manipulation;
  display: grid;
  place-items: center;
  padding: 56px 20px 30px;
  border-radius: 28px;
}
.coin-btn:focus-visible { outline: 5px solid var(--lava); outline-offset: 4px; }

.coin-wrap {
  --size: min(58vw, 34vh, 260px);
  position: relative;
  display: block;
  width: var(--size);
  height: var(--size);
  perspective: 900px;
  pointer-events: none; /* taps go to the button; 3D faces can confuse hit-testing */
}
.coin-wrap::after { /* shadow on the table */
  content: "";
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: -26px;
  height: 16px;
  border-radius: 50%;
  background: rgba(43, 33, 24, 0.18);
  filter: blur(3px);
}
.coin-wrap.toss { animation: toss 1.6s cubic-bezier(.3,.6,.4,1); }
.coin-wrap.toss::after { animation: toss-shadow 1.6s cubic-bezier(.3,.6,.4,1); }
@keyframes toss {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-30%) scale(1.06); }
  80% { transform: translateY(0) scale(1); }
  88% { transform: translateY(-5%); }
  100% { transform: translateY(0); }
}
@keyframes toss-shadow {
  40% { transform: translateY(30%) scale(0.5); opacity: 0.4; }
  80% { transform: none; opacity: 1; }
}

.coin {
  position: absolute;
  inset: 0;
  display: block;
  transform-style: preserve-3d;
  transition: transform 1.6s cubic-bezier(.25,.7,.3,1);
}

.coin-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 7px solid var(--ink);
  background:
    radial-gradient(circle at 35% 30%, #fff3c4 0 8%, transparent 30%),
    radial-gradient(circle, #fcd34d 0 62%, #f5b301 63% 100%);
  box-shadow: inset 0 0 0 10px #f5b301, inset 0 0 0 13px #d48f00;
  backface-visibility: hidden;
}
.coin-face svg { width: 78%; height: 78%; }
.coin-face.heads { transform: translateZ(6px); }
.coin-face.tails { transform: rotateX(180deg) translateZ(6px); }

/* The coin's edge: a few stacked discs give it thickness while it spins */
.coin-edge {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #c98500;
  border: 7px solid var(--ink);
}

.result .swatch.coin-result {
  background: #f5b301;
  color: var(--ink);
  text-shadow: none;
}

.tally {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  display: flex;
  gap: 12px;
  align-items: center;
}
.tally[hidden] { display: none; }
.reset {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  background: #efe4d8;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .coin { transition-duration: 0.2s; }
  .coin-wrap.toss, .coin-wrap.toss::after { animation: none; }
}
