:root {
  color-scheme: light;
  --sky: #bfefff;
  --mint: #7ee7c7;
  --pink: #ff77a8;
  --yellow: #ffd95c;
  --purple: #8d7cff;
  --red: #ff5c6c;
  --ink: #283149;
  --panel: #fff9e8;
  --glass: rgba(255, 255, 255, 0.42);
  --shadow: 0 20px 50px rgba(65, 88, 130, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    "Nunito", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 18%, #fff 0 6px, transparent 7px),
    radial-gradient(circle at 82% 18%, #fff 0 5px, transparent 6px),
    linear-gradient(135deg, #bfefff 0%, #f8f4ff 48%, #fff3bd 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.game-shell {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.play-area {
  width: min(1120px, 100%);
  display: grid;
  place-items: center;
}

.machine-wrap {
  display: grid;
  place-items: center;
  min-height: 660px;
}

.settings-toggle {
  position: fixed;
  right: 24px;
  top: 22px;
  z-index: 5;
  border: 4px solid #fff;
  border-radius: 999px;
  padding: 11px 22px;
  color: #fff;
  background: linear-gradient(135deg, #6acfff, #8d7cff);
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(75, 91, 182, 0.24);
}

.machine {
  position: relative;
  width: min(520px, 94vw);
  height: 630px;
  filter: drop-shadow(var(--shadow));
}

.top-sign {
  position: absolute;
  left: 50%;
  top: 2px;
  z-index: 2;
  width: 250px;
  transform: translateX(-50%) rotate(-1deg);
  padding: 12px 22px;
  border: 5px solid #ffef91;
  border-radius: 24px;
  text-align: center;
  color: #fff;
  background: linear-gradient(135deg, #ff7cae, #ffb347);
  box-shadow: 0 8px 0 #e34f83;
}

.top-sign span,
.top-sign strong {
  display: block;
}

.top-sign span {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.top-sign strong {
  font-size: 13px;
  letter-spacing: 0.28em;
}

.globe {
  position: absolute;
  left: 50%;
  top: 72px;
  width: 430px;
  height: 360px;
  transform: translateX(-50%);
  overflow: hidden;
  border: 13px solid #ff6f9d;
  border-bottom-width: 20px;
  border-radius: 48% 48% 43% 43%;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.92), transparent 24%),
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.95), transparent 16%),
    rgba(255, 255, 255, 0.36);
  box-shadow:
    inset 0 0 35px rgba(255, 255, 255, 0.88),
    inset 0 -28px 34px rgba(86, 176, 219, 0.2);
  backdrop-filter: blur(2px);
}

.shine {
  position: absolute;
  left: 58px;
  top: 38px;
  z-index: 3;
  width: 62px;
  height: 150px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: rotate(24deg);
}

.capsule-field {
  position: absolute;
  inset: 22px 30px 10px;
  transition: transform 0.3s ease;
}

.machine.spinning .capsule-field {
  animation: tumble 0.45s linear infinite;
}

.capsule {
  position: absolute;
  width: 58px;
  height: 38px;
  border: 3px solid rgba(40, 49, 73, 0.14);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 7px 12px rgba(40, 49, 73, 0.14);
  transform: rotate(var(--rotation));
}

.capsule::before,
.capsule::after {
  content: "";
  position: absolute;
  inset: 0;
}

.capsule::before {
  clip-path: inset(0 50% 0 0);
  background: var(--left);
}

.capsule::after {
  clip-path: inset(0 0 0 50%);
  background: var(--right);
}

.machine-body {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 380px;
  height: 270px;
  transform: translateX(-50%);
  border: 8px solid #db4d75;
  border-radius: 42px 42px 28px 28px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.24), transparent 18%),
    linear-gradient(180deg, #ff7fa9, #ff4f84);
  box-shadow: inset 0 -16px 0 rgba(151, 30, 74, 0.18);
}

.slot {
  position: absolute;
  left: 35px;
  top: 42px;
  width: 162px;
  min-height: 60px;
  display: grid;
  place-items: center;
  padding: 8px 14px;
  border: 5px solid #ffe077;
  border-radius: 16px;
  color: #7b3350;
  background: #fffaf0;
  font-weight: 900;
  text-align: center;
}

.knob {
  position: absolute;
  right: 52px;
  top: 36px;
  width: 112px;
  height: 112px;
  border: 8px solid #fff0a5;
  border-radius: 50%;
  background: linear-gradient(145deg, #75ddff, #5aa6ff);
  box-shadow:
    0 10px 0 #317ad4,
    inset 0 9px 12px rgba(255, 255, 255, 0.45);
}

.knob span {
  position: absolute;
  left: 50%;
  top: 18px;
  width: 22px;
  height: 62px;
  border-radius: 999px;
  background: #fff7c9;
  transform: translateX(-50%);
  transform-origin: 50% 37px;
}

.machine.spinning .knob span {
  animation: twist 0.55s ease-in-out infinite;
}

.knob:disabled {
  cursor: wait;
}

.tray {
  position: absolute;
  left: 50%;
  bottom: 28px;
  width: 240px;
  height: 78px;
  transform: translateX(-50%);
  border: 7px solid #c23864;
  border-radius: 0 0 28px 28px;
  background: #ffe5f0;
  box-shadow: inset 0 10px 14px rgba(139, 40, 77, 0.12);
}

.prize-capsule {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 168px;
  height: 48px;
  transform: translate(-50%, -50%);
  border: 4px solid rgba(40, 49, 73, 0.16);
  border-radius: 999px;
  color: #64263f;
  background: linear-gradient(90deg, var(--yellow) 0 50%, var(--mint) 50% 100%);
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 7px 0 rgba(144, 64, 76, 0.2);
}

.prize-capsule.hidden {
  display: none;
}

.prize-capsule.drop-in {
  animation: dropIn 0.62s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-dialog {
  width: min(390px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(40, 49, 73, 0.26);
  backdrop-filter: blur(2px);
}

.control-panel {
  position: relative;
  padding: 28px;
  border: 4px solid rgba(255, 255, 255, 0.84);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-panel h1 {
  margin: 0 42px 8px 0;
  color: #ff4f84;
  font-size: 34px;
  line-height: 1;
}

.control-panel p {
  margin: 0 0 22px;
  color: #5f6378;
  line-height: 1.7;
}

.panel-close {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: #ff4f84;
  background: #ffe4ef;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  font-weight: 900;
}

input {
  width: 100%;
  border: 3px solid #ffd56c;
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus {
  border-color: #56c7f6;
  box-shadow: 0 0 0 4px rgba(86, 199, 246, 0.18);
}

.secondary-button,
.result-card #playAgain {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 13px 16px;
  color: #fff;
  background: linear-gradient(135deg, #6acfff, #8d7cff);
  font-weight: 900;
  box-shadow: 0 7px 0 rgba(75, 91, 182, 0.26);
}

.gift-preview {
  margin-top: 24px;
}

.gift-preview h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.gift-preview ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  max-height: 214px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.gift-preview li {
  min-width: 0;
  padding: 9px 10px;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-dialog {
  width: min(420px, calc(100vw - 30px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.result-dialog::backdrop {
  background: rgba(40, 49, 73, 0.38);
  backdrop-filter: blur(3px);
}

.result-card {
  position: relative;
  padding: 32px;
  border: 6px solid #fff0a5;
  border-radius: 8px;
  text-align: center;
  background: #fffaf0;
  box-shadow: var(--shadow);
}

.result-card .close-button {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #ff4f84;
  background: #ffe4ef;
  box-shadow: none;
  font-size: 24px;
  line-height: 1;
}

.eyebrow {
  margin: 0;
  color: #ff4f84;
  font-weight: 900;
}

.gift-emoji {
  margin: 10px auto;
  font-size: 76px;
}

.result-card h2 {
  margin: 0 0 8px;
  font-size: 30px;
}

.result-card p:last-of-type {
  margin: 0 0 24px;
  color: #60667a;
}

@keyframes tumble {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.04);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

@keyframes twist {
  0%,
  100% {
    transform: translateX(-50%) rotate(0deg);
  }
  50% {
    transform: translateX(-50%) rotate(180deg);
  }
}

@keyframes dropIn {
  0% {
    transform: translate(-50%, -250px) rotate(-25deg);
    opacity: 0;
  }
  70% {
    transform: translate(-50%, -42%) rotate(9deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
}

@media (max-width: 880px) {
  .game-shell {
    padding: 18px;
  }

  .machine-wrap {
    min-height: 590px;
  }

  .machine {
    transform: scale(0.9);
    transform-origin: top center;
  }
}

@media (max-width: 520px) {
  .game-shell {
    padding: 12px;
  }

  .settings-toggle {
    right: 14px;
    top: 14px;
    padding: 9px 18px;
  }

  .control-panel {
    padding: 20px;
  }

  .machine-wrap {
    min-height: 525px;
    overflow: hidden;
  }

  .machine {
    transform: scale(0.78);
  }

  .gift-preview ul {
    grid-template-columns: 1fr;
  }
}
