@property --wheel-angle {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0deg;
}

#sheet[data-kind="wheel"] {
  --wheel-unit: calc(min(var(--phone-width), 390px) / 100);
  inset: 0;
  margin: auto;
  width: min(calc(var(--phone-width) - 20px), 365px);
  max-height: calc(100dvh - 18px);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #fff3d2;
  text-align: center;
  scrollbar-width: none;
}
#sheet:is([data-kind="wheel"], [data-kind="wheel-result"])::backdrop {
  --spot-width: var(--phone-width);
  background:
    radial-gradient(circle 2px at calc(50% - .06 * var(--spot-width)) 7%, #fff7daaa, transparent),
    radial-gradient(circle 3px at calc(50% + .05 * var(--spot-width)) 12%, #fff2c38c, transparent),
    radial-gradient(circle 2.5px at calc(50% - .1 * var(--spot-width)) 15%, #fff4d194, transparent),
    radial-gradient(circle 2px at calc(50% + .09 * var(--spot-width)) 18%, #fff3d378, transparent),
    radial-gradient(ellipse calc(.14 * var(--spot-width)) 14dvh at 50% -1%, #fff5d4c7, #fff4d077 46%, transparent 100%),
    radial-gradient(ellipse calc(.23 * var(--spot-width)) 29dvh at 50% 0%, #fff5d175, #fff0c33b 48%, transparent 100%),
    radial-gradient(ellipse calc(.40 * var(--spot-width)) 28dvh at 50% 8%, #fff1ca34, #ffebbc18 60%, transparent 100%),
    #150a0ad6;
}
#sheet[data-kind="wheel"] .sheet-inner {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 12px 11px 8px;
}
#sheet[data-kind="wheel"] .sheet-head { display: contents; }
#sheet[data-kind="wheel"] #sheet-title {
  grid-row: 1;
}
#sheet[data-kind="wheel"] #sheet-title img {
  display: block;
  width: clamp(124px, calc(46 * var(--wheel-unit)), 180px);
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}
#sheet[data-kind="wheel"] #sheet-body {
  grid-row: 2;
  display: grid;
  grid-template: 40px auto auto / minmax(0, 1fr);
}
.wheel-status {
  grid-row: 1;
  margin-top: 2px;
  color: #fff1df;
  font-size: clamp(11px, calc(3.6 * var(--wheel-unit)), 15px);
  font-weight: 600;
  line-height: 1.45;
}
.wheel-effects {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.wheel-effects::before {
  content: "";
  position: absolute;
  inset: 1% 0 8%;
  background: radial-gradient(ellipse at 50% 52%, #fc874e90, #ff893830 51%, transparent 74%);
}
.wheel-effects i {
  position: absolute;
  width: clamp(8px, calc(4 * var(--wheel-unit)), 18px);
  aspect-ratio: 1;
  background: #ffebad;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}
.wheel-effects i:nth-child(1) { left: 8%; top: 13%; opacity: .78; }
.wheel-effects i:nth-child(2) { right: 6%; top: 22%; }
.wheel-effects i:nth-child(3) { left: 3%; top: 62%; scale: .65; }

.wheel-stage {
  grid-row: 2;
  position: relative;
  width: min(100%, 334px);
  aspect-ratio: 1;
  margin: 0 auto;
}
.wheel-rim {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    conic-gradient(from 225deg, #fc6e3100, #fff7b63d 15%, #fffadaba 24%, #fff0a43d 32%,
      #ff579c00 44%, #ff5a9e00 53%, #ff8ac65c 64%, #ff678440 77%, #a42a2900 92%, #fc6e3100),
    radial-gradient(circle, transparent 90%, #fff3c578 95%, #fff4c3b8 97.4%, #762423b3 99.8%),
    linear-gradient(120deg, #ffb244 0%, #ff7e22 24%, #ff5338 47%, #f52d60 75%, #ff456e 100%);
  box-shadow: 0 4px 0 #ba3825, 0 7px 0 #782219, 0 17px 25px #160700ab,
    0 0 29px #ff743e48, inset 2px 3px 7px #fff5caca, inset -4px -5px 8px #a91e479e;
}
.wheel-rim::before,
.wheel-rim::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}
.wheel-rim::before {
  inset: 1.15%;
  background:
    radial-gradient(circle, transparent 89%, #99262d48 90%, #ffb47200 91%, #fffbd865 95.2%,
      #fffbe474 95.8%, #ffd69115 96.8%, transparent 98.4%),
    conic-gradient(from -105deg, transparent 0deg, #fffdeca3 25deg, #fffbed87 69deg, transparent 107deg,
      transparent 185deg, #ff9ec570 245deg, transparent 285deg);
  mask-image: radial-gradient(circle, transparent 86.5%, #000 87.1%);
}
.wheel-rim::after {
  inset: 4.2%;
  box-shadow: 0 0 0 1px #a93a2c, 0 0 0 2px #ffdcb691,
    0 2px 5px 2px #7d232374, inset 0 0 0 1px #fff5d5;
}
.wheel-disk {
  position: absolute;
  inset: 4.2%;
  border-radius: 50%;
  overflow: hidden;
  rotate: var(--wheel-angle);
  background:
    repeating-conic-gradient(from -30deg, #ca7f5d9e 0deg .34deg, transparent .34deg 59.58deg, #fffdf6 59.58deg 60deg),
    radial-gradient(circle at 44% 39%, #fffaf8e6 0%, #fffdf93d 54%, transparent 72%),
    repeating-conic-gradient(from -30deg, #fff2dc 0deg 60deg, #ffe0d6 60deg 120deg);
  box-shadow: inset 0 0 15px #93392543, inset 0 1px 2px #87291d78;
}
.wheel-slot, .wheel-stud {
  position: absolute;
  left: var(--x);
  top: var(--y);
  translate: -50% -50%;
}
.wheel-slot {
  display: grid;
  place-content: center;
  isolation: isolate;
  width: 20.5%;
  aspect-ratio: 1.05;
  border: 1px solid #fff8cf;
  border-radius: 25%;
  color: #833108;
  background: radial-gradient(ellipse 95% 70% at 28% 0%, #fffdf2, #fff9d660 66%, transparent 79%),
    linear-gradient(156deg, #fff6bb 5%, #ffdc79 48%, #ffc050 84%, #ffd173);
  box-shadow: 0 0 0 .5px #da9d42, 0 2px 0 #d8943b, 0 4px 5px #86400e36,
    inset 0 1px 3px #fff9db, inset 0 -2px 2px #ec98354d;
  rotate: calc(-1 * var(--wheel-angle));
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.wheel-slot::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 3% 7% 46%;
  border-radius: 41% 41% 50% 50%;
  background: linear-gradient(#ffffffb8, #fff9e924 82%, transparent);
}

.wheel-slot--winner {
  z-index: 1;
  border-color: #fffdf2;
  box-shadow: 0 0 0 2px #fff7c9, 0 0 17px 4px #ffc944, inset 0 1px 7px #fff9dd;
}
.wheel-slot b {
  font-size: clamp(16px, calc(6.35 * var(--wheel-unit)), 26px);
  font-weight: 900;
  letter-spacing: -.045em;
}
.wheel-slot small {
  margin-top: .25em;
  font-size: clamp(8px, calc(2.7 * var(--wheel-unit)), 11px);
  font-weight: 750;
}
.wheel-stud {
  width: 2.7%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 26%, #fffce5 5%, #ffd6a2 31%, #efa88c 58%, #ffd8b1 82%);
  box-shadow: 0 1px 2px #8543316b, inset 0 0 0 1px #fff8d87a;
}
.wheel-hub {
  position: absolute;
  display: grid;
  place-items: center;
  inset: 40%;
  border: 1px solid #fff4c4;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 22%, #fff3d3, #f9ad50 60%, #e36e2b 89%);
  box-shadow: 0 2px 0 #ce7729, 0 6px 10px #9d431a53,
    inset 0 1px 4px #ffffda, inset 0 -1px 3px #bf582b;
}
.wheel-hub img { width: 90%; height: auto; filter: drop-shadow(0 1px 1px #91410070); }
.wheel-pointer {
  position: absolute;
  z-index: 2;
  top: -5%;
  left: 50%;
  translate: -50%;
  width: 10.7%;
  aspect-ratio: .78;
  filter: drop-shadow(0 4px 3px #7a22268f);
}
.wheel-pointer::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0%, 71% 4%, 88% 15%, 98% 31%, 98% 47%, 89% 63%, 57% 98%, 50% 100%, 43% 98%,
    11% 63%, 2% 47%, 2% 31%, 12% 15%, 29% 4%);
  background: radial-gradient(ellipse at 38% 12%, #fffbdca6, transparent 40%),
    radial-gradient(ellipse at 62% 24%, #ff5b9694, transparent 65%),
    linear-gradient(128deg, #fff4ce 0%, #ffbd6c 25%, #ff805e 48%, #f0416e 76%, #b42449 100%);
}
.wheel-pointer i {
  position: absolute;
  inset: 12% 24% auto;
  aspect-ratio: 1;
  border: 1px solid #ffe2aa;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 23%, #fff6d7, #ffb273 23%, #ff7437 55%, #ed3e46 78%, #ff8a6a 100%);
  box-shadow: 0 1px 3px #8f241a92, inset 0 -1px 2px #b83036, 0 0 0 1px #d6393678;
}

.wheel-button {
  grid-row: 3;
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  width: min(80%, 285px);
  min-height: clamp(48px, calc(15.5 * var(--wheel-unit)), 67px);
  margin: -10px auto 0;
  padding: 3px 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-on-accent);
}
.wheel-button::before,
.wheel-button::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: inherit;
}
.wheel-button::before {
  inset: -3px 0;
  background: linear-gradient(162deg, #fff8d6, #ffda74 19%, #fff4bd 45%, #fff2ba 61%, #ffca61 90%, #fff2bd);
  box-shadow: 0 1px 2px #b3421160;
}
.wheel-button::after {
  inset: -1px 2px;
  background: radial-gradient(ellipse 85% 90% at 52% 104%, #ffca705c, #ffa7361a 52%, transparent 76%),
    radial-gradient(ellipse 140% 80% at 51% -11%, #ffad6f, #ff8b5266 48%, transparent 84%),
    linear-gradient(#ff663a, #ff4716 43%, #ff4412 64%, #ff762b);
  box-shadow: inset 0 2px 4px #fff5c481, inset 0 -3px 6px #ffcd5d7a,
    inset 2px 0 5px #ff9b58a1, inset -2px 0 5px #ff9b58a1;
}
.wheel-button:active:not(:disabled) { scale: .98; }
.wheel-button-copy {
  position: relative;
  z-index: 2;
  font-size: clamp(19px, calc(7.3 * var(--wheel-unit)), 31px);
  font-weight: 950;
  line-height: 1.05;
  letter-spacing: .025em;
}
.wheel-tap {
  position: absolute;
  z-index: 1;
  top: 42%;
  right: -3%;
  width: 29%;
  aspect-ratio: 1.65;
  pointer-events: none;
}
.wheel-tap::before {
  content: "";
  position: absolute;
  width: 71%;
  left: 0;
  top: -8%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #fff3de8c 0% 33%, #fff3de56 34% 69%, transparent 71%);
}
.wheel-tap i {
  position: absolute;
  right: -1%;
  top: 52%;
  width: 55%;
  height: 62%;
  border-radius: 45% 43% 39% 36%;
  rotate: 34deg;
  background: linear-gradient(155deg, #fff4de 4%, #ffd2b5 58%, #ffb593 88%);
  box-shadow: inset 0 1px 3px #fffefa9c, 0 2px 3px #94351a43;
}
.wheel-tap i::before, .wheel-tap i::after { content: ""; position: absolute; }
.wheel-tap i::before {
  left: -64%;
  top: 4%;
  width: 112%;
  height: 40%;
  border-radius: 999px;
  background: linear-gradient(#fff9e9 5%, #ffd6bd 69%, #ffc4a6);
  box-shadow: 0 1px 3px #b65b383a;
}
.wheel-tap i::after {
  right: -10%;
  bottom: -4%;
  width: 28%;
  height: 70%;
  border-radius: 18% 24% 31% 24%;
  rotate: -11deg;
  background: linear-gradient(#ffe2aa, #ffc478);
}

#sheet[data-kind="wheel"] .close-btn {
  grid-row: 3;
  place-self: center;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-top: 22px;
  padding: 0 0 2px;
  border: 1px solid #fff3d794;
  border-radius: 50%;
  background: #2d15188c;
  color: var(--close-on-accent);
  font-size: 24px;
  line-height: 1;
}
#sheet[data-kind="wheel"] :focus-visible { outline: 2px solid #fff5d2; outline-offset: 3px; }

#sheet.result-sheet[data-kind="wheel-result"] {
  width: min(calc(var(--phone-width) * .82), 320px);
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
}

#sheet.result-sheet[data-kind="wheel-result"] .sheet-inner {
  isolation: isolate;
  padding: 19px 17px 21px;
}

#sheet[data-kind="wheel-result"] .sheet-inner::before,
#sheet[data-kind="wheel-result"] .sheet-inner::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

#sheet[data-kind="wheel-result"] .sheet-inner::before {
  z-index: -2;
  inset: -20% -26%;
  background: radial-gradient(ellipse, #ffd05b 12%, #ffa850a6 46%, transparent 69%),
    repeating-conic-gradient(from 3deg, #ffd68685 0deg 8deg, transparent 15deg 36deg);
  mask-image: radial-gradient(ellipse, #000 30%, #000a 53%, transparent 72%);
}

#sheet[data-kind="wheel-result"] .sheet-inner::after {
  z-index: -1;
  inset: 0;
  border: 1px solid #fff6c8;
  border-radius: 26px;
  background: radial-gradient(ellipse 90% 53% at 50% 0%, #ffd47e, transparent),
    linear-gradient(#fff0cf, #fffaf0 83%);
  box-shadow: inset 0 0 0 3px #fff9e771, 0 14px 34px #38160469;
}

#sheet[data-kind="wheel-result"] .sheet-art { height: 88px; }
#sheet[data-kind="wheel-result"] .sheet-art img { width: 76px; height: 76px; }
#sheet.result-sheet[data-kind="wheel-result"] .sheet-head { margin: 4px 0 12px; }
#sheet[data-kind="wheel-result"] .result-actions .button-earn { font-size: 16px; }

@media (prefers-reduced-motion: no-preference) {
  #sheet[data-kind="wheel"][open]::backdrop { animation: wheel-backdrop-in 260ms ease-out both; }
  #sheet[data-kind="wheel"][open] #sheet-title,
  #sheet[data-kind="wheel"][open] .close-btn { animation: wheel-fade-in 290ms ease-out both; }
  #sheet[data-kind="wheel"][open] .wheel-effects::before { animation: wheel-light-in 950ms ease-out both; }
  #sheet[data-kind="wheel"][open] .wheel-stage { animation: wheel-stage-in 480ms cubic-bezier(.22,.75,.35,1) both; }
  #sheet[data-kind="wheel"][open] .wheel-button { animation: wheel-fade-in 260ms ease-out 150ms both; }
  .wheel-tap i { animation: wheel-hand 3.2s ease-in-out .65s infinite; }
  .wheel-tap::before { animation: wheel-ripple 3.2s ease-out .65s infinite; }
  .wheel-landed .wheel-pointer { animation: wheel-pointer-land 280ms ease-out; }
  .wheel-landed .wheel-hub { animation: wheel-coin-land 410ms ease-out; }
  .wheel-slot--winner { animation: wheel-prize-land 420ms ease-out both; }
  #sheet.result-sheet[data-kind="wheel-result"][open]:not([data-closing]) .sheet-inner {
    animation: wheel-stage-in 360ms cubic-bezier(.22,.75,.35,1) both;
  }
  #sheet[data-kind="wheel-result"][open] .sheet-inner::before {
    animation: wheel-light-in 650ms ease-out both;
  }
  #sheet:is([data-kind="wheel"], [data-kind="wheel-result"])[data-closing] .sheet-inner {
    animation: wheel-out 160ms ease-in both;
  }
  #sheet:is([data-kind="wheel"], [data-kind="wheel-result"])[data-closing]:not([data-closing="wheel-result"])::backdrop {
    animation: wheel-backdrop-out 160ms ease-in both;
  }
}

@keyframes wheel-fade-in { from { opacity: 0; } }
@keyframes wheel-backdrop-in { from { opacity: .45; } }
@keyframes wheel-backdrop-out { to { opacity: 0; } }
@keyframes wheel-light-in {
  from { opacity: 0; scale: .67; }
  52% { opacity: 1; scale: 1.09; }
  to { opacity: .82; scale: 1; }
}
@keyframes wheel-stage-in {
  from { opacity: 0; transform: translateY(12px) scale(.85); }
  67% { opacity: 1; transform: translateY(-2px) scale(1.035); }
  to { opacity: 1; transform: none; }
}
@keyframes wheel-hand {
  0%, 19%, 100% { translate: 0 0; }
  8% { translate: -5% -9%; }
}
@keyframes wheel-ripple {
  0%, 100% { opacity: .8; scale: 1; }
  8% { opacity: 1; scale: .78; }
  24% { opacity: .6; scale: 1.12; }
  30% { opacity: .8; scale: 1; }
}
@keyframes wheel-pointer-land {
  32% { rotate: -7deg; }
  68% { rotate: 3deg; }
}
@keyframes wheel-coin-land {
  34% { scale: 1.11; }
  70% { scale: .98; }
}
@keyframes wheel-prize-land {
  38% { scale: 1.12; }
  100% { scale: 1; }
}
@keyframes wheel-out { to { opacity: 0; transform: scale(.97); } }
