:root {
  --blue: #77b7ff;
  --blue-deep: #4b8fe6;
  --pastel: #dceeff;
  --white: #ffffff;
  --yellow: #ffd966;
  --navy: #243b65;
  --gold: #ffd700;
  --gold-deep: #e6a800;
  --muted: #5b6f93;
  --radius: 22px;
  --shadow: 0 10px 30px rgba(36, 59, 101, 0.12);
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--navy);
  background: var(--white);
  background-image:
    radial-gradient(circle at 15% 10%, rgba(119, 183, 255, 0.18) 0, transparent 40%),
    radial-gradient(circle at 90% 30%, rgba(255, 217, 102, 0.18) 0, transparent 35%),
    radial-gradient(circle at 50% 100%, rgba(220, 238, 255, 0.9) 0, transparent 55%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; }
[hidden] { display: none !important; }
.sp { display: inline; }
@media (min-width: 560px) { .sp { display: none; } }

/* background deco */
.bg-deco { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.star { position: absolute; color: var(--yellow); font-size: 22px; animation: twinkle 2.8s ease-in-out infinite; }
.star.s1 { top: 8%; left: 6%; }
.star.s2 { top: 18%; right: 8%; color: var(--blue); animation-delay: .6s; }
.star.s3 { top: 46%; left: 3%; font-size: 16px; animation-delay: 1.2s; }
.star.s4 { top: 60%; right: 5%; font-size: 26px; animation-delay: .3s; }
.star.s5 { top: 82%; left: 10%; color: var(--blue); animation-delay: 1.6s; }
.star.s6 { top: 34%; right: 22%; font-size: 14px; animation-delay: 2s; }
.bubble { position: absolute; border-radius: 50%; background: var(--pastel); opacity: .6; }
.bubble.b1 { width: 120px; height: 120px; top: -40px; right: -30px; }
.bubble.b2 { width: 80px; height: 80px; bottom: 12%; left: -30px; }
.bubble.b3 { width: 50px; height: 50px; top: 40%; right: -12px; background: #fff3c9; }
@keyframes twinkle { 0%, 100% { opacity: .35; transform: scale(.85) rotate(0); } 50% { opacity: 1; transform: scale(1.1) rotate(20deg); } }

.demo-badge {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: repeating-linear-gradient(45deg, #ff6b6b, #ff6b6b 12px, #ff8787 12px, #ff8787 24px);
  color: #fff; font-size: 12px; font-weight: 800; text-align: center; padding: 4px;
}

.page { position: relative; z-index: 1; width: 100%; max-width: 520px; margin: 0 auto; padding: 14px 16px 32px; }
.page-center { text-align: center; padding-top: 28px; }

/* header */
.top-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.logo-h { height: 40px; width: auto; }
.logo-h.small { height: 34px; margin: 0 auto 6px; }
.pill {
  background: var(--navy); color: #fff; font-size: 12px; font-weight: 800;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}

/* hero */
.hero { text-align: center; margin-top: 6px; }
.title {
  margin: 4px 0 4px; font-size: clamp(25px, 7.4vw, 36px); line-height: 1.2; font-weight: 800;
  letter-spacing: .02em;
  background: linear-gradient(180deg, var(--navy) 0%, #34589a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.title-emoji { -webkit-text-fill-color: initial; color: initial; margin-right: 4px; }
.lead { margin: 0; font-size: 14px; font-weight: 700; color: var(--muted); line-height: 1.55; }

/* stage */
.stage { text-align: center; margin-top: 4px; }
.stage-msg {
  min-height: 1.6em; margin: 6px 0 0; font-size: 18px; font-weight: 800; color: var(--blue-deep);
  transition: opacity .2s;
}
.machine-wrap { position: relative; width: min(100%, 380px); margin: 0 auto; }
.machine { width: 78%; height: auto; margin-left: 0; overflow: visible; animation: wobble 3.2s ease-in-out infinite; transform-origin: 50% 95%; }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-1.2deg); } 75% { transform: rotate(1.2deg); } }
body[data-state="drawing"] .machine { animation: none; }
.drum { transform-origin: 160px 129px; transform-box: view-box; }
.ib { transform-box: fill-box; transform-origin: center; }
body[data-state="drawing"] .ib { animation: jiggle .28s ease-in-out infinite alternate; }
body[data-state="drawing"] .ib:nth-child(2n) { animation-duration: .22s; }
body[data-state="drawing"] .ib:nth-child(3n) { animation-duration: .34s; }
@keyframes jiggle { from { transform: translate(-4px, 3px); } to { transform: translate(4px, -9px); } }
.out-ball { transition: none; }

.chara-wrap { position: absolute; right: -2%; bottom: 2%; width: 40%; }
.chara { width: 100%; height: auto; animation: float 2.6s ease-in-out infinite; filter: drop-shadow(0 8px 10px rgba(36, 59, 101, .12)); }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
body[data-state="drawing"] .chara { animation: cheer .45s ease-in-out infinite alternate; }
@keyframes cheer { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-10px) rotate(4deg); } }
.speech {
  position: absolute; top: -34px; right: 8%; background: #fff; border: 3px solid var(--blue);
  border-radius: 16px; padding: 4px 10px; font-size: 13px; font-weight: 800; white-space: nowrap;
  box-shadow: var(--shadow);
}
.speech::after {
  content: ""; position: absolute; bottom: -9px; left: 40%; width: 12px; height: 12px;
  background: #fff; border-right: 3px solid var(--blue); border-bottom: 3px solid var(--blue); transform: rotate(45deg);
}

/* buttons */
.btn {
  appearance: none; border: 0; cursor: pointer; font-weight: 800; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 22px; font-size: 16px; color: var(--navy);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(3px); }
.btn:focus-visible { outline: 4px solid var(--yellow); outline-offset: 3px; }
.btn-spin {
  width: min(100%, 340px); min-height: 72px; margin-top: 8px; font-size: 22px; color: #fff;
  background: linear-gradient(180deg, #9fd0ff 0%, var(--blue) 45%, var(--blue-deep) 100%);
  box-shadow: 0 7px 0 #2f6fc4, 0 14px 26px rgba(75, 143, 230, .45), inset 0 3px 0 rgba(255, 255, 255, .55);
  text-shadow: 0 2px 0 rgba(36, 59, 101, .25);
  animation: pulse 1.8s ease-in-out infinite;
}
.btn-spin:active { box-shadow: 0 3px 0 #2f6fc4, 0 6px 14px rgba(75, 143, 230, .4), inset 0 3px 0 rgba(255,255,255,.5); }
.btn-spin:disabled { filter: grayscale(.5) brightness(1.05); cursor: default; animation: none; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
.spin-note { margin: 12px 0 0; font-size: 12px; font-weight: 700; color: var(--muted); }
.btn-primary {
  color: #fff; background: linear-gradient(180deg, #9fd0ff, var(--blue-deep));
  box-shadow: 0 5px 0 #2f6fc4, 0 10px 20px rgba(75, 143, 230, .35); width: min(100%, 320px);
}
.btn-x { color: #fff; background: #0f1419; box-shadow: 0 5px 0 #000, 0 10px 20px rgba(0,0,0,.2); width: 100%; font-size: 17px; }
.btn-ghost { background: #fff; border: 3px solid var(--blue); color: var(--navy); box-shadow: 0 4px 0 var(--pastel); width: 100%; }
.x-logo { font-size: 20px; font-weight: 800; }
.btn-link { background: none; border: 0; color: var(--muted); font-weight: 700; text-decoration: underline; padding: 14px; cursor: pointer; font-size: 14px; }

/* prizes */
.prizes { margin-top: 30px; }
.section-title { text-align: center; font-size: 20px; margin: 0 0 14px; font-weight: 800; }
.prize-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.prize-card {
  background: #fff; border-radius: var(--radius); padding: 10px 10px 12px; box-shadow: var(--shadow);
  border: 3px solid var(--pastel); position: relative; overflow: hidden;
}
.prize-card img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 14px; background: var(--pastel); }
.prize-card h3 { margin: 6px 0 2px; font-size: 14px; line-height: 1.3; }
.prize-card .rank { margin: 8px 0 0; }
.prize-card.soldout img { filter: grayscale(1) opacity(.5); }
.prize-card.soldout::after {
  content: "本日終了"; position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%) rotate(-12deg);
  background: var(--navy); color: #fff; font-weight: 800; padding: 6px 14px; border-radius: 10px; font-size: 15px;
}
.rank { font-size: 11px; font-weight: 800; letter-spacing: .06em; color: var(--gold-deep); }
.rank-blue { color: var(--blue-deep); }
.stock { margin: 0; font-size: 13px; font-weight: 800; color: var(--blue-deep); }
.stock b { font-size: 18px; }
.thanks-card { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; margin-top: 12px; }
.thanks-card .rank { margin: 0; }
.soldout-banner { background: #fff7d6; border: 2px dashed var(--yellow); border-radius: 14px; padding: 10px; font-size: 13px; font-weight: 800; text-align: center; }

.notes { margin-top: 26px; background: rgba(220, 238, 255, .55); border-radius: var(--radius); padding: 14px 18px; }
.notes-title { font-size: 14px; margin: 0 0 6px; }
.notes ul { margin: 0; padding-left: 1.2em; font-size: 12.5px; line-height: 1.7; color: var(--muted); font-weight: 700; }
.footer { text-align: center; margin-top: 28px; color: var(--muted); font-size: 11px; font-weight: 700; }
.footer img { margin: 0 auto 4px; width: 84px; height: auto; }

/* already */
.sleep-wrap { margin: 24px auto 4px; width: 220px; }
.chara-sleep { width: 100%; height: auto; animation: breathe 3.2s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.02, .97); } }
.already-title { font-size: 22px; margin: 12px 0 4px; }
.already-sub { margin: 0 0 20px; color: var(--muted); font-weight: 700; }
.already-result {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px;
  display: flex; gap: 12px; align-items: center; text-align: left; margin: 0 auto 18px; max-width: 360px;
}
.already-result img { width: 72px; height: 72px; border-radius: 12px; background: var(--pastel); }
.already-result p { margin: 0; font-size: 12px; font-weight: 800; }
.already-result h3 { margin: 2px 0 0; font-size: 15px; }

/* result */
.result { text-align: center; overflow: hidden; }
.result-inner { position: relative; z-index: 1; }
.rays {
  position: fixed; left: 50%; top: 34%; width: 160vmax; height: 160vmax; margin: -80vmax 0 0 -80vmax; z-index: 0;
  background: repeating-conic-gradient(from 0deg, rgba(119, 183, 255, .16) 0 10deg, transparent 10deg 20deg);
  animation: spin 24s linear infinite; pointer-events: none;
  -webkit-mask-image: radial-gradient(circle, #000 0, transparent 60%); mask-image: radial-gradient(circle, #000 0, transparent 60%);
}
.result.special .rays { background: repeating-conic-gradient(from 0deg, rgba(255, 215, 0, .3) 0 10deg, transparent 10deg 20deg); }
@keyframes spin { to { transform: rotate(360deg); } }
.result-title { margin: 6px 0 0; font-size: clamp(30px, 9vw, 44px); font-weight: 800; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1) both; }
.result.special .result-title {
  background: linear-gradient(180deg, #ffe680 0%, var(--gold) 45%, var(--gold-deep) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #b07a00) drop-shadow(0 8px 16px rgba(255, 190, 0, .35));
}
.result.thanks .result-title { color: var(--blue-deep); text-shadow: 0 3px 0 var(--pastel); }
.result-sub { margin: 4px 0 10px; font-size: 16px; font-weight: 800; line-height: 1.6; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.prize-show { position: relative; margin: 6px auto 0; max-width: 360px; animation: pop .7s .15s cubic-bezier(.2, 1.5, .4, 1) both; }
.prize-show .rank { font-size: 13px; margin: 0 0 6px; }
.prize-frame {
  background: #fff; border-radius: 28px; padding: 10px; box-shadow: var(--shadow);
  border: 5px solid var(--pastel);
}
.result.special .prize-frame { border-color: var(--gold); box-shadow: 0 0 0 6px #fff4b8, 0 0 40px rgba(255, 215, 0, .55), var(--shadow); }
.prize-frame img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 20px; }
.result-name { margin: 12px 0 0; font-size: 22px; }
.result-chara { position: absolute; right: -18px; bottom: 40px; width: 42%; animation: cheer .5s ease-in-out infinite alternate; filter: drop-shadow(0 6px 8px rgba(36,59,101,.18)); }
.result.thanks .result-chara { animation: float 2.6s ease-in-out infinite; left: -26px; right: auto; }
.actions { display: grid; gap: 12px; margin: 22px auto 0; max-width: 360px; }

.claim { margin: 22px auto 0; max-width: 380px; background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); border: 3px dashed var(--blue); }
.result.special .claim { border-color: var(--gold); }
.claim-msg { margin: 0; font-size: 14px; font-weight: 800; line-height: 1.55; }
.claim-box { display: flex; gap: 14px; align-items: center; text-align: left; }
.qr { width: 108px; height: 108px; flex: none; background: #fff; }
.qr svg { width: 100%; height: 100%; }
.claim-label { margin: 0; font-size: 11px; font-weight: 800; color: var(--muted); }
.claim-code { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: .12em; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.claim-meta { margin: 2px 0 0; font-size: 11px; color: var(--muted); font-weight: 700; }
.claim-status { margin: 6px 0 0; font-size: 12px; font-weight: 800; }
.claim-status.done { color: #c0392b; }

/* share sheet */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(36, 59, 101, .45); animation: fade .2s; }
.sheet-panel {
  position: relative; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  background: #fff; border-radius: 26px 26px 0 0; padding: 22px 18px calc(20px + env(safe-area-inset-bottom));
  animation: up .28s cubic-bezier(.2, 1, .3, 1);
}
@media (min-width: 640px) { .sheet { align-items: center; } .sheet-panel { border-radius: 26px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.sheet-close { position: absolute; top: 10px; right: 12px; width: 40px; height: 40px; border: 0; background: var(--pastel); border-radius: 50%; font-size: 22px; color: var(--navy); cursor: pointer; }
.sheet-title { font-size: 18px; margin: 0 40px 12px 0; }
.share-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 14px; box-shadow: var(--shadow); }
.share-text-label { display: block; font-size: 12px; font-weight: 800; margin: 12px 0 4px; color: var(--muted); }
.share-text { width: 100%; font: inherit; font-size: 14px; border: 2px solid var(--pastel); border-radius: 12px; padding: 10px; color: var(--navy); resize: none; background: #f8fbff; }
.sheet-actions { display: grid; gap: 10px; margin-top: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 .btn { font-size: 14px; padding: 10px; }
.share-steps { margin: 14px 0 0; padding-left: 1.3em; font-size: 12.5px; font-weight: 700; line-height: 1.8; color: var(--muted); }
.share-note { font-size: 11px; color: var(--muted); margin: 8px 0 0; }

/* ball opening fx */
.open-fx { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; pointer-events: none; }
.flash { position: absolute; inset: 0; background: radial-gradient(circle, #fff 0, rgba(255,255,255,.9) 30%, rgba(255,255,255,0) 70%); opacity: 0; }
.big-ball { position: relative; width: 150px; height: 150px; }
.half { position: absolute; left: 0; width: 150px; height: 75px; background: var(--ball, var(--blue)); border: 5px solid #fff; box-shadow: 0 8px 24px rgba(36,59,101,.25); }
.half.top { top: 0; border-radius: 75px 75px 0 0; border-bottom-width: 2px; }
.half.bottom { bottom: 0; border-radius: 0 0 75px 75px; border-top-width: 2px; filter: brightness(.92); }
.open-fx.play .big-ball { animation: ballIn .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.open-fx.play .half.top { animation: openTop .5s .55s ease-in both; }
.open-fx.play .half.bottom { animation: openBottom .5s .55s ease-in both; }
.open-fx.play .flash { animation: flash .7s .6s ease-out both; }
@keyframes ballIn { from { transform: scale(.1) rotate(-200deg); } to { transform: scale(1) rotate(0); } }
@keyframes openTop { to { transform: translateY(-140px) rotate(-35deg); opacity: 0; } }
@keyframes openBottom { to { transform: translateY(140px) rotate(25deg); opacity: 0; } }
@keyframes flash { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 45; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: var(--navy); color: #fff; font-weight: 800; font-size: 14px; padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow); animation: up .25s;
}

/* PC: put stage and prizes side by side-ish via wider column */
@media (min-width: 900px) {
  .page { max-width: 560px; }
  .prize-list { grid-template-columns: repeat(4, 1fr); }
  #top.page { max-width: 880px; }
  #top .hero, #top .stage { max-width: 520px; margin-left: auto; margin-right: auto; }
  #top .notes { max-width: 640px; margin-left: auto; margin-right: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .rays { display: none; }
}

/* demo badge spacing */
body.is-demo { padding-top: 26px; }
