:root {
  color-scheme: light;
  --ink: #17221d;
  --muted: #69756e;
  --paper: #f2eee4;
  --paper-deep: #e7dfcf;
  --jade: #315f4d;
  --jade-dark: #173b30;
  --cinnabar: #9f3529;
  --gold: #b38a4b;
  --line: rgba(27, 45, 37, .12);
  --shadow: 0 18px 45px rgba(27, 36, 31, .14);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #d8d3c7; color: var(--ink); font-family: "PingFang SC", "Noto Serif SC", "Songti SC", system-ui, sans-serif; }
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.app-shell { position: relative; width: min(100%, 480px); min-height: 100svh; margin: 0 auto; overflow: hidden; background: var(--paper); box-shadow: 0 0 70px rgba(0,0,0,.16); }
main { min-height: 100svh; }
.screen { display: none; min-height: 100svh; padding: 24px 20px 110px; animation: reveal .35s ease; }
.screen.active { display: block; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } }

.landing { position: relative; display: none; padding: max(52px, env(safe-area-inset-top)) 26px 30px; color: #f7f2e6; background: radial-gradient(circle at 70% 22%, rgba(181,143,79,.19), transparent 28%), linear-gradient(160deg, #24382f 0%, #13241e 54%, #0b1511 100%); }
.landing.active { display: flex; flex-direction: column; }
.mountains { position: absolute; inset: 0; overflow: hidden; opacity: .65; }
.mountains i { position: absolute; display: block; width: 430px; height: 430px; border-radius: 44% 60% 8% 10%; background: linear-gradient(145deg, rgba(112,139,124,.1), rgba(2,9,6,.72)); transform: rotate(45deg); }
.mountains i:nth-child(1) { left: -280px; top: 165px; }
.mountains i:nth-child(2) { right: -300px; top: 90px; width: 500px; height: 500px; }
.mountains i:nth-child(3) { left: 70px; top: 280px; opacity: .55; }
.landing-copy, .arrival-card { position: relative; z-index: 1; }
.landing-copy { margin-top: 16vh; }
.eyebrow { margin: 0 0 12px; color: var(--gold); font-size: 12px; letter-spacing: .24em; text-transform: uppercase; }
.landing h1 { margin: 0; font-family: "STKaiti", "KaiTi", serif; font-size: clamp(38px, 10vw, 52px); font-weight: 500; line-height: 1.3; letter-spacing: .05em; }
.lead { max-width: 290px; margin-top: 22px; color: rgba(247,242,230,.68); font-size: 14px; line-height: 1.8; }
.arrival-card { margin-top: auto; padding: 22px; border: 1px solid rgba(255,255,255,.13); border-radius: 20px; background: rgba(255,255,255,.07); box-shadow: 0 22px 70px rgba(0,0,0,.22); backdrop-filter: blur(12px); }
.arrival-card p { margin: 0 0 8px; color: rgba(255,255,255,.72); font-size: 13px; }
.arrival-card strong { color: #fff; }
.arrival-card small { display: block; margin-top: 11px; text-align: center; color: rgba(255,255,255,.48); }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #6fbf8f; box-shadow: 0 0 0 4px rgba(111,191,143,.12); }
.primary { width: 100%; margin-top: 14px; padding: 15px 20px; border: 0; border-radius: 13px; color: #fff; background: var(--cinnabar); box-shadow: 0 8px 24px rgba(159,53,41,.25); cursor: pointer; }

.world-bar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; height: 70px; padding: max(10px, env(safe-area-inset-top)) 18px 8px; border-bottom: 1px solid var(--line); background: rgba(242,238,228,.9); backdrop-filter: blur(18px); }
.world-bar > div { display: flex; align-items: center; gap: 10px; }
.world-bar strong, .world-bar small { display: block; }
.world-bar strong { font-size: 13px; }
.world-bar small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.seal { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid currentColor; color: var(--cinnabar); font-family: "STKaiti", serif; font-size: 12px; line-height: 1; transform: rotate(-2deg); }
.seal.large { width: 45px; height: 45px; font-size: 21px; }
.weather { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.48); font-size: 11px; }
.weather > span:first-child { color: var(--jade); font-family: "STKaiti", serif; font-size: 17px; }

.town { padding-top: 26px; background: linear-gradient(180deg, rgba(211,219,208,.6), transparent 230px), var(--paper); }
.town-heading h2 { margin: 5px 0 10px; font-family: "STKaiti", serif; font-size: 30px; font-weight: 500; }
.town-heading > p:last-child { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.headline-card { display: grid; grid-template-columns: 48px 1fr 12px; align-items: center; gap: 13px; margin: 25px 0 30px; padding: 16px; border: 1px solid rgba(179,138,75,.22); border-radius: 17px; background: #fffaf0; box-shadow: 0 12px 35px rgba(75,59,35,.07); cursor: pointer; }
.headline-icon { display: grid; place-items: center; width: 48px; height: 52px; color: #f7e9d1; background: var(--cinnabar); font-family: "STKaiti", serif; font-size: 24px; clip-path: polygon(0 0,100% 0,100% 85%,50% 100%,0 85%); }
.headline-card span { color: var(--cinnabar); font-size: 10px; letter-spacing: .15em; }
.headline-card h3 { margin: 3px 0 4px; font-size: 15px; }
.headline-card p { margin: 0; color: var(--muted); font-size: 11px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-title h3 { margin: 0; font-size: 17px; }
.section-title span { color: var(--muted); font-size: 10px; }
.places { display: grid; gap: 10px; }
.place { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 13px; width: 100%; padding: 13px; border: 1px solid var(--line); border-radius: 16px; text-align: left; background: rgba(255,255,255,.58); cursor: pointer; }
.place.featured { border-color: rgba(49,95,77,.25); background: #f7f8f2; box-shadow: 0 10px 30px rgba(36,72,57,.07); }
.place-art { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px 12px 4px 4px; color: #e9e3d4; background: #58665f; font-family: "STKaiti", serif; font-size: 20px; }
.inn-art { background: linear-gradient(145deg, #73483a, #3c2d28); }
.place strong, .place small { display: block; }
.place strong { margin-bottom: 5px; font-size: 14px; }
.place small { color: var(--muted); font-size: 11px; }
.place em { color: var(--jade); font-size: 10px; font-style: normal; white-space: nowrap; }
.place em i { display: inline-block; width: 5px; height: 5px; margin-right: 4px; border-radius: 50%; background: #51a472; }

.scene { padding: 0 0 88px; background: #eee9de; }
.scene-heading { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; padding: 15px 16px 13px; border-bottom: 1px solid var(--line); background: rgba(242,238,228,.94); }
.scene-heading .back, .people-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.55); }
.scene-heading .back { font-size: 26px; }
.scene-heading div { text-align: center; }
.scene-heading p, .scene-heading h2, .scene-heading span { margin: 0; }
.scene-heading p { color: var(--muted); font-size: 9px; }
.scene-heading h2 { margin: 2px 0 3px; font-family: "STKaiti", serif; font-size: 21px; font-weight: 500; }
.scene-heading span { color: var(--muted); font-size: 9px; }
.scene-atmosphere { position: relative; min-height: 150px; padding: 40px 31px 28px 100px; color: #f3eee3; background: radial-gradient(circle at 17% 20%, rgba(227,154,71,.24), transparent 18%), linear-gradient(135deg, #452f28, #1e2822 80%); overflow: hidden; }
.scene-atmosphere:after { content: ""; position: absolute; inset: auto -15px -55px 45%; width: 180px; height: 130px; border: 14px solid rgba(255,255,255,.035); border-radius: 50% 50% 0 0; }
.scene-atmosphere p { position: relative; z-index: 1; margin: 0; font-family: "STKaiti", serif; font-size: 14px; line-height: 1.8; }
.lantern { position: absolute; top: 24px; left: 30px; width: 43px; padding: 12px 0; border-radius: 18px; text-align: center; color: #ffe5bc; background: #9d392d; box-shadow: 0 0 34px rgba(239,157,64,.27); font-family: "STKaiti", serif; line-height: 1.25; }
.story-feed { padding: 19px 17px 140px; }
.moment { margin-bottom: 18px; }
.moment.system { display: flex; gap: 12px; padding: 11px 13px; border-left: 2px solid rgba(159,53,41,.25); color: var(--muted); background: rgba(255,255,255,.35); font-family: "STKaiti", serif; font-size: 12px; line-height: 1.6; }
.moment.system time { font-family: system-ui; font-size: 9px; white-space: nowrap; }
.moment.system p { margin: 0; }
.moment.speech { display: flex; align-items: flex-start; gap: 10px; }
.avatar { display: grid; flex: 0 0 auto; place-items: center; width: 36px; height: 36px; border-radius: 10px 10px 3px 3px; color: #fff; background: #7a5550; font-family: "STKaiti", serif; }
.avatar.green { background: #426455; }
.avatar.npc { border: 1px solid #9d392d; color: #9d392d; background: transparent; }
.moment.speech b { font-size: 12px; }
.moment.speech b small { padding: 2px 5px; border-radius: 4px; color: var(--cinnabar); background: rgba(159,53,41,.08); font-size: 8px; font-weight: 400; }
.moment.speech p { display: inline-block; margin: 6px 0 0; padding: 10px 12px; border-radius: 4px 13px 13px 13px; background: rgba(255,255,255,.78); font-size: 13px; line-height: 1.6; box-shadow: 0 4px 15px rgba(33,46,39,.05); }
.moment.player .avatar { background: var(--cinnabar); }
.moment.player p { background: #e1e9df; }
.choices { position: absolute; z-index: 5; right: 14px; bottom: 77px; left: 14px; padding: 13px; border: 1px solid var(--line); border-radius: 16px; background: rgba(248,245,236,.96); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.choices > p { margin: 0 0 9px; color: var(--muted); font-size: 10px; }
.choices button { margin: 3px 3px 3px 0; padding: 8px 10px; border: 1px solid rgba(49,95,77,.18); border-radius: 20px; color: var(--jade-dark); background: #f2f6f0; font-size: 11px; }
.composer { position: absolute; z-index: 7; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; padding: 11px 14px max(11px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(246,242,233,.96); backdrop-filter: blur(16px); }
.composer button { border: 0; background: transparent; }
.composer > button:first-child { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; }
.composer input { min-width: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 18px; outline: none; background: #fff; font-size: 12px; }
.composer .send { color: var(--jade); font-size: 12px; font-weight: 600; }

.journal { padding-top: 30px; background: linear-gradient(165deg, rgba(204,215,203,.7), transparent 35%), var(--paper); }
.journal-cover { padding: 30px 22px; border: 1px solid rgba(64,80,70,.15); border-radius: 4px 25px 4px 4px; text-align: center; background: #eae3d5; box-shadow: var(--shadow); }
.journal-cover .seal { margin: 0 auto 17px; }
.journal-cover p { color: var(--muted); font-size: 10px; letter-spacing: .2em; }
.journal-cover h2 { margin: 8px 0; font-family: "STKaiti", serif; font-size: 28px; font-weight: 500; }
.journal-cover > span:last-child { color: var(--muted); font-size: 11px; }
.journal-body { padding: 25px 5px; }
.journal-body h3 { margin: 0 0 15px; font-size: 15px; }
.journal-body h3:not(:first-child) { margin-top: 30px; }
.timeline { border-left: 1px solid rgba(159,53,41,.22); }
.timeline > div { position: relative; display: grid; grid-template-columns: 52px 1fr; gap: 12px; margin-left: -4px; padding: 0 0 18px; }
.timeline > div:before { content: ""; width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--cinnabar); }
.timeline time { position: absolute; left: 14px; color: var(--cinnabar); font-size: 10px; }
.timeline p { grid-column: 2; margin: 0; font-family: "STKaiti", serif; font-size: 13px; line-height: 1.7; }
.empty-relation { padding: 17px; border: 1px dashed rgba(49,95,77,.2); border-radius: 14px; color: var(--muted); background: rgba(255,255,255,.35); font-size: 12px; line-height: 1.7; }

.tab-bar { position: absolute; z-index: 15; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(4,1fr); padding: 7px 4px max(7px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(246,242,233,.94); backdrop-filter: blur(18px); }
.tab-bar button { border: 0; color: #7a847e; background: transparent; font-size: 9px; }
.tab-bar button span { display: block; height: 23px; font-family: "STKaiti", serif; font-size: 17px; }
.tab-bar button.active { color: var(--cinnabar); }

dialog { width: min(calc(100% - 34px), 420px); padding: 0; border: 0; border-radius: 22px; background: var(--paper); box-shadow: 0 28px 90px rgba(0,0,0,.32); }
dialog::backdrop { background: rgba(9,17,13,.65); backdrop-filter: blur(4px); }
dialog form { padding: 27px 24px 23px; text-align: center; }
dialog .seal { margin: 0 auto 15px; }
dialog h2 { margin: 5px 0 20px; font-family: "STKaiti", serif; font-size: 24px; font-weight: 500; }
dialog input { width: 100%; padding: 13px; border: 0; border-bottom: 1px solid rgba(49,95,77,.25); outline: 0; text-align: center; background: transparent; font-family: "STKaiti", serif; font-size: 19px; }
.name-suggestions { display: flex; justify-content: center; gap: 7px; margin-top: 13px; }
.name-suggestions button { padding: 6px 9px; border: 1px solid var(--line); border-radius: 15px; color: var(--muted); background: transparent; font-size: 10px; }
dialog small { display: block; margin-top: 11px; color: var(--muted); font-size: 10px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 95px; max-width: 360px; padding: 10px 15px; border-radius: 20px; color: #fff; background: rgba(20,35,29,.9); font-size: 11px; opacity: 0; pointer-events: none; transform: translate(-50%, 15px); transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  body { padding: 24px 0; }
  .app-shell { min-height: calc(100svh - 48px); border-radius: 30px; }
  main, .screen { min-height: calc(100svh - 48px); }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
