:root {
  --ink: #241713;
  --muted: #725f5a;
  --paper: #fff8ef;
  --rose: #ff6f7f;
  --gold: #f7c969;
  --green: #84c98b;
  --blue: #6aaee8;
  --violet: #9c79d6;
  --shadow: 0 24px 70px rgba(56, 24, 19, 0.22);
  --card-ratio: 902 / 555;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 111, 127, 0.32), transparent 28%),
    radial-gradient(circle at 84% 18%, rgba(106, 174, 232, 0.25), transparent 30%),
    linear-gradient(135deg, #fff8ef 0%, #fff3de 48%, #f8fbf4 100%);
  font-family: Avenir Next, Helvetica Neue, PingFang SC, Hiragino Sans GB, sans-serif;
}

button,
img {
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100vh;
  overflow: hidden;
}

.screen {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(22px, 5vw, 56px);
}

.eyebrow {
  margin: 0 0 12px;
  color: #9f493e;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.24em;
}

.intro-screen {
  grid-template-columns: minmax(0, 0.95fr) minmax(280px, 1.05fr);
  gap: clamp(24px, 8vw, 92px);
}

.intro-copy {
  max-width: 560px;
  animation: riseIn 900ms ease both;
}

.intro-copy h1 {
  margin: 0;
  font-size: clamp(52px, 10vw, 124px);
  line-height: 0.92;
  font-weight: 900;
}

.intro-copy p:last-child {
  max-width: 460px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 2.2vw, 24px);
  line-height: 1.65;
}

.ambient {
  position: absolute;
  width: 34vmax;
  aspect-ratio: 1;
  border-radius: 46% 54% 62% 38%;
  filter: blur(24px);
  opacity: 0.22;
  pointer-events: none;
}

.ambient-one {
  left: -12vmax;
  bottom: -12vmax;
  background: conic-gradient(from 45deg, var(--rose), var(--gold), var(--green), var(--blue), var(--rose));
}

.ambient-two {
  right: -16vmax;
  top: -14vmax;
  background: conic-gradient(from 210deg, var(--violet), var(--blue), var(--gold), var(--rose), var(--violet));
}

.cover-stack,
.shuffle-stage {
  position: relative;
  width: min(72vw, 660px);
  aspect-ratio: var(--card-ratio);
}

.cover-card,
.shuffle-card {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: clamp(14px, 2.2vw, 24px);
  box-shadow: var(--shadow);
}

.cover-card {
  animation: stackFloat 2200ms ease-in-out infinite alternate;
}

.cover-card-1 { transform: translate(-18px, -22px) rotate(-7deg); }
.cover-card-2 { transform: translate(22px, -10px) rotate(5deg); animation-delay: 120ms; }
.cover-card-3 { transform: translate(-4px, 18px) rotate(-2deg); animation-delay: 240ms; }
.cover-card-4 { transform: translate(48px, 30px) rotate(9deg); animation-delay: 360ms; }
.cover-card-5 { transform: translate(0, 0) rotate(0deg); animation-delay: 480ms; }

.guide-screen {
  align-content: center;
}

.guide-board {
  width: min(760px, 100%);
  display: grid;
  gap: 16px;
}

.guide-step {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: clamp(18px, 4vw, 28px);
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(36, 23, 19, 0.1);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(70, 42, 30, 0.12);
  opacity: 0;
  transform: translateY(22px);
  animation: guideIn 700ms ease forwards;
  animation-delay: var(--delay);
}

.guide-step span {
  display: grid;
  place-items: center;
  width: 54px;
  aspect-ratio: 1;
  border: 1px solid rgba(159, 73, 62, 0.28);
  border-radius: 50%;
  color: #9f493e;
  font-size: 13px;
  font-weight: 900;
}

.guide-step p {
  margin: 0;
  font-size: clamp(18px, 3vw, 25px);
  line-height: 1.48;
  font-weight: 750;
}

.breath-ring {
  position: absolute;
  width: min(70vmin, 560px);
  aspect-ratio: 1;
  border: 1px solid rgba(159, 73, 62, 0.15);
  border-radius: 50%;
  animation: breathe 2800ms ease-in-out infinite;
  pointer-events: none;
}

.shuffle-screen {
  text-align: center;
}

.shuffle-stage {
  width: min(72vw, 590px);
  margin: 18px auto 24px;
}

.shuffle-card {
  animation: shuffleOrbit 3600ms cubic-bezier(0.76, 0, 0.24, 1) infinite;
  animation-delay: calc(var(--n, 0) * 70ms);
}

.shuffle-card-1 { --n: 1; }
.shuffle-card-2 { --n: 2; }
.shuffle-card-3 { --n: 3; }
.shuffle-card-4 { --n: 4; }
.shuffle-card-5 { --n: 5; }
.shuffle-card-6 { --n: 6; }
.shuffle-card-7 { --n: 7; }
.shuffle-card-8 { --n: 8; }
.shuffle-card-9 { --n: 9; }
.shuffle-card-10 { --n: 10; }
.shuffle-card-11 { --n: 11; }
.shuffle-card-12 { --n: 12; }
.shuffle-card-13 { --n: 13; }

.screen-note {
  margin: 0;
  color: var(--muted);
  font-size: clamp(15px, 2.4vw, 18px);
}

.draw-screen {
  grid-template-rows: auto minmax(310px, 0.9fr) auto;
  gap: clamp(12px, 3vh, 28px);
  align-content: center;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 111, 127, 0.24), transparent 28%),
    radial-gradient(circle at 84% 18%, rgba(106, 174, 232, 0.2), transparent 30%),
    linear-gradient(135deg, #fff8ef 0%, #fff3de 48%, #f8fbf4 100%);
  color: var(--ink);
}

.draw-hint {
  align-self: end;
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.draw-hint p {
  margin: 0;
}

.draw-hint p:first-child {
  color: #9f493e;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.draw-hint p:last-child {
  margin-top: 8px;
  font-size: clamp(16px, 3.6vw, 22px);
}

.fan-stage {
  position: relative;
  width: 100vw;
  min-height: clamp(300px, 42vh, 520px);
  overflow: hidden;
  touch-action: pan-x;
  user-select: none;
  cursor: grab;
}

.fan-stage.is-dragging {
  cursor: grabbing;
}

.fan-track {
  position: absolute;
  left: 50%;
  bottom: clamp(88px, 12vh, 150px);
  width: var(--track-width);
  height: clamp(250px, 38vh, 470px);
  transform: translate3d(-50%, 0, 0);
  will-change: transform;
  z-index: 3;
}

.fan-card {
  position: absolute;
  left: 50%;
  bottom: var(--lift);
  width: clamp(112px, 19vw, 210px);
  aspect-ratio: var(--card-ratio);
  padding: 0;
  border: 0;
  border-radius: clamp(8px, 1.8vw, 16px);
  background: transparent;
  cursor: pointer;
  z-index: var(--z);
  transform: translateX(calc(var(--x) - 58px)) rotate(var(--angle));
  transform-origin: 50% 118%;
  transition: filter 150ms ease, translate 150ms ease, scale 150ms ease;
  will-change: transform;
}

.fan-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  border: 3px solid rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  -webkit-user-drag: none;
}

.fan-card:hover,
.fan-card:focus-visible {
  outline: 0;
  filter: brightness(1.05);
  translate: 0 -16px;
  scale: 1.04;
}

.fan-card.is-picked {
  filter: brightness(1.08);
  translate: 0 -22px;
  scale: 1.08;
}

.draw-instruction {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  width: min(760px, 100%);
  align-self: start;
  margin: clamp(4px, 1.5vh, 14px) auto 0;
  padding: clamp(18px, 4vw, 28px);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(36, 23, 19, 0.1);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(70, 42, 30, 0.12);
}

.draw-instruction p {
  margin: 0;
  color: var(--ink);
  font-size: clamp(18px, 3vw, 25px);
  line-height: 1.48;
  font-weight: 750;
}

.result-screen {
  grid-template-columns: minmax(280px, 1.12fr) minmax(260px, 0.88fr);
  gap: clamp(24px, 6vw, 72px);
}

.result-image-wrap {
  width: min(100%, 820px);
  aspect-ratio: var(--card-ratio);
}

.result-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: clamp(14px, 2vw, 24px);
  box-shadow: var(--shadow);
  animation: resultIn 720ms ease both;
}

.result-copy {
  max-width: 480px;
  animation: riseIn 760ms ease 160ms both;
}

.result-copy h2 {
  margin: 0 0 18px;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 0.98;
}

.result-copy p,
.result-copy li {
  color: var(--muted);
  font-size: clamp(15px, 2.1vw, 18px);
  line-height: 1.72;
}

.result-copy ul {
  margin: 22px 0;
  padding: 0;
  list-style: none;
}

.result-copy li {
  padding: 12px 0;
  border-top: 1px solid rgba(36, 23, 19, 0.1);
}

.result-copy .action {
  margin: 0;
  color: var(--ink);
  font-weight: 750;
}

.draw-again-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin-top: 26px;
  padding: 0 24px;
  border: 1px solid rgba(159, 73, 62, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: #9f493e;
  box-shadow: 0 14px 34px rgba(70, 42, 30, 0.12);
  cursor: pointer;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.draw-again-button:hover,
.draw-again-button:focus-visible {
  outline: 0;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 42px rgba(70, 42, 30, 0.16);
  transform: translateY(-2px);
}

.draw-again-button:active {
  transform: translateY(0);
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes stackFloat {
  to {
    translate: 0 -12px;
  }
}

@keyframes guideIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(0.84);
    opacity: 0.18;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.4;
  }
}

@keyframes shuffleOrbit {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  24% {
    transform: translate(calc((var(--n) - 7) * 18px), calc((7 - var(--n)) * 7px)) rotate(calc((var(--n) - 7) * 8deg));
  }
  54% {
    transform: translate(calc((7 - var(--n)) * 15px), calc((var(--n) - 7) * 12px)) rotate(calc((7 - var(--n)) * 10deg));
  }
  78% {
    transform: translate(calc((var(--n) - 7) * 8px), calc((var(--n) - 7) * -6px)) rotate(calc((var(--n) - 7) * 4deg));
  }
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
}

@keyframes dealIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(80px) scale(0.86);
  }
}

@keyframes railDealIn {
  from {
    opacity: 0;
    transform: translateY(42px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fanDealIn {
  from {
    opacity: 0;
    translate: 0 80px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes resultIn {
  from {
    opacity: 0;
    transform: rotate(-2deg) scale(0.94);
  }
  to {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
}

@media (max-width: 760px) {
  .screen {
    min-height: 100svh;
  }

  .intro-screen,
  .result-screen {
    grid-template-columns: 1fr;
    align-content: center;
  }

  .intro-copy {
    order: 2;
  }

  .cover-stack {
    order: 1;
    width: min(92vw, 520px);
  }

  .guide-step {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 14px;
  }

  .guide-step span {
    width: 42px;
  }

  .draw-screen {
    gap: 10px;
    padding-inline: 0;
  }

  .draw-hint {
    margin-top: 18px;
  }

  .fan-stage {
    min-height: 360px;
  }

  .fan-track {
    bottom: 104px;
    height: 330px;
  }

  .fan-card {
    width: clamp(102px, 34vw, 148px);
  }

  .draw-instruction {
    width: calc(100vw - 44px);
    margin-top: 18px;
  }

  .result-copy {
    max-width: none;
  }
}

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