:root {
  --ink: #3b3552;
  --muted: #746f86;
  --cream: #fff8e8;
  --card: rgba(255, 255, 255, 0.88);
  --yellow: #ffd84d;
  --pink: #ff6f91;
  --blue: #58b8f7;
  --green: #64cf9b;
  --purple: #9a82ec;
  --orange: #ff9c4a;
  --wheel-size: clamp(282px, 82vw, 376px);
  --label-offset: clamp(-141px, -30.7vw, -106px);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: #fff6da;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #fff6da;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 216, 77, 0.38) 0 5px, transparent 6px),
    radial-gradient(circle at 88% 16%, rgba(88, 184, 247, 0.24) 0 7px, transparent 8px),
    radial-gradient(circle at 8% 54%, rgba(255, 111, 145, 0.2) 0 6px, transparent 7px),
    radial-gradient(circle at 92% 65%, rgba(100, 207, 155, 0.22) 0 8px, transparent 9px),
    linear-gradient(180deg, #fff7dd 0%, #fffdf8 52%, #fff6e5 100%);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 4px solid rgba(65, 91, 202, 0.35);
  outline-offset: 3px;
}

.app {
  width: min(100%, 480px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.page-header {
  position: relative;
  z-index: 1;
  text-align: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 216, 77, 0.38);
  color: #9c651a;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.eyebrow span {
  color: #ff9c4a;
}

h1 {
  margin: 9px 0 4px;
  font-size: clamp(27px, 7vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.04em;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.game-card {
  position: relative;
  margin-top: 16px;
  padding: 12px 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 30px;
  background: var(--card);
  box-shadow: 0 20px 60px rgba(121, 91, 33, 0.13);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sound-row {
  display: flex;
  justify-content: flex-end;
  min-height: 30px;
  padding-right: 4px;
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 5px 10px;
  border: 0;
  border-radius: 999px;
  background: #f4f0fb;
  color: #665f77;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.wheel-stage {
  position: relative;
  width: var(--wheel-size);
  height: calc(var(--wheel-size) + 18px);
  margin: -4px auto 4px;
  padding-top: 18px;
}

.pointer {
  position: absolute;
  z-index: 6;
  top: 0;
  left: 50%;
  width: 46px;
  height: 64px;
  transform: translateX(-50%);
  filter: drop-shadow(0 5px 3px rgba(99, 43, 51, 0.24));
  pointer-events: none;
}

.pointer::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 5px;
  width: 36px;
  height: 48px;
  border-radius: 18px 18px 13px 13px;
  background: linear-gradient(145deg, #ff7a8e, #f44366);
  clip-path: polygon(50% 100%, 0 31%, 7% 13%, 22% 2%, 78% 2%, 93% 13%, 100% 31%);
}

.pointer-dot {
  position: absolute;
  z-index: 1;
  top: 9px;
  left: 16px;
  width: 14px;
  height: 14px;
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  background: #ffced7;
}

.wheel-button {
  display: block;
  width: var(--wheel-size);
  height: var(--wheel-size);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.wheel-button:active:not(:disabled) {
  transform: scale(0.985);
}

.wheel-button:disabled {
  cursor: default;
}

.wheel {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border: 9px solid #fffdf5;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 12px 0 #e8c785,
    0 18px 30px rgba(77, 54, 30, 0.24),
    inset 0 0 0 3px rgba(77, 54, 30, 0.11);
  overflow: hidden;
  transform: rotate(0deg);
  transition-property: transform;
  transition-timing-function: cubic-bezier(0.13, 0.72, 0.13, 1);
  will-change: transform;
}

.wheel.is-spinning {
  box-shadow:
    0 12px 0 #e8c785,
    0 22px 36px rgba(77, 54, 30, 0.28),
    0 0 0 6px rgba(255, 216, 77, 0.13),
    inset 0 0 0 3px rgba(77, 54, 30, 0.11);
}

.outer-wheel {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    repeating-conic-gradient(from -22.5deg, transparent 0 44deg, rgba(255, 255, 255, 0.8) 44deg 45deg),
    conic-gradient(
      from -22.5deg,
      #ffd84d 0 12.5%,
      #ff8379 12.5% 25%,
      #65c7f2 25% 37.5%,
      #7dd99f 37.5% 50%,
      #b494ef 50% 62.5%,
      #ffae58 62.5% 75%,
      #f784b7 75% 87.5%,
      #5ed0c6 87.5% 100%
    );
}

.outer-wheel::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
}

.number-label {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  margin: -21px;
  color: #fff;
  font-size: clamp(25px, 7vw, 34px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(71, 55, 59, 0.25);
  transform: rotate(var(--angle)) translateY(var(--label-offset)) rotate(calc(-1 * var(--angle)));
}

.inner-wheel {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  display: block;
  width: clamp(122px, 36vw, 164px);
  height: clamp(122px, 36vw, 164px);
  border: 7px solid #fffdf8;
  border-radius: 50%;
  background:
    linear-gradient(180deg, transparent calc(50% - 1px), rgba(255, 255, 255, 0.8) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    conic-gradient(from -90deg, #61c98d 0 50%, #f26783 50% 100%);
  box-shadow:
    0 7px 13px rgba(67, 46, 48, 0.2),
    inset 0 0 0 2px rgba(54, 48, 78, 0.12);
  transform: translate(-50%, -50%);
  overflow: hidden;
}

.choice-label {
  position: absolute;
  left: 50%;
  z-index: 2;
  color: #fff;
  font-size: clamp(17px, 5vw, 23px);
  font-weight: 900;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 0 rgba(56, 43, 50, 0.2);
  transform: translate(-50%, -50%);
}

.choice-label--yes {
  top: 27%;
}

.choice-label--no {
  top: 73%;
}

.hub {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  border: 5px solid #fff;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 2px 5px rgba(67, 46, 48, 0.28);
  transform: translate(-50%, -50%);
}

.spin-button,
.modal-again {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: min(80%, 320px);
  min-height: 54px;
  margin: 0 auto;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #ff6f91 0%, #f15178 100%);
  box-shadow: 0 7px 0 #ca355b, 0 12px 22px rgba(216, 58, 96, 0.22);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  touch-action: manipulation;
}

.spin-button:active:not(:disabled),
.modal-again:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #ca355b, 0 8px 16px rgba(216, 58, 96, 0.2);
}

.spin-button:disabled {
  background: linear-gradient(180deg, #b9b3c5, #9f98ad);
  box-shadow: 0 5px 0 #7f788d;
  cursor: default;
}

.button-star {
  font-size: 22px;
}

.tap-tip {
  margin: 10px 0 14px;
  color: #8c8699;
  font-size: 12px;
  text-align: center;
}

.result-card {
  margin: 0 6px;
  padding: 13px 16px;
  border: 1px solid #efe7d9;
  border-radius: 20px;
  background: #fffdf9;
}

.result-title {
  margin-bottom: 7px;
  color: #8a8296;
  font-size: 12px;
  font-weight: 800;
}

.result-placeholder {
  padding: 5px 0;
  color: #aaa4b2;
  font-size: 13px;
  text-align: center;
}

.result-values {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 13px;
  align-items: center;
}

.result-values[hidden] {
  display: none;
}

.result-values > div {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.result-label {
  color: #827b8e;
  font-size: 13px;
}

.result-values strong {
  color: #e64f74;
  font-size: 24px;
  line-height: 1;
}

.result-divider {
  width: 1px;
  height: 31px;
  background: #eee6df;
}

.history {
  margin: 18px 8px 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading h2 {
  margin: 0;
  font-size: 14px;
}

.section-heading button {
  padding: 5px 7px;
  border: 0;
  background: transparent;
  color: #9a93a5;
  font-size: 12px;
  cursor: pointer;
}

.history ol {
  display: grid;
  gap: 7px;
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
}

.history li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  border-radius: 12px;
  background: #f7f4fb;
  color: #716a7d;
  font-size: 13px;
}

.history li:first-child {
  background: #fff0f3;
  color: #aa3d59;
  font-weight: 700;
}

.history-index {
  color: #aaa3b4;
  font-size: 11px;
}

footer {
  padding: 16px 0 0;
  color: #aaa083;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-align: center;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(51, 43, 64, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 340px);
  padding: 26px 22px 22px;
  border: 4px solid #fff;
  border-radius: 28px;
  background: linear-gradient(180deg, #fff9dc, #fff 38%);
  box-shadow: 0 24px 60px rgba(38, 28, 46, 0.3);
  text-align: center;
  animation: pop-in 0.25s ease-out both;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #f1edf4;
  color: #7d7585;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.celebration {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 8px;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 5px 0 #e6b62e;
  color: #fff;
  font-size: 28px;
  transform: rotate(-8deg);
}

.modal-kicker {
  margin: 14px 0 2px;
  color: #9b7690;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.modal-panel h2 {
  margin: 0 0 16px;
  font-size: 25px;
}

.modal-results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.modal-results > div {
  display: flex;
  min-height: 92px;
  flex-direction: column;
  justify-content: center;
  border-radius: 18px;
  background: #f8f3fa;
}

.modal-results span {
  color: #847c8c;
  font-size: 12px;
}

.modal-results strong {
  margin-top: 5px;
  color: #e94d75;
  font-size: 32px;
  line-height: 1;
}

.modal-again {
  width: 100%;
  min-height: 49px;
  font-size: 16px;
}

body.modal-open {
  overflow: hidden;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-height: 720px) and (orientation: portrait) {
  :root {
    --wheel-size: clamp(268px, 76vw, 326px);
    --label-offset: clamp(-122px, -28.5vw, -100px);
  }

  .app {
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .game-card {
    margin-top: 10px;
  }

  .wheel-stage {
    margin-top: -7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }

  .wheel {
    transition-duration: 0.7s !important;
  }

  .modal-panel {
    animation: none;
  }
}
