:root {
  --bg: #f7fbff;
  --ink: #172033;
  --muted: #5f6b7a;
  --panel: #ffffff;
  --panel-dark: #243b6b;
  --red: #f04f4f;
  --blue: #2f80ed;
  --yellow: #ffd84d;
  --green: #2dbf78;
  --shadow: 0 24px 60px rgba(23, 32, 51, 0.18);
  --radius-lg: 28px;
  --radius-md: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 216, 77, 0.38), transparent 28%),
    radial-gradient(circle at 85% 12%, rgba(47, 128, 237, 0.2), transparent 26%),
    linear-gradient(135deg, #f7fbff 0%, #eef7ff 48%, #fff8dc 100%);
}

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

.confetti-piece {
  position: absolute;
  top: -24px;
  width: 12px;
  height: 18px;
  border: 2px solid rgba(23, 32, 51, 0.22);
  border-radius: 4px;
  animation: confetti-fall var(--fall-duration, 1200ms) ease-out forwards;
  transform: translate3d(0, 0, 0) rotate(0deg);
}

.app-shell {
  display: grid;
  min-height: 100vh;
  padding: 32px 18px;
  place-items: center;
}

.game-panel {
  position: relative;
  width: min(960px, 100%);
  overflow: hidden;
  padding: 32px;
  background: var(--panel);
  border: 4px solid #172033;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.game-panel::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(90deg, rgba(240, 79, 79, 0.1) 0 20%, transparent 20% 80%, rgba(47, 128, 237, 0.1) 80%),
    radial-gradient(circle at 48% 0%, rgba(255, 216, 77, 0.25), transparent 30%);
}

.brand-row,
.hero-row,
.intro,
.machine {
  position: relative;
  z-index: 1;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 28px;
}

.brand-lights {
  display: flex;
  gap: 10px;
}

.brand-dot {
  width: 18px;
  height: 18px;
  border: 3px solid var(--ink);
  border-radius: 999px;
}

.brand-dot.is-pulsing {
  animation: lamp-pulse 520ms ease-in-out infinite;
}

.brand-dot-red {
  background: var(--red);
}

.brand-dot-blue {
  background: var(--blue);
}

.brand-dot-yellow {
  background: var(--yellow);
}

.sound-button {
  min-width: 112px;
  padding: 10px 14px;
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 900;
  background: #ffffff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 5px 0 rgba(23, 32, 51, 0.22);
  cursor: pointer;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background-color 120ms ease;
}

.sound-button:hover {
  background: #fff7cc;
}

.sound-button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--blue);
}

.sound-button:active {
  box-shadow: 0 2px 0 rgba(23, 32, 51, 0.22);
  transform: translateY(3px);
}

.sound-button:focus-visible {
  outline: 4px solid var(--yellow);
  outline-offset: 4px;
}

.intro {
  max-width: 680px;
}

.hero-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 18px;
  align-items: center;
}

.three-stage {
  min-height: 214px;
}

.fortune-3d {
  display: block;
  width: 100%;
  height: 214px;
  pointer-events: none;
}

.mini-label {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 5rem);
  line-height: 1;
}

.intro p:last-child {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.8;
}

.machine {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 24px;
  align-items: stretch;
  margin-top: 34px;
}

.ticket {
  position: relative;
  min-height: 260px;
  padding: 30px;
  background: #fffdf2;
  border: 4px solid var(--ink);
  border-radius: var(--radius-md);
  box-shadow: inset 0 -10px 0 rgba(255, 216, 77, 0.36);
  transition:
    transform 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease;
}

.ticket.is-revealed {
  animation: pop-reveal 360ms cubic-bezier(0.18, 0.9, 0.28, 1.2);
}

.ticket.is-sparkling::after {
  position: absolute;
  top: 24px;
  right: 28px;
  width: 18px;
  height: 18px;
  background: var(--yellow);
  border-radius: 50%;
  box-shadow:
    -32px 28px 0 -4px var(--blue),
    20px 42px 0 -5px var(--red),
    -10px 70px 0 -6px var(--green);
  content: "";
  animation: sparkle-burst 520ms ease-out forwards;
}

.ticket.is-drawing {
  animation: shake 420ms ease-in-out infinite;
}

.ticket.is-great {
  background: #fff3f3;
  box-shadow: inset 0 -10px 0 rgba(240, 79, 79, 0.28);
}

.ticket.is-good {
  background: #eff7ff;
  box-shadow: inset 0 -10px 0 rgba(47, 128, 237, 0.24);
}

.ticket.is-small {
  background: #f1fff7;
  box-shadow: inset 0 -10px 0 rgba(45, 191, 120, 0.24);
}

.ticket.is-late {
  background: #fffbea;
  box-shadow: inset 0 -10px 0 rgba(255, 216, 77, 0.34);
}

.ticket-label {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.fortune-result {
  margin: 0;
  font-size: clamp(2.4rem, 9vw, 5.5rem);
  font-weight: 900;
  line-height: 1;
}

.fortune-message {
  max-width: 560px;
  margin: 22px 0 0;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.75;
}

.draw-button {
  position: relative;
  display: grid;
  gap: 14px;
  place-items: center;
  min-height: 150px;
  padding: 22px;
  color: #ffffff;
  font: inherit;
  font-size: 1.4rem;
  font-weight: 900;
  background: linear-gradient(180deg, #ff6b6b 0%, #f04f4f 100%);
  border: 4px solid var(--ink);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 0 #9e2d2d;
  cursor: pointer;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    filter 120ms ease;
}

.draw-stage {
  position: relative;
  display: grid;
  width: 78px;
  height: 62px;
  place-items: center;
}

.draw-button-label {
  position: relative;
  z-index: 2;
}

.omikuji-box {
  position: relative;
  width: 54px;
  height: 46px;
  background: #fff7cc;
  border: 4px solid var(--ink);
  border-radius: 12px 12px 18px 18px;
  box-shadow: inset 0 -8px 0 rgba(255, 216, 77, 0.62);
  transform-origin: 50% 80%;
}

.omikuji-box::before {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 34px;
  height: 14px;
  background: #ffffff;
  border: 4px solid var(--ink);
  border-radius: 999px;
  content: "";
  transform: translateX(-50%);
}

.stick {
  position: absolute;
  top: -26px;
  width: 8px;
  height: 32px;
  background: #ffffff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  transform-origin: 50% 100%;
}

.stick-one {
  left: 13px;
  transform: rotate(-15deg);
}

.stick-two {
  left: 25px;
}

.stick-three {
  right: 13px;
  transform: rotate(15deg);
}

.flying-slip {
  position: absolute;
  top: 27px;
  left: 50%;
  width: 14px;
  height: 44px;
  opacity: 0;
  background: #ffffff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  transform: translate(-50%, 0) rotate(0deg);
}

.draw-button:hover {
  filter: brightness(1.04);
}

.draw-button:active,
.draw-button.is-pressed {
  box-shadow: 0 4px 0 #9e2d2d;
  transform: translateY(6px);
}

.draw-button.is-pressed .omikuji-box {
  animation: box-shake 180ms ease-in-out infinite;
}

.draw-button.is-pressed .stick {
  animation: stick-wiggle 180ms ease-in-out infinite;
}

.draw-button.is-pressed .flying-slip {
  animation: slip-fly 720ms cubic-bezier(0.18, 0.9, 0.28, 1.2) forwards;
}

.draw-button:focus-visible {
  outline: 4px solid var(--yellow);
  outline-offset: 4px;
}

.status-grid {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.status-card {
  padding: 18px 20px;
  color: #ffffff;
  background: var(--panel-dark);
  border: 4px solid var(--ink);
  border-radius: var(--radius-md);
}

.status-label {
  display: block;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.9rem;
  font-weight: 800;
}

.status-card strong {
  font-size: 1.45rem;
}

.history-panel {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  padding: 18px 20px;
  color: #ffffff;
  background: #172033;
  border: 4px solid var(--ink);
  border-radius: var(--radius-md);
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 10px 0 0;
  list-style: none;
}

.history-list li {
  padding: 8px 10px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 900;
  background: #ffffff;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.reset-button {
  min-width: 134px;
  padding: 10px 12px;
  color: #ffffff;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 900;
  background: transparent;
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background-color 120ms ease;
}

.reset-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.reset-button:active {
  transform: translateY(2px);
}

.reset-button:focus-visible {
  outline: 4px solid var(--yellow);
  outline-offset: 4px;
}

@keyframes shake {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
  }

  25% {
    transform: rotate(-1.4deg) scale(1.01);
  }

  50% {
    transform: rotate(1.4deg) scale(1.015);
  }

  75% {
    transform: rotate(-0.7deg) scale(1.01);
  }
}

@keyframes pop-reveal {
  0% {
    opacity: 0.86;
    transform: translateY(18px) scale(0.94) rotate(-1deg);
  }

  70% {
    opacity: 1;
    transform: translateY(-4px) scale(1.025) rotate(0.4deg);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

@keyframes box-shake {
  0%,
  100% {
    transform: rotate(-7deg) translateY(0);
  }

  50% {
    transform: rotate(7deg) translateY(-3px);
  }
}

@keyframes stick-wiggle {
  0%,
  100% {
    translate: 0 0;
  }

  50% {
    translate: 0 -4px;
  }
}

@keyframes slip-fly {
  0% {
    opacity: 0;
    transform: translate(-50%, 4px) rotate(0deg) scale(0.8);
  }

  35% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -78px) rotate(22deg) scale(1.05);
  }
}

@keyframes sparkle-burst {
  0% {
    opacity: 0;
    transform: scale(0.2) rotate(0deg);
  }

  55% {
    opacity: 1;
    transform: scale(1.16) rotate(18deg);
  }

  100% {
    opacity: 0;
    transform: scale(0.62) rotate(42deg);
  }
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate3d(0, -24px, 0) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--drift, 20px), 105vh, 0) rotate(var(--spin, 280deg));
  }
}

@keyframes lamp-pulse {
  0%,
  100% {
    filter: brightness(1);
    transform: scale(1);
  }

  50% {
    filter: brightness(1.35);
    transform: scale(1.12);
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 18px 12px;
  }

  .game-panel {
    padding: 24px 18px;
    border-width: 3px;
    border-radius: 22px;
  }

  .brand-row {
    margin-bottom: 22px;
  }

  .sound-button {
    min-width: 98px;
    padding: 9px 12px;
    font-size: 0.8rem;
  }

  .machine {
    grid-template-columns: 1fr;
  }

  .hero-row {
    grid-template-columns: 1fr;
  }

  .three-stage {
    min-height: 166px;
  }

  .fortune-3d {
    height: 166px;
  }

  .ticket {
    min-height: 230px;
    padding: 24px 20px;
  }

  .draw-button {
    min-height: 92px;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .history-panel {
    grid-template-columns: 1fr;
  }

  .reset-button {
    width: 100%;
  }
}

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