@font-face {
  font-family: 'Press Start 2P';
  src: url('assets/press-start-2p.ttf') format('truetype');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --background: #f8f6f0;
  --text: #29251d;
  --text-shadow: #e8bb53;
  --focus: #9a6500;
  --coin-size: min(calc(100vw - 64px), calc(100svh - 180px), 680px);
  --coin-outline: polygon(35% 0, 65% 0, 65% 3%, 75% 3%, 75% 7%, 82% 7%, 82% 12%, 88% 12%, 88% 18%, 93% 18%, 93% 25%, 97% 25%, 97% 35%, 100% 35%, 100% 65%, 97% 65%, 97% 75%, 93% 75%, 93% 82%, 88% 82%, 88% 88%, 82% 88%, 82% 93%, 75% 93%, 75% 97%, 65% 97%, 65% 100%, 35% 100%, 35% 97%, 25% 97%, 25% 93%, 18% 93%, 18% 88%, 12% 88%, 12% 82%, 7% 82%, 7% 75%, 3% 75%, 3% 65%, 0 65%, 0 35%, 3% 35%, 3% 25%, 7% 25%, 7% 18%, 12% 18%, 12% 12%, 18% 12%, 18% 7%, 25% 7%, 25% 3%, 35% 3%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 24px;
  background: var(--background);
  color: var(--text);
}

main {
  display: grid;
  justify-items: center;
  gap: clamp(28px, 6svh, 48px);
}

.coin-toggle {
  display: block;
  width: var(--coin-size);
  height: var(--coin-size);
  padding: 0;
  border: 0;
  background: transparent;
  perspective: 1000px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.coin-toggle:focus-visible {
  outline: 3px dashed var(--focus);
  outline-offset: 18px;
}

.coin {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  animation: spin 5s linear infinite;
}

.edge, .face {
  position: absolute;
  inset: 0;
  clip-path: var(--coin-outline);
}

.edge {
  background: #93601d;
  transform: translateZ(var(--depth));
}

.edge:nth-child(even) { background: #bc8327; }

.face {
  padding: 6%;
  background: linear-gradient(135deg, #fff0a2 0 18%, #f9cb50 18% 44%, #e3a32b 44% 74%, #b97a21 74%);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.front { transform: translateZ(8px); }
.back { transform: rotateY(180deg) translateZ(8px); }

.face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  clip-path: var(--coin-outline);
  image-rendering: pixelated;
  user-select: none;
}

h1 {
  margin: 0;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(18px, 4.5vw, 28px);
  font-weight: 400;
  line-height: 1.6;
  text-align: center;
  text-shadow: 3px 3px 0 var(--text-shadow);
}

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

@media (prefers-color-scheme: dark) {
  :root {
    --background: #111214;
    --text: #f8d475;
    --text-shadow: #765119;
    --focus: #f8d475;
  }
}

@media (prefers-reduced-motion: reduce) {
  .coin { animation-play-state: paused; }
}
