:root {
  --bg: #061125;
  --panel: rgba(10, 29, 55, 0.76);
  --panel-border: rgba(123, 199, 255, 0.16);
  --text: #f7fbff;
  --muted: #90a9c8;
  --cyan: #25e6ff;
  --blue: #4285ff;
  --purple: #8c5cff;
  --pink: #ff4fd8;
  --gold: #ffd65a;
  --radius: 22px;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 34%, rgba(38, 98, 184, .22), transparent 32%),
    linear-gradient(145deg, #040c1c 0%, #07162d 48%, #060d1c 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .25;
  background-image:
    linear-gradient(rgba(65, 135, 210, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(65, 135, 210, .08) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black, transparent 85%);
}

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

.ambient {
  position: fixed;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .16;
  pointer-events: none;
}
.ambient-one { background: var(--purple); left: -180px; top: 15%; }
.ambient-two { background: var(--cyan); right: -180px; bottom: 8%; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
  z-index: 1;
}

.topbar {
  min-height: 88px;
  padding: 16px clamp(20px, 3vw, 54px);
  display: flex;
  align-items: center;
  gap: 15px;
  border-bottom: 1px solid rgba(118, 183, 255, .13);
  background: rgba(4, 13, 29, .6);
  backdrop-filter: blur(18px);
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--cyan), var(--blue) 48%, var(--purple));
  box-shadow: 0 0 28px rgba(37, 230, 255, .27), inset 0 1px rgba(255,255,255,.5);
  color: #041022;
  font-weight: 950;
  letter-spacing: -1px;
  transform: rotate(-4deg);
}

.brand-mark span { transform: rotate(4deg); }
.title-group { min-width: 0; }
.eyebrow { margin: 0 0 2px; color: #68dff0; font-size: 12px; letter-spacing: .08em; }
h1 { margin: 0; font-size: clamp(22px, 2vw, 32px); line-height: 1.15; letter-spacing: .04em; }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.sound-toggle {
  min-height: 44px;
  padding: 0 15px;
  border-radius: 13px;
  color: #dceaff;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,.045);
  cursor: pointer;
}
.sound-toggle[aria-pressed="false"] { color: var(--muted); }

.button {
  min-height: 46px;
  border-radius: 13px;
  padding: 0 19px;
  color: var(--text);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
  transition: transform .18s ease, filter .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.button:active { transform: translateY(1px) scale(.99); }
.button:focus-visible, .sound-toggle:focus-visible, .start-button:focus-visible { outline: 3px solid rgba(37,230,255,.42); outline-offset: 3px; }
.button-secondary { background: linear-gradient(135deg, #00bddb, #3978f8); box-shadow: 0 7px 22px rgba(33, 132, 243, .25); }
.button-outline { width: 100%; background: rgba(255,255,255,.035); border-color: rgba(134, 190, 247, .18); }
.danger-soft { color: #ffc1cf; border-color: rgba(255,91,133,.18); }

.main-layout {
  width: min(1740px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 2vw, 32px) clamp(18px, 3vw, 54px) 12px;
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(480px, 1fr) minmax(230px, 280px);
  gap: clamp(16px, 2vw, 32px);
  align-items: center;
}

.side-panel {
  padding: 22px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(15, 39, 72, .77), rgba(7, 23, 45, .69));
  box-shadow: 0 22px 70px rgba(0,0,0,.2), inset 0 1px rgba(255,255,255,.04);
  backdrop-filter: blur(18px);
}

.panel-heading { display: flex; gap: 12px; align-items: center; margin-bottom: 19px; }
.panel-heading p, .panel-heading strong { margin: 0; display: block; }
.panel-heading p { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.panel-icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: #ffd8f8; font-weight: 900; background: rgba(255,79,216,.14); border: 1px solid rgba(255,79,216,.2);
}
.panel-icon.cyan { color: #c4fbff; background: rgba(37,230,255,.12); border-color: rgba(37,230,255,.2); }

.count-card {
  min-height: 112px;
  padding: 17px 18px;
  border-radius: 17px;
  background: radial-gradient(circle at 85% 20%, rgba(140,92,255,.24), transparent 40%), rgba(94, 88, 220, .11);
  border: 1px solid rgba(147, 115, 255, .2);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.count-card > span { color: #b8c6df; font-size: 13px; }
.count-card strong { font-size: 43px; line-height: 1.1; margin-top: 5px; background: linear-gradient(90deg, #fff, #a8dbff); color: transparent; background-clip: text; }
.count-card small { font-size: 15px; color: #b8c6df; }
.sample-notice { font-size: 12px; line-height: 1.55; color: #ffc8e9; margin: 15px 0; }
.sample-notice span { color: var(--pink); font-size: 9px; margin-right: 5px; }
.privacy-note { font-size: 11px; line-height: 1.55; color: #7891b2; margin: 15px 3px 0; }

.wheel-stage { min-width: 0; display: flex; flex-direction: column; align-items: center; }
.wheel-kicker { color: #70c6e8; font-size: 11px; letter-spacing: .13em; display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.wheel-kicker span { width: 28px; height: 1px; background: linear-gradient(90deg, transparent, #4bc4ee); }
.wheel-kicker span:last-child { transform: scaleX(-1); }

.wheel-wrap {
  position: relative;
  width: min(57vh, 600px, 100%);
  aspect-ratio: 1;
  filter: drop-shadow(0 26px 35px rgba(0,0,0,.34));
}

#wheelCanvas { width: 100%; height: 100%; display: block; }
.pointer { position: absolute; left: 50%; top: -6px; width: 62px; height: 88px; transform: translateX(-50%); z-index: 5; filter: drop-shadow(0 8px 11px rgba(0,0,0,.5)); }
.pointer-cap {
  position: absolute; left: 10px; top: 0; width: 42px; height: 31px; border-radius: 12px 12px 8px 8px;
  background: linear-gradient(155deg, #fff8bd, #ffda48 46%, #ff9e22); border: 3px solid rgba(255,255,255,.76);
  box-shadow: inset 0 -5px 9px rgba(190,87,0,.27), 0 0 22px rgba(255,205,55,.5);
}
.pointer-tip {
  position: absolute; left: 12px; top: 21px; width: 38px; height: 57px;
  background: linear-gradient(145deg, #fff5ae, #ffc72e 55%, #ff832e);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.wheel-hub {
  position: absolute; left: 50%; top: 50%; width: 112px; height: 112px; transform: translate(-50%,-50%);
  border-radius: 50%; z-index: 4; display: flex; flex-direction: column; justify-content: center; align-items: center;
  background: radial-gradient(circle at 35% 28%, #ffffff, #d8f2ff 17%, #4a8eff 45%, #4025a3 73%, #140b4d 100%);
  border: 5px solid rgba(221,245,255,.9); box-shadow: 0 0 0 8px rgba(38,27,112,.7), 0 0 28px rgba(91,169,255,.75), inset 0 -10px 22px rgba(27,10,99,.52);
  text-shadow: 0 2px 5px rgba(0,0,0,.5);
}
.hub-star { font-size: 22px; line-height: .8; color: #fff5a9; }
.wheel-hub b { font-size: 17px; letter-spacing: .1em; }
.wheel-hub small { font-size: 10px; opacity: .9; margin-top: 2px; }

.primary-area { width: min(440px, 92%); margin-top: 10px; }
.start-button {
  width: 100%; min-height: 75px; border: 1px solid rgba(137,244,255,.64); border-radius: 21px; cursor: pointer;
  color: white; background: linear-gradient(110deg, #6843e9, #326ff5 48%, #06bfcf);
  box-shadow: 0 14px 38px rgba(62,96,239,.34), inset 0 1px rgba(255,255,255,.35), 0 0 0 5px rgba(64,118,245,.08);
  display: grid; grid-template-columns: 48px 1fr; grid-template-rows: 1fr 1fr; align-items: end; padding: 13px 25px;
  transition: transform .2s ease, filter .2s ease, box-shadow .2s ease;
}
.start-button:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 18px 42px rgba(62,96,239,.44), inset 0 1px rgba(255,255,255,.35); }
.start-button:active { transform: translateY(1px) scale(.99); }
.start-button.is-spinning { background: linear-gradient(110deg, #ff8a34, #ff4f7e 55%, #d440c8); border-color: rgba(255,218,173,.8); box-shadow: 0 14px 38px rgba(255,73,125,.34); }
.start-button:disabled { cursor: wait; filter: saturate(.7); }
.start-icon { grid-row: 1 / 3; align-self: center; font-size: 24px; }
#startButtonText { font-size: 21px; font-weight: 900; align-self: end; line-height: 1.2; }
.start-button small { align-self: start; font-size: 11px; opacity: .75; margin-top: 2px; }

.progress-track { height: 7px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; margin: -4px 0 20px; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--purple), var(--cyan)); border-radius: inherit; transition: width .35s ease; }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 16px 0; border-top: 1px solid rgba(255,255,255,.06); border-bottom: 1px solid rgba(255,255,255,.06); cursor: pointer; margin-bottom: 15px; }
.switch-row > span { flex: 1; }
.switch-row strong, .switch-row small { display: block; }
.switch-row strong { font-size: 14px; margin-bottom: 4px; }
.switch-row small { color: var(--muted); font-size: 11px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row i { width: 48px; height: 27px; border-radius: 99px; background: #263b57; position: relative; transition: .2s ease; box-shadow: inset 0 2px 6px rgba(0,0,0,.25); }
.switch-row i::after { content: ""; position: absolute; width: 21px; height: 21px; left: 3px; top: 3px; border-radius: 50%; background: white; transition: .2s ease; box-shadow: 0 2px 7px rgba(0,0,0,.35); }
.switch-row input:checked + i { background: linear-gradient(90deg, var(--purple), var(--cyan)); }
.switch-row input:checked + i::after { transform: translateX(21px); }
.switch-row input:focus-visible + i { outline: 3px solid rgba(37,230,255,.35); outline-offset: 3px; }
.recent-box { margin-top: 16px; padding: 14px; border-radius: 14px; background: rgba(37,230,255,.05); border: 1px solid rgba(37,230,255,.09); }
.recent-box span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.recent-box strong { color: #baf8ff; font-size: 16px; overflow-wrap: anywhere; }

footer { min-height: 48px; padding: 10px 4vw 14px; display: flex; justify-content: center; align-items: center; gap: 18px; color: #64809f; font-size: 11px; letter-spacing: .04em; }
footer p { margin: 0; }
footer span { font-size: 9px; letter-spacing: .18em; color: #415b79; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  background: rgba(2,8,20,.82); backdrop-filter: blur(16px); animation: fadeIn .28s ease;
}
.modal-backdrop[hidden] { display: none; }
.result-card {
  width: min(690px, 94vw); min-height: 470px; padding: 70px 36px 38px; position: relative; overflow: hidden;
  border: 1px solid rgba(156,231,255,.43); border-radius: 34px; text-align: center;
  background: radial-gradient(circle at 50% 0%, rgba(84,136,255,.35), transparent 42%), linear-gradient(145deg, #10294e, #0b1534 58%, #231453);
  box-shadow: 0 0 80px rgba(50,112,255,.4), inset 0 1px rgba(255,255,255,.14);
  animation: resultPop .55s cubic-bezier(.18,.85,.2,1.18);
}
.result-card::before { content: ""; position: absolute; inset: 9px; border: 1px solid rgba(255,255,255,.08); border-radius: 27px; pointer-events: none; }
.crown { width: 70px; height: 70px; display: grid; place-items: center; position: absolute; left: 50%; top: 25px; transform: translateX(-50%); border-radius: 50%; font-size: 39px; color: #fff5a5; text-shadow: 0 0 24px #ffc845; background: rgba(255,213,90,.08); }
.result-label { margin: 28px 0 8px; color: #74eaff; font-size: 12px; letter-spacing: .16em; }
.result-card h2 { margin: 0; font-size: clamp(50px, 8vw, 90px); line-height: 1.3; background: linear-gradient(180deg, #fff, #d9f6ff 45%, #8ecaff); color: transparent; background-clip: text; filter: drop-shadow(0 5px 18px rgba(83,167,255,.32)); overflow-wrap: anywhere; }
.blessing { margin: 8px 0 36px; font-size: clamp(19px, 2.4vw, 27px); color: #ffdd82; font-weight: 700; }
.result-actions { display: flex; justify-content: center; gap: 13px; }
.result-actions .button { min-width: 150px; }
.result-actions .button-outline { width: auto; }
.result-orbit { position: absolute; border: 1px solid rgba(90,218,255,.17); border-radius: 50%; pointer-events: none; }
.orbit-one { width: 520px; height: 520px; left: -300px; top: -190px; }
.orbit-two { width: 370px; height: 370px; right: -230px; bottom: -190px; border-color: rgba(255,93,218,.15); }
.confetti-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti { position: absolute; top: -20px; width: 9px; height: 18px; border-radius: 3px; animation: confettiFall var(--duration) linear forwards; transform: rotate(var(--rotate)); }

.toast {
  position: fixed; left: 50%; bottom: 30px; z-index: 80; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 13px 20px; max-width: min(88vw, 520px); text-align: center; border-radius: 13px; color: white;
  background: rgba(15,38,68,.94); border: 1px solid rgba(101,210,255,.28); box-shadow: 0 14px 40px rgba(0,0,0,.35);
  transition: .25s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { border-color: rgba(255,95,131,.4); color: #ffd6df; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes resultPop { from { opacity: 0; transform: translateY(35px) scale(.9); } }
@keyframes confettiFall { to { top: 110%; transform: translateX(var(--drift)) rotate(calc(var(--rotate) + 520deg)); } }

@media (max-width: 1180px) {
  .main-layout { grid-template-columns: 220px minmax(430px, 1fr) 220px; gap: 14px; padding-inline: 18px; }
  .side-panel { padding: 17px; }
  .wheel-wrap { width: min(54vh, 540px, 100%); }
}

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .main-layout { grid-template-columns: 1fr 1fr; align-items: start; }
  .wheel-stage { grid-column: 1 / -1; grid-row: 1; }
  .panel-left { grid-column: 1; }
  .panel-right { grid-column: 2; }
  .wheel-wrap { width: min(57vh, 520px, 88vw); }
}

@media (max-width: 620px) {
  .topbar { padding: 13px 15px; gap: 10px; }
  .brand-mark { width: 42px; height: 42px; }
  .eyebrow { font-size: 9px; }
  h1 { font-size: 19px; }
  .header-actions { width: 100%; }
  .header-actions > * { flex: 1; }
  .main-layout { grid-template-columns: 1fr; padding: 18px 14px; }
  .wheel-stage, .panel-left, .panel-right { grid-column: 1; }
  .panel-left { grid-row: 2; }
  .panel-right { grid-row: 3; }
  .wheel-wrap { width: min(92vw, 500px); }
  .pointer { transform: translateX(-50%) scale(.82); transform-origin: top; }
  .wheel-hub { transform: translate(-50%,-50%) scale(.78); }
  .start-button { min-height: 68px; }
  footer { flex-direction: column; gap: 4px; text-align: center; }
  .result-card { min-height: 420px; padding-inline: 19px; }
  .result-actions { flex-direction: column; }
  .result-actions .button { width: 100%; }
}

@media (max-height: 780px) and (min-width: 901px) {
  .topbar { min-height: 72px; padding-block: 10px; }
  .brand-mark { width: 42px; height: 42px; }
  .main-layout { padding-top: 12px; }
  .wheel-wrap { width: min(53vh, 500px, 100%); }
  .start-button { min-height: 65px; padding-block: 8px; }
  .side-panel { padding: 16px; }
  .count-card { min-height: 92px; }
  footer { min-height: 35px; padding-block: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
