/* Phones and tablets (html.touch-play, set by mobile-controls.js): full-screen 3D view, floating HUD, a joystick on
   the left half and big buttons on the right, compact windows. The notch and the home indicator are respected.
   Desktop keeps its layout: every rule here is scoped to .touch-play. */
.touch-ui,.tc-rotate {display:none}
html.touch-play,html.touch-play body {height:100%;overflow:hidden;overscroll-behavior:none;-webkit-text-size-adjust:100%}
html.touch-play body {position:fixed;inset:0;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;touch-action:manipulation}
html.touch-play :is(input,textarea,select) {font-size:16px!important;-webkit-user-select:text;user-select:text}
html.touch-play :is(button,a,select,summary) {touch-action:manipulation}
html.touch-play #world canvas {touch-action:none}

/* ── The 3D view fills the screen; the old header becomes two chips at the top right ── */
html.touch-play body>header {position:fixed!important;top:0;left:auto;right:0;height:auto!important;z-index:31;background:none!important;box-shadow:none!important;border:0!important;padding:calc(6px + env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) 0 0!important;pointer-events:none}
html.touch-play body>header .brand {display:none!important}
html.touch-play body>header .player {pointer-events:auto;gap:6px!important}
html.touch-play body>header #xp {font-size:11px!important;padding:4px 8px!important;min-height:0!important}
html.touch-play body>header #character-profile {font-size:10px!important;padding:4px 8px!important;min-width:0!important;min-height:0!important}
html.touch-play body>header #character-title,html.touch-play body>header #avatar,html.touch-play body>header .brand-sub {display:none!important}
html.touch-play .world-shell {position:fixed!important;inset:0!important;height:auto!important;min-height:0!important;margin:0!important;border-radius:0!important}
html.touch-play #world {inset:0!important}

/* ── Top-left toolbar: Menu + Guide, the rest behind "More" ── */
html.touch-play .world-top {top:calc(6px + env(safe-area-inset-top))!important;left:max(8px,env(safe-area-inset-left))!important;right:auto!important;max-width:60vw!important;z-index:30}
html.touch-play .town-toolbar {gap:5px!important;flex-wrap:nowrap!important;align-items:flex-start}
html.touch-play .town-toolbar>button {min-height:34px!important;padding:5px 9px!important;font-size:11px!important;border-radius:10px!important;white-space:nowrap}
html.touch-play .town-toolbar kbd,html.touch-play .madrid-clock,html.touch-play .quest-card {display:none!important}
html.touch-play .town-toolbar:not(.tc-open)>button:nth-child(n+3):not(#tc-more) {display:none!important}
html.touch-play .town-toolbar.tc-open {flex-direction:column;align-items:stretch}
html.touch-play .town-toolbar.tc-open>button {text-align:left}
#tc-more {display:none}
html.touch-play #tc-more {display:inline-block!important;background:#1b2446!important;color:#fff!important}

/* ── Missions, notes and notifications: small and out of the thumbs' way ── */
html.touch-play #playtest-tracker {top:calc(46px + env(safe-area-inset-top))!important;left:max(8px,env(safe-area-inset-left))!important;bottom:auto!important;width:215px!important;max-height:44vh;overflow:auto;padding:8px 10px!important;transform:none!important;z-index:22!important}
html.touch-play #playtest-tracker h3 {font-size:13px!important;margin:4px 0!important}
html.touch-play #playtest-tracker p {font-size:11px!important;padding:5px 7px!important;min-height:0!important}
html.touch-play #playtest-tracker header {padding:0!important;min-height:0!important}
html.touch-play #playtest-tracker header small {font-size:10px!important}
html.touch-play :is(#first-task,#current-activity,#town-object-info) {top:calc(46px + env(safe-area-inset-top))!important;left:max(8px,env(safe-area-inset-left))!important;width:230px!important;max-width:40vw!important;max-height:52vh!important;overflow:auto;padding:9px!important;font-size:12px;z-index:22!important}
html.touch-play #town-notifications {z-index:23!important;left:50%!important;transform:translateX(-50%)!important;width:min(360px,46vw)!important;top:calc(8px + env(safe-area-inset-top))!important;bottom:auto!important}
html.touch-play .place-tag {top:calc(46px + env(safe-area-inset-top))!important;left:50%!important;transform:translateX(-50%) scale(.85)!important;right:auto!important}
html.touch-play .world-toast {top:22%!important;bottom:auto!important;max-width:60vw}
html.touch-play .minimap-panel {top:calc(44px + env(safe-area-inset-top))!important;right:max(8px,env(safe-area-inset-right))!important;bottom:auto!important;left:auto!important;width:92px!important;padding:4px!important;z-index:21!important}
html.touch-play .minimap-panel canvas {width:84px!important;height:84px!important;border-radius:50%}
html.touch-play .minimap-panel>:not(canvas) {display:none!important}
html.touch-play .minimap-panel::after,html.touch-play .minimap-panel::before {display:none!important;content:none!important}
html.touch-play .bottom-hud .key-guide,html.touch-play .world-version,html.touch-play .touch-pad,html.touch-play .mobile-actions {display:none!important}
html.touch-play .bottom-hud #interact {display:none!important}
html.touch-play .bottom-hud {pointer-events:none}
html.touch-play .bottom-hud :is(button,a) {pointer-events:auto}

/* ── Joystick and buttons ── */
html.touch-play .touch-ui {display:block;position:absolute;inset:0;z-index:19;pointer-events:none}
.touch-ui[data-mode=splat] .tc-zone {width:34%}
html.touch-play .touch-ui[data-mode=hidden] {display:none}
.tc-zone {position:absolute;left:0;bottom:0;width:46%;height:74%;pointer-events:auto;touch-action:none}
.tc-base {position:absolute;left:0;top:0;border-radius:50%;background:radial-gradient(rgba(255,255,255,.22),rgba(255,255,255,.06) 70%);border:3px solid rgba(255,255,255,.65);box-shadow:0 0 0 2px rgba(27,36,70,.25);opacity:0;transition:opacity .12s;pointer-events:none}
.tc-zone.on .tc-base {opacity:1}
.tc-knob {position:absolute;left:50%;top:50%;width:48%;height:48%;margin:-24% 0 0 -24%;border-radius:50%;background:radial-gradient(circle at 35% 30%,#fff,#ffe08a 45%,#f2b33d);border:3px solid #1b2446;box-shadow:0 4px 0 rgba(27,36,70,.5)}
.tc-hint {position:absolute;left:calc(28px + env(safe-area-inset-left));bottom:calc(26px + env(safe-area-inset-bottom));display:grid;justify-items:center;gap:2px;color:#fff;font:800 12px Fredoka,Nunito,system-ui,sans-serif;text-shadow:0 2px 0 #1b2446;pointer-events:none;animation:tc-breathe 2.2s ease-in-out infinite}
.tc-hint b {display:grid;place-items:center;width:84px;height:84px;border-radius:50%;border:3px dashed rgba(255,255,255,.8);font-size:34px;background:rgba(27,36,70,.18)}
.tc-hint small {font-weight:600;opacity:.9}
html.tc-used .tc-hint {display:none}
.tc-pad {position:absolute;right:calc(12px + env(safe-area-inset-right));bottom:calc(12px + env(safe-area-inset-bottom));width:200px;height:176px;pointer-events:none}
.tc-btn {position:absolute;display:grid;place-items:center;align-content:center;gap:0;pointer-events:auto;touch-action:none;border-radius:50%;border:3px solid #1b2446;box-shadow:0 5px 0 #1b2446;color:#1b2446;font:800 12px Fredoka,Nunito,system-ui,sans-serif;padding:0;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.tc-btn b {font-size:30px;line-height:1}
.tc-btn small {font-size:10px;font-weight:800;max-width:88px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.tc-btn.down {transform:translateY(3px);box-shadow:0 2px 0 #1b2446}
.tc-action {right:0;bottom:8px;width:98px;height:98px;background:#f4f1ea;opacity:.8}
.tc-action.ready {background:#ffd24d;opacity:1;animation:tc-pulse 1.3s ease-in-out infinite}
.tc-jump {right:108px;bottom:0;width:74px;height:74px;background:#6fd3ff}
.tc-mini {right:12px;bottom:118px;width:46px;height:46px;background:rgba(255,255,255,.9);font-size:22px}
.touch-ui[data-mode=kart] .tc-pad,.touch-ui[data-mode=splat] :is(.tc-action,.tc-mini) {display:none}
.touch-ui[data-mode=splat] .tc-jump {right:112px;bottom:0}
@keyframes tc-pulse {50% {box-shadow:0 5px 0 #1b2446,0 0 0 8px rgba(255,210,77,.35)}}
@keyframes tc-breathe {50% {opacity:.55}}

/* ── Karts: steer with the joystick; drift, item and reset on the right ── */
html.touch-play #gp-hud .gp-touch {display:block!important;position:absolute;right:calc(12px + env(safe-area-inset-right));bottom:calc(12px + env(safe-area-inset-bottom));width:210px;height:170px;pointer-events:none}
html.touch-play #gp-hud .gp-touch button {position:absolute;pointer-events:auto;touch-action:none;border-radius:50%;border:3px solid #1b2446;box-shadow:0 5px 0 #1b2446;font:800 14px Fredoka,Nunito,system-ui,sans-serif;color:#1b2446;padding:0}
html.touch-play #gp-hud .gp-touch [data-gp=drift] {right:0;bottom:0;width:100px;height:100px;background:#6fd3ff;font-size:17px}
html.touch-play #gp-hud .gp-touch [data-gp=item] {right:112px;bottom:10px;width:82px;height:82px;background:#ffd24d}
html.touch-play #gp-hud .gp-touch [data-gp=reset] {right:18px;bottom:114px;width:50px;height:50px;background:#fff;font-size:22px}
html.touch-play #gp-hud .gp-touch button:active {transform:translateY(3px);box-shadow:0 2px 0 #1b2446}
html.touch-play #gp-hud :is(.gp-keys,.gp-board) {display:none!important}
html.touch-play #gp-hud .gp-pos {top:calc(8px + env(safe-area-inset-top))!important;left:max(10px,env(safe-area-inset-left))!important;padding:2px 10px!important}
html.touch-play #gp-hud .gp-pos b {font-size:32px!important}
html.touch-play #gp-hud .gp-lapbox {top:calc(8px + env(safe-area-inset-top))!important;bottom:auto!important;gap:8px!important;padding:3px 10px!important}
html.touch-play #gp-hud .gp-lapbox #gp-lap {font-size:15px!important}
html.touch-play #gp-hud .gp-lapbox #gp-time {font-size:16px!important;min-width:76px!important}
html.touch-play #gp-hud .gp-lapbox small {display:none}
html.touch-play #gp-hud .gp-item {top:calc(52px + env(safe-area-inset-top))!important;right:max(10px,env(safe-area-inset-right))!important;width:70px!important;height:70px!important;border-radius:18px!important}
html.touch-play #gp-hud .gp-item-icon {font-size:28px!important}
html.touch-play #gp-hud .gp-item small,html.touch-play #gp-hud .gp-item kbd {display:none!important}
html.touch-play #gp-hud .gp-quit {top:calc(8px + env(safe-area-inset-top))!important;right:max(10px,env(safe-area-inset-right))!important;font-size:11px!important}
html.touch-play #gp-hud .gp-map {left:max(10px,env(safe-area-inset-left))!important;top:calc(58px + env(safe-area-inset-top))!important;bottom:auto!important;width:120px!important;height:80px!important}
html.touch-play #gp-hud .gp-speed {right:calc(234px + env(safe-area-inset-right))!important;bottom:calc(12px + env(safe-area-inset-bottom))!important;left:auto!important;transform:scale(.8);transform-origin:bottom right}
html.touch-play #gp-hud .gp-rule {top:calc(130px + env(safe-area-inset-top))!important;right:max(10px,env(safe-area-inset-right))!important;transform:scale(.85);transform-origin:top right}
html.touch-play #gp-hud .gp-quiz {top:calc(48px + env(safe-area-inset-top))!important;padding:4px 10px 6px!important}
html.touch-play #gp-hud .gp-quiz b {font-size:15px!important}
html.touch-play #gp-hud .gp-quiz span {min-width:74px!important;font-size:15px!important;padding:2px 8px!important}
html.touch-play #gp-hud .gp-center {font-size:64px!important}
html.touch-play #gp-hud .gp-toast {font-size:18px!important;top:40%!important}

/* ── Splat Island: drag the right half to aim; fire, bomb and E on the right ── */
html.touch-play #splat-hud .sp-touch {display:block!important;position:absolute;right:calc(12px + env(safe-area-inset-right));bottom:calc(12px + env(safe-area-inset-bottom));width:110px;height:200px;pointer-events:none}
html.touch-play #splat-hud .sp-touch button {position:absolute;pointer-events:auto;touch-action:none;border-radius:50%;border:3px solid #1b2446;box-shadow:0 5px 0 #1b2446;font:800 14px Fredoka,Nunito,system-ui,sans-serif;color:#1b2446;padding:0}
html.touch-play #splat-hud .sp-touch [data-sp=fire] {right:0;bottom:0;width:104px;height:104px;background:#ff4fb0;color:#fff;font-size:18px}
html.touch-play #splat-hud .sp-touch [data-sp=bomb] {right:4px;bottom:118px;width:56px;height:56px;background:#fff;font-size:24px}
html.touch-play #splat-hud .sp-touch [data-sp=use] {right:66px;bottom:124px;width:48px;height:48px;background:#ffd24d}
html.touch-play #splat-hud .sp-touch button:active {transform:translateY(3px);box-shadow:0 2px 0 #1b2446}
html.touch-play #splat-hud :is(.sp-lock) {display:none!important}
html.touch-play #splat-hud .sp-map {transform:scale(.7);transform-origin:top left}
html.touch-play #splat-hud .sp-weapon {transform:scale(.8);transform-origin:bottom center}

/* ── Windows: always fit the screen and scroll inside ── */
html.touch-play dialog[open] {max-width:calc(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right))!important;max-height:calc(100dvh - 12px - env(safe-area-inset-top) - env(safe-area-inset-bottom))!important;overflow:auto!important;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;-webkit-user-select:text;user-select:text}
html.touch-play dialog :is(button,a.button,select) {min-height:40px}
html.touch-play :is(.welcome-dialog,.first-dialog,.town-panel) {padding:14px!important}
html.touch-play .welcome-dialog h2,html.touch-play .town-panel h2 {font-size:20px!important}
html.touch-play #places-dialog {padding:12px}
html.touch-play .places-grid {grid-template-columns:repeat(3,minmax(0,1fr))!important}
html.touch-play .places-grid button {min-width:0}
html.touch-play #cinema-skip {right:max(12px,env(safe-area-inset-right));top:calc(12px + env(safe-area-inset-top))}
html.touch-play .cinema-caption {left:max(18px,env(safe-area-inset-left));right:max(18px,env(safe-area-inset-right));bottom:calc(20px + env(safe-area-inset-bottom))}
html.touch-play #title-quit,html.touch-play #session-quit {display:none!important}

/* ── Title screen on a landscape phone ── */
html.touch-play .title-screen {padding:calc(10px + env(safe-area-inset-top)) max(18px,env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(18px,env(safe-area-inset-left))!important;overflow:auto;align-items:center}
@media (max-height:520px) {
 html.touch-play .title-center {padding:0!important}
 html.touch-play .title-eyebrow {display:none}
 html.touch-play .town-wordmark {font-size:44px!important;margin:0 auto!important;line-height:.95}
 html.touch-play .title-tagline {margin:6px auto!important;font-size:13px!important}
 html.touch-play .title-actions {display:flex!important;flex-wrap:wrap;justify-content:center;gap:8px!important;max-width:560px;margin:0 auto}
 html.touch-play .title-actions button {min-height:44px!important;padding:8px 18px!important;font-size:16px!important;flex:1 1 150px}
 html.touch-play .title-actions .play-button {flex:1 1 100%}
 html.touch-play .title-player {margin:6px 0 0!important;font-size:12px}
 html.touch-play .title-account-row {margin-top:6px!important}
 html.touch-play .title-foot {display:none!important}
 html.touch-play .title-clock {transform:scale(.8);transform-origin:top right}
}
#title-install {display:inline-block;margin-left:8px}

/* ── Portrait: ask to turn the phone ── */
@media (orientation:portrait) {
 html.touch-play .tc-rotate {display:flex;position:fixed;inset:0;z-index:2147483000;align-items:center;justify-content:center;flex-direction:column;gap:10px;background:#173e39f2;color:#fff8e9;text-align:center;font:800 20px Fredoka,Nunito,system-ui,sans-serif;pointer-events:auto}
 html.touch-play .tc-rotate b {font-size:64px;animation:tc-turn 1.8s ease-in-out infinite}
 html.touch-play .tc-rotate small {display:block;font-size:15px;font-weight:600;opacity:.85;margin-top:4px}
}
@keyframes tc-turn {40%,60% {transform:rotate(-90deg)}}

/* ── Activities take the whole screen: the town toolbar, missions and chips step aside ── */
html.touch-play body:is(.gp-racing,.splat-playing,.gp-podium) :is(.world-top,#playtest-tracker,.minimap-panel,.place-tag,#first-task,#current-activity),
html.touch-play body:is(.gp-racing,.splat-playing,.gp-podium)>header {display:none!important}
html.touch-play #splat-hud .sp-map {top:calc(8px + env(safe-area-inset-top))!important;left:max(8px,env(safe-area-inset-left))!important;right:auto!important;bottom:auto!important;transform:scale(.62)!important;transform-origin:top left!important}
html.touch-play #splat-hud .sp-weapon {left:38%!important;right:auto!important;bottom:calc(6px + env(safe-area-inset-bottom))!important;transform:translateX(-50%) scale(.72)!important;transform-origin:bottom center!important}
html.touch-play #splat-hud .sp-vitals {transform:scale(.8);transform-origin:bottom left}

/* ── MOBILE rendering profile: no backdrop blur over the moving 3D view. The compositor would re-blur the town behind
   every such button on every frame; the panels are already almost opaque, so they look the same. Dialog backdrops
   (the game is paused behind them) keep their blur. ── */
html.touch-play .world-shell *:not(dialog) {backdrop-filter:none!important;-webkit-backdrop-filter:none!important}
