:root {
  color-scheme: light;
  --canvas: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #ebeef2;
  --ink: #22201f;
  --muted: #686461;
  --line: #dfe2e6;
  --accent: #d94a32;
  --accent-strong: #9f2d1f;
  --accent-soft: #fde8e2;
  --shadow: 0 22px 70px rgba(69, 52, 46, 0.14);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
  overscroll-behavior-x: none;
  touch-action: pan-y;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 5%, rgba(217, 74, 50, 0.1), transparent 27rem),
    var(--canvas);
  -webkit-font-smoothing: antialiased;
  touch-action: pan-y;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

[hidden] {
  display: none !important;
}

.draw-app {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 20px max(30px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  font-size: 13px;
}

.event-mark {
  font-weight: 800;
  letter-spacing: 0.08em;
}

.gift-trigger {
  display: inline-flex;
  min-height: 36px;
  cursor: pointer;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(159, 45, 31, 0.16);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(69, 52, 46, 0.07);
  transition: border-color 150ms ease, transform 150ms ease, background 150ms ease;
}

.gift-trigger svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.gift-trigger:hover {
  border-color: rgba(159, 45, 31, 0.32);
  background: #ffffff;
}

.gift-trigger:active {
  transform: translateY(1px);
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 0 14px;
  text-align: center;
}

.hero-copy {
  width: 100%;
}

.scene-label {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 14ch;
  margin: 0 auto;
  font-size: clamp(32px, 8.5vw, 44px);
  line-height: 1.08;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.hero-subtitle {
  max-width: 28ch;
  margin: 11px auto 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.shake-stage {
  position: relative;
  display: grid;
  width: 240px;
  height: 240px;
  margin: 30px auto 18px;
  place-items: center;
}

.shake-stage::before,
.shake-stage::after {
  position: absolute;
  border: 1px solid rgba(217, 74, 50, 0.15);
  border-radius: 50%;
  content: "";
}

.shake-stage::before {
  inset: 17px;
}

.shake-stage::after {
  inset: 0;
}

.shake-orb {
  position: relative;
  z-index: 2;
  display: flex;
  width: 168px;
  height: 168px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent-strong);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 20px 46px rgba(159, 45, 31, 0.28);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.shake-orb:focus-visible,
.primary-action:focus-visible,
.text-action:focus-visible,
.gift-trigger:focus-visible,
.modal-close:focus-visible,
.modal-primary:focus-visible,
.modal-secondary:focus-visible {
  outline: 3px solid rgba(217, 74, 50, 0.38);
  outline-offset: 4px;
}

.shake-orb:active {
  transform: scale(0.97);
}

.orb-ring {
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
}

.orb-label {
  font-size: 66px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.08em;
}

.orb-caption {
  margin-top: 9px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0.82;
}

.motion-line {
  position: absolute;
  z-index: 1;
  width: 42px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0;
}

.motion-line-one {
  top: 69px;
  left: 0;
  transform: rotate(-22deg);
}

.motion-line-two {
  right: 0;
  bottom: 69px;
  transform: rotate(-22deg);
}

.shake-stage.is-ready .shake-orb {
  animation: ready-pulse 1.8s ease-in-out infinite;
}

.shake-stage.is-sensing .shake-orb {
  animation: physical-shake 190ms linear infinite;
}

.shake-stage.is-sensing .motion-line {
  animation: line-flash 520ms ease-in-out infinite alternate;
}

.shake-stage.is-drawing .shake-orb {
  animation: reveal-spin 850ms cubic-bezier(0.52, 0.05, 0.22, 1) infinite;
}

.shake-stage.is-result .shake-orb {
  transform: scale(0.86);
  box-shadow: 0 12px 28px rgba(159, 45, 31, 0.2);
}

.motion-meter {
  width: min(230px, 64vw);
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.meter-fill {
  display: block;
  width: calc(var(--level, 0) * 100%);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 90ms linear;
}

.state-copy {
  min-height: 76px;
  margin-top: 18px;
}

.state-copy h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.state-copy p {
  max-width: 34ch;
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.primary-action {
  width: min(100%, 320px);
  min-height: 52px;
  margin-top: 16px;
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  color: #ffffff;
  background: var(--accent-strong);
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(159, 45, 31, 0.2);
  transition: transform 150ms ease, opacity 150ms ease;
}

.primary-action:hover {
  opacity: 0.94;
}

.primary-action:active {
  transform: translateY(1px) scale(0.99);
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.text-action {
  margin-top: 16px;
  cursor: pointer;
  border: 0;
  border-bottom: 1px solid currentColor;
  color: var(--accent-strong);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.modal-shell {
  width: min(calc(100% - 28px), 450px);
  max-width: none;
  max-height: calc(100dvh - 28px);
  margin: auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 26px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(37, 27, 23, 0.28);
}

.modal-shell::backdrop {
  background: rgba(32, 27, 25, 0.58);
  backdrop-filter: blur(5px);
}

.modal-shell[open] {
  animation: modal-enter 210ms cubic-bezier(0.22, 0.78, 0.32, 1);
}

.result-card,
.gift-card {
  position: relative;
  max-height: calc(100dvh - 30px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.result-card {
  padding: 18px 22px 22px;
  text-align: center;
}

.modal-close {
  display: grid;
  width: 36px;
  height: 36px;
  cursor: pointer;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 0;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.88);
}

.result-card > .modal-close {
  position: absolute;
  z-index: 2;
  top: 16px;
  right: 16px;
}

.icon-close span,
.icon-close span::after {
  display: block;
  width: 14px;
  height: 1.5px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.icon-close span {
  transform: rotate(45deg);
}

.icon-close span::after {
  transform: rotate(90deg);
}

.result-visual {
  width: min(100%, 210px);
  aspect-ratio: 1;
  margin: -3px auto 6px;
  overflow: hidden;
  border-radius: 24px;
  background: #f7f8fa;
}

.result-visual img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-kicker {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.result-card h2 {
  margin: 0;
  font-size: 31px;
  line-height: 1.15;
  letter-spacing: -0.05em;
}

.result-prize {
  margin: 12px 0 0;
  color: var(--accent-strong);
  font-size: 19px;
  font-weight: 800;
}

.result-description,
.result-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.result-description {
  margin: 7px 0 0;
}

.result-card[data-result-type="grand"] .result-kicker,
.result-card[data-result-type="grand"] .result-prize {
  color: #956100;
}

.result-card[data-result-type="none"] .result-kicker,
.result-card[data-result-type="none"] .result-prize {
  color: var(--muted);
}

.ticket-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 24px 0 18px;
  text-align: left;
}

.ticket-details div {
  min-width: 0;
  padding: 14px;
  border-radius: 14px;
  background: var(--canvas);
}

.ticket-details dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

.ticket-details dd {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  word-break: break-all;
}

.result-note {
  margin: 0;
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-heading h2 {
  margin: 0;
  font-size: 27px;
  letter-spacing: -0.04em;
}

.modal-eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.gift-card {
  padding: 24px;
}

.gift-rule {
  margin: 16px 0 4px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  border-radius: 0 12px 12px 0;
  color: var(--muted);
  background: var(--canvas);
  font-size: 12px;
}

.prize-item {
  display: grid;
  grid-template-columns: minmax(74px, auto) 1fr auto;
  gap: 13px;
  align-items: center;
  padding: 15px 0;
  border-top: 1px solid var(--line);
}

.prize-tier {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.prize-name {
  min-width: 0;
}

.prize-name strong,
.prize-name small {
  display: block;
}

.prize-name strong {
  font-size: 14px;
}

.prize-name small {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sold-out {
  color: var(--muted);
  font-size: 11px;
}

.prize-skeleton {
  height: 61px;
  border-top: 1px solid var(--line);
  background: linear-gradient(90deg, transparent, rgba(223, 226, 230, 0.58), transparent);
  background-size: 200% 100%;
  animation: skeleton 1.3s linear infinite;
}

.empty-prizes {
  margin: 0;
  padding: 30px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.modal-primary,
.modal-secondary {
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  cursor: pointer;
  border-radius: 13px;
  font-weight: 800;
}

.modal-primary {
  border: 0;
  color: #ffffff;
  background: var(--accent-strong);
  box-shadow: 0 10px 24px rgba(159, 45, 31, 0.19);
}

.modal-secondary {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
}

.activity-footer {
  padding: 16px 6px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
  text-align: center;
}

.activity-footer p {
  margin: 4px 0;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 20px;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 20px;
  max-width: 440px;
  margin: 0 auto;
  padding: 13px 16px;
  border-radius: 14px;
  color: #ffffff;
  background: var(--ink);
  font-size: 13px;
  text-align: center;
  box-shadow: var(--shadow);
}

.confetti-layer {
  position: fixed;
  z-index: 30;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -18px;
  width: 8px;
  height: 18px;
  border-radius: 2px;
  background: var(--accent);
  animation: confetti-fall var(--duration) cubic-bezier(0.23, 0.78, 0.42, 1) forwards;
  animation-delay: var(--delay);
}

@keyframes ready-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.035);
  }
}

@keyframes physical-shake {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0);
  }
  20% {
    transform: translate3d(-13px, 4px, 0) rotate(-7deg) scale(1.02);
  }
  40% {
    transform: translate3d(11px, -4px, 0) rotate(6deg) scale(0.99);
  }
  60% {
    transform: translate3d(-9px, -2px, 0) rotate(-5deg) scale(1.02);
  }
  80% {
    transform: translate3d(13px, 3px, 0) rotate(7deg) scale(0.99);
  }
}

@keyframes line-flash {
  from {
    opacity: 0.15;
    transform: translateX(8px) rotate(-22deg) scaleX(0.7);
  }
  to {
    opacity: 0.9;
    transform: translateX(0) rotate(-22deg) scaleX(1);
  }
}

@keyframes reveal-spin {
  0% {
    transform: rotate(0deg) scale(0.94);
  }
  50% {
    transform: rotate(8deg) scale(1.03);
  }
  100% {
    transform: rotate(0deg) scale(0.94);
  }
}

@keyframes skeleton {
  to {
    background-position: -200% 0;
  }
}

@keyframes confetti-fall {
  0% {
    transform: translate3d(0, -10vh, 0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--drift), 112vh, 0) rotate(700deg);
    opacity: 0.9;
  }
}

@keyframes modal-enter {
  from {
    transform: translateY(14px) scale(0.97);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (min-width: 700px) {
  .draw-app {
    padding-right: 30px;
    padding-left: 30px;
  }
}

@media (max-height: 720px) {
  .hero {
    padding-top: 24px;
  }

  .shake-stage {
    width: 210px;
    height: 210px;
    margin-top: 20px;
  }

  .shake-orb {
    width: 148px;
    height: 148px;
  }

  .orb-label {
    font-size: 58px;
  }

  .result-visual {
    width: 160px;
  }

  .result-card {
    padding-top: 14px;
  }
}

@media (max-width: 380px) {
  .draw-app {
    padding-right: 16px;
    padding-left: 16px;
  }

  h1 {
    font-size: 31px;
  }

  .ticket-details {
    gap: 8px;
  }

  .ticket-details div {
    padding: 11px;
  }

  .gift-card {
    padding: 20px;
  }
}

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