:root{font-family:system-ui,-apple-system,sans-serif;color:#304743;background:#eeeee4;color-scheme:light;font-synthesis:none;--game-nav-bg:#f8f8ed;--game-nav-fg:#304743;--game-nav-line:#bdc9b7;--game-nav-button:#faf9ef;--game-nav-hover:#e0e8d6;--game-nav-focus:#426c65}*{box-sizing:border-box}body{margin:0;height:100vh;height:100dvh;display:flex;flex-direction:column}a{color:inherit}button,input,select{font:inherit;color:inherit}button,.file-button{min-height:44px;padding:10px 14px;border:1px solid #a6b6a4;border-radius:11px;background:#faf9ef;cursor:pointer}button:disabled{opacity:.5;cursor:default}button:not(:disabled):hover{background:#e0e8d6}:focus-visible{outline:3px solid #426c65;outline-offset:3px}.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}h2{font-size:23px;line-height:1.3}[hidden]{display:none!important}

/* One screen: shared bar on top, chapter line, play area, controls. Nothing scrolls the page during play. */
main{flex:1;min-height:0;width:100%;max-width:1400px;margin:0 auto;display:flex;flex-direction:column;gap:8px;padding:8px max(12px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left))}
.chapter-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;flex:none}.chapter-bar>div{flex:1;min-width:0}.chapter-bar h2{margin:2px 0 0;font-size:18px;overflow-wrap:anywhere}.chapter-bar>div>span{font-size:10px;letter-spacing:.7px;color:#5a7167}#chapter-status{font-size:11px;line-height:1.4;color:#536c66;margin:4px 0;overflow-wrap:normal;white-space:normal}#chapter-progress{display:block;width:100%;height:6px;accent-color:#5f897d}#chapter-next{max-width:42%;font-size:12px;opacity:1;font-weight:750;border:2px solid #6c8e80;background:#eef1df;min-height:48px}#chapter-next.ready{background:#426b5c;color:white;border-color:#426b5c}#chapter-next:disabled{opacity:.65}
.layout{flex:1;min-height:0;display:flex;flex-direction:column;gap:8px}
.stage{position:relative;flex:1 1 auto;min-height:0;display:flex;flex-direction:column;justify-content:space-between;overflow:hidden;border:2px solid #b9c6b0;border-radius:16px;background:#d9dac3}
.stage canvas{display:block;width:100%;flex:1 1 0;min-height:0;object-fit:contain;image-rendering:pixelated}
.time-bar{display:flex;justify-content:space-between;gap:8px;padding:6px 10px;background:#e7eddd;color:#3f584e;font-size:11px;font-variant-numeric:tabular-nums}
.scene-bar{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:0 10px;background:#f1f1de;font-size:11px}.scene-bar #age{flex:1}
#save-status{color:#57705a}
#coins{min-height:44px;margin:0;padding:5px 9px;font-size:11px;background:#faf1d8;border-color:#bbae83}
#action-progress{padding:6px 10px;background:#f7f3da;display:flex;align-items:center;gap:12px;justify-content:space-between;font-size:11px}#action-meter{width:30%;height:7px;accent-color:#6f9070}
.hint{position:absolute;z-index:2;left:8px;right:8px;top:34px;display:flex;align-items:center;gap:10px;padding:8px 8px 8px 12px;border:1px solid #98ad94;border-radius:12px;background:#faf9ecf2;box-shadow:0 6px 18px #26382c33}.hint p{flex:1;margin:0;font-size:12px;line-height:1.45}.hint button{flex:none;font-size:12px;padding:6px 12px}

/* Controls: needs and people, schedule note, speech, story cue, actions. */
.control-column{flex:none;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px;min-height:0}.control-column>*{grid-column:1/-1;min-width:0}
.family-panel{order:1;padding:0}.person-prompt{display:none;font-size:12px;margin:0 0 6px}#people{display:flex;gap:6px;margin-bottom:6px}#people:has(button:only-child){display:none}#people button{flex:1;min-width:0;font-size:12px;padding:8px 6px}#people button[aria-pressed=true]{background:#526f65;color:#fff;border-color:#526f65}
#needs{display:grid;grid-template-columns:repeat(auto-fit,minmax(100px,1fr));gap:5px}.need{padding:5px 7px;border:1px solid #cbd1b8;border-radius:9px;background:#faf9ed;display:grid;grid-template-columns:1fr auto;gap:3px;font-size:10px}.need strong{font-size:10px;font-weight:500}.need meter{grid-column:1/-1;width:100%;height:8px}meter::-webkit-meter-bar{background:#dfe3cd;border:none}meter::-webkit-meter-optimum-value{background:#829e70}meter::-moz-meter-bar{background:#829e70}
.caregiver-note{order:2;margin:0;padding:0 9px;height:22px;line-height:22px;font-size:11px;color:#465d61;background:#e5ebe2;border-radius:8px;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;overflow:hidden}
#speech{order:3;margin:0;padding:6px 10px;background:#f8f8ec;border:1px solid #c2ccb8;border-radius:12px;text-align:center;align-content:center;font-size:12px;line-height:1.4;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
#activity-controls,.sleep-controls{order:3;display:flex;gap:8px;justify-content:center;align-items:center;margin:0}.sleep-controls:has([hidden]):not(:has(:not([hidden]))){display:none}#activity-controls button,#wake{font-size:12px}#sleep-status{font-variant-numeric:tabular-nums;font-size:13px}
.story-goal{order:4;grid-column:1;display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;padding:6px 12px;text-align:left;background:#eff1e7;border:1px solid #c5cebf;border-radius:11px;line-height:1.35}.story-goal small{font-size:10px;color:#596d68}.story-goal strong{font-size:12px;font-weight:650}
#journal-open{order:4;grid-column:2;font-size:12px}#story-goal[hidden]+#journal-open{grid-column:1/-1}
#notice{order:5;margin:0;padding:8px 10px;background:#f8e6c9;border-radius:9px;font-size:12px;line-height:1.4}#notice:empty{display:none}#retry{order:5}
.actions{order:6;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.actions button{display:flex;flex-direction:row;align-items:center;justify-content:center;gap:6px;min-height:46px;padding:6px 4px;border:1px solid #859d82}.actions span{font-size:18px;line-height:1}.actions strong{font-size:11px;font-weight:650}

/* Journal, dialogs and the rest of the secondary screens. */
summary{cursor:pointer;min-height:44px;align-content:center}#goal-content p{margin:8px 0;line-height:1.5}.story{margin:28px 0;padding:20px;border-top:1px solid #c7d0bd;line-height:1.6}.story h2{margin-top:0;font-size:20px}.story p{font-size:14px}
dialog{width:min(520px,calc(100% - 24px));max-height:90dvh;overflow:auto;border:1px solid #98ad94;border-radius:18px;padding:24px;background:#f9f8eb;color:inherit}dialog::backdrop{background:#263b2f88}dialog h2{margin-top:0}dialog p{line-height:1.6;font-size:14px}dialog label{display:grid;gap:8px;margin:14px 0;font-size:13px}dialog small{font-size:12px;line-height:1.5}input:not([type=checkbox]),select{width:100%;min-height:44px;padding:8px;border:1px solid #a5b59c;border-radius:8px;background:#fffdf1}.check{display:flex;align-items:center;gap:9px}.check input{width:20px;height:20px}dialog form>button{width:100%;background:#526f65;color:white}.save-tools{display:grid;gap:8px}.file-button{position:relative;overflow:hidden;text-align:center;margin:0}.file-button input{position:absolute;inset:0;opacity:0;cursor:pointer}hr{border:0;border-top:1px solid #ccd3bb;margin:22px 0}#memories{padding-left:20px;font-size:13px}#confirm-dialog button,#chapter-dialog button{margin:4px 6px 4px 0}
#intro-dialog button{display:block;width:100%;margin-top:18px;background:#526f65;color:#fff;border-color:#526f65}
#help-dialog footer{text-align:center;color:#587064;font-size:12px;line-height:1.6;margin:18px 0 0}#help-dialog footer a{display:inline-block;min-height:44px;line-height:44px;padding:0 4px}#help-dialog #game-feedback{margin:16px 0 0;width:100%}html.game-expanded #help-dialog #game-feedback,html.game-expanded #help-dialog #game-privacy{display:block}
#journal-dialog #goals{display:block;margin:0}#journal-dialog .story{display:block;margin:15px 0;padding:15px 0}#activity-options{display:grid;gap:10px;margin:14px 0}#activity-options button{text-align:left;display:grid;gap:7px}#activity-options span{font-size:12px;line-height:1.5}#activity-close{width:100%}#quiz-options{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}#quiz-options button{font-size:24px}#quiz-question{font-size:25px;text-align:center;font-weight:700}#quiz-result{min-height:42px}#wallet-total{font-size:22px;font-weight:700}#wallet-close{display:block;margin-top:18px;width:100%}#update-ack{background:#466b5c;color:#fff}#update-error:empty{display:none}
#book-dialog{width:min(760px,calc(100% - 24px))}#book-photos{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}#book-photos figure{margin:0;overflow:hidden;border:1px solid #c7d0bd;border-radius:12px;background:#efefdf}#book-photos img{display:block;width:100%;height:auto;image-rendering:pixelated}#book-photos figcaption{display:grid;gap:5px;padding:12px;font-size:13px}#book-photos figcaption span{font-size:11px;line-height:1.5}#family-tree{padding-left:22px;line-height:1.5}#family-tree li{padding:10px 4px;border-bottom:1px solid #c7d0bd}#family-tree p{font-size:12px;margin:4px 0}.book-pages{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:14px 0;font-size:12px}.book-pages button{font-size:12px}#book-export,#book-open,#generation-cancel{width:100%;margin:8px 0}#book-status:empty,#book-empty:empty{display:none}
.book-heading{position:sticky;top:-24px;z-index:2;display:flex;align-items:center;justify-content:space-between;gap:14px;margin:-24px -24px 18px;padding:16px 24px;background:#f9f8eb;border-bottom:1px solid #c7d0bd}.book-heading h2{margin:0;font-size:22px}.book-heading #book-close{flex:none;min-height:44px;margin:0;font-size:13px}
.journal-heading{position:sticky;top:-24px;z-index:2;display:flex;align-items:center;justify-content:space-between;gap:12px;margin:-24px -24px 16px;padding:14px 24px;background:#f9f8eb;border-bottom:1px solid #c7d0bd}.journal-heading h2{margin:0;font-size:20px}.journal-heading button{width:auto;flex:none;font-size:13px}
.story-arc{margin:12px 0;border-top:1px solid #c9cebf;padding-top:12px}.story-arc summary{font-weight:650;line-height:1.5}.story-arc>small{display:block;margin-top:6px;color:#596d68}.story-arc ol{padding-left:23px;line-height:1.65}.story-arc li{padding:5px 0}.story-current{font-weight:700}.story-reward{font-size:12px;color:#52685f}#family-stories{scroll-margin-top:80px}#story-continue{min-height:44px}
@media(max-width:480px){#book-photos{grid-template-columns:1fr}#book-dialog{padding:18px}.book-pages button{font-size:11px;padding:8px}.book-heading{top:-18px;margin:-18px -18px 16px;padding:12px 18px}.book-heading h2{font-size:20px}.story-arc{font-size:13px}}

/* Phone: the chapter status line lives in the journal; the page never scrolls. */
@media(max-width:720px){#chapter-status{display:none}.chapter-bar h2{font-size:17px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#chapter-next{font-size:11px;min-height:44px}.chapter-bar h2{margin:0;line-height:1.2}main{gap:5px;padding-top:4px;padding-bottom:max(6px,env(safe-area-inset-bottom))}.layout,.control-column{gap:5px}.actions{gap:5px}.actions button{min-height:44px}.story-goal{min-height:44px;padding:3px 10px;justify-content:center}.story-goal small{display:none}.story-goal strong{max-width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#needs{gap:4px}.need{padding:3px 6px;gap:2px}.need meter{height:6px}}
@media(min-height:760px) and (max-width:720px){.chapter-bar h2{white-space:normal}}
@media(max-height:700px) and (max-width:720px){.time-bar{padding:3px 8px;font-size:10px}.scene-bar{font-size:10px;padding:0 8px}#action-progress{padding:3px 8px}}

/* Computer and landscape: the play area is centred, whole-number scaled, with status and controls beside it. */
@media(min-width:1000px),(min-width:721px) and (max-height:520px){
 main{padding-top:8px;padding-bottom:max(8px,env(safe-area-inset-bottom))}
 .chapter-bar{width:100%;max-width:1400px;margin:0 auto}
 .layout{width:100%;max-width:1400px;margin:0 auto;display:grid;grid-template-columns:minmax(0,1fr) minmax(280px,340px);align-content:center;justify-content:center;gap:16px;align-items:center}
 .layout:has(.stage[data-scale]){grid-template-columns:auto minmax(280px,340px)}
 .stage{flex:none;align-self:center;justify-content:flex-start}
 .stage canvas{flex:none;height:auto;aspect-ratio:3/2}
 .stage[data-scale="1"] canvas{width:480px;height:320px}.stage[data-scale="2"] canvas{width:960px;height:640px}.stage[data-scale="3"] canvas{width:1440px;height:960px}.stage[data-scale="4"] canvas{width:1920px;height:1280px}
 .stage[data-scale] #action-progress{min-height:28px}
 .stage:not([data-scale]){align-self:stretch;justify-content:space-between}.stage:not([data-scale]) canvas{flex:1 1 0;height:0;aspect-ratio:auto}
 .time-bar{font-size:12px;padding:6px 12px}.scene-bar{font-size:12px;padding:0 12px}.hint{top:36px}#chapter-status{margin:2px 0 4px}
 .control-column{align-self:center;max-height:100%;overflow:auto;padding:12px;border:1px solid #c2ccb8;border-radius:16px;background:#f6f6e9;gap:8px}
 .person-prompt{display:block}.person-prompt:has(+#people button:only-child){display:none}
 #needs{grid-template-columns:1fr 1fr;gap:7px}.need{padding:7px;font-size:12px}.need strong{font-size:11px}
 .caregiver-note{display:block;height:auto;padding:8px;font-size:12px;line-height:1.5}
 #speech{font-size:12px;padding:10px}
 .actions{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}.actions button{flex-direction:row;justify-content:flex-start;min-height:46px;padding:9px 10px;gap:9px;text-align:left}.actions span{font-size:18px}.actions strong{font-size:12px}
 #chapter-status{display:block}.chapter-bar h2{font-size:20px}.chapter-bar>div>span{font-size:11px}
}
@media(min-width:721px) and (max-height:520px){#chapter-status,.chapter-bar>div>span{display:none}.chapter-bar h2{font-size:16px}.person-prompt{display:none}.control-column{padding:6px;gap:5px}.layout{gap:10px}#needs{grid-template-columns:repeat(3,1fr);gap:4px}.need{padding:3px 6px;font-size:10px}.caregiver-note{height:22px;padding:0 9px;line-height:22px;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.actions{grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}.actions button{min-height:44px;padding:4px 6px}}
