:root {
  color-scheme: light;
  --paper: #fff8ed;
  --ink: #311d3c;
  --muted: #624b65;
  --violet: #663584;
  --peach: #ffc09d;
  --lemon: #ffda70;
  --display: Georgia, 'Times New Roman', serif;
  font-family: 'Trebuchet MS', 'DejaVu Sans', sans-serif;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body, p, h1 {
  margin: 0;
}

.page {
  max-inline-size: 75rem;
  margin-inline: auto;
  padding: clamp(1.25rem, 3vw, 2.5rem) clamp(1rem, 4vw, 3rem) 2.5rem;
}

.lottery {
  display: grid;
  grid-template-areas:
    'intro'
    'wheel'
    'controls';
  gap: 1.25rem;
  margin-block-start: clamp(1.5rem, 5vw, 4.5rem);
}

.intro {
  grid-area: intro;
}

h1 {
  font: 700 clamp(2.75rem, 6.8vw, 6rem) / 0.98 var(--display);
  letter-spacing: -0.06em;
}

h1 em {
  color: var(--violet);
}

.intro p {
  max-inline-size: 31ch;
  margin-block-start: 1rem;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.1875rem);
  line-height: 1.5;
}

.wheel-stage {
  grid-area: wheel;
  display: grid;
  place-items: center;
  min-inline-size: 0;
  padding: clamp(1.5rem, 5vw, 3.75rem);
  border: 1px solid #d5badf;
  border-radius: clamp(1.5rem, 4vw, 2.75rem);
  background:
    radial-gradient(circle, #66358429 1px, transparent 1.4px) center / 1rem 1rem,
    radial-gradient(ellipse at 42% 34%, #f6e8fe, #e1c4ee 85%);
}

.wheel-frame {
  --rim: clamp(0.55rem, 1.35vw, 1rem);
  position: relative;
  isolation: isolate;
  inline-size: min(100%, 28rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0.4rem 0 var(--ink), 0 1.1rem 1.5rem #48205f38;
}

.wheel-frame::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: repeating-conic-gradient(from -1deg, #ebc7ed 0deg 2deg, #4f2c65 2deg 15deg);
}

#wheel {
  position: absolute;
  inset: var(--rim);
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 50%;
  transform: rotate(0deg);
  transform-origin: 50% 50%;
}

#wheel::after {
  content: '';
  position: absolute;
  inset-block: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--ink);
  pointer-events: none;
}

.sector {
  position: absolute;
  inset-block: 0;
  width: 50%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
}

/* At 0deg the option centers sit at 90deg and 270deg clockwise from the pointer. */
.sector--right {
  right: 0;
  background: radial-gradient(ellipse at 38% 36%, #ffe1be, var(--peach) 83%);
}

.sector--left {
  left: 0;
  background: radial-gradient(ellipse at 62% 36%, #f5e1fc, #d6abea 83%);
}

.sector img {
  display: block;
  inline-size: 76%;
  max-inline-size: 9rem;
  block-size: auto;
}

.wheel-hub,
.wheel-pointer {
  position: absolute;
  left: 50%;
  pointer-events: none;
}

.wheel-hub {
  top: 50%;
  inline-size: clamp(1.125rem, 3vw, 2.2rem);
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle, var(--ink) 18%, var(--lemon) 20% 65%, #e8a84b 67%);
  transform: translate(-50%, -50%);
}

.wheel-pointer {
  --pointer-shape: polygon(0 13%, 11% 0, 89% 0, 100% 13%, 50% 100%);
  top: calc(var(--rim) * -0.85);
  inline-size: clamp(1.75rem, 5vw, 3.25rem);
  aspect-ratio: 1.2;
  background: var(--ink);
  clip-path: var(--pointer-shape);
  transform: translateX(-50%);
}

.wheel-pointer::before {
  content: '';
  position: absolute;
  inset: 2px 3px 4px;
  background: linear-gradient(#ffeea6, var(--lemon));
  clip-path: var(--pointer-shape);
}

.controls {
  grid-area: controls;
  display: grid;
  justify-self: center;
  inline-size: min(100%, 22rem);
}

#spin-button {
  min-block-size: 3.5rem;
  padding: 0.85rem 1.25rem;
  border: 1px solid var(--ink);
  border-radius: 0.9rem;
  background: var(--violet);
  box-shadow: 0 0.25rem 0 var(--ink);
  color: #fffaf3;
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
}

#spin-button:enabled:hover {
  background: #522761;
}

#spin-button:enabled:active {
  transform: translateY(2px);
  box-shadow: 0 0.125rem 0 var(--ink);
}

#spin-button:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: 4px;
}

#spin-button:disabled {
  background: #e6d5ed;
  color: #52395d;
  box-shadow: 0 0.25rem 0 #84698f;
  cursor: default;
}

#result {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 36rem) {
  .page {
    padding: 1.5rem clamp(0.75rem, 3.5vw, 1rem) 1rem;
  }

  .lottery {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
    margin-block-start: 0;
  }

  h1 {
    font-size: clamp(2.375rem, 11vw, 2.75rem);
  }

  .intro p {
    margin-block-start: 0.5rem;
    line-height: 1.4;
  }

  .wheel-stage {
    padding: 0.875rem;
  }

  .sector img {
    inline-size: 80%;
  }

  .wheel-pointer {
    inline-size: clamp(2rem, 8vw, 2.5rem);
  }

  .controls {
    inline-size: 100%;
  }
}

@media (min-width: 48rem) {
  .lottery {
    grid-template-areas:
      'intro wheel'
      'controls wheel';
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    grid-template-rows: 1fr 1fr;
    column-gap: clamp(2rem, 5vw, 4.5rem);
    row-gap: 1.5rem;
  }

  .intro {
    align-self: end;
  }

  h1 em {
    display: block;
  }

  .controls {
    align-self: start;
    justify-self: start;
  }
}
