:root {
  --mp-brand: #3182f6;
  --mp-brand-dark: #1b64da;
  --mp-brand-light: #69a5ff;
  --mp-grey-bg: #f2f4f6;
  --mp-surface: #ffffff;
  --mp-border: #e5e8eb;
  --mp-ink: #191f28;
  --mp-text: #6b7684;
  --mp-caption: #8b95a1;
  --mp-ease: cubic-bezier(0.22, 1, 0.36, 1);

  --story-bg: #0f1724;
  --story-mid: #152033;
  --story-text: #ffffff;
  --story-muted: #9aa8bc;

  --font-body: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;

  --radius-sm: 12px;
  --radius-btn: 16px;
  --radius-lg: 20px;
  --header-h: 64px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

html {
  height: 100%;
}

html.js-soft-snap {
  scroll-snap-type: none;
  scroll-behavior: auto;
}

html:not(.js-soft-snap) {
  scroll-snap-type: y proximity;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--story-text);
  background: var(--story-bg);
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* ——— Header ——— */
.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 40;
  height: var(--header-h);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  padding: 0 clamp(16px, 4vw, 40px);
  background: linear-gradient(180deg, rgba(15, 23, 36, 0.75) 0%, transparent 100%);
  color: #fff;
  pointer-events: none;
}

.site-header > * {
  pointer-events: auto;
}

.site-header .brand-mark {
  justify-self: start;
}

.site-header .site-nav {
  justify-self: end;
}

.header-status {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  white-space: nowrap;
}

.header-status__players {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.92);
}

.header-status__badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.88);
}

.header-status[data-load="pleasant"] .header-status__badge {
  background: rgba(25, 193, 120, 0.22);
  color: #8dffc0;
}

.header-status[data-load="busy"] .header-status__badge {
  background: rgba(255, 91, 91, 0.22);
  color: #ffb0b0;
}

.header-status[data-load="unknown"] .header-status__badge {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.75);
}

@media (max-width: 560px) {
  .site-header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    height: auto;
    min-height: var(--header-h);
    padding-top: 10px;
    padding-bottom: 10px;
    row-gap: 8px;
  }

  .brand-mark span {
    display: none;
  }

  .header-status {
    grid-column: 1 / -1;
    justify-self: stretch;
    justify-content: space-between;
  }

  .site-nav {
    grid-column: 2;
    grid-row: 1;
  }
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
}

.brand-mark__icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-cta {
  padding: 0.5rem 0.95rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s;
}

.nav-cta:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 52px;
  padding: 0.85rem 1.35rem;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.25s var(--mp-ease), background 0.2s, color 0.2s, border-color 0.2s,
    box-shadow 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn--primary {
  background: #fff;
  color: var(--mp-ink);
  border-color: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

.btn--primary:hover {
  background: #f2f4f6;
  border-color: #f2f4f6;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.btn--ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.32);
  box-shadow: none;
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.48);
}

.btn--lg {
  min-width: min(240px, 86vw);
  min-height: 56px;
  font-size: 1.05rem;
  margin-top: 0;
}

/* Light surfaces (QR / donate copy) keep blue primary */
.qr-modal__card .btn--primary,
.donate-panel .btn--primary {
  background: var(--mp-brand);
  color: #fff;
  border-color: var(--mp-brand);
  box-shadow: none;
}

.qr-modal__card .btn--primary:hover,
.donate-panel .btn--primary:hover {
  background: var(--mp-brand-dark);
  border-color: var(--mp-brand-dark);
}

.donate-panel .btn--ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.32);
}

/* ——— Story ——— */
.story {
  background: var(--story-bg);
  color: var(--story-text);
}

.story-panel {
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--header-h) + 1.5rem) clamp(20px, 5vw, 48px) 3rem;
  text-align: center;
  position: relative;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.story-panel--intro {
  padding-bottom: 5.5rem;
}

/* ——— Thanks to marquee ——— */
.thanks-marquee {
  position: absolute;
  left: 0;
  right: 0;
  bottom: clamp(1.5rem, 4vh, 2.75rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.9s var(--mp-ease) 0.35s, transform 0.9s var(--mp-ease) 0.35s;
  pointer-events: none;
}

.story-panel--intro.is-active .thanks-marquee {
  opacity: 1;
  transform: translateY(0);
}

.thanks-marquee__label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(154, 168, 188, 0.85);
}

.thanks-marquee__viewport {
  width: min(720px, 100%);
  overflow: hidden;
  mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 12%,
    #000 88%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 12%,
    #000 88%,
    transparent 100%
  );
}

.thanks-marquee__track {
  display: flex;
  width: max-content;
  gap: 0;
  will-change: transform;
  animation: thanks-marquee 28s linear infinite;
}

.thanks-marquee__item {
  flex: 0 0 auto;
  padding: 0 1.35rem;
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
}

.thanks-marquee__sep {
  flex: 0 0 auto;
  width: 4px;
  height: 4px;
  margin: auto 0;
  border-radius: 50%;
  background: rgba(154, 168, 188, 0.45);
}

@keyframes thanks-marquee {
  from {
    transform: translateX(-50%);
  }
  to {
    transform: translateX(0);
  }
}

.story-panel--accent {
  background: linear-gradient(180deg, var(--story-bg) 0%, #1a2d52 50%, var(--story-bg) 100%);
}

.story-panel--brand {
  background:
    radial-gradient(ellipse 65% 50% at 50% 40%, rgba(91, 141, 239, 0.28) 0%, transparent 70%),
    var(--story-bg);
}

.brand-reveal__icon {
  width: clamp(88px, 18vw, 120px);
  height: clamp(88px, 18vw, 120px);
  border-radius: 22%;
  margin-bottom: 1.5rem;
  opacity: 0;
  transform: translateY(28px) scale(0.94);
  transition: opacity 0.95s var(--mp-ease), transform 0.95s var(--mp-ease);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}

.brand-reveal__name {
  font-weight: 800;
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  letter-spacing: -0.03em;
  margin-bottom: 0.85rem;
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.95s var(--mp-ease) 0.12s, transform 0.95s var(--mp-ease) 0.12s;
}

.brand-reveal__tagline {
  width: min(520px, 88%);
  font-weight: 600;
  font-size: clamp(1.1rem, 2.8vw, 1.45rem);
  line-height: 1.5;
  letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.88);
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.95s var(--mp-ease) 0.22s, transform 0.95s var(--mp-ease) 0.22s;
}

.brand-reveal__actions {
  margin-top: 1.75rem;
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.95s var(--mp-ease) 0.32s, transform 0.95s var(--mp-ease) 0.32s;
}

.story-panel--brand.is-active .brand-reveal__icon,
.story-panel--brand.is-active .brand-reveal__name,
.story-panel--brand.is-active .brand-reveal__tagline,
.story-panel--brand.is-active .brand-reveal__actions {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.story-panel--finale {
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: visible;
  background:
    radial-gradient(ellipse 70% 45% at 50% 70%, rgba(91, 141, 239, 0.35) 0%, transparent 70%),
    var(--story-bg);
}

.finale-icon {
  width: 72px;
  height: 72px;
  border-radius: 22%;
  margin-bottom: 1.5rem;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.9s var(--mp-ease), transform 0.9s var(--mp-ease);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.story-panel--finale.is-active .finale-icon {
  opacity: 1;
  transform: translateY(0);
}

.finale-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  margin-top: 2rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.85s var(--mp-ease) 0.2s, transform 0.85s var(--mp-ease) 0.2s;
}

.story-panel--finale.is-active .finale-actions {
  opacity: 1;
  transform: translateY(0);
}

.story-text {
  width: min(900px, 88%);
  font-weight: 700;
  font-size: clamp(1.55rem, 4.2vw, 3rem);
  line-height: 1.45;
  letter-spacing: -0.03em;
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.9s var(--mp-ease), transform 0.9s var(--mp-ease);
}

.story-text--accent {
  background: linear-gradient(105deg, #ffffff 0%, #7eb0ff 55%, #5b8def 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.story-panel.is-active .story-text,
.story-panel.is-active .story-note,
.story-panel.is-active .counter {
  opacity: 1;
  transform: translateY(0);
}

.story-note {
  width: min(900px, 88%);
  margin-top: 1.35rem;
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--story-muted);
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s var(--mp-ease) 0.12s, transform 0.9s var(--mp-ease) 0.12s;
}

.counter {
  font-weight: 800;
  font-size: clamp(3.25rem, 11vw, 5.75rem);
  letter-spacing: -0.04em;
  line-height: 1;
  color: #fff;
  opacity: 0;
  transform: translateY(36px);
  transition: opacity 0.9s var(--mp-ease), transform 0.9s var(--mp-ease);
}

/* QR modal — fixed overlay so story snap heights stay stable */
.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.qr-modal[hidden] {
  display: none;
}

.qr-modal__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(15, 23, 36, 0.72);
  cursor: pointer;
}

.qr-modal__card {
  position: relative;
  z-index: 1;
  width: min(320px, 92vw);
  padding: 1.5rem 1.25rem 1.35rem;
  background: #fff;
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--mp-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: panel-in 0.35s var(--mp-ease) both;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.qr-modal__close {
  align-self: flex-end;
  margin: -0.35rem -0.15rem 0.5rem 0;
  border: 0;
  background: transparent;
  color: var(--mp-caption);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.35rem;
}

.qr-modal__close:hover {
  color: var(--mp-ink);
}

.qr-panel__title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
  width: 100%;
  text-align: center;
}

.qr-panel__image {
  display: block;
  width: 220px;
  height: 220px;
  margin: 0 auto;
  border-radius: 12px;
}

.qr-panel__hint {
  margin-top: 0.9rem;
  font-size: 0.85rem;
  color: #4e5968;
  line-height: 1.45;
  width: 100%;
  text-align: center;
}

.qr-panel__link {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--mp-brand);
  text-align: center;
}

.qr-panel__link:hover {
  text-decoration: underline;
}

/* Donate panel */
.donate-panel {
  width: min(420px, 92%);
  margin-top: 1.75rem;
  padding: 1.35rem 1.2rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-lg);
  text-align: center;
  animation: panel-in 0.4s var(--mp-ease) both;
}

.donate-panel[hidden] {
  display: none;
}

.donate-panel__title {
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--story-muted);
  margin-bottom: 0.45rem;
}

.donate-panel__account {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 1.1rem;
  word-break: break-all;
}

.donate-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
}

.donate-panel__hint {
  margin-top: 0.9rem;
  font-size: 0.85rem;
  color: var(--story-muted);
}

.donate-panel__status {
  margin-top: 0.55rem;
  font-size: 0.9rem;
  color: var(--mp-brand-light);
  min-height: 1.2em;
}

/* ——— Footer ——— */
.site-footer {
  padding: 2rem clamp(20px, 5vw, 40px) 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-snap-align: end;
  scroll-snap-stop: normal;
}

.site-footer--dark {
  background: #0a1018;
  color: var(--story-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.site-footer__brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-footer__brand-row img {
  border-radius: 7px;
}

.site-footer--dark .site-footer__brand {
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}

.site-footer__disclaimer {
  font-size: 0.8rem;
  line-height: 1.5;
  max-width: 42em;
}

.site-footer__meta a {
  font-size: 0.85rem;
  color: var(--mp-brand-light);
  font-weight: 600;
}

.site-footer__meta a:hover {
  color: #fff;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .brand-mark span {
    font-size: 0.88rem;
  }

  .finale-actions {
    width: 100%;
  }

  .finale-actions .btn {
    flex: 1 1 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html,
  html.js-soft-snap,
  html:not(.js-soft-snap) {
    scroll-behavior: auto;
    scroll-snap-type: none;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .story-text,
  .story-note,
  .counter,
  .finale-icon,
  .finale-actions,
  .brand-reveal__icon,
  .brand-reveal__name,
  .brand-reveal__tagline,
  .brand-reveal__actions,
  .thanks-marquee {
    opacity: 1;
    transform: none;
  }

  .thanks-marquee__track {
    animation: none;
    flex-wrap: wrap;
    justify-content: center;
    width: min(720px, 92vw);
    row-gap: 0.35rem;
  }

  .thanks-marquee__sep {
    display: none;
  }
}
