:root {
  color-scheme: dark;
  --ink: #f7f4ed;
  --muted: rgba(238, 243, 247, 0.7);
  --line: rgba(255, 255, 255, 0.13);
  --night: #091522;
  --navy: #10243c;
  --sky: #3d7194;
  --sun: #f4b476;
  --stop: #ffd0b8;
  --panel: rgba(11, 26, 43, 0.84);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: var(--night); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Noto Sans CJK SC", sans-serif; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid #ffe0bd; outline-offset: 3px; }
.is-hidden { display: none !important; }
.modal-open { overflow: hidden; }

.story-header { position: fixed; z-index: 20; top: 0; left: 0; right: 0; height: calc(58px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; background: linear-gradient(180deg, rgba(4, 12, 21, 0.72), transparent); }
.story-header p { margin: 0; color: rgba(255,255,255,.58); font-size: 11px; letter-spacing: .12em; }
.story-brand { min-height: 44px; margin-left: -7px; padding: 0 7px; display: inline-flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; }
.story-brand span { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid rgba(255,255,255,.5); border-radius: 50%; font-family: "Songti SC", serif; }
.story-brand strong { font-size: 14px; letter-spacing: .14em; }

.story-app { min-height: 100dvh; }
.intro-screen { position: relative; min-height: 100dvh; overflow: hidden; display: grid; align-items: start; padding: calc(92px + env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) calc(42px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); isolation: isolate; background: #173752; }
.intro-screen::before { content: ""; position: absolute; z-index: -1; inset: 0; background: linear-gradient(180deg, rgba(3,12,22,.3) 0%, rgba(5,16,29,.1) 44%, rgba(5,13,22,.62) 100%), linear-gradient(90deg, rgba(4,13,23,.42), transparent 70%); }
.intro-screen::after { content: ""; position: absolute; z-index: -1; inset: auto 0 0; height: 25%; background: linear-gradient(180deg, transparent, rgba(3,10,17,.58)); }
.intro-art { position: absolute; z-index: -2; inset: 0; }
.intro-art img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center center; }
.intro-sky i { position: absolute; z-index: -1; display: block; width: 47vw; height: 11vw; max-height: 94px; border-radius: 50%; background: rgba(255,255,255,.25); filter: blur(16px); transform: rotate(-8deg); }
.intro-sky i:nth-child(1) { top: 28%; left: -9%; }
.intro-sky i:nth-child(2) { top: 42%; right: -16%; }
.intro-sky i:nth-child(3) { top: 15%; right: 25%; width: 24vw; opacity: .65; }
.intro-copy { position: relative; z-index: 2; width: min(100%, 560px); margin: clamp(32px, 8vh, 84px) auto 0; text-shadow: 0 2px 22px rgba(5,13,22,.6); }
.intro-kicker { margin: 0 0 13px; font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: rgba(255,255,255,.73); }
.intro-copy h1 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: clamp(34px, 10.3vw, 58px); line-height: 1.22; letter-spacing: -.045em; font-weight: 700; }
.intro-lead { margin: 18px 0 30px; font-family: "Songti SC", serif; font-size: 18px; letter-spacing: .06em; }
.primary-action { min-height: 52px; border: 0; border-radius: 999px; padding: 0 24px; display: inline-flex; align-items: center; justify-content: center; gap: 28px; color: #122237; background: linear-gradient(135deg, #fff7e8, #f3ba83); font-weight: 800; box-shadow: 0 12px 30px rgba(6, 16, 28, .27); cursor: pointer; }
.intro-copy .primary-action { width: 100%; }
.intro-note { margin: 14px 0 0; text-align: center; font-size: 11px; color: rgba(255,255,255,.72); }
.load-error, .script-error { margin: 13px 0 0; padding: 10px 12px; border: 1px solid rgba(255,255,255,.22); border-radius: 12px; color: rgba(255,255,255,.88); background: rgba(4,13,23,.46); font-size: 12px; line-height: 1.5; text-align: center; }
.script-error a { color: #ffe1bd; }
.primary-action:disabled { cursor: not-allowed; opacity: .66; }

.play-screen { min-height: 100dvh; padding: calc(76px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: radial-gradient(circle at 88% 3%, rgba(80, 122, 151, .37), transparent 27%), #08131f; }
.play-progress { width: min(100%, 760px); margin: 0 auto 14px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.play-progress span { font-size: 11px; letter-spacing: .12em; color: var(--muted); }
.play-progress button { min-width: 44px; min-height: 44px; margin: -12px -8px -12px 0; border: 0; color: var(--muted); background: transparent; font-size: 12px; cursor: pointer; }
.progress-line { height: 2px; overflow: hidden; background: rgba(255,255,255,.13); }
.progress-line i { display: block; width: 14%; height: 100%; background: linear-gradient(90deg, #f0ae76, #fff1d1); transition: width .35s ease; }
.story-card { width: min(100%, 760px); margin: 0 auto; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: var(--panel); box-shadow: 0 24px 70px rgba(0,0,0,.28); }
.scene-visual { position: relative; height: clamp(170px, 27vh, 260px); overflow: hidden; background: #19324a url("/static/assets/story-blue-hour.webp") center 60% / cover no-repeat; }
.scene-visual::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(6,15,26,.02), rgba(6,15,26,.34)); }
.scene-moon, .scene-water, .scene-window { display: none; }
.story-card[data-scene="hotel"] .scene-visual { background-position: center 78%; }
.story-card[data-scene="cinema"] .scene-visual { background-position: center 58%; }
.story-card[data-scene="bride_price"] .scene-visual,
.story-card[data-scene="split_cards"] .scene-visual { background-position: center 88%; }
.story-card[data-scene="property"] .scene-visual { background-position: center 62%; }
.story-card[data-scene="medical_bills"] .scene-visual { background-position: center 91%; }
.story-card[data-scene="final_request"] .scene-visual { background-position: center 48%; }
.story-copy { padding: 22px 21px 23px; }
.chapter-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.chapter-row span { font-size: 9px; letter-spacing: .17em; color: #f2b783; }
.chapter-row em { font-style: normal; font-size: 11px; color: var(--muted); }
.story-copy h2 { margin: 0; font-family: "Songti SC", serif; font-size: clamp(25px, 7vw, 36px); line-height: 1.28; letter-spacing: -.03em; }
.node-narrative { margin: 14px 0 18px; color: rgba(241,244,247,.73); font-size: 14px; line-height: 1.75; }
.amount-panel { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 4px 12px; padding: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.amount-panel span { font-size: 11px; color: var(--muted); }
.amount-panel strong { font-size: 19px; color: #ffe1bd; }
.amount-panel small { grid-column: 1 / -1; font-size: 11px; color: rgba(255,255,255,.68); }
.risk-tags { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0 0; padding: 0; list-style: none; }
.risk-tags li { padding: 6px 9px; border: 1px solid rgba(255, 197, 156, .25); border-radius: 999px; color: #f2cab1; background: rgba(160, 86, 55, .11); font-size: 10px; }
.choice-panel { position: sticky; z-index: 10; bottom: 0; width: min(100%, 760px); margin: 12px auto 0; padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: 1fr 1fr; gap: 10px; background: linear-gradient(180deg, transparent, #08131f 24%); }
.choice { min-height: 68px; padding: 12px 14px; border-radius: 17px; text-align: left; cursor: pointer; }
.choice small { display: block; margin-bottom: 4px; font-size: 11px; letter-spacing: .1em; opacity: .72; }
.choice strong { display: block; font-size: 13px; line-height: 1.35; }
.choice-continue { border: 1px solid var(--line); color: #dce6ec; background: rgba(18,38,58,.92); }
.choice-stop { border: 1px solid rgba(255,205,172,.34); color: #241a18; background: linear-gradient(135deg, #ffe7d2, #e7a977); }
.choice-stop small { opacity: .82; }

.stop-modal { position: fixed; z-index: 50; inset: 0; display: grid; align-items: end; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(1, 7, 13, .74); backdrop-filter: blur(8px); }
.modal-card { position: relative; max-height: calc(100dvh - 34px); overflow: auto; width: min(100%, 540px); margin: 0 auto; padding: 29px max(22px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left)); border: 1px solid rgba(255,255,255,.13); border-radius: 28px 28px 0 0; background: linear-gradient(165deg, #17354d, #0c1b2b 45%, #09131f); box-shadow: 0 -24px 70px rgba(0,0,0,.38); }
.modal-close { position: absolute; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); width: 44px; height: 44px; border: 0; border-radius: 50%; color: rgba(255,255,255,.78); background: rgba(255,255,255,.07); font-size: 26px; cursor: pointer; }
.modal-kicker { margin: 0 0 9px; color: #f1b481; font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.modal-card h2 { max-width: calc(100% - 40px); margin: 0; font-family: "Songti SC", serif; font-size: 27px; line-height: 1.3; }
.modal-card > p:not(.modal-kicker):not(.modal-insight) { margin: 10px 0 20px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.saved-amount { margin: 0 0 10px; padding: 18px; border-radius: 18px; background: linear-gradient(135deg, rgba(255,223,188,.16), rgba(238,150,99,.07)); border: 1px solid rgba(255,211,177,.18); }
.saved-amount span, .saved-amount small, .modal-fact span, .modal-fact small { display: block; color: var(--muted); font-size: 10px; }
.saved-amount strong { display: block; margin: 5px 0; color: #ffe1bd; font-size: clamp(25px, 8vw, 36px); line-height: 1.18; overflow-wrap: anywhere; }
.modal-fact { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.modal-fact strong { font-size: 14px; }
.modal-fact small { grid-column: 1 / -1; }
.postscript-note { margin: 12px 0 0; color: rgba(255,255,255,.68); font-size: 11px; line-height: 1.6; }
.modal-insight { margin: 15px 0 18px; color: rgba(241,244,247,.7); font-size: 12px; line-height: 1.7; }
.modal-actions { display: grid; gap: 9px; }
.modal-actions .primary-action, .secondary-action { width: 100%; min-height: 50px; }
.secondary-action { border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: transparent; cursor: pointer; }

.ending-screen { min-height: 100dvh; display: grid; align-content: center; justify-items: center; padding: calc(90px + env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); text-align: center; background: radial-gradient(circle at 50% 28%, rgba(74,117,148,.5), transparent 30%), linear-gradient(180deg, #11273c, #07121e); }
.ending-orbit { position: relative; width: 112px; height: 112px; margin-bottom: 22px; border: 1px solid rgba(255,255,255,.15); border-radius: 50%; }
.ending-orbit::before, .ending-orbit i { content: ""; position: absolute; border-radius: 50%; }
.ending-orbit::before { inset: 20px; background: radial-gradient(circle at 35% 30%, #fff9e4, #edb37f 45%, #9f5f48); box-shadow: 0 0 40px rgba(238,171,114,.27); }
.ending-orbit i { width: 9px; height: 9px; top: 12px; left: 13px; background: #fff2cf; box-shadow: 70px 75px 0 -2px rgba(255,255,255,.7); }
.ending-kicker { margin: 0 0 10px; color: #eeb17f; font-size: 10px; font-weight: 800; letter-spacing: .15em; }
.ending-screen h2 { margin: 0; font-family: "Songti SC", serif; font-size: clamp(30px, 9vw, 48px); line-height: 1.25; }
.ending-screen > p:not(.ending-kicker) { max-width: 480px; margin: 15px 0 24px; color: var(--muted); font-size: 13px; line-height: 1.75; }
.ending-ledger { width: min(100%, 430px); margin-bottom: 24px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.04); }
.ending-ledger span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.ending-ledger strong { color: #ffe0bd; font-size: clamp(22px, 7vw, 32px); overflow-wrap: anywhere; }
.ending-screen .primary-action { min-width: min(100%, 280px); }
.secondary-link { min-height: 44px; margin-top: 8px; display: inline-flex; align-items: center; color: rgba(255,255,255,.66); font-size: 12px; }

.story-footer { padding: 18px max(20px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); background: #050c14; }
.story-footer p { max-width: 700px; margin: 0 auto; color: rgba(255,255,255,.62); font-size: 11px; line-height: 1.7; text-align: center; }

@media (min-width: 720px) {
  .intro-screen { align-items: center; }
  .intro-copy { margin: 0 0 0 12vw; }
  .intro-art img { object-position: center 58%; }
  .story-card { display: grid; grid-template-columns: .92fr 1.08fr; }
  .scene-visual { height: auto; min-height: 470px; }
  .story-copy { padding: 34px; display: flex; flex-direction: column; justify-content: center; }
  .choice-panel { position: static; }
  .modal-card { margin-bottom: 28px; border-radius: 28px; }
}

@media (max-height: 700px) and (max-width: 719px) {
  .intro-screen { padding-top: calc(70px + env(safe-area-inset-top)); }
  .intro-copy { margin-top: 12px; }
  .intro-copy h1 { font-size: clamp(30px, 9.5vw, 40px); }
  .intro-lead { margin: 12px 0 18px; }
  .intro-note { display: none; }
}

@media (orientation: landscape) and (max-height: 560px) {
  .play-screen { padding-top: calc(62px + env(safe-area-inset-top)); }
  .story-card { display: grid; grid-template-columns: .72fr 1.28fr; }
  .scene-visual { height: auto; min-height: 280px; }
  .story-copy { padding: 18px 22px; }
  .story-copy h2 { font-size: 24px; }
  .node-narrative { margin: 8px 0 12px; line-height: 1.55; }
  .risk-tags { margin-top: 9px; }
  .choice { min-height: 58px; }
  .choice-panel { position: sticky; }
}

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