/* --- HUD, CONTROLES MÓVILES Y PANTALLAS --- */

/* ── HUD ─────────────────────────────────────────────────────── */
#hud {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: clamp(48px, 8vw, 65px);
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    border-bottom: 3px solid #fff;
    color: #fff;
    font-weight: bold;
    padding: 0 clamp(8px, 2vw, 20px);
    gap: 4px;
}

.hud-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.hud-label {
    font-size: clamp(7px, 1.5vw, 10px);
    color: #aaa;
    white-space: nowrap;
}
.hud-val {
    font-size: clamp(12px, 3vw, 18px);
    white-space: nowrap;
}

/* Indicador de jugador */
#control-indicator {
    position: absolute;
    top: clamp(52px, 9vw, 75px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.5);
    color: #0ff;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: clamp(9px, 1.8vw, 12px);
    border: 1px solid #0ff;
    z-index: 90;
    white-space: nowrap;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── BOTÓN PAUSA ─────────────────────────────────────────────── */
#pause-btn {
    background: transparent;
    border: 2px solid rgba(255,255,255,0.6);
    color: #fff;
    font-family: 'Courier New', monospace;
    font-size: clamp(10px, 2vw, 13px);
    font-weight: bold;
    padding: 0;
    cursor: pointer;
    transition: all 0.1s;
    flex-shrink: 0;
    width:  clamp(36px, 7vw, 48px);
    height: clamp(36px, 7vw, 48px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
#pause-btn:hover  { background: #fff; color: #000; border-color: #fff; }
#pause-btn:active { transform: scale(0.92); }

/* ── CONTROLES MÓVILES ───────────────────────────────────────── */
#mobile-controls {
    position: fixed;
    bottom: 18%;
    left: 0;
    width: 100%;
    display: none;
    padding: 12px clamp(12px, 4vw, 28px);
    justify-content: space-between;
    align-items: center;
    z-index: 200;
    background: transparent;
    pointer-events: none;
    box-sizing: border-box;
}

/* Joystick */
#joystick {
    width:  clamp(88px, 20vw, 120px);
    height: clamp(80px, 20vw, 120px);
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    position: relative;
    pointer-events: all;
    flex-shrink: 0;
}

#joy-knob {
    width:  clamp(32px, 7.5vw, 46px);
    height: clamp(32px, 7.5vw, 46px);
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Grupo de botones derecha */
.mobile-btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    pointer-events: all;
    flex-shrink: 0;
}

.btn {
    width:  clamp(72px, 18vw, 96px);
    height: clamp(44px, 10vw, 56px);
    border: none;
    border-radius: 10px;
    background: #444;
    color: white;
    font-weight: bold;
    font-size: clamp(11px, 2.5vw, 14px);
    letter-spacing: 1px;
    box-shadow: 0 3px 0 #222;
    cursor: pointer;
    pointer-events: all;
    min-width: 44px;
    min-height: 44px;
    box-sizing: border-box;
}
.btn:active  { transform: translateY(3px); box-shadow: none; }
.btn-boost   { background: #e67e00; box-shadow: 0 3px 0 #a05000; }
.btn-switch  { background: #0055aa; box-shadow: 0 3px 0 #003377; }
.mobile-btn-group {
    display: flex;
    flex-direction: column;
    gap: clamp(5px, 1.2vh, 10px);
    align-items: flex-end;
    pointer-events: all;
    flex-shrink: 0;
}

.btn {
    width:  clamp(68px, 17vw, 88px);
    height: clamp(38px, 8.5vw, 52px);
    border: none;
    border-radius: 10px;
    background: #444;
    color: white;
    font-weight: bold;
    font-size: clamp(10px, 2.2vw, 13px);
    letter-spacing: 1px;
    box-shadow: 0 3px 0 #222;
    cursor: pointer;
    pointer-events: all;
    min-width: 44px;
    min-height: 44px;
    box-sizing: border-box;
}
.btn:active  { transform: translateY(3px); box-shadow: none; }
.btn-boost   { background: #e67e00; box-shadow: 0 3px 0 #a05000; }
.btn-switch  { background: #0055aa; box-shadow: 0 3px 0 #003377; }

/* ── HINT ESCRITORIO ─────────────────────────────────────────── */
#desktop-hint {
    position: absolute;
    bottom: 10px;
    width: 100%;
    text-align: center;
    color: rgba(255,255,255,0.7);
    font-size: clamp(10px, 1.5vw, 12px);
    pointer-events: none;
    z-index: 50;
}

/* ── PANTALLAS NIVEL Y GAME OVER ─────────────────────────────── */
#screen-level,
#screen-over {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    color: white;
    text-align: center;
    padding: 20px;
}

#screen-level h1,
#screen-over h1 {
    font-size: clamp(20px, 5vw, 32px);
    margin-bottom: 12px;
}

#screen-level p,
#screen-over p {
    font-size: clamp(12px, 2.5vw, 16px);
}

.start-btn {
    background: #000;
    border: 2px solid #fff;
    color: #fff;
    padding: clamp(8px, 2vw, 12px) clamp(16px, 4vw, 24px);
    font-size: clamp(13px, 2.5vw, 16px);
    font-weight: bold;
    cursor: pointer;
    font-family: monospace;
    margin-top: 20px;
    min-width: 44px;
    min-height: 44px;
}
.start-btn:hover { background: #fff; color: #000; }

/* ── BREAKPOINTS ─────────────────────────────────────────────── */

/* Móvil pequeño (< 400px — ej. 320px, iPhone SE) */
@media (max-width: 400px) {
    #hud { height: 48px; padding: 0 8px; }
    .hud-label { font-size: 7px; }
    .hud-val   { font-size: 13px; }
    #mobile-controls { height: 120px; }
    #joystick  { width: 76px; height: 76px; }
    #joy-knob  { width: 28px; height: 28px; }
    .btn       { width: 62px; height: 40px; font-size: 10px; }
}

/* Móvil estándar (400–768px) */
@media (min-width: 401px) and (max-width: 768px) {
    #mobile-controls { display: flex; }
    #desktop-hint    { display: none; }
}

/* Tablet (769–1024px) — mostrar controles táctiles si es touch */
@media (max-width: 768px) {
    #mobile-controls { display: flex; }
    #desktop-hint    { display: none; }
}

/* Pantalla muy alta (landscape móvil) */
@media (max-height: 420px) and (max-width: 900px) {
    #mobile-controls {
        height: 80px;
        padding: 4px clamp(10px, 3vw, 20px);
    }
    #joystick { width: 66px; height: 66px; }
    #joy-knob { width: 24px; height: 24px; }
    .btn      { height: 34px; min-height: 34px; font-size: 9px; width: 60px; }
    .mobile-btn-group { gap: 4px; }
}
