:root{color-scheme:light;font-family:system-ui,-apple-system,sans-serif;color:#303820;background:#f8f2e4;--green:#526c3e;--line:#d7caab;--gap:8px;--pad:10px;--col:176px;--game-nav-bg:#fff9eb;--game-nav-fg:#303820;--game-nav-line:#a1a680;--game-nav-button:#fffaf0;--game-nav-hover:#e7edcd;--game-nav-focus:#526c3e}
*{box-sizing:border-box}
html{height:100%}
body{margin:0;height:100%;height:100dvh;display:flex;flex-direction:column;overflow:hidden;background:radial-gradient(ellipse at 50% 30%,#fffdf5,transparent 65%)}
body>#game-privacy,body>#game-feedback{display:none}
.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}
a{color:inherit;text-underline-offset:4px}
button,input,select{font:inherit;color:inherit}
button,.file-button{min-height:44px;border:1px solid #a1a680;background:#fffaf0;border-radius:12px;padding:8px 14px;cursor:pointer;touch-action:manipulation}
button:hover:not(:disabled),.file-button:hover{background:#e7edcd}
button:active:not(:disabled){transform:translateY(1px)}
button:disabled{opacity:.5;cursor:default}
:focus-visible{outline:3px solid #526c3e;outline-offset:3px}
[hidden]{display:none!important}
.muted{font-size:13px;color:#6b6a55}

/* Play screen: one screen tall. Phone portrait is a single column; wide screens put status and controls beside the scene. */
main{flex:1 1 0;min-height:0;width:100%;max-width:620px;margin:0 auto;display:grid;gap:var(--gap);padding:var(--pad) calc(var(--pad) + env(safe-area-inset-right,0px)) calc(var(--pad) + env(safe-area-inset-bottom,0px)) calc(var(--pad) + env(safe-area-inset-left,0px));
 grid-template-columns:minmax(0,1fr) minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) var(--speech-h,46px) 44px auto;
 grid-template-areas:"meters meters" "room room" "speech speech" "unlock rest" "actions actions"}
.meters{grid-area:meters;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
.meter{border:2px solid var(--line);border-radius:12px;padding:5px 7px 7px;background:#fff9eb;display:grid;grid-template-columns:minmax(0,1fr);gap:1px;font-size:11px;min-width:0}
.meter>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:15px}
.meter strong{font-size:11px;font-weight:500;line-height:14px;font-variant-numeric:tabular-nums}
meter{width:100%;height:8px;border:0;background:#e4dcc6;border-radius:10px;overflow:hidden;margin-top:2px}
meter::-webkit-meter-bar{background:#e4dcc6;border:0}
meter::-webkit-meter-optimum-value{background:var(--meter);border-radius:10px}
meter::-moz-meter-bar{background:var(--meter)}
.room{grid-area:room;min-height:0;display:flex;flex-direction:column;overflow:hidden;border-radius:20px;background:#ead2aa;border:3px solid #d8bd8f}
.stage{flex:1 1 0;min-height:0;display:flex;align-items:flex-end;justify-content:center}
.view{position:relative;flex:none;width:var(--cw,min(100%,480px));height:var(--ch,auto);aspect-ratio:8/5}
canvas{display:block;width:100%;height:auto;image-rendering:crisp-edges;image-rendering:pixelated}
#scene{height:100%;contain:content}
.scene-caption{flex:none;display:flex;justify-content:space-between;gap:8px;padding:6px 14px;background:#fff8e7cc;font-size:11px;font-weight:600}
.scene-caption #save-state{color:#526c3e}
.scene-caption #save-state:before{content:'●';margin-right:5px}
#pause-cover{position:absolute;inset:0;z-index:3;display:flex;align-items:center;justify-content:center;padding:28px;text-align:center;background:#fff5ddaa;font-weight:700;backdrop-filter:blur(2px)}
#speech{grid-area:speech;margin:0;overflow:hidden;display:flex;align-items:center;justify-content:center;padding:6px 14px;text-align:center;font-weight:650;font-size:14px;line-height:1.3;background:#fff9eb;border:2px solid var(--line);border-radius:14px}
#unlock{grid-area:unlock;display:block;width:100%;min-height:0;overflow:hidden;padding:2px 6px;font-size:11px;line-height:1.2;text-align:center;color:#66734e;background:#fff8e7}
#unlock-label{line-height:1.2}
.actions{grid-area:actions;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
.actions button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;min-height:64px;padding:6px 4px;border:2px solid #6e7d51;box-shadow:0 4px 0 #d4ccb2;font-size:13px;min-width:0}
.actions strong{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.actions span{font:30px/1 ui-monospace,monospace}
.actions button:nth-child(1) span{color:#be533b}
.actions button:nth-child(2) span{color:#c55747}
.actions button:nth-child(3) span{color:#3b8ba0}
.actions button:nth-child(4) span{color:#b78426}
#rest{grid-area:rest;display:block;width:100%;min-height:0;overflow:hidden;padding:2px 8px;font-size:13px;line-height:1.2;font-weight:650;background:#e7edcd}

/* Progress of an action and the start card / hints share the space of the speech line and reward button. */
#action-progress{grid-row:speech-start/unlock-end;grid-column:1/-1;z-index:2;display:grid;grid-template-columns:minmax(0,1fr) minmax(60px,35%);gap:6px 10px;align-items:center;padding:8px 12px;background:#fff8e7;border:2px solid var(--line);border-radius:14px;font-size:12px;font-weight:650}
#action-progress progress{width:100%;height:8px;accent-color:#526c3e}
#action-label{white-space:normal;min-width:0}
#throw-toy,#end-play{min-height:44px;padding:6px 9px;font-size:12px}
#throw-toy{grid-column:1}
#end-play{grid-column:2}
#coach{grid-row:speech-start/unlock-end;grid-column:1/-1;z-index:3;display:flex;align-items:center;gap:10px;padding:8px 10px 8px 14px;background:#fff9eb;border:2px solid #a2a77e;border-radius:14px;box-shadow:0 4px 14px #26321c30}
#coach p{margin:0;font-size:13px;line-height:1.35}
#coach .coach-text{flex:1;min-width:0}
#coach #coach-a{font-weight:650}
#coach button{flex:none;min-width:84px;background:#526c3e;color:#fff9eb;border-color:#526c3e}
.coach-on #speech,.coach-on #unlock,.coach-on #rest{visibility:hidden}
#action-progress:not([hidden])~#unlock,#action-progress:not([hidden])~#speech,#action-progress:not([hidden])~#rest{visibility:hidden}
#notice{padding:12px 14px;background:#fff1d3;border:1px solid #b48439;border-radius:12px;line-height:1.5;font-size:13px}
#notice:empty{display:none}
#notice:not(:empty){position:fixed;z-index:30;left:8px;right:8px;bottom:calc(8px + env(safe-area-inset-bottom,0px))}
#retry:not([hidden]){position:fixed;z-index:30;left:10px;bottom:calc(90px + env(safe-area-inset-bottom,0px))}

@media(max-height:700px) and (max-width:639px){:root{--gap:6px;--pad:8px;--speech-h:38px}.actions button{min-height:50px}.actions span{font-size:24px}#speech{font-size:13px;padding:2px 12px;line-height:1.25}.scene-caption{padding:3px 12px}.meter{padding:3px 6px 5px}.meter>span{line-height:14px;height:14px}.meter strong{line-height:13px;height:13px}}

/* Wide screens: status on the left, scene in the middle, controls on the right. */
@media(min-width:640px) and (min-aspect-ratio:5/4){
 :root{--gap:12px;--pad:12px}
 main{max-width:none;margin:0;grid-template-columns:minmax(var(--col),1fr) auto minmax(var(--col),1fr);grid-template-rows:1fr auto auto auto auto 1fr;
  grid-template-areas:". room ." "meters room speech" "meters room coach" "meters room actions" "unlock room rest" ". room ."}
 .room{align-self:center;grid-row:1/-1}
 .stage{flex:none;align-items:center}
 .meters{grid-template-columns:minmax(0,1fr);align-content:space-between;gap:8px;align-self:stretch}
 .meter{grid-template-columns:minmax(0,1fr) auto;padding:8px 12px 10px;font-size:13px;gap:4px 8px}
 .meter strong{font-size:12px}
 meter{grid-column:1/-1;height:10px}
 #speech{min-height:84px;font-size:15px;overflow:visible}
 #unlock,#rest{min-height:44px}
 #unlock{align-self:start}
 .actions{grid-template-columns:minmax(0,1fr);gap:10px}
 .actions button{flex-direction:row;gap:12px;min-height:56px;font-size:15px}
 .actions span{font-size:28px}
 #action-progress{grid-row:speech-start/coach-end;grid-column:3}
 #coach{grid-row:auto;grid-column:3;grid-area:coach;flex-direction:column;align-items:stretch}
 #coach button{width:100%}
 .coach-on #speech,.coach-on #unlock,.coach-on #rest{visibility:visible}
 #action-progress:not([hidden])~#unlock,#action-progress:not([hidden])~#rest{visibility:visible}
}
@media(min-width:640px) and (min-aspect-ratio:5/4) and (max-height:520px){
 :root{--gap:8px;--pad:8px}
 .actions{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
 .actions button{min-height:44px;padding:4px 6px;flex-direction:row;gap:6px;font-size:13px;box-shadow:0 3px 0 #d4ccb2}
 .actions span{font-size:20px}
 .meters{gap:6px}
 .meter{padding:4px 9px 6px;gap:2px 6px;font-size:12px}
 #speech{min-height:40px;font-size:12px;padding:4px 8px}
 #coach{padding:6px 8px;gap:6px}
 #coach p{font-size:12px;line-height:1.25}
 .coach-on #speech{display:none}
}
@media(min-width:640px) and (min-aspect-ratio:5/4) and (max-height:420px){:root{--col:150px}}

dialog{border:2px solid #a2a77e;border-radius:22px;background:#fff9eb;color:inherit;padding:24px;max-width:460px;width:calc(100% - 28px);max-height:90dvh;overflow:auto}
dialog::backdrop{background:#26321c80;backdrop-filter:blur(4px)}
dialog h2{margin:0 0 18px}
dialog h3{margin:18px 0 4px;font-size:15px}
dialog p{line-height:1.6;font-size:14px;margin:6px 0}
dialog label{display:grid;gap:8px;margin:16px 0;font-size:14px}
input:not([type=checkbox]),select{width:100%;min-height:44px;border:1px solid #a6aa8b;border-radius:8px;background:#fffcf4;padding:8px}
.check{display:flex!important;align-items:center}
.check input{width:20px;height:20px;accent-color:#526c3e}
dialog form>button{width:100%;background:#526c3e;color:white}
.save-tools{display:grid;gap:8px}
.file-button{position:relative;display:block;margin:0;overflow:hidden;text-align:center}
.file-button input{position:absolute;inset:0;opacity:0;cursor:pointer}
.file-button:focus-within{outline:3px solid #526c3e;outline-offset:3px}
hr{border:0;border-top:1px solid var(--line);margin:20px 0}
#settings-notice{font-size:13px;line-height:1.5}
#help-dialog .credits{font-size:12px;color:#6b6a55}
#close-help{width:100%;margin-top:14px}
#privacy-settings:not(:empty){margin-top:16px}
#game-privacy,#game-feedback{max-width:none!important;margin:12px 0!important;padding:12px!important;font-size:13px!important}
.play-choices{display:grid;gap:10px;margin:18px 0}
.play-choices button{text-align:left;display:grid;gap:7px;min-height:76px}
.play-choices strong{font-size:16px}
.play-choices span{font-size:12px;line-height:1.5}
#play-dialog>p,#rewards-dialog>p{font-size:13px;line-height:1.7}
#close-play,#close-rewards{width:100%}
#rewards-list{list-style:none;padding:0;display:grid;gap:10px;margin:20px 0}
#rewards-list li{padding:12px;border:1px solid #d8c9a5;border-radius:10px;color:#6a6b56;font-size:13px}
.earned{background:#e4eccb;color:#3c5936!important}

#hunt-dialog{width:min(620px,calc(100% - 24px));max-width:620px;padding:18px}
#hunt-dialog h2{margin-bottom:10px}
#hunt-status{min-height:3em;line-height:1.5;font-size:14px}
#hunt-scene{border-radius:12px}
.hunt-choices{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:14px 0}
.hunt-choices button{padding:10px 4px;font-size:13px}
.hunt-bottom{display:flex;justify-content:space-between;gap:10px}
@media(max-height:520px){#hunt-dialog{padding:12px}#hunt-scene{width:auto;max-width:100%;height:38dvh;margin:auto}#hunt-status{min-height:0;margin:6px 0}.hunt-choices{margin:8px 0}#hunt-dialog h2{font-size:19px}}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important}}
