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

:root {
  --bg: #111416;
  --bg2: #182024;
  --gold: #b89557;
  --gold-light: #e0c083;
  --cold: #8fb3c1;
  --text: #ece8dd;
  --muted: #a5adb0;
  --border: rgba(184, 149, 87, 0.28);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Serif KR', serif;
  line-height: 1.8;
}

/* ── HERO ── */
.hero {
  --hero-image-width: 100%;
  --hero-image-height: 56.3vw;
  --hero-fade-start: calc(var(--hero-image-height) - 190px);
  --hero-fade-mid: calc(var(--hero-image-height) - 95px);
  --hero-fade-end: var(--hero-image-height);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: clamp(220px, 26vh, 280px) 24px 64px;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(55, 82, 92, 0.72) 0%, rgba(17, 20, 22, 0) 58%),
    linear-gradient(180deg, #15191b 0%, var(--bg) 100%);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(17, 20, 22, 0) 0, rgba(17, 20, 22, 0) var(--hero-fade-start), rgba(17, 20, 22, 0.5) var(--hero-fade-mid), var(--bg) var(--hero-fade-end), var(--bg) 100%),
    linear-gradient(90deg, rgba(17, 20, 22, 0.24) 0%, rgba(17, 20, 22, 0.04) 48%, rgba(17, 20, 22, 0.24) 100%),
    url("assets/wrist-bandage.png") center top / var(--hero-image-width) auto no-repeat;
  filter: saturate(1.12) contrast(1.08) brightness(1.04);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute; inset: 0;
  z-index: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Ccircle cx='300' cy='300' r='180' fill='none' stroke='%23c9a84c' stroke-width='0.6' opacity='0.026'/%3E%3Ccircle cx='300' cy='300' r='270' fill='none' stroke='%23c9a84c' stroke-width='0.6' opacity='0.018'/%3E%3C/svg%3E") center/800px;
  pointer-events: none;
}

@media (max-width: 700px) {
  .hero {
    --hero-image-width: min(175vw, 760px);
    --hero-image-height: min(98.5vw, 428px);
    min-height: 100svh;
    justify-content: flex-start;
    padding: clamp(230px, 32vh, 300px) 18px 48px;
  }

  .hero::before {
    background:
      linear-gradient(180deg, rgba(17, 20, 22, 0) 0, rgba(17, 20, 22, 0) var(--hero-fade-start), rgba(17, 20, 22, 0.5) var(--hero-fade-mid), var(--bg) var(--hero-fade-end), var(--bg) 100%),
      linear-gradient(90deg, rgba(17, 20, 22, 0.34) 0%, rgba(17, 20, 22, 0.12) 50%, rgba(17, 20, 22, 0.34) 100%),
      url("assets/wrist-bandage.png") center top / var(--hero-image-width) auto no-repeat;
  }

  .hero::after {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Ccircle cx='300' cy='300' r='180' fill='none' stroke='%23c9a84c' stroke-width='0.6' opacity='0.018'/%3E%3Ccircle cx='300' cy='300' r='270' fill='none' stroke='%23c9a84c' stroke-width='0.6' opacity='0.012'/%3E%3C/svg%3E") center top/760px;
  }
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-size: clamp(1.7rem, 5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.4;
  word-break: keep-all;
  max-width: 680px;
  margin-bottom: 20px;
  position: relative; z-index: 1;
}

.hero h1 em { color: var(--gold-light); font-style: normal; }

.hero-sub {
  color: var(--muted);
  font-size: 0.95rem;
  word-break: keep-all;
  max-width: 480px;
  margin-bottom: 44px;
  position: relative; z-index: 1;
}

/* ── CTA BUTTONS ── */
.cta-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  justify-content: center;
  margin-top: 36px;
  position: relative; z-index: 1;
}

.cta-btn, .cta-btn-paid, .cta-btn-free {
  padding: 16px 32px;
  font-size: 0.95rem;
  font-family: inherit;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, opacity .2s, background .2s;
  text-decoration: none;
  display: inline-block;
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.cta-btn, .cta-btn-paid {
  background: linear-gradient(135deg, #7a5010, var(--gold));
  color: #fff;
  border: none;
  box-shadow: 0 0 24px rgba(201,168,76,0.3);
  margin-top: 36px;
}
.cta-btn:hover, .cta-btn-paid:hover { transform: translateY(-2px); box-shadow: 0 0 40px rgba(201,168,76,0.5); }

.cta-btn-free {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold);
}
.cta-btn-free:hover { background: rgba(201,168,76,0.1); transform: translateY(-2px); }

.cta-container .cta-btn-paid, .cta-container .cta-btn-free { margin-top: 0; }

.hero-cta { margin-top: 32px; }

.hero-scroll-down {
  width: 46px;
  height: 46px;
  margin-top: 18px;
  border: 1px solid rgba(224, 192, 131, 0.44);
  border-radius: 50%;
  background: rgba(17, 20, 22, 0.56);
  color: var(--gold-light);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 18px rgba(201, 168, 76, 0.14);
  transition: transform .2s, border-color .2s, background .2s, box-shadow .2s;
}

.hero-scroll-down:hover {
  transform: translateY(2px);
  border-color: rgba(224, 192, 131, 0.74);
  background: rgba(24, 32, 36, 0.72);
  box-shadow: 0 0 24px rgba(201, 168, 76, 0.22);
}

.hero-scroll-down:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 4px;
}

.hero-scroll-down-icon {
  width: 12px;
  height: 12px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

@media (min-width: 768px) {
  .cta-container {
    flex-direction: row;
    gap: 20px;
  }
}

/* ── EMAIL MODAL ── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  display: none; /* Initial state */
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

#email-modal .modal-box {
  background: #171b1d;
  border: 1px solid var(--gold);
  padding: 32px;
  border-radius: 12px;
  width: 90%;
  max-width: 460px;
  text-align: center;
  position: relative;
  box-shadow: 0 0 40px rgba(201,168,76,0.2);
}

#email-modal .modal-box h3 {
  color: var(--gold);
  margin-bottom: 12px;
  font-size: 1.25rem;
}

#email-modal .modal-box p {
  font-size: 0.9rem;
  color: #ccc;
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-input {
  width: 100%;
  padding: 12px;
  background: #0d1113;
  border: 1px solid #444;
  color: #fff;
  border-radius: 6px;
  margin-bottom: 16px;
  font-family: inherit;
  font-size: 1rem;
}

.privacy-consent-box {
  text-align: left;
  border: 1px solid rgba(201,168,76,0.18);
  background: rgba(201,168,76,0.05);
  padding: 14px;
  margin: 0 0 16px;
  border-radius: 6px;
}

#email-modal .privacy-summary {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 12px;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: #d8d2c4;
  font-size: 0.8rem;
  line-height: 1.5;
  margin-bottom: 9px;
}

.consent-row input {
  flex: 0 0 auto;
  margin-top: 4px;
  accent-color: var(--gold);
}

#email-modal .consent-note {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 10px 0 0;
}

.consent-note a {
  color: var(--gold);
}

#email-modal .consent-error {
  min-height: 1.2em;
  color: #f0a080;
  font-size: 0.76rem;
  margin: 8px 0 0;
}

#email-modal [hidden] {
  display: none !important;
}

#email-modal .email-status {
  min-height: 1.4em;
  color: #f0a080;
  font-size: 0.82rem;
  margin: 0 0 14px;
  line-height: 1.5;
}

#email-modal .email-status:empty {
  margin-bottom: 0;
}

#email-modal .email-success-panel {
  padding-top: 4px;
}

#email-modal .email-success-panel h4 {
  color: var(--gold-light);
  font-size: 1.05rem;
  line-height: 1.5;
  margin: 0 0 12px;
}

#email-modal .email-success-panel p {
  color: #ddd;
  font-size: 0.9rem;
  line-height: 1.7;
  margin: 0 0 22px;
}

.modal-input:focus {
  outline: none;
  border-color: var(--gold);
}

.modal-submit {
  width: 100%;
  padding: 14px;
  background: var(--gold);
  color: #000;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s;
}

.modal-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-secondary {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold);
}

.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  color: #666;
  cursor: pointer;
  font-size: 1.5rem;
}

/* ── CHAR PROFILE (A variant) ── */
.char-profile {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 28px 28px 24px;
  max-width: 440px;
  width: 100%;
  text-align: left;
  position: relative; z-index: 1;
}
.char-name { font-size: 1.25rem; color: var(--gold-light); margin-bottom: 4px; }
.char-line { font-size: 0.84rem; color: var(--gold-light); font-style: italic; margin-bottom: 18px; }
.char-traits { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.char-trait { border: 1px solid var(--border); padding: 3px 10px; font-size: 0.75rem; color: var(--muted); }
.char-quote { font-style: italic; font-size: 0.88rem; color: var(--muted); border-left: 2px solid var(--gold); padding-left: 14px; }

@media (max-width: 700px) {
  .hero-a {
    padding-top: clamp(218px, 30vh, 258px);
    padding-bottom: 28px;
  }

  .hero-a h1 {
    margin-bottom: 16px;
  }

  .hero-a .hero-sub {
    margin-bottom: 34px;
  }

  .hero-a .char-profile {
    padding: 24px 22px 20px;
  }

  .hero-a .char-line,
  .hero-a .char-traits {
    margin-bottom: 14px;
  }

  .hero-a .hero-cta {
    margin-top: 24px;
  }

  .hero-a .hero-scroll-down {
    width: 44px;
    height: 44px;
    margin-top: 14px;
  }
}

/* ── WORLD CARD (B variant) ── */
.world-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 28px;
  max-width: 480px;
  width: 100%;
  text-align: left;
  position: relative; z-index: 1;
}
.world-card h3 { color: var(--gold-light); font-size: 1rem; margin-bottom: 10px; }
.world-card p { font-size: 0.88rem; color: var(--muted); line-height: 1.9; }
.badge-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.badge { border: 1px solid var(--border); color: var(--gold); padding: 5px 14px; font-size: 0.8rem; letter-spacing: 1px; }

@media (max-width: 700px) {
  .hero-b {
    padding-top: clamp(198px, 26vh, 232px);
    padding-bottom: 28px;
  }

  .hero-b .hero-sub {
    margin-bottom: 24px;
  }

  .hero-b .world-card {
    padding: 20px 20px 18px;
  }

  .hero-b .world-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
  }

  .hero-b .world-card p {
    font-size: 0.82rem;
    line-height: 1.68;
  }

  .hero-b .badge-row {
    gap: 7px;
    margin-top: 12px;
  }

  .hero-b .hero-cta {
    margin-top: 18px;
  }

  .hero-b .hero-scroll-down {
    width: 42px;
    height: 42px;
    margin-top: 12px;
  }
}

/* ── CHOICE PREVIEW (C variant) ── */
.choice-preview {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 28px;
  max-width: 480px;
  width: 100%;
  text-align: left;
  position: relative; z-index: 1;
}
.scene-text { font-style: italic; font-size: 0.88rem; color: var(--muted); margin-bottom: 20px; }
.choice-option {
  border: 1px solid var(--border);
  padding: 12px 18px;
  margin-bottom: 10px;
  font-size: 0.88rem;
  cursor: default;
  transition: border-color .2s, color .2s;
}
.choice-option:hover { border-color: var(--gold); color: var(--gold-light); }
.choice-option:last-child { margin-bottom: 0; }
.choice-option-button {
  width: 100%;
  display: block;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  line-height: 1.7;
  text-align: left;
  cursor: pointer;
}
.choice-option-button:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 3px;
}
.ending-badges { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.ending-badge { padding: 5px 16px; font-size: 0.8rem; border: 1px solid; }
.ending-badge.happy { border-color: #4a8c5a; color: #7bcf90; }
.ending-badge.tragedy { border-color: #8c3a3a; color: #c06060; }
.ending-badge.twist { border-color: var(--border); color: var(--gold); }

/* ── FEATURES ── */
.features {
  padding: 80px 24px;
  max-width: 820px;
  margin: 0 auto;
}
.features h2 { text-align: center; font-size: 1.1rem; color: var(--gold); letter-spacing: 2px; margin-bottom: 48px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.feature-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 28px 22px;
  text-align: center;
}
.feature-card .icon { font-size: 1.8rem; margin-bottom: 14px; }
.feature-card h3 { font-size: 0.95rem; color: var(--gold-light); margin-bottom: 8px; }
.feature-card p { font-size: 0.83rem; color: var(--muted); }

/* ── DIVIDER ── */
.divider { text-align: center; color: var(--gold); letter-spacing: 8px; opacity: 0.4; padding: 8px 0; font-size: 0.7rem; }

/* ── PROLOGUE ── */
#prologue {
  padding: 80px 24px;
  max-width: 660px;
  margin: 0 auto;
}
#prologue::before {
  content: '◈  프롤로그  ◈';
  display: block;
  text-align: center;
  color: var(--gold);
  font-size: 0.75rem;
  letter-spacing: 5px;
  margin-bottom: 48px;
}
.prologue-text { font-size: 0.97rem; color: var(--muted); line-height: 2.1; }
.prologue-text strong { color: var(--text); }
.prologue-text .gap { margin: 14px 0; display: block; }
.dialog {
  color: var(--cold);
  font-style: italic;
  margin: 14px 0;
  padding-left: 18px;
  border-left: 2px solid rgba(201,168,76,0.35);
  display: block;
}

/* ── CTA SECTION ── */
.cta-section {
  padding: 80px 24px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 100%, rgba(55, 82, 92, 0.52) 0%, transparent 65%);
}
.cta-section h2 { font-size: 1.4rem; margin-bottom: 10px; }
.cta-section p { color: var(--muted); font-size: 0.9rem; margin-bottom: 0; }

/* ── MODAL: 출시알림 / 무료 대화 소진 게이트 ── */
#payment-modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(8, 10, 12, 0.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#payment-modal.open { display: flex; }

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 44px 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}
.modal-box h3 { font-size: 1.1rem; color: var(--gold-light); margin-bottom: 10px; }
.modal-desc { font-size: 0.85rem; color: var(--muted); margin-bottom: 28px; }

#payment-modal .modal-box {
  background: linear-gradient(180deg, #1d262b 0%, #141a1d 100%);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 38px 30px 26px;
  max-width: 416px;
  position: relative;
  box-shadow: 0 26px 64px rgba(0, 0, 0, 0.62), 0 0 48px rgba(184, 149, 87, 0.12);
  animation: payment-gate-in 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes payment-gate-in {
  from { opacity: 0; transform: translateY(18px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* 자물쇠 엠블럼 */
.gate-emblem {
  width: 60px; height: 60px;
  margin: 2px auto 16px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-light);
  background: radial-gradient(circle, rgba(184, 149, 87, 0.22) 0%, transparent 72%);
  box-shadow: 0 0 22px rgba(184, 149, 87, 0.16);
}
.gate-emblem svg { width: 26px; height: 26px; }

/* 무료 대화 10회 소진 미터 */
.gate-meter {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-bottom: 18px;
}
.gate-pip {
  width: 15px; height: 5px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  opacity: 0.82;
}

#payment-modal .modal-box h3 {
  font-size: 1.22rem;
  color: var(--gold-light);
  margin-bottom: 12px;
  line-height: 1.5;
}
#payment-modal .modal-desc {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 24px;
}

#payment-modal .price-display {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(184, 149, 87, 0.05);
  padding: 14px 12px;
  margin-bottom: 22px;
}
.price-display .price-label {
  font-size: 0.72rem;
  color: var(--gold);
  letter-spacing: 2.5px;
  margin-bottom: 6px;
}
.price-display .price-value {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}

.pay-btn {
  background: linear-gradient(135deg, #8a5d1a, var(--gold-light));
  color: #1a1205;
  border: none;
  padding: 15px 0;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  border-radius: 9px;
  cursor: pointer;
  width: 100%;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
  box-shadow: 0 8px 22px rgba(184, 149, 87, 0.26);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.pay-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(184, 149, 87, 0.36);
}

#payment-modal .modal-secondary {
  border-radius: 9px;
  padding: 13px 0;
  font-size: 0.92rem;
  margin-bottom: 14px;
}

.modal-close-link {
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.16s ease;
}
.modal-close-link:hover { color: var(--gold-light); }

/* ── FOOTER ── */
footer { text-align: center; padding: 36px 24px; font-size: 0.72rem; color: var(--muted); border-top: 1px solid var(--border); opacity: .55; }

/* ── CHAT PAGE ── */
.chat-page {
  height: 100vh;
  overflow: hidden;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 12% 0%, rgba(143, 179, 193, 0.18) 0%, transparent 42%),
    linear-gradient(180deg, #15191b 0%, var(--bg) 45%, #0d1113 100%);
}

.chat-shell {
  width: min(1180px, 100%);
  height: 100vh;
  min-height: 0;
  margin: 0 auto;
  padding: 24px;
  overflow: hidden;
}

.chat-topbar {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 10px 0 22px;
}

.chat-back-link {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  color: var(--gold-light);
  text-decoration: none;
  font-size: 1.3rem;
  background: rgba(24, 32, 36, 0.76);
}

.chat-kicker {
  display: block;
  color: var(--gold);
  font-size: 0.68rem;
  letter-spacing: 3px;
  margin-bottom: 3px;
}

.chat-title-group h1 {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  line-height: 1.25;
}

.chapter-badge {
  border: 1px solid var(--border);
  color: var(--gold-light);
  background: rgba(24, 32, 36, 0.86);
  padding: 9px 14px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
  height: calc(100vh - 112px);
  min-height: 0;
}

.character-panel,
.chat-panel {
  border: 1px solid var(--border);
  background: rgba(24, 32, 36, 0.78);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.character-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.character-portrait {
  min-height: 230px;
  background:
    linear-gradient(180deg, rgba(17, 20, 22, 0.02) 0%, rgba(17, 20, 22, 0.86) 100%),
    url("assets/wrist-bandage.png") center top / cover no-repeat;
  border-bottom: 1px solid var(--border);
}

.character-summary {
  padding: 22px 22px 18px;
}

.character-role {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  letter-spacing: 2px;
  margin-bottom: 7px;
}

.character-summary h2 {
  color: #fff;
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.character-summary p {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.7;
}

.state-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.state-grid div {
  padding: 16px 18px;
}

.state-grid div + div {
  border-left: 1px solid var(--border);
}

.state-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 3px;
}

.state-grid strong {
  color: var(--gold-light);
  font-size: 1rem;
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 22px 24px;
}

.chapter-step {
  border-left: 2px solid rgba(184, 149, 87, 0.28);
  color: var(--muted);
  padding-left: 12px;
  font-size: 0.82rem;
}

.chapter-step.active {
  border-left-color: var(--gold-light);
  color: var(--gold-light);
}

.chapter-step.past {
  color: var(--text);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto auto auto;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chat-context-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.chat-context-strip span {
  border: 1px solid rgba(184, 149, 87, 0.22);
  color: var(--muted);
  padding: 5px 10px;
  font-size: 0.75rem;
  background: rgba(13, 17, 19, 0.44);
}

.message-list {
  min-height: 0;
  overflow-y: auto;
  padding: 24px 22px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.message-bubble {
  width: min(76%, 620px);
  margin-bottom: 16px;
  padding: 15px 17px 16px;
  border: 1px solid rgba(184, 149, 87, 0.22);
  background: rgba(13, 17, 19, 0.68);
}

.message-bubble.user {
  margin-left: auto;
  border-color: rgba(143, 179, 193, 0.32);
  background: rgba(41, 58, 64, 0.7);
}

.message-bubble.action {
  width: min(72%, 560px);
  margin-left: auto;
  border-color: rgba(184, 149, 87, 0.3);
  background: rgba(184, 149, 87, 0.1);
}

.message-bubble.character-action {
  width: min(80%, 620px);
  margin-right: auto;
  margin-left: 7%;
  border-color: rgba(143, 179, 193, 0.2);
  background: rgba(28, 36, 40, 0.48);
}

.message-bubble.narration {
  width: min(88%, 680px);
  margin-right: auto;
  margin-left: auto;
  border-color: rgba(184, 149, 87, 0.16);
  background: rgba(17, 20, 22, 0.42);
  text-align: center;
}

.message-speaker {
  display: block;
  color: var(--gold-light);
  font-size: 0.72rem;
  letter-spacing: 1px;
  margin-bottom: 5px;
}

.message-bubble.user .message-speaker {
  color: var(--cold);
}

.message-bubble.action .message-speaker {
  color: var(--gold-light);
}

.message-bubble.character-action .message-speaker {
  color: var(--muted);
}

.message-bubble.narration .message-speaker {
  color: var(--muted);
}

.message-bubble p {
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.85;
  white-space: pre-line;
}

.message-bubble.narration p {
  color: #c9c2b2;
  font-size: 0.86rem;
}

.message-bubble.action p {
  color: #ded0b6;
  font-size: 0.88rem;
}

.message-bubble.character-action p {
  color: #b8c4c7;
  font-size: 0.87rem;
}

.thinking-indicator {
  min-height: 1.4em;
  padding: 0 22px 12px;
  color: var(--gold-light);
  font-size: 0.8rem;
  letter-spacing: 0.4px;
}

.thinking-indicator[hidden] {
  display: none;
}

.starter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 20px 18px;
}

.starter-label {
  flex: 1 0 100%;
  color: var(--gold-light);
  font-size: 0.78rem;
  letter-spacing: 1px;
  padding: 0 2px;
}

.starter-chip.starter-reopen {
  flex: 1 0 100%;
  text-align: center;
  border-color: var(--gold);
  color: var(--gold-light);
  letter-spacing: 0.3px;
}
.starter-chip.starter-reopen:hover,
.starter-chip.starter-reopen:focus-visible {
  background: rgba(184, 149, 87, 0.14);
  border-color: var(--gold-light);
  color: var(--gold-light);
}

.starter-chip {
  flex: 1 1 180px;
  border: 1px solid var(--border);
  background: rgba(184, 149, 87, 0.08);
  color: var(--text);
  font-family: inherit;
  font-size: 0.84rem;
  line-height: 1.5;
  padding: 11px 12px;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}

.starter-chip:hover,
.starter-chip:focus-visible {
  border-color: var(--gold-light);
  color: var(--gold-light);
  outline: none;
}

.starter-chip:disabled {
  opacity: 0.52;
  cursor: wait;
}

.branch-chip {
  border-color: rgba(224, 192, 131, 0.54);
  background: rgba(184, 149, 87, 0.16);
}

.free-turn-counter {
  min-height: 1.4em;
  padding: 0 20px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
  padding: 18px 20px 20px;
  border-top: 1px solid var(--border);
}

.chat-input-row input {
  width: 100%;
  border: 1px solid rgba(184, 149, 87, 0.25);
  background: #0d1113;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 13px 14px;
}

.chat-input-row input:focus {
  outline: none;
  border-color: var(--gold);
}

.chat-input-row button {
  border: none;
  background: linear-gradient(135deg, #7a5010, var(--gold));
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.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;
}

@media (max-width: 860px) {
  .chat-page {
    height: auto;
    overflow: auto;
  }

  .chat-shell {
    height: auto;
    min-height: 100svh;
    overflow: visible;
    padding: 16px;
  }

  .chat-topbar {
    grid-template-columns: 40px 1fr;
  }

  .chapter-badge {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .chat-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
  }

  .character-panel {
    max-height: 360px;
  }

  .character-portrait {
    min-height: 180px;
    background-position: center 18%;
  }

  .chat-panel {
    height: min(680px, 72svh);
    min-height: 560px;
  }
}

@media (max-width: 560px) {
  .message-bubble {
    width: 100%;
  }

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

  .chat-input-row button {
    min-height: 44px;
  }
}

.site-legal {
  background: var(--bg);
  color: var(--muted);
  padding: 28px 20px 40px;
  margin-top: 64px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.7;
  font-family: 'Noto Serif KR', serif;
}
.site-legal p { margin: 0; }
.site-legal .divider { color: var(--border); margin: 0 .55em; }
.chat-page .site-legal { margin-top: 0; }
