/* ============================================================
   mobile.css — Layout móvil: barra superior unificada
   ============================================================ */

/* ── Joystick: solo en touch ─────────────────────────────── */
#mobile-controls { display: none; }

@media (hover: none) and (pointer: coarse),
       (max-width: 768px) {
    #mobile-controls { display: block; }
}

/* ══════════════════════════════════════════════════════════
   JOYSTICK VIRTUAL
══════════════════════════════════════════════════════════ */
#joystick-zone {
    position: fixed;
    bottom: 28px;
    left: 20px;
    width: 120px;
    height: 120px;
    z-index: 45;
    touch-action: none;
    user-select: none;
}
#joystick-base {
    width: 120px; height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,.06);
    border: 1.5px solid rgba(255,255,255,.14);
    position: absolute; top: 0; left: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
#joystick-base::before, #joystick-base::after {
    content:''; position:absolute;
    background: rgba(255,255,255,.08); border-radius:1px;
}
#joystick-base::before { width:1px;height:50%;top:25%;left:50%;transform:translateX(-50%); }
#joystick-base::after  { height:1px;width:50%;left:25%;top:50%;transform:translateY(-50%); }
#joystick-thumb {
    width: 46px; height: 46px; border-radius: 50%;
    background: radial-gradient(circle at 38% 35%, rgba(255,255,255,.85), rgba(123,95,212,.6));
    border: 1.5px solid rgba(255,255,255,.4);
    position: absolute; top:50%; left:50%;
    transform: translate(-50%,-50%);
    box-shadow: 0 3px 10px rgba(0,0,0,.4);
    pointer-events: none; will-change: transform;
}

/* ══════════════════════════════════════════════════════════
   BARRA SUPERIOR UNIFICADA — PORTRAIT MÓVIL
   Reemplaza los 3 paneles flotantes por 1 franja compacta
══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {

    /* ── Ocultar paneles originales ─── */
    #hud-container,
    #score-container,
    #inventory-container,
    #octalysis-wheel-hud { display: none !important; }

    /* ── Barra superior ─────────────── */
    body::before {
        content: '';
        position: fixed; top: 0; left: 0; right: 0;
        height: 64px; z-index: 30;
        background: rgba(10,8,22,.88);
        border-bottom: 1px solid rgba(255,255,255,.08);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        pointer-events: none;
    }

    /* ── HUD móvil unificado ─────────── */
    #mobile-hud {
        position: fixed; top: 0; left: 0; right: 0;
        height: 64px; z-index: 31;
        display: flex; align-items: center;
        padding: 0 12px; gap: 8px;
        pointer-events: none;
    }

    /* Sección izquierda: drives + monedas */
    #mhud-left {
        display: flex; flex-direction: column; gap: 2px;
        flex: 1; min-width: 0;
    }
    #mhud-drives {
        font-size: 12px; font-weight: 700;
        color: #FFD700; white-space: nowrap;
    }
    #mhud-coins {
        font-size: 11px; color: rgba(255,255,255,.5);
    }

    /* Centro: wheel compacto */
    #mhud-wheel {
        flex-shrink: 0;
        width: 52px; height: 52px;
    }
    #mhud-wheel svg { width: 52px; height: 52px; }

    /* Sección derecha: puntos */
    #mhud-right {
        display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
        flex: 1;
    }
    #mhud-score {
        font-size: 14px; font-weight: 800; color: #FFD700;
    }
    #mhud-label {
        font-size: 9px; color: rgba(255,255,255,.35);
        text-transform: uppercase; letter-spacing: 1px;
    }

    /* Botones interactivos en la barra */
    #mhud-shop-btn, #mhud-diary-btn {
        pointer-events: all; cursor: pointer;
        background: rgba(255,255,255,.08);
        border: 1px solid rgba(255,255,255,.14);
        border-radius: 8px; color: rgba(255,255,255,.7);
        font-size: 10px; font-weight: 700; padding: 4px 8px;
        white-space: nowrap;
    }
    #mhud-shop-btn { color: #FFD700; border-color: rgba(255,215,0,.3); }

    /* Mover el canvas para que no quede debajo de la barra */
    #gameCanvas { margin-top: 0; }

    /* Mute: encima del joystick */
    #audio-mute-btn {
        bottom: 156px !important;
        right: 14px !important;
        width: 44px !important; height: 44px !important;
        font-size: 18px !important;
    }
}

/* ══════════════════════════════════════════════════════════
   TABLET / LANDSCAPE MÓVIL (601–768px)
══════════════════════════════════════════════════════════ */
@media (min-width: 601px) and (max-width: 768px) {
    #info-panel { max-width: 180px; padding: 10px 12px; }
    #info-panel h3 { font-size: 11px; }
    #info-panel p  { font-size: 10px; }
    #player-position, #current-zone { display: none; }

    #score-container   { top: 12px; right: 12px; }
    #score-panel       { padding: 10px 14px; min-width: 120px; }
    #score-value       { font-size: 15px; }
    #coins-value       { font-size: 11px; }
    #shop-hud-btn      { font-size: 10px; padding: 5px 8px; }

    #inventory-container { right: 140px; top: 12px; }
    #inventory-panel   { width: 120px; padding: 8px; }
    #inventory-items   { grid-template-columns: repeat(4,1fr); gap: 4px; }
    .inventory-item    { font-size: 16px; padding: 4px 2px; }

    #octalysis-wheel-hud {
        bottom: auto; top: 80px; left: 10px;
        transform: none;
    }
    #wheel-svg { width: 72px; height: 72px; }
    #wheel-label { display: none; }

    #audio-mute-btn {
        bottom: 148px !important;
        right: 14px !important;
    }
}

/* ══════════════════════════════════════════════════════════
   MODALES — bottom sheet en móvil pequeño
══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {

    /* Todos los overlays de modal desde abajo */
    #fb-overlay,
    #npc-v2-overlay,
    #shop-overlay,
    #diary-overlay {
        padding: 0;
        align-items: flex-end;
    }

    #fb-card,
    #npc-v2-card,
    #shop-card,
    #diary-panel {
        max-width: 100% !important;
        width: 100%;
        border-radius: 20px 20px 0 0 !important;
        max-height: 88vh;
    }

    /* Victory: scroll completo */
    #victory-overlay  { padding: 0; align-items: flex-start; }
    #victory-container { padding: 16px 14px 80px; }

    /* Onboarding: pantalla completa */
    #onboarding-overlay { padding: 0; }
    #ob-container {
        height: 100dvh;
        max-width: 100%;
        border-radius: 0;
        padding: 20px 16px 28px;
        justify-content: space-between;
    }

    /* Botones táctiles ≥ 44px (Apple HIG) */
    .modal-btn, .ob-btn, .npc-v2-btn,
    .vbtn, .shop-buy-btn, .quiz-btn,
    .leaderboard-choice-btn, .npc-v2-choice,
    .diary-tab {
        min-height: 44px;
    }

    /* Quiz/choices en columna */
    .quiz-buttons         { grid-template-columns: 1fr; gap: 8px; }
    .npc-v2-choices       { grid-template-columns: 1fr; }
    .leaderboard-choices  { grid-template-columns: 1fr; }
    .ob-drives-grid       { grid-template-columns: repeat(2,1fr); }
    .ob-controls-grid     { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════
   GLOBAL TOUCH
══════════════════════════════════════════════════════════ */
* { -webkit-tap-highlight-color: transparent; touch-action: pan-y; }
canvas { touch-action: none; }
button, [role="button"] { touch-action: manipulation; }
