:root{
  
  
  --text: #e9edf7;
  --muted: #9aa3b2;
  --accent: #6aa9ff;
  
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.5;
  margin: 0;
}

.app{
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.card{
    width: min(720px, 92vw);
    border: 1px solid #2a335a;
    border-radius: 18px;
    background-color: #ffde59;
    padding: 1.5rem;
    box-shadow: 0 20px 60px #0008, inset 0 1px 0 #fff1;
}

h1{
  margin: 0 0 1rem;
  font-size: clamp(1.6rem, 2vw + 1rem, 2.2rem);
  letter-spacing: 0.3px;
}

.coin-stage{
  width: 260px;
  height: 260px;
  margin: 1rem auto 0.5rem;
  perspective: 1000px;
  filter: drop-shadow(0 12px 24px rgba(0,0,0,.55));
}

.coin{
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 800ms cubic-bezier(.2,.7,.2,1);
  transform: rotateY(var(--end-rotation, 0deg));
}

.face{
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  backface-visibility: hidden;
  border: 6px solid #0b1020;
  box-shadow:
    inset 0 0 12px rgba(255,255,255,.25),
    inset 0 0 48px rgba(0,0,0,.6);
}

.face.heads{
  background-image: url("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRQcSYgjXt5usPOYf_p8paIRTIQKvp5_Y1e7w&usqp=CAU");
}

.face.tails{
  transform: rotateY(180deg);
  background-image: url("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSUjq5xIDU1j54osHM8x80fv_QlDZAVFIeb8A&usqp=CAU");
}

/* Flip animation class */
.coin.flipping{
  animation: spinY var(--spin-duration, 1600ms) cubic-bezier(.2,.7,.2,1) var(--spin-delay, 0ms);
}

@keyframes spinY{
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(var(--target-rotation, 1800deg)); }
}

.result{
  text-align: center;
  margin: .5rem 0 1rem;
  color: #1f2124;;
  min-height: 1.3em;
}

.controls{
  display: flex;
  gap: .6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}

.btn{
  
  border: 1px solid #2a335a;
  color: var(--text);
  padding: .7rem 1.1rem;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: transform .08s ease, box-shadow .2s ease, background .2s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}

.btn:hover{  }
.btn:active{ transform: translateY(1px); }
.btn:focus-visible{
  outline: none;
  box-shadow: 0 0 0 6px var(--ring);
}

.btn.primary{
  
  border-color: #3f63ff;
}
.btn.primary:hover{ filter: brightness(1.05); }

.stats{
  margin: .6rem auto 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .6rem;
  max-width: 420px;
}

.stat{
  
  border: 1px solid #242c51;
  border-radius: 12px;
  padding: .6rem .8rem;
  text-align: center;
}
.stat span{
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
}
.stat small{
  display: block;
  color: #000;
  margin-top: .15rem;
  letter-spacing: .3px;
}

.history{
  margin-top: .8rem;
  color: var(--muted);
}
.history summary{
  cursor: pointer;
  color: #000;
  margin-bottom: .4rem;
}
.history ol{
  margin: .2rem 0 0;
  padding-left: 1.2rem;
}

.footer{
  display: none;
  margin-top: 1rem;
  color: var(--muted);
  text-align: center;
  font-size: .9rem;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce){
  .coin, .coin.flipping{
    animation: none !important;
    transition: none !important;
  }
}
