/* Phone / touch layout. Everything is scoped to html.touch (set by touch.js),
   so the desktop page is unaffected. Designed for landscape:

     race:  [ race info + steering ] [ game view ] [ actions + throttle ]
     menu:  [ map preview ] [ scrolling settings ]
*/

.touch-help { display: none; }
.touch .touch-help { display: block; }
.touch .keys-help { display: none; }
.touch .desktop-only { display: none; }

#touch-steer, #touch-drive, #touch-side { display: none; }

html.touch, .touch body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.touch body {
    padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
    box-sizing: border-box;
}
.touch input[type="text"], .touch input[type="number"] {
    -webkit-user-select: text;
    user-select: text;
}

/* --- Loading screen ------------------------------------------------------- */
.touch .loading-screen {
    justify-content: flex-start;
    overflow-y: auto;
    padding: 12px 0 24px;
    font-size: 14px;
    box-sizing: border-box;
}
.touch .loading-screen > div { width: 86%; margin: 4px; }

/* --- Menu ----------------------------------------------------------------- */
.touch #canvas_div {
    flex: 0 0 auto;
    width: auto;
    height: auto;
    position: relative;   /* anchors the minimap */
    align-self: center;
}
.touch #game {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.touch .panel {
    padding: 0.75rem 1rem;
    gap: 0.6rem;
    margin: 6px;
    width: calc(100% - 12px);
    box-sizing: border-box;
    flex: 0 0 auto;
}
.touch h3 { font-size: 1.15rem; }
.touch input[type="range"] { height: 0.4rem; margin: 0.5rem 0; }
.touch input[type="range"]::-webkit-slider-thumb { width: 1.6rem; height: 1.6rem; }
.touch input[type="checkbox"] { width: 1.3rem; height: 1.3rem; }
.touch select, .touch input[type="text"], .touch input[type="number"] { min-height: 2.4rem; }

/* --- Race ----------------------------------------------------------------- */
.touch #info {
    order: -1;            /* left of the game view */
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    align-items: center;
    gap: 0;
    overflow-y: auto;
}
.touch #info canvas {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100%;
}
.touch.racing #touch-side {
    order: 1;             /* right of the game view */
    flex: 1 1 0;
    min-width: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 40px;
    align-content: start;
    gap: 8px;
    padding: 10px;
}
.touch-action {
    padding: 0 4px;
    font-size: 0.8rem;
    border-radius: 0.6rem;
    background-color: #334155;
    color: #e2e8f0;
    box-shadow: none;
    border: 1px solid #475569;
}
.touch-action:hover { background-color: #334155; }
.touch-action.on { background-color: #0369a1; border-color: #38bdf8; }

.touch.racing:not(.finished) #touch-steer,
.touch.racing:not(.finished) #touch-drive {
    display: flex;
}
.touch-pad {
    position: fixed;
    bottom: 14px;
    z-index: 50;
    gap: 10px;
    touch-action: none;
}
#touch-steer { left: calc(12px + env(safe-area-inset-left)); }
#touch-drive { right: calc(12px + env(safe-area-inset-right)); }
.touch-zone {
    width: 78px;
    height: 92px;
    border-radius: 16px;
    background: rgba(148, 163, 184, 0.28);
    border: 2px solid rgba(226, 232, 240, 0.55);
    color: #f1f5f9;
    font-size: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;   /* the pad itself receives the touches */
}
.touch-zone.down { background: rgba(56, 189, 248, 0.6); border-color: #38bdf8; }
