/* ============================================================
   Touch / pointer controls
   ============================================================ */

.touch-only {
    display: none !important;
}

html.is-touch .touch-only {
    display: flex !important;
}

.desktop-only {
    display: none !important;
}

html:not(.is-touch) .desktop-only {
    display: flex !important;
}

html:not(.is-touch) .mobile-controls {
    display: none !important;
}

/* This layer spans the whole viewport, so it MUST stay transparent to
   pointers. Only the joystick zone and the action cluster below opt back
   in. If the layer itself becomes a hit target it sits over the HUD and
   silently swallows every tap aimed at the pause button or the minimap. */
.mobile-controls {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 40;
    pointer-events: none;
}

.mobile-controls.active {
    display: block;
}

/* --- Joystick ------------------------------------------------ */
/* Generous invisible drag zone: the stick base follows the thumb
   wherever it lands inside this area. */
.joystick-area {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 48%;
    height: 62%;
    min-height: 180px;
    max-height: 460px;
    pointer-events: auto;
    touch-action: none;
}

.joystick-base {
    width: clamp(96px, 27vmin, 150px);
    height: clamp(96px, 27vmin, 150px);
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(0, 180, 255, 0.2);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.6;
    transition: opacity 0.15s ease, border-color 0.15s ease;
    pointer-events: none;
}

.joystick-base.active {
    opacity: 1;
    border-color: rgba(0, 212, 255, 0.55);
}

.joystick-stick {
    width: 42%;
    height: 42%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 180, 255, 0.35), rgba(0, 100, 200, 0.15));
    border: 2px solid rgba(0, 180, 255, 0.45);
    transition: transform 0.05s linear;
    will-change: transform;
}

/* --- Action cluster (bottom-right) ---------------------------- */
.mobile-actions {
    position: absolute;
    right: calc(10px + var(--safe-r));
    bottom: calc(10px + var(--safe-b));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: clamp(6px, 1.4vh, 12px);
    pointer-events: none;
    max-width: 58vw;
}

.mobile-ability-row {
    display: flex;
    gap: clamp(4px, 1vw, 8px);
    pointer-events: auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
}

.mobile-button-row {
    display: flex;
    align-items: flex-end;
    gap: clamp(6px, 1.6vw, 12px);
    pointer-events: auto;
}

.mobile-btn {
    border-radius: 50%;
    border: 2px solid;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    flex: 0 0 auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s, background 0.1s;
}

.mobile-btn:active {
    transform: scale(0.92);
}

.fire-btn {
    width: clamp(66px, 19vmin, 104px);
    height: clamp(66px, 19vmin, 104px);
    font-size: clamp(10px, 2.6vmin, 14px);
    background: rgba(255, 60, 60, 0.15);
    border-color: rgba(255, 80, 80, 0.4);
    color: #ff6666;
}

.fire-btn.pressed {
    background: rgba(255, 60, 60, 0.35);
    border-color: #ff4444;
    box-shadow: 0 0 20px rgba(255, 60, 60, 0.4);
}

.boost-btn {
    width: clamp(50px, 14vmin, 76px);
    height: clamp(50px, 14vmin, 76px);
    font-size: clamp(8px, 2vmin, 11px);
    background: rgba(0, 180, 255, 0.1);
    border-color: rgba(0, 180, 255, 0.3);
    color: var(--primary);
}

.boost-btn.pressed {
    background: rgba(0, 180, 255, 0.3);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 180, 255, 0.3);
}

/* --- Ability buttons (mirrors the desktop ability bar) -------- */
.ability-btn {
    position: relative;
    width: clamp(36px, 10.5vmin, 56px);
    height: clamp(36px, 10.5vmin, 56px);
    font-size: clamp(9px, 2.4vmin, 12px);
    background: rgba(10, 14, 30, 0.8);
    border-color: rgba(255,255,255,0.12);
    color: var(--text);
    overflow: hidden;
}

.ability-btn .ability-cooldown {
    font-size: clamp(9px, 2.4vmin, 12px);
}

.ability-btn.on-cooldown {
    opacity: 0.55;
}

.ability-btn.no-energy {
    opacity: 0.35;
}

.ability-btn.pressed {
    transform: scale(0.9);
    border-color: var(--primary);
}

/* --- In-game pause button (touch only) ------------------------ */
.hud-pause-btn {
    margin-top: 6px;
    width: clamp(30px, 9vmin, 40px);
    height: clamp(30px, 9vmin, 40px);
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--text);
    font-size: clamp(9px, 2.4vmin, 12px);
    letter-spacing: 1px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    flex: 0 0 auto;
}

.hud-pause-btn:active {
    transform: scale(0.92);
    border-color: var(--primary);
    color: var(--primary);
}

.hud-pause-desktop {
    margin-top: 0;
    align-self: flex-start;
}

/* A thumb needs roughly a 44px target, and the two pause bars need room
   to stay legible, so the touch variant outgrows the compact desktop one. */
html.is-touch .hud-pause-btn {
    width: clamp(40px, 11vmin, 48px);
    height: clamp(40px, 11vmin, 48px);
    font-size: clamp(12px, 3vmin, 16px);
    margin-top: 8px;
}

/* Portrait phones: keep the action cluster clear of the minimap
   by moving the minimap to the right edge middle (see responsive.css) */
