:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #191f28;
  --muted: #6b7684;
  --soft: #8b95a1;
  --line: #edf0f3;
  --blue: #3182f6;
  --blue-pressed: #1b64da;
  --blue-soft: #eaf3ff;
  --green: #00a881;
  --coral: #ff6f61;
  --ink: #0f1720;
  --shadow: 0 10px 28px rgba(25, 31, 40, 0.06);
  --button-shadow: 0 8px 20px rgba(49, 130, 246, 0.24);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Noto Sans KR", sans-serif;
  letter-spacing: 0;
}

body.playing {
  overflow: hidden;
}

button {
  font: inherit;
  letter-spacing: 0;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.intro-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 38px;
  padding: 24px;
  background: var(--surface);
}

.intro-copy {
  margin: 0;
  color: var(--text);
  font-size: 27px;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
}

.gender-choice {
  width: min(360px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.gender-button {
  min-width: 0;
}

.primary-button,
.secondary-button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  padding: 0 20px;
  font-size: 16px;
  font-weight: 850;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease,
    box-shadow 120ms ease;
}

.primary-button {
  background: var(--blue);
  color: #fff;
  box-shadow: var(--button-shadow);
}

.primary-button:hover {
  background: var(--blue-pressed);
}

.secondary-button {
  background: #eef2f6;
  color: var(--text);
  box-shadow: none;
}

.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.trailer-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fff;
  color: var(--text);
}

.trailer-bg {
  display: none;
}

.trailer-progress {
  position: absolute;
  top: 22px;
  left: 50%;
  z-index: 2;
  width: min(420px, calc(100vw - 40px));
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  transform: translateX(-50%);
}

.trailer-progress span {
  height: 3px;
  overflow: hidden;
  border-radius: 8px;
  background: #e5e8eb;
}

.trailer-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.trailer-frame {
  position: relative;
  z-index: 1;
  width: min(430px, 100%);
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
}

.trailer-kicker {
  width: fit-content;
  margin: 0 0 14px;
  border-radius: 8px;
  padding: 8px 10px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.trailer-title {
  margin: 0;
  font-size: 40px;
  line-height: 1.13;
  font-weight: 900;
}

.trailer-detail {
  min-height: 54px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
}

.scene-pop .trailer-kicker,
.scene-pop .trailer-title,
.scene-pop .trailer-detail {
  animation: scenePop 150ms ease both;
}

.scene-pop .trailer-title {
  animation-delay: 12ms;
}

.scene-pop .trailer-detail {
  animation-delay: 24ms;
}

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

.result-screen {
  position: relative;
  width: min(480px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  overflow-x: hidden;
  background: var(--bg);
  box-shadow: var(--shadow);
  padding: clamp(56px, 9dvh, 86px) 18px 54px;
}

.result-visual {
  display: none;
}

.result-header,
.summary-panel,
.risk-panel,
.action-row,
.story-panel,
.life-player,
.collection-panel,
.earth-panel,
.source-panel {
  position: relative;
  z-index: 1;
}

.result-header {
  display: none;
  padding-top: 18px;
}

.eyebrow,
.section-label,
.source-type,
.metric-label {
  display: block;
  margin: 0;
  color: var(--soft);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
}

.result-header h1 {
  margin: 8px 0 0;
  color: var(--text);
  font-size: 34px;
  line-height: 1.18;
  font-weight: 900;
}

.result-subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.55;
}

.summary-panel {
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  overflow: hidden;
}

.summary-list {
  padding: 16px 16px 4px;
}

.summary-item {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 10px;
  align-items: start;
  min-height: 34px;
}

.summary-item + .summary-item {
  margin-top: 8px;
}

.summary-dot {
  width: 7px;
  height: 7px;
  margin-top: 9px;
  border-radius: 50%;
  background: var(--blue);
}

.summary-item p {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 760;
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.life-player[data-card-type="summary"] .summary-item {
  grid-template-columns: 1fr;
  min-height: auto;
  border-top: 0;
  padding: 0;
}

.life-player[data-card-type="summary"] .summary-item + .summary-item {
  margin-top: 12px;
}

.life-player[data-card-type="summary"] .summary-dot {
  display: none;
}

.life-player[data-card-type="summary"] .summary-item p {
  color: #333d4b;
  font-size: 21px;
  font-weight: 850;
  line-height: 1.45;
}

.life-player[data-card-type="summary"] .summary-item:last-child p {
  color: #4e5968;
  font-size: 20px;
}

.life-player[data-card-type="summary"] .life-card-head h2 {
  font-size: 30px;
  line-height: 1.24;
}

.life-player[data-card-type="story"] .section-label {
  color: var(--blue);
}

.life-player[data-card-type="story"] .life-card-head h2 {
  font-size: 30px;
}

.life-player[data-card-type="risk"] .life-card-head h2 {
  font-size: 28px;
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  background: #f9fafb;
}

.metric-row > div {
  min-width: 0;
  padding: 16px;
}

.metric-row > div + div {
  border-left: 1px solid var(--line);
}

.metric-row strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.25;
}

.risk-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.risk-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.risk-panel-head strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  text-align: right;
}

.risk-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.risk-item {
  min-width: 0;
  border-radius: 8px;
  background: #f9fafb;
  padding: 12px;
}

.risk-item span {
  display: block;
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.risk-item strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 16px;
  font-weight: 850;
  line-height: 1.35;
}

.risk-item em {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.45;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.result-screen:not(.show-end-panels) .action-row,
.result-screen:not(.show-end-panels) .collection-panel,
.result-screen:not(.show-end-panels) .earth-panel,
.result-screen:not(.show-end-panels) .source-panel {
  display: none;
}

.result-screen.show-end-panels {
  padding-bottom: 54px;
}

.action-row button {
  flex: 1 1 180px;
}

.life-player {
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 0;
  border: 1px solid rgba(229, 232, 235, 0.9);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8),
    0 10px 26px rgba(25, 31, 40, 0.05);
}

.life-player.is-card-enter {
  animation: card-enter 180ms ease both;
}

@keyframes card-enter {
  from {
    opacity: 0.72;
  }

  to {
    opacity: 1;
  }
}

.result-screen:not(.show-end-panels) .life-player {
  height: auto;
  min-height: 0;
}

.result-screen:not(.show-end-panels) .life-player[data-card-type="summary"] {
  height: auto;
  min-height: 0;
}

.result-screen.show-end-panels .life-player {
  min-height: auto;
}

.result-screen.show-end-panels .story-nav {
  position: static;
  left: auto;
  bottom: auto;
  width: auto;
  margin: 10px 18px 18px;
  transform: none;
}

.card-progress {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 14px 16px 0;
}

.card-progress span {
  height: 2px;
  border-radius: 8px;
  background: #e5e8eb;
  transition: background 180ms ease, transform 180ms ease;
}

.card-progress span.is-past,
.card-progress span.is-active {
  background: var(--blue);
}

.card-progress span.is-active {
  transform: scaleY(1.8);
}

.life-card-head {
  padding: 18px 20px 0;
}

.life-card-head h2 {
  margin: 10px 0 0;
  color: var(--text);
  font-size: 29px;
  font-weight: 900;
  line-height: 1.27;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.life-card-head p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 760;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.life-card-basis {
  display: block;
  margin-top: 10px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
}

.life-player .risk-toggle {
  width: calc(100% - 36px);
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 14px 18px 0;
  background: #f2f4f6;
  color: #333d4b;
  font-size: 15px;
  box-shadow: none;
}

.life-player .risk-toggle::after {
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: translateY(-2px) rotate(45deg);
}

.life-player .risk-toggle[aria-expanded="true"]::after {
  transform: translateY(2px) rotate(225deg);
}

.life-player .summary-list {
  flex: none;
  padding: 18px 20px 14px;
}

.life-player .metric-row {
  margin-top: 4px;
}

.rarity-slot {
  --slot-row-height: 46px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 0 20px 18px;
  border: 1px solid #e8edf3;
  border-radius: 8px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #fbfcfd 0%, #f7f9fb 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.rarity-slot-label {
  color: #4e5968;
  font-size: 14px;
  font-weight: 850;
  white-space: nowrap;
}

.rarity-slot-window {
  position: relative;
  height: var(--slot-row-height);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.rarity-slot-window::before,
.rarity-slot-window::after {
  position: absolute;
  z-index: 2;
  right: 0;
  left: 0;
  height: 13px;
  pointer-events: none;
  content: "";
}

.rarity-slot-window::before {
  top: 0;
  background: linear-gradient(180deg, #fff 0%, rgba(255, 255, 255, 0) 100%);
}

.rarity-slot-window::after {
  bottom: 0;
  background: linear-gradient(0deg, #fff 0%, rgba(255, 255, 255, 0) 100%);
}

.rarity-slot-reel {
  --slot-index: 0;
  transform: translateY(calc(var(--slot-index) * var(--slot-row-height) * -1));
}

.rarity-slot.is-settled .rarity-slot-reel {
  transition: transform 2600ms cubic-bezier(0.16, 1, 0.3, 1);
}

.rarity-slot-reel span {
  height: var(--slot-row-height);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: var(--blue);
  font-size: 27px;
  font-weight: 950;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.story-card-body {
  flex: none;
  min-height: 0;
  margin: 0;
  padding: 18px 20px 24px;
  color: #333d4b;
  font-size: 17px;
  font-weight: 550;
  line-height: 1.68;
  overflow: hidden;
  white-space: pre-line;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.life-player .risk-grid {
  margin-top: 0;
  padding: 18px;
}

.story-nav {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  position: static;
  z-index: 20;
  left: auto;
  bottom: auto;
  width: auto;
  margin: 2px 18px 18px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
}

.life-player[data-card-type="summary"] .story-nav {
  grid-template-columns: minmax(84px, 0.76fr) minmax(96px, 0.9fr) 1fr;
  margin: 0 18px 18px;
  border: 0;
  padding: 0;
}

.life-player[data-card-type="summary"] .story-nav .secondary-button {
  color: #4e5968;
  background: #f2f4f6;
}

.life-player[data-card-type="summary"] .story-nav .copy-button {
  color: var(--blue);
  background: var(--blue-soft);
}

.compact-button {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.copy-button.is-copied {
  color: #fff !important;
  background: var(--green) !important;
}

.copy-button.is-error {
  color: #fff !important;
  background: var(--coral) !important;
}

.story-nav .primary-button {
  position: relative;
  font-size: 17px;
  box-shadow: none;
}

.story-nav .primary-button[data-action="next"]::after {
  width: 7px;
  height: 7px;
  margin-left: 9px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  content: "";
  transform: rotate(45deg);
}

.story-nav button:disabled {
  cursor: default;
  opacity: 0.38;
  transform: none;
}

.story-panel {
  max-height: 1800px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  transition: max-height 240ms ease, border-width 240ms ease, margin 240ms ease;
}

.story-panel.collapsed {
  max-height: 0;
  margin-top: 0;
  border-width: 0;
}

.story-panel article {
  padding: 20px 18px;
}

.story-panel article + article {
  border-top: 1px solid var(--line);
}

.story-panel h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.3;
}

.story-panel p {
  margin: 0;
  color: #333d4b;
  font-size: 16px;
  line-height: 1.8;
}

.collection-panel,
.earth-panel,
.source-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.earth-panel p,
.source-panel p {
  margin: 8px 0 0;
  color: #333d4b;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.65;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 8px;
  padding: 0 10px;
  background: #eef2f6;
  color: #333d4b;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.chip:nth-child(3n) {
  background: rgba(0, 168, 129, 0.1);
  color: #08785f;
}

.chip:nth-child(4n) {
  background: rgba(255, 111, 97, 0.1);
  color: #b9483d;
}

.earth-bars {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.earth-bar {
  display: grid;
  grid-template-columns: 94px 1fr 28px;
  gap: 10px;
  align-items: center;
}

.earth-bar span {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.earth-bar i {
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: #eef2f6;
}

.earth-bar b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.earth-bar em {
  color: var(--soft);
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
  text-align: right;
}

.source-panel {
  display: grid;
  gap: 14px;
  background: #fbfcfd;
}

.source-type {
  color: var(--blue);
}

.source-type.creative {
  color: var(--green);
}

@media (max-width: 480px) {
  .intro-copy {
    font-size: 24px;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .intro-button {
    width: auto;
    min-width: 178px;
  }

  .gender-choice {
    width: min(320px, 100%);
  }

  .trailer-frame {
    min-height: 78dvh;
    padding: 22px;
  }

  .trailer-title {
    font-size: 39px;
  }

  .trailer-detail {
    font-size: 17px;
  }

  .result-screen {
    box-shadow: none;
    padding: clamp(62px, 9dvh, 84px) 18px 54px;
  }

  .result-header h1 {
    font-size: 31px;
  }

  .summary-item p {
    font-size: 16px;
  }

  .life-player[data-card-type="summary"] .life-card-head h2 {
    font-size: 29px;
  }

  .life-player[data-card-type="summary"] .summary-item p {
    font-size: 20px;
  }

  .life-player[data-card-type="summary"] .summary-item:last-child p {
    font-size: 19px;
  }

  .metric-row strong {
    font-size: 18px;
  }

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

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