:root {
  --lottery-wheel-accent: #c9973d;
  --lottery-wheel-accent-dark: #8a601e;
  --lottery-wheel-ink: #1f1d1a;
  --lottery-wheel-muted: #716c65;
  --lottery-wheel-surface: #fffdf8;
  --lottery-wheel-border: rgba(54, 43, 29, 0.15);
}

html.lottery-wheel-modal-open {
  overflow: hidden;
}

body.lottery-wheel-modal-open {
  overflow: hidden;
}

.lottery-wheel {
  box-sizing: border-box;
  width: 100%;
  color: var(--lottery-wheel-ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Arial, sans-serif;
}

/* Triggerless H5 mode must not add a section, gap, or inline placeholder. */
.lottery-wheel--triggerless,
.lottery-wheel[data-lottery-wheel-host="auto"] {
  position: fixed !important;
  z-index: 0;
  width: 0 !important;
  min-width: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  border: 0 !important;
  pointer-events: none;
}

.lottery-wheel--triggerless .lottery-wheel__open,
.lottery-wheel[data-lottery-wheel-host="auto"] .lottery-wheel__open {
  display: none !important;
}

.lottery-wheel__open {
  min-height: 48px;
  padding: 11px 24px;
  border: 0;
  border-radius: 4px;
  background: var(--lottery-wheel-accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: background-color 160ms ease, transform 160ms ease;
}

.lottery-wheel__open:hover {
  background: var(--lottery-wheel-accent-dark);
  transform: translateY(-1px);
}

.lottery-wheel__open:focus-visible,
.lottery-wheel__close:focus-visible,
.lottery-wheel__spin:focus-visible {
  outline: 3px solid rgba(201, 151, 61, 0.42);
  outline-offset: 3px;
}

.lottery-wheel__modal {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  overflow: auto;
  place-items: center;
  padding: clamp(14px, 3vw, 30px);
  background: rgba(20, 16, 10, 0.68);
  pointer-events: auto;
}

.lottery-wheel__modal[hidden] {
  display: none;
}

.lottery-wheel__dialog {
  position: relative;
  box-sizing: border-box;
  width: min(100%, 640px);
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: clamp(20px, 4vw, 36px);
  border: 1px solid var(--lottery-wheel-border);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0%, rgba(201, 151, 61, 0.11), transparent 48%),
    var(--lottery-wheel-surface);
  text-align: center;
  box-shadow: 0 16px 38px rgba(19, 14, 7, 0.3);
}

.lottery-wheel__close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--lottery-wheel-muted);
  cursor: pointer;
  font: 400 28px/1 Arial, sans-serif;
}

.lottery-wheel__close:hover {
  background: rgba(54, 43, 29, 0.08);
  color: var(--lottery-wheel-ink);
}

.lottery-wheel__heading {
  margin: 0 0 7px;
  color: var(--lottery-wheel-accent-dark);
  font-size: clamp(1.25rem, 3vw, 1.8rem);
  font-weight: 700;
  line-height: 1.25;
}

.lottery-wheel__subheading {
  min-height: 1.5em;
  margin: 0 0 22px;
  color: var(--lottery-wheel-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.lottery-wheel__description {
  margin: -10px 0 18px;
  color: var(--lottery-wheel-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.lottery-wheel__stage {
  position: relative;
  width: min(100%, 510px);
  margin: 0 auto;
  aspect-ratio: 1;
}

.lottery-wheel__canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  filter: drop-shadow(0 12px 13px rgba(33, 23, 8, 0.16));
}

.lottery-wheel__pointer {
  position: absolute;
  z-index: 2;
  top: -5px;
  left: 50%;
  width: 0;
  height: 0;
  border-right: 14px solid transparent;
  border-left: 14px solid transparent;
  border-top: 30px solid #b5322d;
  transform: translateX(-50%);
  filter: drop-shadow(0 3px 2px rgba(57, 27, 19, 0.24));
}

.lottery-wheel__hub {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 19%;
  aspect-ratio: 1;
  border: 6px solid #fff8e7;
  border-radius: 50%;
  background: var(--lottery-wheel-accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 0 var(--lottery-wheel-accent-dark), 0 7px 16px rgba(62, 39, 10, 0.26);
}

.lottery-wheel__hub::after {
  position: absolute;
  inset: 25%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  content: "";
}

.lottery-wheel__hub-button::after {
  display: none;
}

.lottery-wheel__modal--aipha .lottery-wheel__stage {
  overflow: visible;
}

.lottery-wheel__modal--aipha .lottery-wheel__hub-button {
  background: #6745e8;
  box-shadow: 0 3px 0 #4225af, 0 8px 18px rgba(68, 42, 175, 0.34);
}

.lottery-wheel__led-ring {
  position: absolute;
  z-index: 3;
  inset: -5px;
  pointer-events: none;
}

.lottery-wheel__led {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  margin: -3.5px;
  border-radius: 50%;
  background: #ffd866;
  box-shadow: 0 0 8px rgba(255, 216, 102, 0.9);
  transform: rotate(var(--led-angle)) translateY(-149px);
  transform-origin: center;
}

.lottery-wheel__modal--aipha .lottery-wheel__description {
  margin: -7px 0 12px;
  color: #716a87;
  font-size: 0.78rem;
}

.lottery-wheel__controls {
  display: grid;
  gap: 11px;
  margin-top: 23px;
}

.lottery-wheel__spin {
  min-height: 48px;
  padding: 11px 22px;
  border: 0;
  border-radius: 4px;
  background: var(--lottery-wheel-accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: background-color 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.lottery-wheel__spin:hover:not(:disabled) {
  background: var(--lottery-wheel-accent-dark);
  transform: translateY(-1px);
}

.lottery-wheel__spin:disabled {
  cursor: wait;
  opacity: 0.68;
}

.lottery-wheel__result {
  min-height: 1.75em;
  margin: 0;
  color: var(--lottery-wheel-accent-dark);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.5;
}

.lottery-wheel__legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 7px 12px;
  max-height: none;
  overflow: visible;
  margin: 22px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--lottery-wheel-border);
  color: var(--lottery-wheel-muted);
  font-size: 0.8rem;
  list-style: none;
  text-align: left;
}

.lottery-wheel__legend li {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.lottery-wheel__legend li span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.lottery-wheel__legend-swatch {
  flex: 0 0 11px;
  width: 11px;
  height: 11px;
  border: 1px solid rgba(54, 43, 29, 0.2);
  border-radius: 50%;
}

/* H5/mobile presentation: use the full viewport while preserving safe areas. */
@media (max-width: 640px) {
  .lottery-wheel__open {
    width: min(100%, 360px);
  }

  .lottery-wheel__modal {
    align-items: stretch;
    padding: 0;
  }

  .lottery-wheel__dialog {
    width: 100%;
    max-height: 100dvh;
    min-height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: calc(48px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
  }

  .lottery-wheel__close {
    top: calc(10px + env(safe-area-inset-top));
    right: 12px;
  }

  .lottery-wheel__stage {
    width: min(100%, 360px);
  }

  .lottery-wheel__legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 18px;
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lottery-wheel__open,
  .lottery-wheel__spin {
    transition: none;
  }
}

/* Aipha-style H5 modal: transparent centered wrapper, compact wheel, no page slot. */
.lottery-wheel--aipha[data-lottery-wheel-host="auto"] {
  width: 0 !important;
  height: 0 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
}

.lottery-wheel__modal--aipha {
  position: fixed;
  z-index: 900;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(3px);
  overflow: visible;
}

.lottery-wheel__dialog--aipha {
  position: relative;
  display: flex;
  box-sizing: border-box;
  width: 324px;
  height: 432px;
  max-width: calc(100vw - 24px);
  flex-direction: column;
  align-items: center;
  padding: 20px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  box-shadow: none;
  overflow: visible;
}

.lottery-wheel--aipha .lottery-wheel__heading,
.lottery-wheel--aipha .lottery-wheel__subheading,
.lottery-wheel--aipha .lottery-wheel__description {
  position: relative;
  z-index: 5;
  width: 300px;
  max-width: 100%;
  margin: 0;
  color: #fff;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .4);
}

.lottery-wheel--aipha .lottery-wheel__heading {
  min-height: 24px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 800;
}

.lottery-wheel--aipha .lottery-wheel__subheading {
  min-height: 28px;
  color: #ffe500;
  font-size: 18px;
  line-height: 28px;
  font-weight: 900;
}

.lottery-wheel--aipha .lottery-wheel__description {
  min-height: 24px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 24px;
  font-weight: 700;
}

.lottery-wheel--aipha .lottery-wheel__stage--aipha {
  position: relative;
  width: 300px;
  height: 300px;
  min-height: 300px;
  flex: 0 0 300px;
  margin: 0 auto;
  aspect-ratio: auto;
  filter: drop-shadow(0 8px 22px rgba(110, 128, 255, .45));
}

/* Fixed top pointer: the wheel rotates underneath this marker. */
.lottery-wheel__modal--aipha .lottery-wheel__pointer {
  display: block;
  z-index: 8;
  top: -3px;
  left: 50%;
  border-right: 14px solid transparent;
  border-left: 14px solid transparent;
  border-top: 28px solid #e64747;
  transform: translateX(-50%);
  filter: drop-shadow(0 2px 2px rgba(70, 15, 15, .4));
}

.lottery-wheel--aipha .lottery-wheel__canvas {
  width: 300px;
  height: 300px;
  border-radius: 50%;
}

.lottery-wheel--aipha .lottery-wheel__pointer {
  display: block;
}

.lottery-wheel--aipha .lottery-wheel__hub-button {
  z-index: 6;
  display: grid;
  width: 92px;
  height: 105px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #8154ff 0 42%, #4c1bd4 44% 72%, #251078 74% 100%);
  color: #fff;
  cursor: pointer;
  font: 900 20px/1 Arial, sans-serif;
  white-space: nowrap;
  text-shadow: 0 2px 2px rgba(0,0,0,.35);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 5px rgba(255,255,255,.9), 0 0 0 10px rgba(117, 91, 255, .8), 0 4px 12px rgba(24, 5, 99, .55);
}

.lottery-wheel--aipha .lottery-wheel__hub-button:focus-visible {
  outline: 3px solid #ffe500;
  outline-offset: 5px;
}

.lottery-wheel--aipha .lottery-wheel__hub-button:disabled {
  cursor: wait;
  opacity: .75;
}

.lottery-wheel--aipha .lottery-wheel__led-ring {
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
}

.lottery-wheel--aipha .lottery-wheel__led {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px #fff, 0 0 14px rgba(255,255,255,.85);
  transform: rotate(var(--led-angle)) translateY(-137px);
  animation: lottery-led-flash .7s step-end infinite;
}

.lottery-wheel--aipha .lottery-wheel__led:nth-child(even) { animation-delay: .35s; }
.lottery-wheel--aipha .lottery-wheel__stage--aipha.is-spinning .lottery-wheel__led { animation-duration: .28s; }
.lottery-wheel--aipha .lottery-wheel__stage--aipha.is-spinning .lottery-wheel__led:nth-child(even) { animation-delay: .14s; }

@keyframes lottery-led-flash {
  0%, 49% { opacity: 1; box-shadow: 0 0 8px #fff, 0 0 14px rgba(255,255,255,.85); }
  50%, 100% { opacity: .35; box-shadow: none; }
}

.lottery-wheel--aipha .lottery-wheel__controls,
.lottery-wheel--aipha .lottery-wheel__legend {
  display: none !important;
}

/* Keep the live result line while removing the secondary spin button. */
.lottery-wheel--aipha .lottery-wheel__controls {
  display: block !important;
  width: 100%;
  margin: 0;
}

.lottery-wheel--aipha .lottery-wheel__controls .lottery-wheel__spin {
  display: none !important;
}

.lottery-wheel--aipha .lottery-wheel__result {
  position: relative;
  z-index: 5;
  min-height: 24px;
  margin: 10px 0 0;
  color: #fff;
  font-size: 15px;
  line-height: 24px;
  text-shadow: 0 1px 4px rgba(0,0,0,.45);
}

.lottery-wheel--aipha .lottery-wheel__close {
  z-index: 20;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  color: #34218f;
  font-size: 22px;
  box-shadow: 0 1px 4px rgba(43, 26, 107, .18);
}

.lottery-wheel--aipha .lottery-wheel__close:hover { background: #fff; color: #251078; }

@media (max-width: 640px) {
  .lottery-wheel__modal--aipha { padding: 0 12px; }
}

/* Override the legacy Aipha card rules above with the transparent reference layout. */
.lottery-wheel__modal--aipha .lottery-wheel__dialog--aipha {
  width: 324px;
  height: 432px;
  max-width: calc(100vw - 24px);
  min-height: 0;
  max-height: none;
  padding: 20px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.lottery-wheel__modal--aipha .lottery-wheel__heading {
  color: #fff;
  font-size: 16px;
  line-height: 24px;
}

.lottery-wheel__modal--aipha .lottery-wheel__subheading {
  color: #ffe500;
  font-size: 18px;
  line-height: 28px;
}

.lottery-wheel__modal--aipha .lottery-wheel__description {
  color: #fff;
  font-size: 14px;
  line-height: 24px;
}

.lottery-wheel__modal--aipha .lottery-wheel__stage--aipha {
  width: 300px;
  height: 300px;
  min-height: 300px;
  flex: 0 0 300px;
  margin: 0 auto;
}

.lottery-wheel__modal--aipha .lottery-wheel__close {
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  color: #fff;
}
