:root {
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  color: #37244a;
  background: #fbf5ed;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(#d9bede 1px, transparent 1px) 0 0 / 22px 22px;
}

.layout {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 48px;
  padding: 42px 0;
}

.intro { padding: 28px; background: #fbf5ed; border-radius: 28px; }
h1 { margin: 0; font-size: clamp(3.5rem, 9vw, 7rem); line-height: .98; letter-spacing: -.085em; }
h1 span { color: #854bb3; }
h2 { font-size: .95rem; margin: 32px 0 12px; }
p { line-height: 1.6; }
ul { display: flex; gap: 8px; flex-wrap: wrap; list-style: none; padding: 0; margin: 0; }
li { padding: 8px 10px; background: #fff; border: 1px solid #e6d7ea; border-radius: 16px; font-size: .8rem; }
.play { text-align: center; }
.machine { width: min(100%, 310px); margin: auto; filter: drop-shadow(0 12px 0 #643c8130); }
.lid {
  background: #f3aece;
  border: 3px solid #563a6e;
  border-radius: 42px 42px 8px 8px;
  padding: 8px;
  font-size: 1.5rem;
}
.glass {
  height: 180px;
  position: relative;
  overflow: hidden;
  border-inline: 3px solid #563a6e;
  background: linear-gradient(135deg, #fff9ff, #dfceff);
}
.glass::after {
  content: "";
  position: absolute;
  inset: 14px auto auto 15px;
  width: 10px;
  height: 74px;
  border-radius: 10px;
  background: #ffffffa0;
}
.glass i {
  background: linear-gradient(#fff6fc 49%, #563a6e 50% 53%, var(--shell, #f1a5cf) 54%);
  border: 2px solid #563a6e;
  border-radius: 50%;
  box-shadow: inset -5px -6px #563a6e19;
}
.glass i { position: absolute; width: 28%; aspect-ratio: 1; }
.glass i:nth-child(1) { left: 15%; bottom: 48px; transform: rotate(28deg); --shell: #aee4d4; }
.glass i:nth-child(2) { right: 18%; bottom: 55px; transform: rotate(-34deg); --shell: #ffcda8; }
.glass i:nth-child(3) { left: 4%; bottom: -12px; transform: rotate(-24deg); --shell: #f8c4e5; }
.glass i:nth-child(4) { left: 35%; bottom: -8px; transform: rotate(16deg); --shell: #b7b0f9; }
.glass i:nth-child(5) { right: 3%; bottom: -8px; transform: rotate(-18deg); --shell: #f8e39f; }
.base {
  border: 3px solid #563a6e;
  border-radius: 8px 8px 32px 32px;
  background: #e9a9d0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 18px 12px;
}
.dial { width: 42px; aspect-ratio: 1; border: 2px solid #563a6e; border-radius: 50%; background: #fff0f7; display: grid; place-items: center; }
.dial::after { content: ""; width: 23px; height: 7px; border-radius: 10px; background: #a775bd; transform: rotate(-30deg); }
.chute { width: clamp(132px, 62%, 174px); min-height: 108px; display: grid; place-items: center; border-radius: 18px; background: #5f4476; color: white; }
.chute > * { grid-area: 1 / 1; }
button { font: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid #854bb3; outline-offset: 4px; }
#capsule { position: relative; z-index: 1; width: 66px; height: 66px; padding: 0; border: 0; border-radius: 50%; background: transparent; animation: bounce-in .58s ease-out both; }
#capsule:focus-visible { outline-color: #fff; }
#capsule.opening { animation: none; }
.shell-top, .shell-bottom { position: absolute; left: 0; width: 100%; height: 50%; border: 2px solid #563a6e; box-shadow: inset -5px -4px #563a6e19; }
.shell-top { top: 0; border-radius: 40px 40px 0 0; background: #fff3fb; }
.shell-bottom { bottom: 0; border-radius: 0 0 40px 40px; background: #f1a5cf; }
.opening .shell-top { --x: -48px; --y: -25px; --tilt: -38deg; animation: split .52s ease-out both; }
.opening .shell-bottom { --x: 48px; --y: 20px; --tilt: 36deg; animation: split .52s ease-out both; }
#result { position: relative; display: grid; justify-items: center; gap: 4px; animation: reveal .36s .12s ease-out both; }
#icon { font-size: 2.25rem; line-height: 1.1; }
.sparkles { position: absolute; inset: 0; pointer-events: none; }
.sparkles i { position: absolute; color: #ffebaa; font-style: normal; animation: sparkle .64s .16s ease-out both; }
.sparkles i:nth-child(1) { left: -18px; top: 9px; }
.sparkles i:nth-child(2) { right: -20px; top: 1px; animation-delay: .22s; }
.sparkles i:nth-child(3) { right: -12px; bottom: 9px; font-size: .7rem; animation-delay: .28s; }
#status { margin: 25px 0 12px; min-height: 2lh; }
#draw { width: min(100%, 310px); border: 0; border-radius: 18px; padding: 15px; color: #fff; background: #7845a2; font-weight: 700; box-shadow: 0 5px #4e2e6b; }
#draw:hover:enabled { background: #673688; }
#draw:disabled { cursor: default; background: #775e86; }
@keyframes bounce-in {
  0% { transform: translateY(-32px) scale(.85) rotate(-16deg); opacity: 0; }
  38% { transform: translateY(8px) scale(1.12, .86); opacity: 1; }
  65% { transform: translateY(-10px) rotate(8deg); }
  84% { transform: translateY(3px) scale(1.04, .95); }
  100% { transform: none; }
}
@keyframes split {
  60% { opacity: 1; }
  to { transform: translate(var(--x), var(--y)) rotate(var(--tilt)); opacity: 0; }
}
@keyframes reveal {
  from { transform: translateY(8px) scale(.65); opacity: 0; }
  70% { transform: translateY(-3px) scale(1.08); }
  to { transform: none; opacity: 1; }
}
@keyframes sparkle {
  0%, 100% { transform: scale(.35); opacity: 0; }
  40% { transform: scale(1.25) rotate(18deg); opacity: 1; }
}

@media (max-width: 650px) {
  .layout { grid-template-columns: 1fr; gap: 20px; padding: 24px 0 32px; }
  .intro { padding: 12px; text-align: center; }
  h1 br { display: none; }
  h1 { font-size: clamp(2.5rem, 11vw, 4rem); }
  h2 { margin-top: 18px; }
  ul { justify-content: center; }
  .glass { height: 150px; }
}
@media (prefers-reduced-motion: reduce) {
  #capsule, #result { animation: none; }
  .sparkles { display: none; }
}
