/* Phone play: landscape prompt, twin-thumb controls, compact landscape HUD. */
html.touch-play,html.touch-play body{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;overscroll-behavior:none}
html.touch-play input{-webkit-user-select:text;user-select:text}
html.touch-play button{touch-action:manipulation}
html.touch-play .control-hint{display:none!important}

/* Rotate prompt: phones held upright. */
.rotate-prompt{display:none;position:fixed;inset:0;z-index:100;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:32px;text-align:center;background:radial-gradient(circle at 50% 35%,#24546a,#102d40 70%);color:#fff9e9}
.rotate-prompt h2{font-size:26px;letter-spacing:-1px;margin:26px 0 4px}
.rotate-prompt p{font-size:14px;line-height:1.5;color:#bcd6dd;max-width:290px;margin:0 0 18px}
.rotate-phone{width:62px;height:104px;border:4px solid #fff9e9;border-radius:14px;position:relative;animation:rotate-hint 2.4s ease-in-out infinite}
.rotate-phone i{position:absolute;left:50%;bottom:7px;width:14px;height:4px;margin-left:-7px;border-radius:3px;background:#ffd24e}
.rotate-lock{display:none;width:auto;padding:0 22px;font-size:13px}
html.can-lock-landscape .rotate-lock{display:flex}
@keyframes rotate-hint{0%,25%{transform:rotate(0)}55%,85%{transform:rotate(-90deg)}100%{transform:rotate(0)}}
@media(orientation:portrait) and (pointer:coarse) and (max-width:1100px){.rotate-prompt{display:flex}}
@media(prefers-reduced-motion:reduce){.rotate-phone{animation:none;transform:rotate(-90deg)}}

.menu-actions{display:contents}

.fullscreen-button{display:none;font-size:18px}
html.touch-play.can-fullscreen .fullscreen-button{display:block}

/* Touch controls: whole-screen thumb zones under the HUD. */
.touch-controls{inset:0;padding:0;display:none!important;pointer-events:none;z-index:4}
html.touch-play .touch-controls:not(.hidden){display:block!important}
.move-zone,.look-zone{position:absolute;top:64px;bottom:0;pointer-events:auto;touch-action:none}
.move-zone{left:0;width:44%}
.look-zone{right:0;width:56%}
.look-zone span{position:absolute;left:50%;top:38%;transform:translateX(-50%);font-size:10px;letter-spacing:2px;color:#fff;text-shadow:0 1px 3px #0008;opacity:0;animation:look-hint 5s ease-out;pointer-events:none;white-space:nowrap}
@keyframes look-hint{0%,60%{opacity:.75}100%{opacity:0}}
.touch-controls .joystick{position:absolute;left:calc(env(safe-area-inset-left) + 104px);top:calc(100% - 96px);width:124px;height:124px;transform:translate(-50%,-50%);border:3px solid #ffffffb0;background:radial-gradient(circle,#10304466 40%,#1030448c);border-radius:50%;opacity:.6;transition:opacity .15s;pointer-events:none}
.touch-controls .joystick.active{opacity:1;transition:none}
.touch-controls .joystick>div{left:50%;top:50%;width:54px;height:54px;margin:-27px 0 0 -27px;background:#fffbf2e6;border:3px solid #fff;box-shadow:0 3px 8px #0004}
.touch-controls .touch-buttons{position:absolute;right:calc(env(safe-area-inset-right) + 18px);bottom:calc(env(safe-area-inset-bottom) + 16px);width:180px;height:160px;display:block;pointer-events:none}
.touch-controls .touch-buttons button{position:absolute;pointer-events:auto;border-radius:50%;font-weight:1000;letter-spacing:1px;touch-action:none;-webkit-user-select:none;user-select:none;box-shadow:0 5px 0 #0003,0 6px 16px #0003;transition:transform .06s}
.touch-controls #jumpTouch{right:0;bottom:0;width:98px;height:98px;font-size:15px;background:#ffd24ef2;border:3px solid #fff3c4;color:#5f4325}
.touch-controls #diveTouch{right:104px;bottom:58px;width:72px;height:72px;font-size:12px;background:#f8aed5ec;border:3px solid #ffe3f1;color:#6a3a7f}
/* Hit areas reach past the visible circles so a hurried thumb still lands. JUMP
   is later in the DOM, so it wins where the two overlap. */
.touch-controls .touch-buttons button::before{content:'';position:absolute;inset:-16px;border-radius:50%}
.touch-controls #jumpTouch::before{inset:-22px -40px -40px -22px;border-radius:50% 0 0 0}
.touch-controls .touch-buttons button.active{transform:scale(.9);box-shadow:0 2px 0 #0003;filter:brightness(1.08)}

/* Landing menu on laptops and tablets: fit the viewport without scrolling. */
.menu-panel{scrollbar-width:none}.menu-panel::-webkit-scrollbar{display:none}
@media(min-width:701px) and (min-height:521px) and (max-height:960px){
  .menu-panel{top:calc(50% + 24px);transform:translateY(-50%);max-height:calc(100dvh - 96px)}
  .menu-panel .course-cards{grid-template-rows:1fr;margin-bottom:10px}
  .menu-panel .menu-meta{display:none}
}
@media(min-width:701px) and (min-height:521px) and (max-height:820px){
  .menu-panel{padding:18px 24px 14px}
  .menu-panel .eyebrow,.menu-panel .intro{display:none}
  .menu-panel h1{font-size:34px;margin:0 0 10px}
  .menu-panel .profile{padding-top:10px}.menu-panel .course-label{margin:12px 0 7px}
  .menu-panel .course-art{height:34px}
  .menu-panel .course-brief{margin-bottom:10px}
  .menu-actions>.button{min-height:42px}.menu-actions>.bot-play-button{margin:10px 0 8px}.menu-actions .join-row{margin-top:9px}.menu-actions>.text-button{margin:2px auto 0;padding:6px 0}
}

/* Phones in landscape: short viewport, notches on the sides. */
@media(orientation:landscape) and (max-height:520px){
  .topbar{padding:8px calc(env(safe-area-inset-right) + 14px) 8px calc(env(safe-area-inset-left) + 14px)}
  .brand{font-size:19px}.brand-star{width:26px;height:26px;font-size:18px;border-radius:9px}.brand b{font-size:7px}
  .connection{font-size:8px;padding:7px 9px}.icon-button{width:34px;height:34px}
  /* Menu: profile and courses on the left, play buttons always in view on the right. */
  .menu-panel{display:grid;grid-template-columns:minmax(0,1fr) minmax(190px,36%);column-gap:20px;align-content:start;top:56px;bottom:calc(env(safe-area-inset-bottom) + 10px);left:calc(env(safe-area-inset-left) + 14px);width:min(760px,calc(100vw - 28px - env(safe-area-inset-left) - env(safe-area-inset-right)));padding:14px 18px;transform:none;max-height:none;overflow:auto}
  .menu-panel>*{grid-column:1}
  .menu-panel>.menu-actions{grid-column:2;grid-row:1/span 9;display:flex;flex-direction:column;gap:9px;align-self:center}
  .menu-panel .eyebrow,.menu-panel .intro,.menu-panel .menu-meta,.mobile-key-art,.scene-caption{display:none!important}
  .menu-panel h1{font-size:25px;letter-spacing:-1.4px;margin:0 0 8px}.menu-panel h1 br{display:none}.menu-panel h1 span{margin-left:.25em}
  .menu-panel .profile{padding-top:9px}.menu-panel .course-label{margin:11px 0 6px}
  .menu-panel .course-cards{grid-template-rows:1fr;margin-bottom:6px;padding-bottom:6px}.menu-panel .course-art{height:30px}
  .menu-panel .course-brief{font-size:10px}.menu-panel .course-brief p{margin:3px 0 0}
  .menu-actions>.button{min-height:44px;margin:0}.menu-actions>.bot-play-button{order:-1;min-height:50px;font-size:14px}.menu-actions .join-row{margin:0}.menu-actions>.text-button{margin:0;padding:6px 0}
  .race-hud{top:52px;left:calc(env(safe-area-inset-left) + 14px);right:calc(env(safe-area-inset-right) + 14px)}
  .race-title{padding:6px 11px;max-width:40%}.race-title small{font-size:7px;margin-bottom:2px}.race-title strong{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.race-title>span{display:none}.round-track{margin-top:5px}
  .hud-stats{gap:5px}.hud-stats>div,.hud-stats>div:first-child,.hud-stats>div:last-child{display:block;min-width:58px;padding:5px 9px;border-radius:9px}.hud-stats small{font-size:7px;margin-bottom:1px}.hud-stats strong{font-size:17px}.hud-stats em{font-size:9px}
  .stage-guide{left:calc(env(safe-area-inset-left) + 14px);top:112px;bottom:auto;width:205px;padding:6px 10px}.stage-guide small{font-size:7px}.stage-guide strong{font-size:11px;margin-top:2px}.stage-guide p{font-size:9px;line-height:1.35;margin:3px 0 4px}.stage-guide>span{font-size:7px}
  .race-progress{bottom:calc(env(safe-area-inset-bottom) + 14px);width:min(30vw,240px)}
  .countdown{font-size:92px}.race-banner{font-size:18px;padding:9px 18px;top:34%}
  .spectator-controls{bottom:14px}
  .leave-game-button{top:auto;bottom:calc(env(safe-area-inset-bottom) + 12px);left:calc(env(safe-area-inset-left) + 14px);min-height:34px}
  html.touch-play .leave-game-button{display:none}
  .toast{bottom:12px}
  .modal-backdrop .pause-card{padding:18px 24px}.pause-card h2{font-size:22px;margin:8px 0}.pause-card p{margin-bottom:12px;font-size:11px}
}
@media(orientation:landscape) and (max-height:390px){
  .stage-guide p{display:none}
  .touch-controls .joystick{width:112px;height:112px;top:calc(100% - 86px);left:calc(env(safe-area-inset-left) + 92px)}
  .touch-controls #jumpTouch{width:88px;height:88px}.touch-controls #diveTouch{width:64px;height:64px;right:94px;bottom:50px}
}
