/*
 * Continuity mobile/touch compatibility layer.
 * It keeps the recovered interfaces visually period-correct while ensuring
 * every required interaction remains usable without a physical keyboard or mouse.
 */
.yume-mobile-controls{display:none}

/* Continuity Archive touch targets (safe on desktop too). */
.ca-nav a,.ca-search button,.ca-actions a,.case-state a,.ca-collection-case>div:last-child a,
.ca-file-grid a,.ca-record-row,.case-file-toggle,.case-dossier-head button,
.case-conclusion button,.case-conclusion input{min-height:44px}
.ca-file-grid a{display:grid;place-items:center}
.case-dossier-head button{min-width:44px}

@media (max-width:900px),(hover:none),(pointer:coarse){
  .immersive-page{overscroll-behavior:none}
  .immersive-stage{touch-action:pan-y}

  .immersive-page button,.immersive-page [role="button"],.immersive-page input,
  .immersive-page select,.immersive-page textarea{font-size:max(16px,1em)}

  .immersive-page button,.immersive-page [role="button"],
  .cad-toolbar button,.toolbar button,.app-folders button,.app-record,
  .unknown-menu button,.kernel-cell,.kiosk-options button,.pet-device button,
  .switch-controls button,.fiche-controls button,.irc button{
    min-height:44px;
    touch-action:manipulation;
  }

  .yume-mobile-controls{
    --yc-touch-bg:rgba(10,13,17,.80);
    --yc-touch-border:rgba(255,255,255,.52);
    --yc-touch-ink:#fff;
    display:flex;
    z-index:80;
    gap:10px;
    align-items:center;
    justify-content:center;
    user-select:none;
    -webkit-user-select:none;
    -webkit-touch-callout:none;
    touch-action:none;
  }

  .yume-touch-key{
    appearance:none;
    -webkit-appearance:none;
    min-width:52px;
    min-height:52px;
    border:1px solid var(--yc-touch-border);
    border-radius:12px;
    background:var(--yc-touch-bg);
    color:var(--yc-touch-ink);
    box-shadow:0 5px 16px rgba(0,0,0,.35),inset 0 1px 0 rgba(255,255,255,.12);
    font:800 15px/1 Arial,Helvetica,sans-serif!important;
    letter-spacing:.02em;
    padding:10px 12px;
    touch-action:none!important;
  }

  .yume-touch-key.is-pressed,.yume-touch-key:active{
    transform:translateY(2px) scale(.98);
    background:rgba(243,211,74,.96);
    border-color:#fff4b6;
    color:#17130a;
  }
  .yume-touch-key.primary{background:rgba(243,211,74,.96);color:#17130a;border-color:#fff1a1}
  .yume-touch-key.small{min-width:70px;min-height:44px;font-size:11px!important}

  /* Recovered desktop: single-tap icons + windows that cannot fall off-screen. */
  .desk-icon[data-yume-tap-ready]{min-height:64px;padding:5px;touch-action:manipulation}
  .os-window{
    resize:none!important;
    max-width:calc(100vw - 16px)!important;
    max-height:calc(100dvh - 92px)!important;
  }
  .win-title{min-height:34px!important;touch-action:none}
  .win-title button{min-width:38px!important;min-height:30px!important}
  .cmd-line input,.term-input input{font-size:16px!important;min-height:42px}

  /* Quick command chips use the original terminal/command handlers. */
  .yume-command-bar{
    display:flex;
    gap:6px;
    overflow-x:auto;
    overscroll-behavior-inline:contain;
    scrollbar-width:thin;
    padding:8px 0 2px;
    flex:0 0 auto;
  }
  .yume-command-bar button{
    flex:0 0 auto;
    min-height:40px!important;
    padding:7px 10px;
    border:1px solid currentColor;
    background:rgba(255,255,255,.09);
    color:inherit;
    font:700 12px monospace!important;
  }
  .cmd .yume-command-bar{padding:7px 0 0}

  /* Office-map/CAD: the source CSS hid the Properties panel on phones. */
  .cad-body{
    grid-template-columns:1fr!important;
    grid-template-rows:minmax(0,1fr) auto!important;
    min-height:0!important;
  }
  .cad-tree{display:none!important}
  .cad-canvas{min-height:0!important;padding:8px!important}
  .cad-props{
    display:block!important;
    border:0!important;
    border-top:1px solid #888!important;
    max-height:32dvh;
    overflow:auto;
    padding:10px 12px!important;
    background:#e7e7e7;
  }
  .cad-room{min-width:44px;min-height:44px;font-size:10px!important;padding:3px!important}
  .cad-toolbar{overflow-x:auto;flex-wrap:nowrap!important;overscroll-behavior-inline:contain}
  .cad-toolbar button{flex:0 0 auto;padding:7px 10px!important}

  /* Unknown OS: 220px sidebar was consuming most of a phone display. */
  .unknown-os{padding:8px!important;overflow:auto}
  .unknown-frame{min-height:calc(100dvh - 58px)}
  .unknown-body{grid-template-columns:1fr!important;grid-template-rows:auto minmax(0,1fr)!important;min-height:0}
  .unknown-menu{
    border-right:0!important;
    border-bottom:1px solid #555;
    padding:5px!important;
    display:flex;
    overflow-x:auto;
    overscroll-behavior-inline:contain;
  }
  .unknown-menu button{flex:0 0 auto;width:auto!important;white-space:nowrap;padding:9px 12px!important}
  .unknown-view{padding:14px!important;overflow:auto;min-height:0}
  .unknown-view h1{font-size:clamp(24px,8vw,34px)!important}

  /* Network map: prevent right-hand nodes being clipped on narrow screens. */
  .network-map .node{
    width:28%!important;
    min-width:0!important;
    min-height:48px;
    padding:6px 3px!important;
    overflow-wrap:anywhere;
    font-size:10px!important;
  }

  /* Reconstructed office: larger hit areas; note must not block objects. */
  .office-note{pointer-events:none}
  .office-scene .object{min-width:76px;min-height:44px;padding:7px!important;font-size:11px!important}

  /* Switchboard: 32 jacks and action buttons remain comfortably tappable. */
  .switchboard{overflow:auto;padding-bottom:calc(12px + env(safe-area-inset-bottom,0px))!important}
  .switch-panel{height:auto!important;min-height:58dvh}
  .jack{min-height:46px;display:grid!important;place-content:center;cursor:pointer;touch-action:manipulation}
  .jack:focus-visible{outline:3px solid #f3d34a;outline-offset:2px}
  .switch-controls{display:flex!important;flex-wrap:wrap!important;gap:7px!important}
  .switch-controls button{flex:1 1 calc(50% - 7px);padding:9px 7px!important;font-size:11px!important}
  .patch-log{max-height:18dvh;overflow:auto}

  /* CCTV slider and microfiche controls need finger-sized controls. */
  .timeline{min-height:44px;touch-action:pan-x}
  .fiche-controls button{min-height:44px!important}
  .fiche-controls input[type="range"]{min-height:44px;touch-action:pan-x}

  /* Other recovered apps. */
  .toolbar{overflow-x:auto;overscroll-behavior-inline:contain}
  .toolbar button{flex:0 0 auto}
  .app-record{min-height:52px!important}
  .app-folders button{min-height:44px!important}
  .kernel-cell{min-width:0}
  .kiosk-options button{min-height:56px!important}
  .pet-device button{min-width:76px}
  .irc .chat p[role="button"]{min-height:34px;padding:6px 3px;cursor:pointer}
  .irc .input input{min-width:0;font-size:16px!important}

  /* Case File / Continuity archive */
  .case-dossier-head button{display:grid;place-items:center}
  .case-conclusion form{grid-template-columns:1fr!important}
  .case-conclusion button,.case-conclusion input{width:100%;min-height:46px}
  .case-source a{display:inline-flex;align-items:center;min-height:44px}
  .ca-case-tools input,.ca-case-tools select,.ca-search input,.ca-search button{min-height:46px;font-size:16px}
  .ca-file-grid a{min-height:46px}

  /* Blockworks / voxel case */
  .voxel-frame{position:relative}
  .voxel-help{
    bottom:auto!important;
    top:14px;
    left:auto!important;
    right:14px;
    transform:none!important;
    max-width:42%;
    text-align:right;
    pointer-events:none;
  }
  .yume-voxel-controls{
    position:absolute;
    inset:auto 12px calc(12px + env(safe-area-inset-bottom,0px));
    justify-content:space-between;
    pointer-events:none;
  }
  .yume-voxel-controls>*{pointer-events:auto}
  .yume-touch-dpad{
    width:174px;
    display:grid;
    grid-template-columns:repeat(3,52px);
    grid-template-rows:repeat(2,52px);
    gap:6px;
    grid-template-areas:". up ." "left down right";
  }
  .yume-touch-dpad .up{grid-area:up}.yume-touch-dpad .left{grid-area:left}.yume-touch-dpad .down{grid-area:down}.yume-touch-dpad .right{grid-area:right}
  .voxel-actions{width:min(242px,45vw);display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
  .voxel-actions .primary{grid-column:2;grid-row:1}.voxel-actions .turn:first-child{grid-column:1;grid-row:1}.voxel-actions .turn:nth-child(3){grid-column:3;grid-row:1}
  .voxel-actions .small{grid-row:2}.voxel-actions .small:nth-last-child(2){grid-column:1/3}.voxel-actions .small:last-child{grid-column:3}

  /* Claw-machine case */
  .arcade-cab{position:relative!important}
  .yume-arcade-controls{
    position:absolute;left:50%;bottom:calc(14px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);
    width:min(430px,calc(100% - 24px));pointer-events:auto
  }
  .yume-arcade-controls .arcade-move{flex:1}.yume-arcade-controls .arcade-drop{min-width:110px}
  .arcade-cab>p{margin-bottom:76px!important}

  /* BIOS case */
  .bios{padding-bottom:88px!important;overflow:auto}
  .bios-menu div{min-height:44px;display:flex;align-items:center;cursor:pointer;touch-action:manipulation}
  .bios-menu div[role=button]:focus-visible{outline:2px solid currentColor;outline-offset:-3px}
  .yume-bios-controls{
    position:sticky;bottom:calc(8px + env(safe-area-inset-bottom,0px));margin:18px auto 0;width:min(390px,100%);
    padding:8px;border:1px solid rgba(255,255,255,.28);background:rgba(0,0,90,.90)
  }
  .yume-bios-controls .yume-touch-key{flex:1;background:#c9c9c9;color:#111;border-color:#fff}
  .yume-bios-controls .yume-touch-key.primary{background:#fff;color:#000}
}

@media (max-width:600px){
  .voxel-frame{width:100vw!important;height:calc(100dvh - 42px)!important;max-height:none!important;border-width:0!important}
  .voxel-hud{top:8px!important;left:8px!important;font-size:10px!important;max-width:48vw!important}
  .voxel-help{top:8px!important;right:8px!important;font-size:8px!important;max-width:35%!important;width:auto!important}
  .yume-voxel-controls{inset:auto 8px calc(8px + env(safe-area-inset-bottom,0px));gap:5px}
  .yume-touch-dpad{width:144px;grid-template-columns:repeat(3,44px);grid-template-rows:repeat(2,44px);gap:5px}
  .yume-touch-key{min-width:44px;min-height:44px;border-radius:10px;padding:8px;font-size:13px!important}
  .voxel-actions{width:min(202px,52vw);gap:5px}.voxel-actions .small{min-width:0;min-height:40px;font-size:9px!important;padding:5px}

  .arcade-cab{width:100vw!important;height:calc(100dvh - 42px)!important;max-height:none!important;border-width:7px!important;padding:10px!important}
  .arcade-cab h1{font-size:clamp(22px,7vw,32px)!important;margin:4px 0 8px!important}
  .arcade-cab canvas{height:calc(100% - 150px)!important;min-height:220px}
  .arcade-cab>p{font-size:10px!important;margin:5px 0 70px!important}
  .yume-arcade-controls{width:calc(100% - 16px);gap:7px;bottom:calc(8px + env(safe-area-inset-bottom,0px))}.yume-arcade-controls .arcade-drop{min-width:92px}

  .kiosk-screen{width:calc(100vw - 12px)!important;height:calc(100dvh - 54px)!important;border-width:8px!important;padding:14px!important;overflow:auto}
  .kiosk-screen h1{font-size:clamp(28px,10vw,40px)!important}.kiosk-options{gap:7px!important}
  .pet-device{max-height:calc(100dvh - 54px);overflow:auto;padding:14px!important;border-width:6px!important}.pet-screen{height:min(42dvh,300px)!important}

  .microfiche{position:relative!important;padding:5px!important;grid-template-columns:1fr!important}
  .fiche-screen{border-width:8px!important}
  .fiche-controls{
    position:absolute!important;left:6px!important;right:6px!important;bottom:calc(6px + env(safe-area-inset-bottom,0px))!important;
    width:auto!important;max-height:42dvh;overflow:auto;padding:9px!important;background:#24211df2!important
  }
  .fiche-controls button{padding:8px!important}

  .office-note{right:6px!important;top:6px!important;width:min(230px,62vw)!important;padding:9px!important;font-size:11px}
  .office-scene .object{font-size:10px!important;min-width:68px}

  .unknown-view{padding:10px!important}
  .kernel{padding:8px!important}.kernel-grid{gap:5px!important}.kernel-cell{padding:7px!important}.kernel-cell b{font-size:19px!important}
}

@media (max-width:360px){
  .yume-voxel-controls{gap:3px!important}
  .yume-touch-dpad{width:130px;grid-template-columns:repeat(3,40px);grid-template-rows:repeat(2,40px);gap:5px}
  .yume-touch-key{min-width:40px;min-height:40px;padding:6px;font-size:12px!important}
  .voxel-actions{width:calc(100% - 136px)!important;gap:3px}.voxel-actions .small{font-size:8px!important;padding:3px}
  .yume-arcade-controls .arcade-drop{min-width:78px}
  .switch-controls button{flex-basis:100%}
  .kiosk-options{grid-template-columns:1fr!important}
}

/* Short landscape phones: controls must not consume the entire experience. */
@media (max-height:520px) and (hover:none), (max-height:520px) and (pointer:coarse){
  .voxel-help{display:none!important}.voxel-hud{font-size:8px!important;padding:5px!important}
  .yume-touch-key{min-height:38px;min-width:38px;padding:5px;font-size:11px!important}
  .yume-touch-dpad{width:122px;grid-template-columns:repeat(3,38px);grid-template-rows:repeat(2,38px);gap:4px}
  .voxel-actions{width:min(180px,48vw);gap:4px}.voxel-actions .small{min-height:36px!important}
  .arcade-cab canvas{min-height:140px!important;height:calc(100% - 116px)!important}
  .arcade-cab>p{display:none}.yume-arcade-controls{bottom:4px}.yume-arcade-controls .yume-touch-key{min-height:38px}
  .fiche-controls{max-height:52dvh}
  .bios{padding:8px 8px 62px!important}.bios h1{margin:0 0 4px}.bios-menu{display:grid;grid-template-columns:repeat(3,1fr)}.bios-menu div{min-height:36px}.yume-bios-controls{margin-top:6px;padding:4px}
}

/* Legacy puzzle/reconstruction pages: preserve the old look, remove phone-only friction. */
@media (max-width:700px),(hover:none),(pointer:coarse){
  .puzzle-shell{width:calc(100% - 20px)!important;padding:52px 0!important}
  .puzzle-form{display:grid!important;grid-template-columns:1fr!important;gap:8px!important;width:100%;max-width:100%!important}
  .puzzle-form input,.puzzle-form button,.puzzle-button{width:100%;min-height:46px;font-size:16px!important}
  .desk-voice-toggle{min-height:44px;min-width:44px;padding:9px 11px!important;right:max(8px,env(safe-area-inset-right,0px))!important;bottom:max(8px,env(safe-area-inset-bottom,0px))!important}
  .found-slip,.guest-puzzle-slip,.badge-compare-link,.tape-splice-link,.scrapbook-loose-key{min-height:44px;display:inline-flex!important;align-items:center}

  .keyring-board{margin:16px 10px!important;padding:14px!important;box-shadow:7px 9px 0 rgba(0,0,0,.2)!important}.keyring-head{padding:14px!important}.keyring-head h1{font-size:clamp(2.5rem,13vw,4rem)!important}
  .cabinet-room{padding:5vh 10px!important}.cabinet{padding:12px!important;border-width:7px!important;box-shadow:8px 10px 0 rgba(0,0,0,.18)!important}.cabinet-drawer{min-height:140px!important}
  .response-puzzle{padding:3vh 10px!important}.response-puzzle-box{padding:14px!important}.response-puzzle-six{grid-template-columns:repeat(2,1fr)!important}.response-puzzle-six span{min-height:72px;height:auto!important}
  .order-desk{padding:46px 10px!important}.order-cards button{min-height:108px!important;padding:14px!important}
  .switchboard-grid{grid-template-columns:repeat(3,minmax(0,1fr))!important;width:100%;max-width:100%!important}.switchboard-grid span{height:auto!important;min-height:76px;font-size:1.25rem!important}
  .tape-strips button{min-height:52px;padding:12px!important;border-left-width:16px!important}
  .corridor{scroll-snap-type:x proximity}.corridor .door{scroll-snap-align:start;flex-basis:128px!important;height:240px!important}

  .recon-window{margin:10px!important;max-width:calc(100% - 20px)!important}.recon-main{padding:16px!important}.recon-toolbar{overflow-x:auto;overscroll-behavior-inline:contain}.recon-toolbar span{flex:0 0 auto;min-height:36px;display:flex;align-items:center}.recon-nav a{min-height:44px;display:flex;align-items:center}
  .final-check-shell{padding:4vh 10px!important}.final-check-screen{padding:14px!important;min-height:280px!important}.final-start{min-height:46px;width:100%}

  .maze-grid,.number-board,.toggle-board{width:100%!important;max-width:100%!important;gap:6px!important}
  .maze-grid{grid-template-columns:repeat(5,minmax(0,1fr))!important}.maze-grid button{width:100%!important;height:auto!important;aspect-ratio:1;min-width:0;min-height:48px}
  .number-board{grid-template-columns:repeat(4,minmax(0,1fr))!important}.number-board button{height:auto!important;aspect-ratio:1;min-width:0;min-height:54px}
  .toggle-board{grid-template-columns:repeat(3,minmax(0,1fr))!important}.toggle-board button{height:auto!important;aspect-ratio:1;min-width:0;min-height:64px}

  .web99-deep .deep99{width:calc(100% - 10px)!important;max-width:none!important;border-width:4px!important;padding:10px!important}.web99-deep h1{font-size:clamp(2rem,10vw,3rem)!important}.web99-deep td{padding:6px!important;overflow-wrap:anywhere}
  .web08-deep{padding:10px!important}.xp-body{padding:14px!important}
  .flash-shell{padding:20px 10px!important}.flash-logo{font-size:clamp(3.8rem,20vw,7rem)!important}.flash-stage{height:min(56dvh,440px)!important;border-width:6px!important}.flash-links{flex-wrap:wrap}.flash-links a{min-height:44px;display:inline-flex;align-items:center}
  .paper-stack-page,.crt-page,.printer-page{padding:4vh 10px!important}.paper-stack,.crt-box,.printer-paper{padding:20px!important}.paper-stack h1,.crt-box h1{font-size:clamp(2.2rem,11vw,4rem)!important}

  .mega-button,.sector-seal button,.phone-directory button,.game-grid button,.elevator-panel button{min-height:44px}
  .evidence-sheet{overflow-x:auto}.evidence-sheet table{min-width:520px}
  .fake-window{max-width:100%;overflow:hidden}.fake-body{overflow:auto}
  .oldweb .mega-shell{width:calc(100% - 18px)!important}
}

@media (max-width:390px){
  .number-board{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  .response-puzzle-six{grid-template-columns:1fr 1fr!important}
  .final-check-title{display:block!important}.final-check-title span{display:block;margin-top:5px}
}
