@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

@font-face {
  font-family: "Polysans Bulky";
  src: url("https://cdn.prod.website-files.com/696ed06d2e62378f0a51f2d4/6982c51839ccd087e99f8077_%20PolySans%20Bulky.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --black: #212121;
  --cream: #fff9f1;
  --medium-cream: #f9f3eb;
  --dark-cream: #f4ece1;
  --blue: #007aff;
  --navy: #0c3166;
  --lime: #d6fc3c;
  --wheel-rim: var(--blue);
  --pointer-colour: var(--lime);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  padding: clamp(16px, 4vw, 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: Inter, Arial, sans-serif;
  text-align: center;
  color: var(--black);
  background:
    radial-gradient(circle at 8% 12%, rgb(214 252 60 / 22%) 0 7rem, transparent 7.1rem),
    radial-gradient(circle at 94% 88%, rgb(0 122 255 / 12%) 0 10rem, transparent 10.1rem),
    var(--cream);
}

main {
  width: min(100%, 720px);
  padding: clamp(24px, 5vw, 48px);
  overflow: hidden;
  border: 1px solid var(--dark-cream);
  border-radius: 16px;
  background: rgb(255 255 255 / 82%);
  box-shadow: 0 2px 19px rgb(0 0 0 / 10%);
  backdrop-filter: blur(8px);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(10px, 3vw, 24px);
}

.brand {
  display: block;
  width: min(190px, 38vw);
  height: auto;
}

h1 {
  margin: 0;
  font-family: "Polysans Bulky", Arial, sans-serif;
  font-size: clamp(1.1rem, 4vw, 2rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: .02em;
  text-align: right;
  white-space: nowrap;
}

.tabs {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin: 32px 0 0;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--dark-cream);
  border-radius: 12px 12px 0 0;
  background: var(--medium-cream);
}

.tab {
  position: relative;
  min-width: 0;
  padding: 12px 28px 11px;
  border: 0;
  border-radius: 12px 12px 0 0;
  color: #585756;
  background: transparent;
  font: 600 1rem/1 Inter, Arial, sans-serif;
  cursor: pointer;
  transition: color .2s, background-color .2s;
}

.tab:hover:not(:disabled):not([aria-selected="true"]) {
  color: var(--black);
  background: var(--dark-cream);
}

.tab[aria-selected="true"] {
  z-index: 1;
  color: var(--black);
  background: white;
  box-shadow: 0 -1px 8px rgb(0 0 0 / 6%);
}

.tab[aria-selected="true"]::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: white;
  content: "";
}

.tab:focus-visible,
.wheel:focus-visible {
  outline: 2px solid #4d65ff;
  outline-offset: 3px;
}

[role="tabpanel"][hidden] { display: none; }

.wheel-cost {
  display: flex;
  align-items: center;
  width: max-content;
  gap: 8px;
  margin: 24px 0 0;
  padding: 8px 13px 8px 9px;
  border: 1px solid #e1b928;
  border-radius: 999px;
  color: var(--black);
  background: #fff6c9;
  font-size: .9rem;
  font-weight: 700;
}

.coin {
  display: grid;
  width: 24px;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid #9f7410;
  border-radius: 50%;
  color: #765208;
  background: #f5c842;
  font-size: .7rem;
  box-shadow: inset 0 0 0 2px #ffdf70;
}

.wheel-cost + .wheel-area { margin-top: 18px; }

.wheel-area {
  position: relative;
  width: min(72vw, 460px);
  aspect-ratio: 1;
  margin: clamp(28px, 6vw, 42px) auto 30px;
}

.wheel-area::before {
  position: absolute;
  z-index: 1;
  inset: 0;
  border-radius: 50%;
  background: var(--wheel-rim);
  content: "";
}

.wheel-lights {
  position: absolute;
  z-index: 0;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}

.wheel-light {
  position: absolute;
  width: clamp(16px, 3.4vw, 22px);
  aspect-ratio: 1;
  border: 2px solid #6f5812;
  border-radius: 50%;
  background: #fff4b5;
  box-shadow: 0 0 12px 4px rgb(255 226 92 / 95%);
  transform: translate(-50%, -50%);
  animation: blink-lights 1s steps(1, end) infinite;
}

.wheel-light:nth-child(even) { animation-delay: -.5s; }

@keyframes blink-lights {
  0%, 49% {
    background: #fff4b5;
    box-shadow: 0 0 12px 4px rgb(255 226 92 / 95%);
  }
  50%, 100% {
    background: #8b741e;
    box-shadow: none;
  }
}

.wheel {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  border: clamp(7px, 1.5vw, 11px) solid var(--wheel-rim);
  border-radius: 50%;
  box-shadow: 0 12px 30px rgb(12 49 102 / 20%);
  cursor: pointer;
  touch-action: pan-x;
  transition: transform 5s cubic-bezier(.12, .7, .1, 1);
}

.wheel:active { cursor: grabbing; }

.pointer {
  position: absolute;
  z-index: 3;
  top: 50%;
  right: -14px;
  width: 48px;
  height: 44px;
  transform: translateY(-50%);
  filter: drop-shadow(-3px 0 0 var(--cream));
}

.pointer::before,
.pointer::after {
  position: absolute;
  top: 50%;
  right: 0;
  width: 0;
  height: 0;
  transform: translateY(-50%);
  content: "";
}

.pointer::before {
  border-top: 22px solid transparent;
  border-right: 48px solid var(--black);
  border-bottom: 22px solid transparent;
}

.pointer::after {
  right: 5px;
  border-top: 16px solid transparent;
  border-right: 37px solid var(--pointer-colour);
  border-bottom: 16px solid transparent;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.credit {
  margin: 16px 0 0;
  color: #777573;
  font: 500 clamp(.65rem, 1.8vw, .75rem)/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  text-align: center;
}

.result-dialog {
  --result-accent: var(--blue);
  width: min(calc(100% - 32px), 440px);
  padding: 0;
  overflow: visible;
  border: 1px solid var(--dark-cream);
  border-radius: 20px;
  color: var(--black);
  background: white;
  box-shadow: 0 24px 80px rgb(12 33 63 / 30%);
}

.result-dialog::backdrop {
  background: rgb(12 33 63 / 55%);
  backdrop-filter: blur(4px);
}

.result-card {
  position: relative;
  z-index: 1;
  padding: 36px;
  overflow: hidden;
  border-radius: inherit;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0, rgb(214 252 60 / 30%), transparent 45%),
    white;
}

.result-kicker {
  margin: 0 0 8px;
  color: var(--result-accent);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.result-title {
  margin: 0;
  font-family: "Polysans Bulky", Arial, sans-serif;
  font-size: clamp(2rem, 8vw, 3rem);
  line-height: 1.05;
  letter-spacing: .02em;
}

.result-image {
  display: block;
  width: 150px;
  aspect-ratio: 1;
  margin: 24px auto 0;
  object-fit: cover;
  border: 7px solid var(--cream);
  border-radius: 50%;
  box-shadow: 0 8px 24px rgb(12 49 102 / 20%);
}

.confetti {
  position: fixed;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  pointer-events: none;
}

@media (max-width: 480px) {
  main { padding-inline: 16px; }
  .tabs { margin-top: 24px; }
  .tab {
    flex: 1;
    padding-inline: 12px;
  }
  .wheel-area { width: min(78vw, 360px); }
}

@media (prefers-reduced-motion: reduce) {
  .wheel { transition-duration: .35s; }
  .wheel-light { animation: none; }
  .wheel-light:nth-child(even) {
    background: #8b741e;
    box-shadow: none;
  }
  .tab { transition: none; }
}
