/* Mobile viewport and playable touch layout. Keep the desktop scene untouched. */
/* Let Lenis own desktop wheel/anchor motion; native fallback keeps style.css. */
html.lenis{scroll-behavior:auto}
.mobile-game-screen[hidden]{display:none!important}
@media (max-width:760px){
  .stage[data-era="0"] .scene-world{--camera-x:67.5%;--camera-y:33%;--camera-zoom:1.12}
  .stage[data-era="1"] .scene-world{--camera-x:70.5%;--camera-y:12%;--camera-zoom:.55}
  .stage[data-era="2"] .scene-world{--camera-x:78%;--camera-y:52%;--camera-zoom:1.07}
  .stage{height:100dvh;min-height:0;max-height:none}
  .header{height:64px;padding-inline:5%}
  .header .brand-logo{width:clamp(103px,31vw,140px)}
  .header nav button{min-height:44px;padding:8px 5px;font-size:12px}
  .header-cta{min-height:44px;display:flex;align-items:center;padding:8px 10px}
  .intro-line{top:72px;left:7%;right:7%;font-size:6px}
  .chapter-copy{top:clamp(96px,16dvh,148px)}
  .chapter-copy h1{margin:10px 0 14px;line-height:1.26}
  .chapter-copy .primary{min-height:48px;margin-top:12px}
  .key-hint{font-size:11px;max-width:260px}
  .stage-bottom{bottom:calc(16px + env(safe-area-inset-bottom,0px))}
  .timeline{right:4px;width:44px}
  .timeline button{width:44px;height:44px;min-width:44px;min-height:44px;justify-content:center}
  .timeline>div{height:14px;margin:0 auto}
  /* Starting or choosing a game remains possible during the scroll fade. */
  .stage:not(.is-playing) .primary,.stage:not(.is-playing) .game-choice{pointer-events:auto}
  .collection{padding-inline:6%}
  .game-cards{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .game-cards button{min-width:0;min-height:205px}
  .card-title{font-size:clamp(13px,4vw,16px);overflow-wrap:anywhere}
  .mini-art{height:96px}
  footer{gap:14px}
}
@media (max-width:360px){
  .header .brand-logo{width:106px}
  .header-cta{font-size:11px;padding:6px 8px}
  .header-cta span{margin-left:5px}
  .chapter-copy h1{font-size:clamp(23px,7vw,29px)!important}
  .eyebrow{font-size:7px;letter-spacing:.35px}
}
@media (max-width:760px), (pointer:coarse) and (max-width:1200px){
  .stage{--touch-size:clamp(54px,16vw,64px)}
  html:has(body.mobile-game-active){scroll-behavior:auto}
  body.mobile-game-active{overflow:hidden;overscroll-behavior:none}
  .stage.is-playing .mobile-game-screen{display:block;position:absolute;z-index:9;top:clamp(94px,17dvh,156px);left:50%;transform:translateX(-50%);width:min(calc(100% - 24px),440px);aspect-ratio:4/3;background:#11241c;border:2px solid #d8b979;border-radius:9px;box-shadow:0 12px 35px #000b;overflow:hidden;pointer-events:none}
  .mobile-game-screen canvas{display:block;width:100%;height:100%;image-rendering:pixelated}
  .stage.is-playing .game-help{display:none}
  .stage.is-playing .touch-controls{position:absolute;z-index:11;left:0;right:0;bottom:calc(112px + env(safe-area-inset-bottom,0px))!important;padding:0 12px;display:flex;justify-content:space-between;align-items:end;gap:10px;touch-action:none;user-select:none;-webkit-user-select:none}
  .stage[data-era="0"].is-playing .touch-controls{bottom:calc(66px + env(safe-area-inset-bottom,0px))!important}
  .touch-dpad{display:grid;grid-template-columns:repeat(3,var(--touch-size));grid-template-rows:repeat(3,var(--touch-size));gap:2px;flex:none}
  .touch-actions{display:grid;grid-template-columns:repeat(2,var(--touch-size));grid-auto-rows:var(--touch-size);gap:5px;align-self:end;margin-bottom:12px}
  .touch-dpad button[data-key="ArrowUp"]{grid-column:2;grid-row:1}
  .touch-dpad button[data-key="ArrowLeft"]{grid-column:1;grid-row:2}
  .touch-dpad button[data-key="ArrowRight"]{grid-column:3;grid-row:2}
  .touch-dpad button[data-key="ArrowDown"]{grid-column:2;grid-row:3}
  .touch-actions button[data-key="Space"]{grid-column:2;grid-row:1}
  .touch-actions button[data-key="j"]{grid-column:1;grid-row:1}
  .touch-actions button[data-key="k"]{grid-column:2;grid-row:2}
  .touch-actions button[data-key="l"]{grid-column:1;grid-row:2}
  .touch-controls button{width:100%!important;min-width:0!important;height:100%!important;min-height:44px;border:1px solid #dfc38d;border-radius:10px;background:#172e25f5;color:#fff4d4;font:700 18px/1 Arial,sans-serif;touch-action:none;user-select:none;-webkit-user-select:none;box-shadow:0 3px 0 #0a160f,0 5px 16px #0008}
  .touch-actions button{font-size:clamp(11px,3.5vw,15px);letter-spacing:0;padding:0 2px}
  .touch-controls button:active,.touch-controls button.is-pressed{background:#e4c28a;color:#192c22;transform:translateY(2px);box-shadow:0 1px 0 #0a160f}
  .stage.is-playing .game-toolbar{z-index:12;left:12px;right:12px;bottom:calc(8px + env(safe-area-inset-bottom,0px))!important;width:auto;max-width:none;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px;padding:5px;border-radius:10px}
  .stage.is-playing .game-toolbar #game-picker:not([hidden]){grid-column:1/-1;width:100%;max-width:none;height:42px}
  .stage.is-playing .game-toolbar #swap{display:none!important}
  .stage.is-playing .game-toolbar button{min-width:0;min-height:44px;padding:6px 3px;font-size:clamp(10px,3vw,13px);white-space:nowrap}
  .stage.is-playing .timeline,.stage.is-playing .intro-line,.stage.is-playing .stage-bottom{display:none}
  .stage.is-playing .scene-world{filter:brightness(.45)}
  .stage.is-playing .mechanical-canvas{filter:brightness(.35)}
  .live-status{z-index:10}
}
@media (max-width:760px) and (max-height:630px) and (orientation:portrait), (pointer:coarse) and (max-width:1200px) and (max-height:630px) and (orientation:portrait){
  .stage:not(.is-playing) .key-hint{display:none}
  .stage.is-playing .mobile-game-screen{top:82px;width:min(calc(100% - 36px),calc((100dvh - 210px - 3 * var(--touch-size)) * 4 / 3))}
  .stage.is-playing .touch-controls{bottom:calc(116px + env(safe-area-inset-bottom,0px))!important;padding-inline:8px;gap:8px}
  .stage[data-era="0"].is-playing .touch-controls{bottom:calc(70px + env(safe-area-inset-bottom,0px))!important}
}
@media (max-width:760px) and (orientation:landscape), (pointer:coarse) and (max-width:1200px) and (orientation:landscape){
  .stage{height:100dvh;min-height:0}
  .stage.is-playing .mobile-game-screen{top:8px;width:min(47vw,calc((100dvh - 16px)*4/3))}
  .stage.is-playing .touch-controls,.stage[data-era="0"].is-playing .touch-controls{bottom:calc(8px + env(safe-area-inset-bottom,0px))!important;align-items:center}
  .touch-dpad{grid-template-columns:repeat(3,54px);grid-template-rows:repeat(3,54px)}
  .touch-actions{margin:0;grid-template-columns:repeat(2,54px);grid-auto-rows:54px}
  .touch-actions button{font-size:13px;padding:0;letter-spacing:0}
  .stage.is-playing .game-toolbar{left:50%;right:auto;transform:translateX(-50%);width:min(48vw,390px);bottom:6px!important}
  .stage.is-playing .game-toolbar button{min-height:44px}
  .stage.is-playing .mobile-game-screen{max-height:calc(100dvh - 124px);width:min(45vw,calc((100dvh - 124px)*4/3))}
  .stage.is-playing .touch-controls{pointer-events:none}
  .stage.is-playing .touch-controls button{pointer-events:auto}
}
@media (max-width:760px) and (prefers-reduced-motion:reduce){.touch-controls button{transition:none}}
