/* Entité v0.9 case simulator (case09.html). The case only: no banner, no status line (spec: screen limits). */
@font-face { font-family: 'Chakra Petch'; font-weight: 700; font-display: swap; src: url('../fonts/chakra-petch-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Chakra Petch'; font-weight: 500; font-display: swap; src: url('../fonts/chakra-petch-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 500; font-display: swap; src: url('../fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2'); }
:root {
  --bg: #07080a; --panel: #8c8c8a; --panel2: #6a6a66; --edge: #4a4c48; --silk: #1a1c1e; --ink: #e8eef2;
  --cyan: #2ec8e8; --red: #ff3b30; --blue: #3d8bff; --green: #36f08a; --yellow: #ffd60a; --violet: #b44aff;
  --shell: #161718; --plate: #f3f1ea; --petg: #8c8c8a;
  --f-tech: 'Chakra Petch', system-ui, sans-serif; --f-mono: 'JetBrains Mono', ui-monospace, monospace;
  --gap: 6px; --hit: 45px; --hit-pad: 0px; --H: 45px; --P: 45px; --Hf: 48px; /* --H = real hit size in design px (44 CSS px / fit scale), set by fitStage */
  --design-w: 412px; --design-h: 915px;
}
* { box-sizing: border-box; }
html, body { background: var(--bg); height: 100%; height: 100dvh; overflow: hidden; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html { padding-right: calc(var(--chrome-gutter, 55px) + env(safe-area-inset-right, 0px)); }
body { margin: 0; display: flex; align-items: flex-start; justify-content: center; background: #050608; color: var(--ink); font-family: var(--f-tech); }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#fit, #stage, #case { touch-action: manipulation; }
#fit { position: relative; width: var(--design-w); height: var(--design-h); overflow: hidden; flex: 0 0 auto; }
#stage { position: relative; width: var(--design-w); height: var(--design-h); transform-origin: 0 0; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.silk, .plate { font: 700 12px/1.1 var(--f-mono); letter-spacing: .08em; color: #1a1c1e; text-transform: uppercase; pointer-events: none;
  background: var(--plate); border: 1px solid #d4d0c4; border-radius: 2px; padding: 2px 5px;
  box-shadow: 0 1px 0 rgb(255 255 255 / .55), 0 1px 2px rgb(0 0 0 / .35); }

.case { position: relative; display: grid; gap: var(--gap); padding: var(--gap); max-width: none; margin: 0; width: var(--design-w); height: auto; min-height: var(--design-h); align-content: stretch;
  background:
    linear-gradient(180deg, #2a2c2e, var(--shell) 42%, #0b0c0d);
  border-radius: 20px; border: 1px solid #3a3c3e;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .08), inset 0 -12px 18px rgb(0 0 0 / .45), 0 16px 32px rgb(0 0 0 / .7); }
.half { position: relative; border-radius: 10px; padding: 10px 8px; overflow: hidden;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .18 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    linear-gradient(165deg, #a3a39d 0%, var(--petg) 38%, #6e6e69 100%);
  background-blend-mode: multiply, normal;
  border: 1px solid #5a5a56;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .28), inset 0 -10px 22px rgb(0 0 0 / .28), 0 2px 0 #0a0a0a;
  display: flex; flex-direction: column; min-height: 0; }
.bolt { position: absolute; width: 10px; height: 10px; border-radius: 50%; z-index: 4; background: radial-gradient(circle at 35% 30%, #c5c5c0, #6a6a66 55%, #2a2a28 100%); box-shadow: 0 1px 1px #000, inset 0 1px 0 rgb(255 255 255 / .4); }
.bolt::after { content: '+'; position: absolute; inset: 0; display: grid; place-items: center; font: 700 8px/1 sans-serif; color: #2a2a28; background: none; }
.bolt.tl { top: 7px; left: 7px; } .bolt.tr { top: 7px; right: 7px; } .bolt.bl { bottom: 7px; left: 7px; } .bolt.br { bottom: 7px; right: 7px; }
.case.vibe .half { animation: vibe .09s linear 4; }
@keyframes vibe { 25% { transform: translate(1px, -1px); } 75% { transform: translate(-1px, 1px); } }

/* ---------- lid ---------- */
.lid-top { display: grid; grid-template-columns: 1fr 4fr 1fr; gap: 8px; align-items: center; }
.spk { aspect-ratio: 1 / 2.2; border-radius: 10px; background: repeating-radial-gradient(circle at 50% 50%, #0b0e10 0 2px, #1c2226 2px 4px); border: 1px solid #000; box-shadow: inset 0 0 12px #000; position: relative; }
.spk i { position: absolute; inset: 30% 20%; border-radius: 50%; background: radial-gradient(circle, #20272c, #080a0b); }
.case.talk .spk i { animation: cone .14s ease-in-out infinite alternate; }
@keyframes cone { to { transform: scale(1.08); } }
.cyd { display: grid; gap: 4px; justify-items: center; min-height: 0; width: 100%; }
.cyd .glass { min-height: 0; }
.glass { position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 4px; overflow: hidden; background: #02070d; border: 3px solid #0a0c0e;
  box-shadow: 0 0 0 1px #2a2c28, 0 0 18px rgb(46 200 232 / .12), inset 0 0 18px rgb(0 0 0 / .85); }
.glass canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.glass .scr { touch-action: none; }
#eye2 { transform: scaleX(-1); }                     /* 2nd eye: same eye, turning the other way */
.glass.hide-eye canvas:not(.scr) { visibility: hidden; }
#cyd1.tremble .glass { animation: tremble .08s linear infinite; }
@keyframes tremble { 25% { transform: translate(1.5px, -1px); } 75% { transform: translate(-1.5px, 1px); } }

.bays { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
.bay { display: grid; justify-items: center; gap: 4px; }
.bar { display: grid; grid-template-rows: repeat(8, 1fr); gap: 2px; width: 34%; min-width: 16px; padding: 3px; border-radius: 4px; background: #0a0c0e; border: 1px solid #000; aspect-ratio: 1 / 2.5; }
.led { border-radius: 2px; background: #1a1f24; box-shadow: inset 0 0 2px #000; transition: background-color .06s; }
.led.on { background: var(--c); box-shadow: 0 0 6px var(--c), 0 0 12px color-mix(in srgb, var(--c) 50%, transparent); }
.jack { width: var(--hit); height: var(--hit); min-width: var(--hit); min-height: var(--hit); border-radius: 50%; border: 0; background: radial-gradient(circle at 50% 50%, #000 0 30%, #9aa4ac 32% 44%, #3b444b 46% 62%, #1c2226 64%); box-shadow: 0 2px 3px #000; position: relative; }
.jack.full::after { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--plug); box-shadow: 0 0 0 2px #000, inset 0 -3px 4px rgb(0 0 0 / .4); }
.jack.armed { box-shadow: 0 0 0 2px var(--cyan), 0 2px 3px #000; }

/* ---------- base ---------- */
.ports, .knobs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; justify-items: center; }
.ports { margin-bottom: var(--hit-pad); } /* keeps the plugs' invisible pad off the chevron above the knobs */
.port { position: relative; display: grid; justify-items: center; gap: 2px; background: none; border: 0; padding: 0; min-width: var(--hit); min-height: var(--hit); }
.port .plug { width: var(--hit); height: var(--hit); border-radius: 10px 10px 6px 6px; background: linear-gradient(90deg, rgb(0 0 0 / .3), transparent 40%, rgb(255 255 255 / .15) 60%, rgb(0 0 0 / .3)), var(--plug); border: 2px solid #000; }
.port.black .plug { --plug: #22252a; } .port.blue .plug { --plug: #2b7cff; } .port.green .plug { --plug: #22c55e; } .port.red .plug { --plug: #e53935; } .port.yellow .plug { --plug: #f5c518; }
.port.out .plug { opacity: .15; }
.port.sel .plug { outline: 3px solid var(--cyan); outline-offset: 2px; transform: translateY(-4px); }
.knobs { margin: 0; }
/* Knob = three stacked hit boxes of --H each (chevron up, push face, chevron down): no overlap, every box >= 44 CSS px. */
.knob { position: relative; width: 100%; height: calc(var(--H) * 2 + var(--Hf)); }
.knob .kb { position: absolute; left: calc(50% - var(--P) / 2); z-index: 2; width: var(--P); height: var(--H); min-width: 0; min-height: 0; border: 0; background: none; display: grid; place-items: center; padding: 0; }
.knob .kb.up { top: 0; } .knob .kb.dn { bottom: 0; }
.knob .kb::before { content: ''; border: 7px solid transparent; }
.knob .kb.up::before { border-bottom: 10px solid #9aa4ac; border-top: 0; }
.knob .kb.dn::before { border-top: 10px solid #9aa4ac; border-bottom: 0; }
.knob .face { position: absolute; left: calc(50% - var(--Hf) / 2); top: var(--H); z-index: 3; width: var(--Hf); height: var(--Hf); min-width: 0; min-height: 0; border-radius: 50%; border: 0; display: grid; place-items: center; padding: 0; font: 700 22px/1 var(--f-tech); color: #f1f5f8;
  background: conic-gradient(from var(--rot, 0deg), #3a434a, #1b2024 25%, #3a434a 50%, #1b2024 75%, #3a434a); box-shadow: 0 0 0 4px #0b0d0f, 0 0 0 5px #3a434a, 0 3px 6px #000; }
.knob .face:active { transform: scale(.94); }
.knob .silk { position: absolute; left: calc(50% + 15px); top: calc(var(--H) * 1.5 + var(--Hf) - 9px); z-index: 4; pointer-events: none; }   /* right of the down arrow, inside the column */
.deck { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.mod { display: grid; gap: 8px; align-content: start; }
.m-left { grid-template-columns: auto auto; align-items: center; width: max-content; }
.levers { display: flex; gap: 12px; grid-row: span 2; position: relative; }
.levers::before { content: ''; position: absolute; left: 50%; top: 8px; bottom: 8px; width: 8px; margin-left: -4px; border-radius: 1px; pointer-events: none; z-index: 0;
  background: repeating-linear-gradient(-45deg, #111 0 5px, #e8c000 5px 10px); box-shadow: 0 0 0 1px #000; }
.lever { position: relative; width: 62px; height: 96px; border-radius: 8px; background: #0b0d0f; border: 1px solid #000; display: grid; place-items: center; }
.lv-bat { width: var(--hit); height: 56px; min-width: var(--hit); min-height: var(--hit); border: 0; background: none; display: grid; place-items: center; padding: 0; align-self: end; margin-bottom: 6px; z-index: 3; }
.lv-bat:disabled { pointer-events: none; } /* clicks fall through to the cover while the lid is down */
.lv-bat::before { content: ''; width: 14px; height: 52px; border-radius: 7px; background: linear-gradient(90deg, #8d969d, #e5e9ec, #7c858c); transform-origin: 50% 90%; transform: rotate(-14deg); transition: transform .15s; }
.lv-bat[aria-checked="true"]::before { transform: rotate(14deg) scaleY(-1); }
.lv-plate { position: absolute; top: 1px; left: 50%; transform: translateX(-50%); z-index: 4; pointer-events: none; white-space: nowrap; padding: 1px 4px; letter-spacing: .06em; line-height: 1; }
.lv-cover { position: absolute; inset: 22px 4px 4px; border-radius: 6px; border: 0; display: grid; place-items: end center; padding-bottom: 6px; font: 700 9px/1 var(--f-tech); letter-spacing: .08em;
  background: none; z-index: 2; min-width: var(--hit); min-height: var(--hit); }
.lv-cover::before { content: ''; position: absolute; inset: 0; border-radius: 6px; transform-origin: 50% 0; transition: transform .25s; pointer-events: none; }
.blue .lv-cover::before { background: linear-gradient(180deg, rgb(61 139 255 / .85), rgb(30 80 170 / .9)); }
.red .lv-cover::before { background: linear-gradient(180deg, rgb(255 59 48 / .85), rgb(160 20 20 / .9)); }
.lv-cover[aria-expanded="true"]::before { transform: perspective(300px) rotateX(78deg); }
.lv-cover[aria-expanded="true"] span { opacity: 0; }
.lv-cover[aria-expanded="true"] { inset: 22px 4px auto 4px; height: var(--hit); } /* leave the bat free; keep a 44 px strip to close the cover */
.lv-cover span { display: none; } /* name lives on .lv-plate, clear of the bat */
.lv-led { position: absolute; bottom: -10px; width: 10px; height: 4px; border-radius: 2px; background: #222; display: none; }
.flag-lights .lv-led { display: block; }
.blue.lit .lv-led { background: var(--blue); box-shadow: 0 0 8px var(--blue); animation: pulse 1.2s ease-in-out infinite; }
.red.lit .lv-led { background: var(--red); box-shadow: 0 0 8px var(--red); }
@keyframes pulse { 50% { opacity: .3; } }
.tm { position: relative; justify-self: start; padding: 5px 9px; border-radius: 3px; background: #0a0000; border: 2px solid #1a0a0a; font: 500 24px/1 var(--f-mono); letter-spacing: .04em;
  box-shadow: inset 0 2px 6px #000, 0 0 10px rgb(255 40 30 / .18); }
.tm-ghost { color: rgb(255 40 30 / .1); }
.tm-on { position: absolute; left: 9px; top: 5px; color: #ff2a1a; text-shadow: 0 0 6px rgb(255 32 20 / .95), 0 0 16px rgb(255 40 30 / .5); }
.tm.blink .tm-on { animation: pulse .5s steps(2) infinite; }
.locks { display: flex; gap: 10px; }
.lock { width: 52px; min-width: var(--H); height: 60px; min-height: var(--H); border: 0; background: none; display: grid; justify-items: center; gap: 4px; }
.lock i { width: 44px; height: 44px; border-radius: 50%; background: radial-gradient(circle, #d8dde1 0 30%, #8f989f 32% 60%, #4b545b 62%); box-shadow: 0 2px 4px #000; position: relative; transition: transform .15s; }
.lock i::after { content: ''; position: absolute; left: 50%; top: 8px; bottom: 8px; width: 5px; margin-left: -2.5px; border-radius: 2px; background: #1b1f22; }
.lock.has-key i::before { content: ''; position: absolute; left: 50%; top: -6px; width: 16px; height: 22px; margin-left: -8px; border-radius: 4px 4px 2px 2px; background: #c8a24a; box-shadow: 0 1px 2px #000; z-index: 1; }
.lock[aria-pressed="true"] i { transform: rotate(90deg); }
.lock:disabled, .lock[aria-disabled="true"] { cursor: default; opacity: .55; }
.m-mid { justify-items: stretch; }
.hatches { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hatch { position: relative; height: 36px; touch-action: manipulation; cursor: pointer; border-radius: 4px; background: #0a0b0c; border: 1px solid #000; overflow: hidden;
  box-shadow: inset 0 6px 10px #000, inset 0 0 0 1px #1a1a1a; }
.h-key { position: absolute; left: 50%; top: 50%; width: 26px; height: 12px; margin: -6px 0 0 -13px; border-radius: 3px; background: #c8a24a; }
.h-door { position: absolute; inset: 0; display: grid; place-items: center; font: 700 14px/1 var(--f-tech); color: var(--silk); background: repeating-linear-gradient(135deg, #2a3137 0 6px, #232a2f 6px 12px); border: 1px solid #3a434a; border-radius: 6px; transition: transform .45s cubic-bezier(.3, 1.4, .5, 1); transform-origin: 0 50%; }
.hatch.open .h-door { transform: perspective(200px) rotateY(-75deg); }
.hatch.taken .h-key { display: none; }
.hatch.shake .h-door { animation: shake .12s linear infinite; }
@keyframes shake { 25% { transform: translateX(2px); } 75% { transform: translateX(-2px); } }
.crystal { justify-self: center; width: 64px; height: 64px; border-radius: 50%; border: 2px dashed #3a434a; background: #0b0d0f; }
.crystal[aria-pressed="true"] i { display: block; width: 40px; height: 40px; margin: auto; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #e8fbff, #7fdcff 40%, #3ab2e8 70%, #12506e); box-shadow: 0 0 16px #3ab2e8; }
.m-right { grid-template-columns: 1fr; align-items: center; gap: 8px; }
.keypad { display: grid; grid-template-columns: repeat(4, var(--P)); grid-auto-rows: var(--P); justify-content: center; gap: 0; padding: 4px; border-radius: 8px; background: #0b0d0f; border: 1px solid #000; }
.keypad button { width: var(--hit); height: var(--hit); min-width: 0; min-height: 0; justify-self: center; align-self: center; border: 0; border-radius: 6px; font: 700 16px/1 var(--f-tech); background: linear-gradient(180deg, #e9edf0, #b9c1c7); color: #15191c; box-shadow: 0 2px 0 #5d666d, 0 3px 4px #000; }
.keypad button.alt { background: linear-gradient(180deg, #ff5b4f, #c22a20); color: #fff; }
.keypad button:active { transform: translateY(2px); box-shadow: 0 0 0 #5d666d; }
.keypad.locked button { filter: grayscale(1) brightness(.6); }
.joy { display: grid; grid-template-columns: repeat(3, var(--P)); grid-template-rows: repeat(3, var(--P)); gap: 0; padding: 4px; border-radius: 50%; background: radial-gradient(circle, #1b2024, #0b0d0f 70%); justify-self: center; }
.joy .jd, .joy .jp { width: var(--hit); height: var(--hit); justify-self: center; align-self: center; }
.joy .jd { border: 0; background: #2a3137; border-radius: 8px; position: relative; }
.joy .jd::before { content: ''; position: absolute; left: 50%; top: 50%; border: 7px solid transparent; transform: translate(-50%, -50%); }
.jd.up { grid-area: 1 / 2; } .jd.up::before { border-bottom: 10px solid #c9d0d5; border-top: 0; }
.jd.down { grid-area: 3 / 2; } .jd.down::before { border-top: 10px solid #c9d0d5; border-bottom: 0; }
.jd.left { grid-area: 2 / 1; } .jd.left::before { border-right: 10px solid #c9d0d5; border-left: 0; }
.jd.right { grid-area: 2 / 3; } .jd.right::before { border-left: 10px solid #c9d0d5; border-right: 0; }
.joy .jp { grid-area: 2 / 2; border: 0; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #59636b, #1d2226); box-shadow: 0 2px 4px #000; }
.joy button:active { filter: brightness(1.4); }

.wires { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 5; }
.wires path { fill: none; stroke-linecap: round; }
html[data-orient="landscape"] .wires { opacity: .5; }   /* wires cross the base in landscape: keep the knobs readable */

.chrome { position: fixed; top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); z-index: 30; display: flex; flex-direction: column; gap: 8px; padding: 0; }
.chrome button { width: var(--hit); height: var(--hit); min-width: var(--hit); min-height: var(--hit); border-radius: 50%; border: 1px solid var(--edge); background: rgb(18 22 26 / .9); display: grid; place-items: center; }
.chrome svg { width: 20px; height: 20px; stroke: #c9d0d5; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#hits { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#hits .hit { position: absolute; pointer-events: auto; min-width: var(--hit); min-height: var(--hit); border: 0; padding: 0; background: transparent; color: #cfeeff; font: 700 22px/1 var(--f-tech); display: grid; place-items: center; }
#hits .hit.off { pointer-events: none; }
#hintHit { border-radius: 50%; }
#hintHit.on:not(.off) { background: rgb(2 7 13 / .55); box-shadow: 0 0 0 2px rgb(58 178 232 / .7); }
#pupilHit { border-radius: 50%; }
#digitHits .hit { border-radius: 6px; min-width: 0; }   /* six side-by-side cells: keep own width so neighbours never overlap */

/* Portrait design canvas: 412 x 915, then letterboxed/scaled to the viewport (no breakpoint reflow). */
html[data-orient="portrait"] {
  --design-w: 412px; --design-h: 915px; --gap: 6px;
}
html[data-orient="portrait"] .case { grid-template-rows: 248px auto; min-height: 915px; }
html[data-orient="portrait"] .lid-top { min-height: 0; flex: 1 1 auto; }
html[data-orient="portrait"] .lid .cyd { min-height: 0; width: 197px; justify-self: center; }
html[data-orient="portrait"] .lid .glass { width: 197px; height: 132px; max-height: 132px; aspect-ratio: auto; }
.base { overflow: visible; }
html[data-orient="portrait"] .base { min-height: 0; overflow: visible; }
html[data-orient="portrait"] .deck { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "left left" "mid keys" "mid joy"; min-height: 0; }
html[data-orient="portrait"] .m-left { grid-area: left; width: 100%; max-width: none; justify-self: stretch; }
html[data-orient="portrait"] .m-mid { grid-area: mid; min-height: 0; }
html[data-orient="portrait"] .m-right { display: contents; }
html[data-orient="portrait"] .keypad { grid-area: keys; }
html[data-orient="portrait"] .joy { grid-area: joy; align-self: center; }

/* Landscape design canvas: 915 x 412, then letterboxed/scaled to the viewport. */
html[data-orient="landscape"] {
  --design-w: 915px; --design-h: 412px; --gap: 6px;
}
html[data-orient="landscape"] .case { width: var(--cw, 915px); height: auto; min-height: 412px; grid-template-columns: var(--lidw, 248px) minmax(0, 1fr); grid-template-rows: 1fr; align-items: stretch; padding: 6px; gap: 6px; }
html[data-orient="landscape"] .lid, html[data-orient="landscape"] .base { min-height: 0; }
html[data-orient="landscape"] .base { padding: 6px 16px 6px 6px; overflow: visible; }
html[data-orient="landscape"] .lid-top { grid-template-columns: 28px 1fr 28px; min-height: 0; flex: 1 1 auto; }
html[data-orient="landscape"] .bays { margin-top: 6px; flex: 0 0 auto; gap: 2px; }
html[data-orient="landscape"] .bar { aspect-ratio: 1 / 1.8; }
html[data-orient="landscape"] .deck { grid-template-columns: auto minmax(160px, 1fr) auto; grid-template-areas: "left mid keys" "joy mid keys"; margin-top: 0; gap: 2px; min-height: 0; flex: 1 1 auto; align-items: start; }
html[data-orient="landscape"] .m-left { grid-area: left; }
html[data-orient="landscape"] .m-mid { grid-area: mid; min-width: 160px; min-height: 0; }
html[data-orient="landscape"] .m-right { display: contents; }
html[data-orient="landscape"] .keypad { grid-area: keys; }
html[data-orient="landscape"] .joy { grid-area: joy; align-self: start; justify-self: center; }
html[data-orient="landscape"] .cyd2 { width: 100%; min-width: 160px; max-width: 360px; justify-self: center; min-height: 0; }
html[data-orient="landscape"] .cyd2 .glass { min-width: 160px; }
html[data-orient="landscape"] .ports, html[data-orient="landscape"] .knobs { flex: 0 0 auto; }
html[data-orient="landscape"] .port .silk { position: absolute; left: calc(50% + 26px); top: 14px; }
html[data-orient="landscape"] .lid { overflow: hidden; padding: 6px; }
html[data-orient="landscape"] .base { overflow: visible; }
html[data-orient="landscape"] .jack { width: var(--hit); height: var(--hit); }
html[data-orient="landscape"] .lv-plate { top: 5px; }


.hatch.wiggle .h-door { animation: wiggle .18s linear 3; }
@keyframes wiggle { 25% { transform: perspective(200px) rotateY(-75deg) rotate(4deg); } 75% { transform: perspective(200px) rotateY(-75deg) rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) { .case.vibe .half, #cyd1.tremble .glass, .hatch.shake .h-door, .hatch.wiggle .h-door { animation: none; } }

/* Idle hint: point to the physical ARM lever (sim only; the clock still starts on ARM). */
#arm.pulse-arm .lv-cover, #arm.pulse-arm .lv-bat {
  animation: pulse-arm .8s ease-in-out infinite;
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
@keyframes pulse-arm {
  50% { outline-color: #cfeeff; filter: drop-shadow(0 0 10px var(--blue)); }
}
@media (prefers-reduced-motion: reduce) {
  #arm.pulse-arm .lv-cover, #arm.pulse-arm .lv-bat { animation: none; }
}
#armHint, #holdHint {
  position: fixed; z-index: 40; margin: 0; padding: 8px 12px; max-width: min(420px, 88vw); max-height: 4.4em; overflow: hidden;
  text-align: center; font: 500 15px/1.3 var(--f-tech); color: #e8eef2;
  background: rgb(18 22 26 / .94); border: 1px solid var(--edge); border-radius: 8px;
  pointer-events: none; transform: translateX(-50%);
}
#armHint[hidden], #holdHint[hidden] { display: none; }

/* Invisible hit padding: visual size stays --hit; the clickable box grows so letterbox scale still yields >= 44 CSS px. */
#stage .port, #stage .jack, #stage .lv-bat, #stage .lock, #stage .keypad button, #stage .jd, #stage .jp, #stage .plug { position: relative; }
#stage .port::after, #stage .jack::after, #stage .lv-bat::after, #stage .lv-cover::after, #stage .lock::after, #stage .keypad button::after, #stage .jd::after, #stage .jp::after, #stage .plug::after {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--hit-pad));
  pointer-events: auto;
}
/* 0.9.4 landscape: per-side hit growth set by landHits() in sim.js (invisible only; visual sizes and places unchanged) */
html[data-orient="landscape"] #stage .knob .kb::after { content: ""; position: absolute; pointer-events: auto; }
html[data-orient="landscape"] #stage :is(.port, .jack:not(.full), .lv-bat, .lv-cover, .lock, .keypad button, .jd, .jp, .knob .kb)::after {
  inset: calc(-1 * var(--ht, var(--hit-pad))) calc(-1 * var(--hr, var(--hit-pad))) calc(-1 * var(--hb, var(--hit-pad))) calc(-1 * var(--hl, var(--hit-pad)));
}
#stage .lv-bat:disabled, #stage .lv-bat:disabled::after { pointer-events: none; }
#stage .lock:disabled::after { pointer-events: none; }
#stage .jack.full::after {
  inset: 9px; border-radius: 50%;
  background: var(--plug); box-shadow: 0 0 0 2px #000, inset 0 -3px 4px rgb(0 0 0 / .4);
  pointer-events: none;
}

/* ---------- v0.9 art direction (concept-valise materials; v0.8 component positions kept) ---------- */
.latch { position: absolute; z-index: 6; width: 28px; height: 14px; border-radius: 3px; pointer-events: none;
  background: linear-gradient(180deg, #6a6c6e, #2a2c2e 55%, #141516); box-shadow: inset 0 1px 0 rgb(255 255 255 / .25), 0 2px 3px #000; }
.latch::after { content: ''; position: absolute; left: 50%; top: 3px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ddd, #555 70%); }
.latch.l-top { top: 2px; left: 50%; margin-left: -14px; }
.latch.l-bot { bottom: 2px; left: 50%; margin-left: -14px; }
.latch.l-mid { display: none; }
html[data-orient="landscape"] .latch.l-top { top: 50%; left: 2px; margin: -14px 0 0 0; width: 14px; height: 28px; }
html[data-orient="landscape"] .latch.l-bot { top: 50%; bottom: auto; left: auto; right: 2px; margin: -14px 0 0 0; width: 14px; height: 28px; }
.shell-rim { display: none; }

.spk .plate { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); white-space: normal; text-align: center; width: max-content; max-width: calc(100% + 6px); line-height: 1.15; z-index: 2; font-size: 11px; letter-spacing: .04em; padding: 1px 3px; overflow: visible; }
html[data-orient="landscape"] .spk .plate { display: none; }

.band-s28 { margin: 6px 10px 2px; flex: 0 0 18px; display: grid; place-items: center; pointer-events: none;
  font: 700 10px/1 var(--f-mono); letter-spacing: .1em; color: #f0d000; text-transform: uppercase;
  background: repeating-linear-gradient(-45deg, #111 0 6px, #e8c000 6px 12px);
  border: 1px solid #000; border-radius: 2px; box-shadow: inset 0 0 0 3px #0a0a0a, 0 1px 2px #000; z-index: 3; }
.band-s28 { color: transparent; position: relative; container-type: inline-size; }
.band-s28::after { content: "DO NOT TRANSMIT BEFORE CORE OPEN"; position: absolute; inset: 3px 8px; display: grid; place-items: center; white-space: nowrap; overflow: hidden;
  background: #0a0a0a; color: #f0d000; font: 700 10px/1 var(--f-mono); letter-spacing: .08em; }
@container (max-width: 260px) { .band-s28::after { letter-spacing: .015em; font-size: min(10px, 4.4cqw); } }

.sticker.recovered { position: absolute; z-index: 3; pointer-events: none; width: max-content; max-width: 130px; padding: 5px 6px 4px;
  background: #f4f0e4; color: #161616; border: 1px solid #2a2a2a; border-radius: 2px;
  box-shadow: 0 1px 0 #fff, 0 2px 4px rgb(0 0 0 / .4); display: grid; gap: 1px;
  font: 700 10px/1.2 var(--f-mono); letter-spacing: .04em; }
.sticker.recovered strong { font: 700 12px/1 var(--f-tech); letter-spacing: .04em; display: block; white-space: nowrap; }
.lid-rec { left: 8px; top: 20px; bottom: auto; z-index: 5; }
html[data-orient="landscape"] .lid-rec { width: max-content; transform: none; }
html[data-orient="portrait"] .lid-rec { width: max-content; }
.sticker.core-access { position: absolute; z-index: 5; pointer-events: none; padding: 4px 6px; width: 100px;
  background: #161a1e; color: #e8eef2; border: 1px dashed #3ab2e8; border-radius: 2px;
  font: 700 10px/1.2 var(--f-mono); letter-spacing: .04em; display: grid; gap: 2px;
  box-shadow: 0 2px 4px #000; right: 8px; top: 20px; }
.sticker.core-access strong { font: 700 11px/1 var(--f-tech); letter-spacing: .08em; color: #e8eef2; }
.sticker.core-access span { color: #2ec8e8; }
html[data-orient="portrait"] .sticker.core-access { display: none; }

.bar { width: 78%; min-width: 28px; aspect-ratio: 5 / 1.15; grid-template-columns: repeat(8, 1fr); grid-template-rows: 1fr; position: relative;
  box-shadow: 0 0 8px rgb(46 200 232 / .28), inset 0 0 4px rgb(46 200 232 / .15); }
.led { background: #143038; }
.bar::after { content: ""; position: absolute; left: 50%; top: calc(100% + 1px); width: 0; height: 0; margin-left: -5px;
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid #2ec8e8;
  filter: drop-shadow(0 0 4px #2ec8e8); pointer-events: none; }
.bay:nth-child(even) .bar { transform: translateY(6px); }
html[data-orient="landscape"] .bar { aspect-ratio: 4.4 / 1; width: 86%; }

.m-mid { position: relative; }
.hatch-plates { position: absolute; left: 0; right: 0; top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; justify-items: center; pointer-events: none; z-index: 3; }
.hatch-plates .plate { white-space: nowrap; font-size: 10px; letter-spacing: .02em; padding: 1px 3px; }

/* Entity light spill from the eye / CYD / LED only (no studio fill). */
.cyd .glass { outline: 1px solid rgb(46 200 232 / .15); }
#cyd1 .glass { box-shadow: 0 0 0 1px #2a2c28, 0 0 22px rgb(46 200 232 / .22), inset 0 0 18px rgb(0 0 0 / .85); }
#cyd1 .plate, #cyd2 .plate { position: relative; z-index: 4; justify-self: center; flex: 0 0 auto; }

/* Turquoise circuit frames: optional, default off (?frames=turq or the chrome toggle). */
html[data-frames="turq"] .cyd { position: relative; }
html[data-frames="turq"] .cyd .glass {
  border-color: #0a3038;
  box-shadow: 0 0 0 1px #04181c, 0 0 0 3px #0b3a44, inset 0 0 0 1px #1ad0e8, 0 0 18px rgb(26 208 232 / .35);
}
html[data-frames="turq"] .cyd::before,
html[data-frames="turq"] .cyd::after {
  content: ""; position: absolute; width: 18px; height: 18px; pointer-events: none; z-index: 5;
  border: 2px solid #1ad0e8; box-shadow: 0 0 8px rgb(26 208 232 / .5);
}
html[data-frames="turq"] .cyd::before { top: -3px; left: 8px; border-right: 0; border-bottom: 0; }
html[data-frames="turq"] .cyd::after { top: -3px; right: 8px; border-left: 0; border-bottom: 0; }

#btnFrames { font: 700 9px/1 var(--f-mono); letter-spacing: .06em; color: #9aa4ac; }
#btnFrames[aria-pressed="true"] { color: #1ad0e8; box-shadow: 0 0 0 1px #1ad0e8, 0 0 10px rgb(26 208 232 / .4); }

@media (prefers-reduced-motion: reduce) {
  .bar::after { filter: none; }
  #cyd1 .glass { box-shadow: 0 0 0 1px #2a2c28, inset 0 0 18px rgb(0 0 0 / .85); }
}

.port .silk, .knob .silk { padding: 1px 4px; line-height: 1; }
html[data-orient="landscape"] .joy { align-self: start; max-height: 100%; }


/* Sim chrome (not on the physical case): spoken line, step, build id, always-on press feedback. */
#live.voice-line {
  position: fixed; left: 8px; right: calc(var(--chrome-gutter, 55px) + 8px);
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 35; margin: 0; padding: 8px 10px; max-height: 4.6em; overflow: hidden;
  font: 600 13px/1.25 var(--f-tech); color: #e8f7ff;
  background: rgb(6 10 14 / .88); border: 1px solid rgb(58 178 232 / .45); border-radius: 8px;
  pointer-events: none; text-wrap: pretty;
}
#live.voice-line[hidden] { display: none; }
.step-id {
  position: fixed; left: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px) + 3.2em);
  z-index: 35; margin: 0; padding: 3px 6px; font: 700 10px/1 var(--f-mono); letter-spacing: .08em;
  color: #8ad7f0; background: rgb(6 10 14 / .8); border-radius: 4px; pointer-events: none;
}
.step-id[hidden] { display: none; }
.build-id {
  font: 500 8px/1 var(--f-mono); letter-spacing: .04em; color: #7a848c; text-align: center;
  display: block; margin-top: 2px; pointer-events: none; user-select: text; -webkit-user-select: text;
}
.keypad button.feel-press, .keypad button:active { transform: translateY(2px); box-shadow: 0 0 0 #5d666d; }
.joy button.feel-press, .joy button:active { filter: brightness(1.4); }
.knob .face.feel-press, .knob .face:active { transform: scale(.94); }
.port.feel-press, .jack.feel-press, .lv-cover.feel-press, .lv-bat.feel-press, .kb.feel-press, .lock.feel-press, .chrome button.feel-press {
  filter: brightness(1.25); transform: scale(.96);
}
.hatch.feel-wiggle .h-door { animation: wiggle .18s linear 3; }
.jack.feel-wiggle, .lock.feel-wiggle i { animation: wiggle .18s linear 3; }
.cyd .glass.feel-flash { filter: brightness(1.45); }
#tm.feel-flash .tm-on { filter: brightness(1.6); }

#armHint { display: none !important; } /* one hint line only: the caption (#live) carries the sentence; #armHint stays as state for tests / a11y tree is #live */
#live.nudge { animation: nudge 0.9s ease-out 1; }
@keyframes nudge { 0% { transform: scale(1); filter: brightness(1.8); } 30% { transform: scale(1.04); } 100% { transform: scale(1); filter: none; } }
@media (prefers-reduced-motion: reduce) { #live.nudge { animation: none; } }

html[data-orient="landscape"] #live.voice-line { max-height: 2.7em; padding: 5px 10px; font-size: 12px; line-height: 1.25; }

/* ---------- 0.9.4 wide landscape (phones 915 x 412): data-land="wide", chosen by fitStage() only when the original landscape layout cannot give 44 CSS px ----------
   Same parts, same look; rearranged so no stack is taller than the screen allows with 44 px hit boxes:
     lid (CYD 1 + jacks) | knobs (ports above, levers + clock + locks below) | keypad (hatches + CYD 2 below) | d-pad.
   Cell sizes come from --H / --P (design px = 44.4 CSS px / fit scale), like portrait. */
html[data-orient="landscape"][data-land="wide"] .base { display: grid; grid-template-columns: calc(5 * var(--H) + 16px) auto auto; grid-template-rows: auto auto 1fr; column-gap: 4px; row-gap: 0; align-content: start; justify-content: start; padding: 6px 16px 6px 6px; }
html[data-orient="landscape"][data-land="wide"] .ports { grid-area: 1 / 1; margin-bottom: var(--hit-pad); }
html[data-orient="landscape"][data-land="wide"] .knobs { grid-area: 2 / 1; }
html[data-orient="landscape"][data-land="wide"] .deck, html[data-orient="landscape"][data-land="wide"] .m-right { display: contents; }
html[data-orient="landscape"][data-land="wide"] .m-left { grid-area: 3 / 1; align-self: start; margin-top: 6px; }
html[data-orient="landscape"][data-land="wide"] .keypad { grid-area: 1 / 2 / 3 / 3; align-self: start; margin-left: 16px; }
html[data-orient="landscape"][data-land="wide"] .m-mid { grid-area: 3 / 2 / 4 / 4; display: grid; grid-template-columns: calc(4 * var(--P) + 10px) auto; column-gap: 4px; align-items: start; align-self: start; min-width: 0; margin: 6px 0 0 16px; }
html[data-orient="landscape"][data-land="wide"] .hatches { align-self: start; }
html[data-orient="landscape"][data-land="wide"] .hatch-plates { right: auto; width: calc(4 * var(--P) + 10px); }
html[data-orient="landscape"][data-land="wide"] .joy { grid-area: 1 / 3 / 3 / 4; align-self: center; justify-self: start; margin-left: 4px; }
html[data-orient="landscape"][data-land="wide"] .cyd2 { width: 160px; min-width: 0; max-width: none; justify-self: center; }
html[data-orient="landscape"][data-land="wide"] .cyd2 .glass { min-width: 0; }
html[data-orient="landscape"][data-land="wide"] .hatch { height: max(36px, var(--H)); }
html[data-orient="landscape"][data-land="wide"] .hatch-plates { top: max(18px, calc(var(--H) / 2 - 8px)); }
html[data-orient="landscape"][data-land="wide"] .lever { width: max(62px, var(--H)); }
html[data-orient="landscape"][data-land="wide"] .port .silk { position: static; justify-self: center; margin-top: 1px; }
/* knob faces keep the 0.9.3 look (~52 design px); the 44 px hit box is an invisible ::after around them */
html[data-orient="landscape"][data-land="wide"] .knob .face { width: 52px; height: 52px; left: calc(50% - 26px); top: calc(var(--H) + (var(--Hf) - 52px) / 2); }
html[data-orient="landscape"][data-land="wide"] .knob .face::after { content: ""; position: absolute; left: 50%; top: 50%; width: var(--Hf); height: var(--Hf); transform: translate(-50%, -50%); border-radius: 50%; pointer-events: auto; }
html[data-orient="landscape"][data-land="wide"] .lid-top { padding-top: 46px; }
