/* Story-first presentation. Existing palette and all gameplay IDs are retained. */
html, body { background: var(--paper-deep); }
body, .birth-dialog, .birth-wheel, .event-stage, .game-shell { background-image: none; }
.grain { display: none; }
body:has(#game-screen:not([hidden])) { overflow: hidden; }
#demo-banner { height: 44px; max-width: 520px; margin: auto; padding: 0 10px; display: flex; align-items: center; justify-content: space-between; font-size: 10px; }
#demo-banner button { min-height: 44px; padding: 0 8px; border: 0; background: transparent; color: var(--paper); font-size: 11px; }
#app:has(#demo-banner:not([hidden])) #game-screen { height: calc(100dvh - 44px); min-height: calc(100svh - 44px); }
button, select, input { min-height: 44px; }
button { touch-action: manipulation; }
.start-screen { background: var(--ink); }
#game-screen { width: 100%; max-width: 520px; margin: 0 auto; padding: 16px 16px 0; min-height: 100svh; height: 100dvh; display: flex; flex-direction: column; gap: 12px; background: var(--paper); overflow: auto; }
#game-screen > .game-header, #game-screen > .game-grid, #game-screen > .life-clock { display: none; }
.story-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-shrink: 0; }
.story-identity { flex: 1; min-width: 0; }
.story-name { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
#character-name { margin: 0; font-size: 21px; line-height: 1.3; }
#age-label { font-size: 17px; white-space: nowrap; }
.story-origin { margin: 6px 0 0; line-height: 1.6; font-size: 11px; color: var(--soft-ink); }
#year-label, #character-origin { display: inline; margin: 0; font-size: inherit; font-weight: 400; }
.story-controls { display: grid; grid-template-columns: 44px 44px; gap: 4px; }
.story-controls > button { width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--ink); font-size: 13px; }
.story-controls #childhood-speed { grid-column: 1 / -1; width: 92px; height: 44px; border-radius: 22px; font-size: 11px; }
#stat-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin: 0; }
#stat-list .stat-row { display: flex; flex-direction: column; align-items: stretch; gap: 4px; position: relative; padding: 0; border: 0; }
#stat-list dt { font-size: 11px; color: var(--soft-ink); }
#stat-list output { display: block; order: 1; font-family: "Noto Serif TC", serif; text-align: left; color: var(--ink); font-size: 18px; font-weight: 800; line-height: 1.2; }
#stat-list dd { display: block; order: 2; margin: 0; }
#stat-list .stat-meter { height: 3px; background: var(--paper-deep); }
#stat-list .stat-meter i { display: block; height: 3px; background: var(--ink); }
#stat-list .low output { color: var(--red); }
#stat-list .low .stat-meter i { background: var(--red); }
#stat-list small { position: absolute; right: 0; top: 0; font-size: 10px; }
.story-resources { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; flex-shrink: 0; }
.story-resources dt { color: var(--soft-ink); font-size: 11px; }
.story-resources dd { margin: 4px 0 0; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.story-resources small { color: var(--soft-ink); font-size: 11px; line-height: 1.6; }
.story-food-note { margin: 0; font-size: 12px; line-height: 1.6; color: var(--cinnabar, #8f4636); flex-shrink: 0; }
#retainer-panel { margin: 18px 0; }
#retainer-list { font-size: 13px; line-height: 1.7; }
.retainer-card { padding: 12px; margin: 8px 0; border: 1px solid var(--line); border-radius: 9px; }
.retainer-card h4, .retainer-card p { margin: 0; }
.retainer-card small { color: var(--soft-ink); }
.event-cause { padding: 10px 12px; margin: 0 0 14px; border-left: 3px solid var(--gold); color: var(--soft-ink); background: var(--paper-deep); font-size: 13px; line-height: 1.7; }
#thread-list details { margin: 10px 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
#thread-list summary { cursor: pointer; min-height: 44px; line-height: 1.7; font-size: 14px; }
#thread-list ol { padding-left: 20px; font-size: 13px; line-height: 1.8; }
#thread-list li + li { margin-top: 10px; }
#grain-notice { flex-shrink: 0; width: 100%; padding: 8px 10px; text-align: left; border: 1px solid var(--red); background: transparent; color: var(--red); border-radius: 9px; font-size: 12px; }
.story-tab-pane { min-height: 0; flex: 1 0 auto; }
#pane-life { display: flex; flex-direction: column; flex: 1 0 auto; gap: 14px; }
#pane-life > #event-stage { order: -1; }
#event-stage { width: 100%; min-height: 440px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: #f7f1e5; display: flex; flex-direction: column; box-shadow: none; }
#event-stage, #annual-card { scroll-margin-top: 8px; }
#event-kind { margin: 0 0 7px; font-family: inherit; font-size: 11px; letter-spacing: .04em; color: var(--gold); }
#event-clock-note { margin: 0 0 12px; font-size: 11px; line-height: 1.5; color: var(--soft-ink); }
#event-clock-note.decision-capsule { align-self: flex-start; padding: 3px 8px; border-radius: 30px; color: var(--red); background: #8e2f2810; }
#event-title, #outcome h2 { margin: 0 0 12px; font-size: 32px; line-height: 1.35; font-weight: 800; letter-spacing: 0; }
#event-text, #outcome-text { margin: 0 0 18px; font-size: 17px; line-height: 1.85; }
#event-source { margin: 0 0 12px; font-size: 11px; line-height: 1.6; }
#choices { margin-top: auto; display: grid; gap: 9px; }
#choices .choice-button { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; min-height: 66px; width: 100%; padding: 10px 13px; border: 1px solid var(--ink); border-radius: 12px; color: var(--ink); background: transparent; text-align: left; font-size: 15px; line-height: 1.5; }
#choices .choice-button::after { display: none; }
#choices .choice-button:first-child { color: var(--paper); background: var(--ink); }
#event-stage.battle-card #event-text { font-size: 15px; line-height: 1.7; }
#event-stage.battle-card #choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#event-stage.battle-card #choices .choice-button { min-height: 66px; padding: 9px; }
#event-stage.battle-card #choices .choice-button:first-child { grid-column: 1 / -1; }
.choice-consequence { font-size: 11px; opacity: .75; font-weight: 400; }
#outcome { margin: 0; border: 0; padding: 0; flex: 1; display: flex; flex-direction: column; background: transparent; }
#outcome-delta { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 20px; }
#outcome-delta span { padding: 5px 9px; border-radius: 22px; border: 1px solid currentColor; font-size: 12px; }
.positive { color: #346746; }
.negative { color: var(--red); }
#next-year { margin-top: auto; min-height: 56px; border-radius: 12px; width: 100%; font-size: 16px; }
#next-year:disabled { opacity: .6; }
.life-length-choice { display: grid; gap: 8px; text-align: left; width: 100%; max-width: 360px; margin: 0 auto 12px; }
.life-length-choice label { color: var(--paper); font-size: 15px; }
.life-length-choice select { min-height: 48px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font: inherit; }
.life-length-choice p { margin: 0; color: var(--paper); opacity: .75; font-size: 12px; line-height: 1.7; }
.result-clock { text-align: center; color: var(--soft-ink); margin-top: 8px; font-size: 12px; }
.story-tabs { position: sticky; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 8px 0 max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); flex-shrink: 0; }
.story-tabs button { position: relative; border: 0; border-radius: 8px; min-height: 48px; padding: 6px 0; background: transparent; color: var(--soft-ink); font-size: 14px; }
.story-tabs button[aria-current="page"] { background: var(--ink); color: var(--paper); }
.story-tabs button:disabled { opacity: .5; font-size: 12px; }
.needs-attention::after { content: ''; position: absolute; right: 8px; top: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
#pane-family, #pane-ledger, #pane-estate { overflow-wrap: anywhere; }
#pane-family h2, #pane-estate > h2 { font-size: 25px; margin: 10px 0 20px; }
#pane-family #home-button { color: var(--ink); margin-top: 24px; }
#pane-family #era-label { margin: 12px; }
#pane-ledger { margin-top: 8px; padding-top: 22px; border-top: 1px solid var(--line); }
#pane-ledger .world-strip { display: flex; flex-wrap: wrap; padding: 16px 0; gap: 12px; margin: 0; background: transparent; color: var(--ink); }
#pane-ledger .world-strip > div { flex: 1; }
#pane-ledger #world-note { width: 100%; order: 3; font-size: 13px; }
#pane-ledger .chronicle-panel { padding: 12px 0; border: 0; background: transparent; }
#pane-ledger .timeline { max-height: none; overflow: visible; }
#pane-estate .aside-section { display: block; padding: 0 0 18px; margin: 0; }
#pane-family .aside-section { display: block; }
#pane-estate .life-toolbar { display: flex; flex-wrap: wrap; margin: 0; padding: 16px 0; }
#pane-estate #open-management { display: none; }
#pane-estate .operations-panel, #pane-estate .personal-work, #pane-estate .holdings-panel { margin: 14px 0; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: transparent; }
#pane-estate .operations-summary, #pane-estate .management-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#pane-estate .operations-actions, #pane-estate .action-grid, #pane-estate .spending-actions, #pane-estate .spending-groups > section > div, #pane-estate .force-columns, #pane-estate .asset-list { grid-template-columns: 1fr; }
#pane-estate .business-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#pane-estate .operations-settings { display: flex; flex-wrap: wrap; }
#pane-estate summary { list-style: none; cursor: default; }
#pane-estate summary::marker, #pane-estate summary::-webkit-details-marker { display: none; }
#pane-estate summary > button { border: 0; padding: 0; background: transparent; color: var(--ink); width: 100%; text-align: left; }
#management-dialog { position: static; width: 100%; max-width: 100%; max-height: none; margin: 16px 0; padding: 0; border: 0; background: transparent; box-shadow: none; overflow: visible; }
#management-dialog .management-head { padding: 12px 0; }
#management-dialog .management-tabs { display: flex; flex-wrap: wrap; position: static; padding: 0; }
#management-dialog .management-tabs button { flex: 1 0 30%; }
#management-dialog .management-pane, #management-dialog .management-log { padding: 14px 0; }
#management-dialog .pane-intro { display: block; }
#management-dialog .pane-intro p { font-size: 12px; }
#management-dialog .spending-overview { grid-template-columns: 1fr; }
#pane-estate.food-only > :not(h2):not(.aside-section) { display: none !important; }
.story-tab-pane [hidden] { display: none !important; }
.force-banner { background: var(--ink); }
#life-intentions { order: -2; padding: 16px 0; border-bottom: 1px solid var(--line, #d8cbb4); }
#life-intentions h2, #life-intentions h3 { margin: 0 0 10px; font-size: 16px; }
#life-intentions h3 { margin-top: 16px; font-size: 13px; }
#annual-card { padding: 20px; border: 1px solid #bdac90; border-radius: 10px; background: #f4ecd9; line-height: 1.8; }
#annual-card h2 { font-size: 23px; line-height: 1.5; }
#annual-lines { padding-left: 20px; }
#annual-lines li + li { margin-top: 12px; }
#annual-world { color: #76583d; }
#annual-notice { padding: 12px; border-left: 3px solid #8e3429; color: #70251d; font-weight: 600; background: #eadbc6; }
#annual-stats, #annual-clock-note { font-size: 13px; }
.start-screen h1 { font-size: clamp(30px, 7vw, 56px); letter-spacing: .05em; line-height: 1.4; }
.start-screen .lede { max-width: 38em; margin-inline: auto; line-height: 1.9; }
.intention-options { display: flex; flex-wrap: wrap; gap: 8px; }
.intention-options button { padding: 9px 14px; border: 1px solid #bdac90; background: transparent; color: var(--ink); border-radius: 7px; }
.intention-options button[aria-pressed="true"] { background: var(--ink); color: #fff8e9; border-color: var(--ink); }
#mindset-note, #routine-status { font-size: 13px; line-height: 1.8; color: #665943; }
#routine-status { padding: 24px 0; }
.asset-condition i::after, .clock-track i { background: var(--gold); }
@media (max-width: 420px) {
  #game-screen { padding: 12px 14px 0; gap: 10px; }
  #event-stage { padding: 18px; }
}
