:root {
  color-scheme: dark;
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  background: #070c27;
  color: #f9f7ff;
  font-synthesis: none;
  --gold: #ffe495;
  --muted: #b9c4e3;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  background:
    radial-gradient(ellipse min(90vw, 680px) min(68svh, 520px) at 50% 45%, #0873c5, #114d9f 34%, #102a63 65%, transparent 100%),
    linear-gradient(150deg, #070b23, #070c27 66%, #0c1537);
}
button { font: inherit; }
button:focus-visible { outline: 3px solid #f6f8ff; outline-offset: 5px; }

.draw-layout {
  width: min(100% - 32px, 480px);
  min-height: 100svh;
  margin: auto;
  padding: clamp(22px, 3.5vh, 40px) 0 32px;
  display: grid;
  align-content: center;
}
.intro { margin: 0 0 14px; text-align: center; }
.intro-text {
  margin: 0;
  color: #fff;
  font-size: clamp(1rem, 4.4vw, 1.35rem);
  line-height: 1.5;
  font-weight: 800;
}

.machine {
  display: grid;
  justify-items: center;
  min-width: 0;
}
.machine-art {
  width: min(100%, clamp(256px, calc(80svh - 172px), 470px));
}
.machine-art svg { display: block; width: 100%; height: auto; }
.spin-button {
  width: min(100% - 36px, 366px);
  min-height: 64px;
  padding: 10px 20px 11px;
  border: 2px solid #fff0a2;
  border-radius: 999px;
  background: linear-gradient(#fff3a9 0%, #ffe370 32%, #ffc72e 74%, #f1a515 100%);
  color: #56180e;
  font-size: clamp(1.25rem, 2.4vw, 1.75rem);
  font-weight: 800;
  letter-spacing: .055em;
  line-height: 1.25;
  cursor: pointer;
  box-shadow: inset 0 2px 0 #fff9dc, inset 0 -3px 0 #ba6b16, 0 5px 0 #7c2d0a, 0 9px 26px #020613b0;
  transition: filter 150ms ease, transform 150ms ease;
}
.spin-button:not(:disabled):hover { filter: brightness(1.10); transform: translateY(-2px); }
.spin-button:not(:disabled):active { transform: translateY(3px); }
.spin-button:disabled { cursor: default; filter: brightness(.88); }
.status {
  min-height: 1.7em;
  max-width: 36rem;
  margin: 16px 0 0;
  padding: 0 6px;
  color: #dce7ff;
  text-align: center;
  font-size: .875rem;
  line-height: 1.65;
}

.status:empty { display: none; }
.status[data-spinning] {
  display: flex;
  align-items: center;
  gap: .65em;
  color: var(--gold);
  font-size: 1.125rem;
  font-weight: 800;
  animation: anticipation 760ms cubic-bezier(.28, .76, .35, 1) infinite;
}
.status[data-spinning]::before,
.status[data-spinning]::after {
  content: "";
  width: .32em;
  height: .32em;
  background: currentColor;
  box-shadow: 0 0 .6em #ffc72e96;
  transform: rotate(45deg);
}
@keyframes anticipation {
  0%, 58%, 100% { transform: translateY(0) scale(1); }
  29% { transform: translateY(-4px) scale(1.045); }
  73% { transform: translateY(-1px) scale(1.015); }
}
.farewell { margin: 10px 0 0; color: #dce7ff; font-weight: 650; line-height: 1.65; }
body:has(.result[open]) { overflow: hidden; }
.result {
  --tier: var(--gold);
  width: min(100% - 32px, 430px);
  max-height: calc(100% - 32px);
  padding: 0;
  border: 0;
  overflow: visible;
  background: transparent;
  color: #f9f7ff;
  text-align: center;
}
.result::backdrop { background: #030817d6; backdrop-filter: blur(5px); }
.result-card {
  position: relative;
  z-index: 1;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 24px clamp(12px, 5vw, 26px);
  border: 1px solid var(--tier);
  border-radius: 22px;
  background: radial-gradient(ellipse at 50% 0%, #294784, #101936 75%);
  box-shadow: 0 18px 40px #020613c9, 0 0 32px color-mix(in srgb, var(--tier) 23%, transparent);
}
.result[open] .result-card { animation: result-reveal 440ms cubic-bezier(.2, .72, .26, 1) both; }
@keyframes result-reveal {
  from { opacity: .4; transform: translateY(12px) scale(.94); }
  67% { opacity: 1; transform: translateY(0) scale(1.015); }
  to { transform: translateY(0) scale(1); }
}
.result-confetti {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.result[open] .result-confetti::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 46%, #ffd47045 0%, transparent 49%),
    radial-gradient(ellipse at 50% 48%, #527df849 0%, transparent 66%);
  animation: celebration-glow 1.55s ease-out both;
}
@keyframes celebration-glow {
  from { opacity: 0; transform: scale(.56); }
  20% { opacity: 1; }
  to { opacity: 0; transform: scale(1.15); }
}
.confetti-piece {
  position: absolute;
  border-radius: 1px;
  opacity: 0;
}
.confetti-star {
  clip-path: polygon(50% 0, 62% 35%, 100% 38%, 71% 61%, 81% 100%, 50% 77%, 19% 100%, 29% 61%, 0 38%, 38% 35%);
}
.result .farewell { margin-top: 16px; color: var(--muted); font-size: .875rem; }
.result[data-prize="grand"] { --tier: #ffdc72; }
.result[data-prize="big"] { --tier: #ffa789; }
.result[data-prize="win"] { --tier: #ffefd0; }
.result[data-prize="small"] { --tier: #a3c5ff; }
.result-stars { display: flex; justify-content: center; gap: 5px; color: var(--tier); }
.result-star { width: 32px; height: 32px; }
.result h2 { margin: 3px 0 0; color: var(--tier); font-size: clamp(1.35rem, 5.35vw, 1.65rem); }
.result h2:focus { outline: none; }
.result-prize {
  margin: 7px 0 16px;
  font-size: clamp(1.6rem, 6.2vw, 1.9rem);
  font-weight: 700;
  line-height: 1.35;
  text-wrap: balance;
  white-space: pre-line;
}
.show-staff {
  margin: 0;
  padding-top: 13px;
  border-top: 1px solid #91a6d74d;
  color: #f9f7ff;
  font-weight: 650;
  line-height: 1.6;
}

@media (max-width: 760px) {
  .draw-layout { min-height: auto; }
  .machine-art { width: min(100%, 430px); }
  .spin-button { min-height: 56px; }
  .status { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .spin-button { transition: none; }
  .status[data-spinning] { animation: none; }
  .result[open] .result-card { animation: none; }
  .result-confetti { display: none; }
}
