:root{--case:#d9d0b5;--case-l:#ece5cf;--key:#e4dcc4;--leg:#4a463c;--hi:#fff6c9}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0}
html{min-height:100%;background-color:#c8b389;color-scheme:light}
body{min-height:100vh;min-height:100dvh;background:linear-gradient(#c8b389 0,#c8b389 34%,#5e3d22 34%,#86582f 36%,#774c28 100%)}
/* Safari tints its top bar from the page edge (wall) and its bottom bar from a fixed desk-coloured strip */
body::after{content:"";position:fixed;left:0;right:0;bottom:0;height:max(60px,env(safe-area-inset-bottom));background:#774c28;z-index:-1;pointer-events:none}
body{font-family:ui-monospace,Menlo,monospace;overflow-x:hidden;display:flex;justify-content:center}
.poster{position:absolute;top:4vh;left:5vw;width:clamp(60px,9vw,130px);aspect-ratio:3/4;background:#e9dcb5;border:6px solid #5a3a20;display:grid;place-items:center;text-align:center;font-size:clamp(7px,1vw,12px);color:#5a3a20;font-weight:bold;box-shadow:3px 4px 0 #0003}
.desk{position:relative;width:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100vh;padding:12px 8px 24px}
.scenewrap{width:min(98vw,1500px,calc((100vh - 40px)*1.5));position:relative}
.scene{position:relative;width:100%;aspect-ratio:1180/780;transform-origin:0 0;transition:transform .6s cubic-bezier(.3,.7,.2,1);cursor:zoom-in}
.scene.zoom{cursor:zoom-out}
.scene>svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
.glass{position:absolute;left:calc(235/1180*100%);top:calc(160/780*100%);width:calc(400/1180*100%);height:calc(274/780*100%);border-radius:4% / 5.5%;overflow:hidden;background:#000;box-shadow:inset 0 0 30px #000c}
canvas{width:100%;height:100%;display:block;image-rendering:auto}
.glass::after{content:"";position:absolute;inset:0;background:repeating-linear-gradient(#0000 0 2px,#0003 2px 3px),radial-gradient(ellipse at 30% 20%,#fff2,#0000 50%),radial-gradient(ellipse,#0000 60%,#0008);pointer-events:none}
.hint{margin-top:10px;color:#f3e6c4;font-size:12px;letter-spacing:.1em;opacity:.85;text-shadow:0 1px 0 #0006}
.items{position:absolute;inset:0;pointer-events:none}
.mug{position:absolute;right:6vw;bottom:57%;width:clamp(36px,5vw,70px);aspect-ratio:1;background:#b33;border-radius:4px 4px 12px 12px;box-shadow:inset -6px 0 #0003,3px 5px 0 #0004}
.mug::after{content:"";position:absolute;right:-26%;top:20%;width:30%;height:45%;border:5px solid #b33;border-left:0;border-radius:0 10px 10px 0}
.floppy{position:absolute;left:1vw;bottom:6%;width:clamp(44px,6vw,86px);aspect-ratio:1;background:#2d2d38;border-radius:2px;transform:rotate(-12deg);box-shadow:3px 5px 0 #0004}
.floppy::before{content:"";position:absolute;top:0;left:22%;width:56%;height:30%;background:#bbb}
.floppy::after{content:"OREGON TRAIL";position:absolute;bottom:8%;left:10%;right:10%;height:38%;background:#eee;font:bold 6px/2.6 sans-serif;text-align:center;color:#a33}

/* ---- keyboard (shared) ---- */
.kbd{display:flex;flex-direction:column;gap:6%;user-select:none;-webkit-user-select:none;touch-action:manipulation}
.row{display:flex;gap:.5%;flex:1}
.k{position:relative;flex:var(--w,1) 1 0;min-width:0;border:0;padding:0;border-radius:6%/12%;background:linear-gradient(#efe8d2,var(--key));box-shadow:0 .35em 0 #8f8771,inset 0 1px 0 #fff;color:var(--leg);font:inherit;font-weight:bold;display:flex;flex-direction:column;align-items:center;justify-content:center;line-height:1;cursor:pointer}
.k.down,.k:active{transform:translateY(.25em);box-shadow:0 .1em 0 #8f8771}
.k i{font-style:normal;font-size:.55em;font-weight:bold;color:#7a2a1a;margin-top:.2em;letter-spacing:0;white-space:nowrap}
.k i s{display:none;text-decoration:none}
.k.on{background:linear-gradient(#fffbe0,var(--hi));box-shadow:0 .35em 0 #8f8771,inset 0 0 0 2px #d8a32a}
.k.off{opacity:.55}
.k.sp i,.k.act i{color:#7a2a1a}
/* 3D keyboard on the desk */
.kb3d{position:absolute;left:calc(130/1180*100%);top:calc(538/780*100%);width:calc(696/1180*100%);height:calc(120/780*100%);transform-origin:0 0;transform:matrix(1,0,-.3636,1,0,0);font-size:calc(.95*var(--u))}
.scene{--u:calc(1cqw)}
.scenewrap{container-type:inline-size}
.kb3d .kbd{height:100%;padding:1.2% 2.4%}
.kb3d .k{font-size:calc(.95cqw)}.kb3d .row{flex:1 1 0;min-height:0}.kb3d .kbd{gap:3%}.kb3d .k i{margin-top:.1em}
/* compact keyboard (zoom / tablet / phone) */
.kbflat{display:none;width:min(94vw,760px);font-size:clamp(12px,2.3vw,19px);padding:14px;background:linear-gradient(var(--case-l),var(--case));border-radius:12px;box-shadow:0 8px 0 #a79f88,0 16px 20px #0006}
.kbflat .grid{display:grid;gap:10px}
.kbflat .g5{grid-template-columns:repeat(5,1fr)}
.kbflat .gbot{grid-template-columns:1.2fr 3fr 1.6fr;margin-top:10px}
.kbflat .k{height:clamp(48px,8vh,64px);border-radius:8px;font-size:1.5em}
.kbflat .k i{font-size:.46em;margin-top:.3em}
.kbflat .gbot .k{font-size:1.1em}
.kbflat .grow{display:flex;gap:6px;margin-bottom:8px}
.kbflat .grow .k{flex:1;height:clamp(44px,7.5vh,60px);font-size:1.15em}
body.zoomed .kbflat{display:block;position:fixed;bottom:14px;left:50%;transform:translateX(-50%);z-index:5}
body.zoomed .hint{display:none}body.zoomed .kb3d{opacity:0;transition:opacity .3s}
@media (pointer:coarse),(max-width:900px){
 .desk{justify-content:center;padding-top:14px;gap:16px}
 .poster,.items,.hint,#base,#drives,.kb3d{display:none}
 .kbflat{display:block;margin-top:6px}
 .scenewrap{width:min(94vw,720px,calc((100vh - 360px)*1.12));aspect-ratio:610/544;overflow:hidden}
 .scene{width:193.4%;margin-left:-24.59%;transform:none!important;cursor:default}
}

/* power indicator + rainbow dog key */
#pwr{fill:#4a2a26;transition:fill .3s}
body.powered #pwr{fill:#3df06b;filter:drop-shadow(0 0 5px #3df06b)}
.k.dog svg{width:70%;max-height:78%;display:block;margin:0 auto}
.k.dog{background:linear-gradient(#f5efdc,#e4dcc4)}
.k.dog.on{animation:dogpulse 1.3s ease-in-out infinite}
@keyframes dogpulse{50%{box-shadow:0 .35em 0 #8f8771,inset 0 0 0 2px #d8a32a,0 0 18px 5px #ffd36a}}
.dogpad{display:flex;flex-direction:column;align-items:center;gap:10px;padding:6px 0}
.dogpad .k{width:min(60%,260px);height:clamp(80px,14vh,120px);flex:none}
.dogpad p{margin:0;font-size:.62em;font-weight:bold;letter-spacing:.14em;color:#7a2a1a;text-align:center}
@media (prefers-reduced-motion:reduce){.k.dog.on{animation:none}}

/* installed-app polish: safe areas, no pull-to-refresh bounce or double-tap zoom */
html,body{overscroll-behavior:none;touch-action:manipulation}
.desk{padding-top:max(12px,env(safe-area-inset-top));padding-bottom:max(24px,env(safe-area-inset-bottom));padding-left:max(8px,env(safe-area-inset-left));padding-right:max(8px,env(safe-area-inset-right))}

/* landscape phones / tablets: monitor on the left, keyboard on the right */
@media (pointer:coarse) and (orientation:landscape), (orientation:landscape) and (max-height:520px){
 .desk{flex-direction:row;align-items:center;justify-content:center;gap:clamp(10px,2vw,24px);padding-top:max(8px,env(safe-area-inset-top));padding-bottom:max(8px,env(safe-area-inset-bottom))}
 .scenewrap{width:min(56vw,calc((100vh - 20px)*1.12),760px);flex:none}
 .kbflat{width:min(38vw,calc(100vw - min(56vw,(100vh - 20px)*1.12) - 48px),560px);margin-top:0;padding:10px;font-size:clamp(10px,1.7vw,19px);flex:none}
 .kbflat .grid{gap:7px}
 .kbflat .gbot{margin-top:7px}
 .kbflat .k{height:clamp(30px,calc((100vh - 110px)/4),72px)}
 .kbflat .grow{margin-bottom:6px}
 .kbflat .grow .k{height:clamp(30px,calc((100vh - 110px)/4),72px);font-size:1.2em}
 .kbflat .gbot .k{font-size:1em}
 .dogpad .k{height:clamp(60px,26vh,110px);width:90%}
 .dogpad p{font-size:.5em}
}

/* help button and manual */
.helpbtn{position:fixed;z-index:20;top:max(10px,env(safe-area-inset-top));right:max(10px,env(safe-area-inset-right));width:40px;height:40px;border:0;border-radius:8px;background:linear-gradient(#efe8d2,#e4dcc4);box-shadow:0 4px 0 #8f8771,inset 0 1px 0 #fff;color:#4a463c;font:bold 20px ui-monospace,Menlo,monospace;cursor:pointer}
.helpbtn:active{transform:translateY(3px);box-shadow:0 1px 0 #8f8771}
.helpbtn:focus-visible,.help .x:focus-visible{outline:3px solid #d8a32a;outline-offset:2px}
.help{width:min(94vw,760px);max-height:88vh;padding:0;border:0;border-radius:10px;background:#f4eedb;color:#2e2a22;box-shadow:0 20px 60px #000a;overflow:hidden;font:15px/1.55 ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}
.help[open]{display:flex;flex-direction:column}
.help::backdrop{background:rgba(30,20,10,.65)}
.help header{display:flex;align-items:center;gap:12px;padding:12px 16px;background:#d9d0b5;border-bottom:2px solid #b3aa92}
.help h2{margin:0;font:bold 17px ui-monospace,Menlo,monospace;letter-spacing:.06em;flex:1}
.help .ver{font:12px ui-monospace,Menlo,monospace;color:#6b6450}
.help .x{width:34px;height:34px;border:0;border-radius:6px;background:#efe8d2;box-shadow:0 3px 0 #8f8771;font-size:22px;line-height:1;cursor:pointer;color:#4a463c}
.help .body{padding:6px 20px 24px;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain}
.help h3{margin:26px 0 8px;font:bold 15px ui-monospace,Menlo,monospace;letter-spacing:.08em;text-transform:uppercase;color:#7a2a1a;border-bottom:1px solid #cfc6ab;padding-bottom:4px}
.help p,.help li{margin:6px 0}
.help ul,.help ol{padding-left:22px}
.help table{width:100%;border-collapse:collapse;font-size:14px;margin:8px 0}
.help th,.help td{text-align:left;padding:6px 8px;border-bottom:1px solid #d8cfb4;vertical-align:top}
.help th{background:#ebe3cb}
.help td:first-child{font:bold 14px ui-monospace,Menlo,monospace;width:2.5em;text-align:center}
.help kbd{display:inline-block;min-width:1.6em;padding:0 6px;border-radius:4px;background:#efe8d2;box-shadow:0 2px 0 #8f8771;font:bold 13px ui-monospace,Menlo,monospace;text-align:center;color:#4a463c}
.help code{font:13px ui-monospace,Menlo,monospace;background:#ebe3cb;padding:1px 5px;border-radius:3px}
.help .toc{display:flex;flex-wrap:wrap;gap:6px 14px;margin:14px 0 4px;padding:10px 12px;background:#ebe3cb;border-radius:8px;font-size:13px}
.help .toc a{color:#7a2a1a;text-decoration:none;font-weight:600}
.help .toc a:hover{text-decoration:underline}
.help .rel{margin:10px 0}
.help .rel b{font-family:ui-monospace,Menlo,monospace}
.help .rel small{color:#6b6450;margin-left:6px}
@media (max-width:520px){.help{width:100vw;max-width:none;max-height:none;height:100dvh;border-radius:0;margin:0}.help .body{padding:4px 14px 24px}}
@media (prefers-reduced-motion:no-preference){.help[open]{animation:helpin .18s ease-out}@keyframes helpin{from{opacity:0;transform:translateY(8px)}}}
@supports (height:100dvh){.desk{min-height:100dvh}}
