/**
 * Mobile Controls CSS - Layout Adaptativo v6
 * Argentum Survivor
 * 
 * MEJORAS v6:
 * - Portrait: Canvas ARRIBA de los controles (no superpuesto)
 * - Landscape: Inventario y botones más grandes
 * - Pantalla centrada al entrar al juego
 */

/* ============================================================================
   VARIABLES CSS
   ============================================================================ */

:root {
    --sat: env(safe-area-inset-top, 0px);
    --sar: env(safe-area-inset-right, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);

    --mobile-gold: #c5a059;
    --mobile-gold-bright: #ffd700;
    --mobile-copper: #8b7355;
    --mobile-dark: #1a1510;
    --mobile-panel: #14100b;
    --mobile-border: #554433;

    --btn-red-light: #cc4444;
    --btn-red-mid: #991111;
    --btn-red-dark: #661111;
    --btn-red-border: #8b4444;

    /* Layout: valores canónicos en el bloque VIEWPORT RESPONSIVE más abajo */
    --hud-max-height-mobile: 60vh;
    --ios-scroll-shim: 80px;
}

/* ============================================================================
   LOGIN - iOS SCROLL
   ============================================================================ */

body.mobile-login-mode {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
    min-height: 130vh !important;
    -webkit-overflow-scrolling: touch !important;
    position: relative !important;
}

.mobile-login-mode #screen-auth {
    position: relative !important;
    height: auto !important;
    min-height: 130vh !important;
    padding: 15vh 0 30vh 0;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
}

.mobile-scroll-hint {
    text-align: center;
    font-size: 13px;
    color: #8f8;
    margin: 15px 0;
    padding: 12px 20px;
    background: rgba(26, 74, 42, 0.4);
    border: 1px solid #3a8a5a;
    border-radius: 8px;
    animation: hint-pulse 2s infinite;
}

@keyframes hint-pulse {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

.mobile-login-mode .auth-card {
    width: 280px !important;
    max-width: 85vw !important;
    padding: 18px 20px !important;
}

.mobile-login-mode .auth-card input {
    font-size: 16px !important;
}

.mobile-fullscreen-btn {
    display: none !important;
}

#screen-auth.screen-hidden {
    display: none !important;
}

/* ============================================================================
   MODO JUEGO - FIJO Y CENTRADO
   ============================================================================ */

body.mobile-mode:not(.mobile-login-mode) {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    overscroll-behavior: none !important;
}

html.mobile-mode:not(.mobile-login-mode) {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    overflow: hidden !important;
}

html.mobile-mode.ios-scroll-fullscreen:not(.mobile-login-mode) {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    height: auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

body.mobile-mode.ios-scroll-fullscreen:not(.mobile-login-mode) {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    height: auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

body.mobile-mode.ios-scroll-fullscreen:not(.mobile-login-mode) #ios-scroll-shim-top {
    height: var(--ios-scroll-shim) !important;
}

body.mobile-mode.ios-scroll-fullscreen:not(.mobile-login-mode) .game-layout {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
}

.mobile-mode {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

/* ============================================================================
   OCULTAR ELEMENTOS EN MÓVIL
   ============================================================================ */

.mobile-mode .minimap-section,
.mobile-mode .minimap-panel {
    display: none !important;
}

.mobile-mode .game-column-right {
    display: none !important;
}

/* Consola oculta por defecto en ambas orientaciones; solo con .mobile-console-visible */
.mobile-mode .console-panel:not(.mobile-console-visible) {
    display: none !important;
}

.mobile-mode .sidebar-footer-buttons {
    display: none !important;
}

/* Cuando hay un modal abierto, ocultar HUD móvil, controles y consola. */
body.mobile-mode.modal-open .mobile-hud-left,
body.mobile-mode.modal-open .mobile-hud-right,
body.mobile-mode.modal-open .mobile-chat-toggle,
body.mobile-mode.modal-open .mobile-survivor-attack-slots,
body.mobile-mode.modal-open #mobile-controls-container,
body.mobile-mode.modal-open .console-panel {
    display: none !important;
}

/* Menú AO móvil: misma grilla 2×4 sobre las barras del HUD izquierdo */
.mobile-vitals-host {
    position: relative;
    flex: 0 0 auto;
    min-height: 0;
}

.mobile-mode #game-menu-panel.game-menu-panel {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 5px !important;
    border-radius: 0 !important;
    gap: 4px !important;
    z-index: 6 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

body.mobile-mode #btn-action-menu.menu-open {
    border-color: #d4af37 !important;
    box-shadow: 0 0 0 1px rgba(232, 200, 90, 0.45);
}

.mobile-mode #game-menu-panel .game-menu-item {
    min-height: 0 !important;
    padding: 3px 2px !important;
    font-size: 8px !important;
    border-radius: 0 !important;
    touch-action: manipulation;
}

body.mobile-mode #gold-display-btn.gold-btn-cast {
    justify-content: center;
    gap: 8px;
}

body.mobile-mode #gold-display-btn #mobile-gold-action-label {
    font-weight: 900;
    font-size: 12px;
    letter-spacing: 0.5px;
    color: #ffd700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* ============================================================================
   GAME LAYOUT - BASE
   ============================================================================ */

.mobile-mode .game-layout {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    border: none !important;
    border-radius: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #000 !important;
}

.mobile-mode .game-column-left {
    width: 100% !important;
    height: 100% !important;
}

.mobile-mode .game-viewport {
    width: 100% !important;
    height: 100% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

/* ============================================================================
   LANDSCAPE - CANVAS CENTRADO, HUD GRANDES A LOS LADOS
   ============================================================================ */

.mobile-mode.landscape .game-column-left {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: var(--hud-width-landscape) !important;
    right: var(--hud-width-landscape) !important;
    width: auto !important;
}

.mobile-mode.landscape #game-canvas {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    object-fit: contain;
    object-position: center;
}

.mobile-mode.landscape .game-viewport {
    align-items: stretch;
    justify-content: stretch;
}

.mobile-mode.portrait .game-column-left {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: calc(var(--controls-height-portrait) + var(--hud-portrait-height) + var(--sab) + 10px) !important;
    height: auto !important;
    width: 100vw !important;
}

.mobile-mode.portrait .game-viewport {
    width: 100% !important;
    height: 100% !important;
    align-items: center;
    justify-content: center;
}

.mobile-mode.portrait #game-canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    object-position: center bottom;
}

/* ============================================================================
   HUD IZQUIERDO (LANDSCAPE)
   ============================================================================ */

.mobile-hud-left {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--hud-width-landscape);
    padding: calc(5px + var(--sat)) 5px calc(5px + var(--sab)) calc(5px + var(--sal));
    background: rgba(10, 8, 6, 0.82);
    border-right: 1px solid var(--mobile-copper);
    display: flex;
    flex-direction: column;
    z-index: 500;
    box-sizing: border-box;
    overflow: hidden;
    min-height: 0;
}

/* LANDSCAPE: stats a la derecha y sin invadir la zona de controles */
.mobile-mode.landscape .mobile-hud-left {
    left: auto;
    right: 0;
    top: 0;
    border-right: none;
    border-left: 1px solid var(--mobile-copper);
    bottom: auto;
    height: min(var(--hud-max-height-mobile), calc(100dvh - 140px - var(--sab)));
    padding: 4px calc(4px + var(--sar)) 4px 4px;
}

/* PORTRAIT: mostrar HUD (stats) y recortar abajo para no tapar controles */
.mobile-mode.portrait .mobile-hud-left {
    display: flex !important;
    left: 0;
    right: auto;
    width: 42vw;
    top: auto;
    bottom: calc(var(--controls-height-portrait) + var(--sab) + 10px);
    height: var(--hud-portrait-height);
    padding: 6px 5px 8px calc(5px + var(--sal));
    z-index: 520;
}

#mobile-hud-left {
    font-family: inherit;
}

.mobile-char-info {
    margin-bottom: 6px;
    padding: 6px 6px;
    border-radius: 6px;
    background: rgba(20, 16, 11, 0.92);
    border: 1px solid rgba(85, 68, 51, 0.9);
}

.mobile-char-name {
    font-size: 13px;
    font-weight: 800;
    color: #f0e6d2;
    line-height: 1.1;
}

.mobile-char-meta {
    font-size: 11px;
    color: #b9ae9a;
    line-height: 1.1;
    margin-top: 2px;
}

.mobile-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mobile-stat-row {
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 6px;
    align-items: center;
}

.mobile-stat-label {
    font-size: 10px;
    font-weight: 800;
    color: #d4c8b0;
    text-align: left;
}

.mobile-stat-bar {
    position: relative;
    height: 14px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(85, 68, 51, 0.9);
    overflow: hidden;
}

.mobile-stat-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
}

.mobile-stat-fill.hp {
    background: linear-gradient(90deg, #7a1111, #cc4444);
}

.mobile-stat-fill.mana {
    background: linear-gradient(90deg, #123b7a, #4b8bff);
}

.mobile-stat-fill.sta {
    background: linear-gradient(90deg, #1e6a25, #42c44b);
}

.mobile-stat-fill.ham {
    background: linear-gradient(90deg, #6a4b1e, #c49a42);
}

.mobile-stat-fill.sed {
    background: linear-gradient(90deg, #1e5a6a, #42a9c4);
}

.mobile-stat-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    color: #f0e6d2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
    pointer-events: none;
}

.mobile-exp-bar {
    margin-top: 8px;
}

.mobile-exp-label {
    font-size: 10px;
    font-weight: 800;
    color: #d4c8b0;
    margin-bottom: 4px;
}

.mobile-exp-track {
    position: relative;
    height: 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(85, 68, 51, 0.9);
    overflow: hidden;
}

.mobile-exp-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6a5a1e, #ffd700);
}

/* ============================================================================
   HUD DERECHO (LANDSCAPE) - MÁS GRANDE
   ============================================================================ */

.mobile-hud-right {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: var(--hud-width-landscape);
    padding: calc(5px + var(--sat)) calc(5px + var(--sar)) calc(5px + var(--sab)) 5px;
    background: rgba(10, 8, 6, 0.82);
    border-left: 1px solid var(--mobile-copper);
    display: flex;
    flex-direction: column;
    z-index: 500;
    box-sizing: border-box;
    overflow: hidden;
    min-height: 0;
}

/* LANDSCAPE: inventario/hechizos a la izquierda y sin invadir la zona de controles */
.mobile-mode.landscape .mobile-hud-right {
    right: auto;
    left: 0;
    top: 0;
    border-left: none;
    border-right: 1px solid var(--mobile-copper);
    bottom: auto;
    height: min(var(--hud-max-height-mobile), calc(100dvh - 140px - var(--sab)));
    padding: 4px 4px 4px calc(4px + var(--sal));
}

/* PORTRAIT: mostrar inventario/hechizos y recortar abajo para no tapar controles */
.mobile-mode.portrait .mobile-hud-right {
    display: flex !important;
    right: 0;
    left: auto;
    width: 58vw;
    top: auto;
    bottom: calc(var(--controls-height-portrait) + var(--sab) + 10px);
    height: var(--hud-portrait-height);
    padding: 6px calc(5px + var(--sar)) 8px 5px;
    z-index: 520;
}

.mobile-hud-right .mobile-spells-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 4px;
}

.mobile-hud-right .mobile-spell-btn {
    width: 100%;
    min-height: 34px;
    padding: 6px 8px;
    font-size: 12px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    color: #d4c8b0;
    background: rgba(30, 24, 18, 0.85);
    border: 1px solid var(--mobile-border);
    border-radius: 6px;
}

.mobile-hud-right .mobile-spell-btn.selected {
    border-color: var(--mobile-gold);
    box-shadow: 0 0 0 1px rgba(212, 172, 55, 0.5);
}

.mobile-hud-right .mobile-spell-btn:active {
    transform: translateY(1px);
    filter: brightness(1.08);
}

.mobile-mode.portrait .mobile-hud-right .mobile-inventory {
    flex: 0 0 auto;
    max-height: 88px;
}

.mobile-hud-right .mobile-inventory {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 2px 0;
    min-height: 0;
}

.mobile-hud-right .mobile-spells {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 2px 0;
    flex: 1;
    min-height: 0;
}

.mobile-hud-right .mobile-inventory-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 38px;
    gap: 4px;
    padding: 2px 4px;
}

.mobile-inv-slot {
    min-height: 38px;
    border-radius: 6px;
    background: rgba(26, 21, 16, 0.85);
    border: 1px solid var(--mobile-border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
    -webkit-tap-highlight-color: transparent;
}

.mobile-inv-slot:active {
    transform: translateY(1px);
    filter: brightness(1.08);
}

.mobile-inv-slot-selected {
    border-color: var(--mobile-gold);
    box-shadow: 0 0 0 1px rgba(212, 172, 55, 0.45);
}

.joystick-container {
    position: fixed;
    bottom: calc(20px + var(--sab));
    left: calc(20px + var(--sal));
    z-index: 910;
}

.joystick-base {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, #2a2015 0%, #1a1510 70%, #0d0a08 100%);
    border: 3px solid #8b7355;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8), 0 0 15px rgba(139, 115, 85, 0.3), inset 0 0 40px rgba(139, 115, 85, 0.1);
    position: relative;
}

.joystick-base::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 10px solid #554433;
}

.joystick-knob {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #c5a059, #8b5a2b 60%, #5a3a1a 100%);
    border: 2px solid #ffd700;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5), inset 0 -2px 4px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(255, 215, 0, 0.2);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: box-shadow 0.1s;
}

.joystick-knob.active {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), inset 0 -1px 2px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 215, 0, 0.4);
}

.mobile-mode.landscape .joystick-container {
    position: fixed !important;
    bottom: calc(28px + var(--sab)) !important;
    left: calc(10px + var(--sal)) !important;
    /* Mantener el joystick dentro de la franja izquierda */
    max-width: calc(var(--hud-width-landscape) - 8px);
}

.mobile-mode.landscape .joystick-base {
    width: 108px;
    height: 108px;
}

.mobile-mode.landscape .joystick-knob {
    width: 46px;
    height: 46px;
}

.action-buttons-container {
    display: grid;
    grid-template-areas:
        "left   p     s"
        "med    t     right";
    gap: 8px;
    align-items: center;
    justify-items: center;
}

.mobile-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(20, 16, 11, 0.92);
    border: 2px solid var(--mobile-border);
    color: #d4c8b0;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.55);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mobile-mode.landscape .action-buttons-container {
    position: fixed !important;
    bottom: calc(16px + var(--sab)) !important;
    /* Dentro de la franja derecha mínima (no invadir el POV) */
    right: max(2px, calc(var(--sar) + 2px)) !important;
    max-width: calc(var(--hud-width-landscape) - 6px);
    box-sizing: border-box;
    grid-template-columns: 34px 48px 34px;
    grid-template-rows: 34px 48px;
    gap: 5px;
    justify-content: end;
}

.mobile-mode.portrait .action-buttons-container {
    position: fixed !important;
    bottom: calc(22px + var(--sab)) !important;
    right: calc(6px + var(--sar)) !important;
    grid-template-columns: 46px 62px 46px;
    grid-template-rows: 46px 62px;
    gap: 7px;
}

.mobile-mode.landscape .action-btn-primary {
    width: 46px;
    height: 46px;
    font-size: 18px;
}

.mobile-mode.landscape .action-btn-secondary,
.mobile-mode.landscape .action-btn-tertiary {
    width: 32px;
    height: 32px;
    font-size: 14px;
}

.mobile-mode.landscape .action-btn-left,
.mobile-mode.landscape .action-btn-right,
.mobile-mode.landscape .action-btn-meditate {
    width: 30px;
    height: 30px;
    font-size: 12px;
}

.mobile-mode.portrait .action-btn-left,
.mobile-mode.portrait .action-btn-right,
.mobile-mode.portrait .action-btn-meditate {
    width: 46px;
    height: 46px;
    font-size: 14px;
}

.mobile-mode.portrait .action-btn-primary {
    width: 62px;
    height: 62px;
    font-size: 24px;
}

.mobile-mode.portrait .action-btn-secondary,
.mobile-mode.portrait .action-btn-tertiary {
    width: 46px;
    height: 46px;
    font-size: 16px;
}

.action-btn-primary {
    grid-area: p;
}

.action-btn-secondary {
    grid-area: s;
}

.action-btn-tertiary {
    grid-area: t;
}

.action-btn-left {
    grid-area: left;
}

.action-btn-right {
    grid-area: right;
}

.action-btn-meditate {
    grid-area: med;
}

.mobile-action-btn .btn-icon {
    pointer-events: none;
    text-shadow: 0 1px 2px #000;
}

.mobile-action-btn .btn-icon.sv-icon-fallback-text {
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
    color: #f0e6d2;
}

/* T → A (agarrar): leve acento dorado cuando hay loot bajo el personaje */
.mobile-action-btn.action-btn-tertiary.is-pickup {
    border-color: var(--mobile-gold);
}

/* Toggle consola: siempre flex en mobile-mode (el media desktop lo oculta) */
.mobile-chat-toggle {
    position: fixed;
    top: calc(4px + var(--sat));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    z-index: 700;
    width: 48px;
    height: 24px;
    background: rgba(20, 16, 11, 0.95);
    border: 2px solid var(--mobile-copper);
    border-top: none;
    border-radius: 0 0 8px 8px;
    color: var(--mobile-gold);
    font-size: 10px;
    display: none; /* solo .mobile-mode lo activa */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mobile-mode .mobile-chat-toggle {
    display: flex !important;
}

.mobile-chat-toggle.open,
.mobile-mode.mobile-console-open .mobile-chat-toggle {
    top: calc(var(--mobile-console-expanded) + var(--sat) - 2px);
    bottom: auto;
    border-radius: 0 0 8px 8px;
    border-top: none;
    border-bottom: 2px solid var(--mobile-copper);
}

.mobile-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 4px 4px 6px 4px;
}

.mobile-tab {
    height: 30px;
    border-radius: 8px;
    background: rgba(20, 16, 11, 0.92);
    border: 1px solid var(--mobile-border);
    color: #d4c8b0;
    font-size: 12px;
    font-weight: 800;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mobile-tab:active {
    transform: translateY(1px);
    filter: brightness(1.08);
}

.mobile-tab.active {
    border-color: var(--mobile-gold);
    box-shadow: 0 0 0 1px rgba(212, 172, 55, 0.45);
    color: #f0e6d2;
}

.mobile-gold-row {
    display: flex;
    align-items: stretch;
    gap: 6px;
    margin-top: 6px;
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
}

.mobile-gold-btn {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: calc(100% - 46px);
    height: 40px;
    min-height: 40px;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(197, 160, 89, 0.25), rgba(20, 16, 11, 0.92));
    border: 1px solid var(--mobile-border);
    color: #f0e6d2;
    font-weight: 800;
    font-size: 11px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 6px;
    overflow: hidden;
    white-space: nowrap;
}

.mobile-gold-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-gold-btn:active {
    transform: translateY(1px);
    filter: brightness(1.08);
}

/* Toggle seguro/combate al lado del oro */
.mobile-combat-btn {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 8px;
    background: rgba(20, 16, 11, 0.92);
    border: 2px solid var(--mobile-border);
    color: #d4c8b0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.mobile-combat-btn.active {
    /* Sin recuadro rojo: solo cambia el icono escudo → espada */
    border-color: var(--mobile-border);
    box-shadow: none;
}

.mobile-combat-btn:active {
    transform: translateY(1px);
    filter: brightness(1.08);
}

/* Consola visible (overlay superior; no reserva espacio cuando está cerrada).
   Evitar animar con transform: al pasar de display:none→flex el keyframe
   slideDown puede quedar trabado en translateY(-100%) y la consola invisible. */
.mobile-console-visible {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: calc(var(--mobile-console-expanded) + var(--sat)) !important;
    max-height: calc(50dvh + var(--sat)) !important;
    z-index: 650 !important;
    background: rgba(10, 8, 6, 0.98) !important;
    border-bottom: 2px solid var(--mobile-copper) !important;
    flex-direction: column !important;
    padding: calc(5px + var(--sat)) 10px 5px 10px !important;
    overflow: hidden !important;
    transform: none !important;
    animation: mobileConsoleFade 0.18s ease-out;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

@keyframes mobileConsoleFade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.mobile-console-visible #console-messages,
.mobile-console-visible .console-history {
    flex: 1;
    overflow-y: auto;
    font-size: 12px;
}

.mobile-console-visible .console-input-row {
    display: flex !important;
    gap: 5px;
    padding: 5px 0;
}

.mobile-console-visible #console-input {
    flex: 1;
    min-height: 44px !important;
    font-size: 16px !important;
    padding: 10px 12px !important;
    background: rgba(30, 24, 18, 0.9);
    border: 1px solid var(--mobile-border);
    border-radius: 4px;
    color: #d4c8b0;
    box-sizing: border-box;
}

.mobile-console-visible #console-send {
    min-width: 64px;
    min-height: 44px !important;
    padding: 8px 10px !important;
    font-size: 13px !important;
    touch-action: manipulation;
}

/* ============================================================================
   CONTENEDOR DE CONTROLES
   ============================================================================ */

#mobile-controls-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 900;
    display: none;
}

#mobile-controls-container>* {
    pointer-events: auto;
}

/* Survivor attack slots overlay (sidebar oculto en mobile).
   4 auto-ataques (clase / arma / extra / hechizo).
   Anclada a la derecha: debajo de los stats y arriba de los controles. */
.mobile-survivor-attack-slots {
    position: absolute;
    left: auto;
    right: calc(12px + var(--sar));
    transform: none;
    bottom: calc(var(--sab) + 12px);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 5px 8px;
    background: rgba(13, 10, 8, 0.92);
    border: 2px solid #a67c2d;
    border-radius: 0;
    pointer-events: none !important;
    z-index: 910;
    min-width: 0;
    width: auto;
    justify-content: stretch;
    align-items: center;
    box-shadow: inset 0 1px 0 rgba(232, 200, 90, 0.15);
}

.mobile-survivor-attack-slots[hidden] {
    display: none !important;
}

/* Landscape: encima de los botones de acción (que terminan ~116px + safe area) */
.mobile-mode.landscape .mobile-survivor-attack-slots {
    right: calc(10px + var(--sar));
    bottom: calc(124px + var(--sab));
}

/* Portrait: encima de controles; en run ocupa la franja --attack-bar-portrait */
.mobile-mode.portrait .mobile-survivor-attack-slots {
    right: calc(8px + var(--sar));
    left: auto;
    bottom: calc(var(--controls-height-portrait) + var(--sab) + 6px);
    min-width: 0;
    max-width: calc(58vw - 12px);
    padding: 4px 5px;
    gap: 4px;
}

.mobile-mode.portrait.survivor-run-active .mobile-survivor-attack-slots {
    bottom: calc(var(--controls-height-portrait) + var(--sab) + 4px);
    height: calc(var(--attack-bar-portrait) - 6px);
    max-height: calc(var(--attack-bar-portrait) - 6px);
    box-sizing: border-box;
    align-items: center;
}

.mobile-survivor-attack-slots .surv-atk-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0;
}

.mobile-survivor-attack-slots .surv-atk-label {
    display: none !important;
}

.mobile-mode.portrait .mobile-survivor-attack-slots .surv-atk-icon-wrap {
    width: 30px;
    height: 30px;
}

.mobile-survivor-attack-slots .surv-atk-icon-wrap {
    position: relative;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border: 1px solid #a67c2d;
    border-radius: 0;
    overflow: hidden;
}

.mobile-survivor-attack-slots .surv-atk-slot[data-slot="weapon"] .surv-atk-icon-wrap,
.mobile-survivor-attack-slots .surv-atk-slot[data-slot="class"] .surv-atk-icon-wrap,
.mobile-survivor-attack-slots .surv-atk-slot[data-slot="spell"] .surv-atk-icon-wrap {
    background: #000;
}

.mobile-survivor-attack-slots .surv-atk-slot[data-slot="weapon"] .surv-atk-fallback,
.mobile-survivor-attack-slots .surv-atk-slot[data-slot="weapon"] .surv-atk-icon {
    display: none !important;
}

.mobile-survivor-attack-slots .surv-atk-slot[data-slot="class"] .surv-atk-icon:not([hidden]),
.mobile-survivor-attack-slots .surv-atk-slot[data-slot="spell"] .surv-atk-icon:not([hidden]) {
    z-index: 0;
}

.mobile-survivor-attack-slots .surv-atk-slot[data-slot="class"] .surv-atk-sprite:not([hidden]),
.mobile-survivor-attack-slots .surv-atk-slot[data-slot="spell"] .surv-atk-sprite:not([hidden]),
.mobile-survivor-attack-slots .surv-atk-slot[data-slot="weapon"] .surv-atk-sprite:not([hidden]) {
    display: flex;
}

.mobile-survivor-attack-slots .surv-atk-icon {
    font-size: 16px;
    line-height: 1;
    z-index: 1;
}

.mobile-survivor-attack-slots .surv-atk-sprite {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    pointer-events: none;
}

.mobile-survivor-attack-slots .surv-atk-sprite[hidden] {
    display: none !important;
}

.mobile-survivor-attack-slots .surv-atk-sprite canvas {
    width: 30px;
    height: 30px;
    image-rendering: pixelated;
}

.mobile-survivor-attack-slots .surv-atk-cd {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    clip-path: inset(calc(var(--cd-fill, 0) * 100%) 0 0 0);
    border-radius: 6px;
    pointer-events: none;
}

.mobile-survivor-attack-slots .surv-atk-slot.is-fail-flash .surv-atk-icon-wrap {
    border-color: #ff8844;
    box-shadow: 0 0 8px rgba(255, 120, 60, 0.55);
}

.mobile-survivor-attack-slots .surv-atk-slot.is-ready .surv-atk-icon-wrap {
    border-color: var(--mobile-gold-bright, #ffd700);
}

/* Asegurar que se muestre cuando está activo */
.mobile-mode #mobile-controls-container {
    display: block !important;
}

/* ============================================================================
   OCULTAR EN DESKTOP
   ============================================================================ */

@media (min-width: 1024px) and (pointer: fine) {

#mobile-controls-container,
.mobile-hud-left,
.mobile-hud-right,
.mobile-chat-toggle,
.mobile-scroll-hint {
display: none !important;
}
}

/* ============================================================================
   MODALES - BASE (MÓVIL)
   ============================================================================ */

.mobile-mode .modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    padding: 0 !important;
    margin: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    z-index: 2000;
}

.mobile-mode .modal-window {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
}

.mobile-mode .modal-header {
    flex: 0 0 auto;
    padding-top: calc(10px + var(--sat)) !important;
}

.mobile-mode .modal-content {
    flex: 1 1 auto;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(14px + var(--sab)) !important;
}

.mobile-mode .modal-footer {
    flex: 0 0 auto;
    padding-bottom: calc(10px + var(--sab)) !important;
}

/* ============================================================================
   MODAL DE COMERCIO (MÓVIL)
   ============================================================================ */

.mobile-mode #trade-window-overlay .modal-window,
.mobile-mode #trade-window-overlay .trade-window {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

.mobile-mode #trade-window-overlay {
    align-items: stretch;
    justify-content: stretch;
    padding: 0 !important;
}

.mobile-mode #trade-window-overlay .trade-titlebar {
    min-height: 48px;
    flex-shrink: 0;
}

.mobile-mode #trade-window-overlay .trade-container {
    padding: 8px 10px 0 !important;
    gap: 8px !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: grid !important;
    box-sizing: border-box;
}

.mobile-mode.portrait #trade-window-overlay .trade-container {
    grid-template-columns: 1fr;
}

.mobile-mode.landscape #trade-window-overlay .trade-container {
    grid-template-columns: 1fr 1fr;
}

.mobile-mode #trade-window-overlay .trade-panel {
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-mode #trade-window-overlay .trade-items-list {
    max-height: none !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 2px !important;
    gap: 3px !important;
    grid-auto-rows: 48px;
}

.mobile-mode #trade-window-overlay .trade-item-info {
    margin: 8px 10px 0 !important;
    height: 72px !important;
    min-height: 72px !important;
    max-height: 72px !important;
    flex-shrink: 0;
    overflow: hidden;
}

.mobile-mode #trade-window-overlay .trade-footer {
    height: auto !important;
    min-height: 56px !important;
    max-height: none !important;
    padding: 8px 10px calc(8px + var(--sab)) !important;
    flex: 0 0 auto;
    flex-wrap: wrap;
}

.mobile-mode.portrait #trade-window-overlay .trade-items-list {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
}

.mobile-mode.landscape #trade-window-overlay .trade-items-list {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

.mobile-mode #trade-window-overlay .trade-item-slot {
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    aspect-ratio: unset;
    min-width: 0;
    overflow: hidden;
}

.mobile-mode #trade-window-overlay .trade-item-icon {
    width: 28px !important;
    height: 28px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.mobile-mode #trade-window-overlay .trade-item-icon canvas {
    max-width: 100% !important;
    max-height: 100% !important;
}

.mobile-mode #trade-window-overlay .trade-item-amount {
    z-index: 5;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 2px;
    padding: 1px 3px;
    font-size: 8px;
    line-height: 1;
    pointer-events: none;
}

.mobile-mode.portrait #trade-window-overlay {
    align-items: stretch;
    padding-top: 0;
    padding-bottom: 0;
}

.mobile-mode.portrait #trade-window-overlay .modal-window {
    margin-top: 0 !important;
    max-height: 100% !important;
}

/* ============================================================================
   VIEWPORT RESPONSIVE P0 — conserva el 4:3 nativo sin deformar el canvas
   ============================================================================ */

:root {
    /* Laterales con mínimo usable para HUD/controles (evita hud-width ≈ 0) */
    --hud-width-landscape-min: 132px;
    --game-width-landscape: min(
        calc(100vw - (var(--hud-width-landscape-min) * 2)),
        calc(100dvh * 1.333333)
    );
    --hud-width-landscape: max(
        var(--hud-width-landscape-min),
        calc((100vw - var(--game-width-landscape)) * 0.5)
    );
    /* Franja de controles: joystick/botones un poco más arriba */
    --controls-height-portrait: clamp(136px, 19dvh, 156px);
    /* Stats + inv/hechizos al mismo alto (más tallo para no cortar barras/grilla) */
    --hud-portrait-height: clamp(162px, 23dvh, 192px);
    /* Consola overlay más baja (antes 32dvh/220px comía demasiado POV) */
    --mobile-console-expanded: min(24dvh, 168px);
    /* Franja para la barra clase/arma/extra/hechizo durante una run (portrait) */
    --attack-bar-portrait: 54px;
    /* Alto reservado para el run HUD debajo del cuadrado del juego (portrait) */
    --run-hud-portrait-height: 44px;
    /* Alto reservado para el run HUD en la columna derecha (landscape) */
    --run-hud-landscape-height: 92px;
}

.mobile-mode.landscape .game-column-left {
    left: var(--hud-width-landscape) !important;
    right: var(--hud-width-landscape) !important;
}

.mobile-mode.landscape .game-viewport {
    width: 100% !important;
    height: 100dvh !important;
    align-items: center !important;
    justify-content: center !important;
}

.mobile-mode.landscape #game-canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center !important;
}

/* Portrait: POV a pantalla completa hasta el HUD (consola no reserva alto). */
.mobile-mode.portrait .game-column-left {
    top: 0 !important;
    bottom: calc(var(--controls-height-portrait) + var(--hud-portrait-height) + var(--sab) + 10px) !important;
    display: flex !important;
    align-items: stretch !important;
    justify-content: center !important;
    background: #000;
}

.mobile-mode.portrait .game-viewport {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    aspect-ratio: unset;
    margin: 0 !important;
    align-items: center !important;
    justify-content: center !important;
}

.mobile-mode.portrait #game-canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center !important;
}

/* Consola cerrada: POV sin franja superior reservada (portrait y landscape). */
.mobile-mode:not(.mobile-console-open) .game-column-left {
    top: 0 !important;
}

/* Al abrir consola: empuja el POV para que no quede tapado */
.mobile-mode.mobile-console-open .game-column-left {
    top: calc(var(--mobile-console-expanded) + var(--sat)) !important;
}

/* HUD más arriba y más alto: stats e inv/hechizos alineados, sin corte */
.mobile-mode.portrait .mobile-hud-left,
.mobile-mode.portrait .mobile-hud-right {
    height: var(--hud-portrait-height);
    bottom: calc(var(--controls-height-portrait) + var(--sab) + 10px);
    background: rgba(10, 8, 6, 0.88);
}

/* Portrait: joystick un poco más arriba y hacia el centro (derecha) */
.mobile-mode.portrait .joystick-base {
    width: 108px;
    height: 108px;
}

.mobile-mode.portrait .joystick-knob {
    width: 46px;
    height: 46px;
}

.mobile-mode.portrait .joystick-container {
    bottom: calc(32px + var(--sab)) !important;
    left: calc(28px + var(--sal)) !important;
}

.mobile-mode.portrait .action-buttons-container {
    bottom: calc(22px + var(--sab)) !important;
    right: calc(6px + var(--sar)) !important;
    gap: 7px;
}

.mobile-mode.portrait .mobile-char-info {
    margin-bottom: 3px;
    padding: 4px;
}

.mobile-mode.portrait .mobile-char-meta {
    font-size: 8px;
}

.mobile-mode.portrait .mobile-stat-row {
    min-height: 15px;
    margin-bottom: 1px;
}

.mobile-mode.portrait.survivor-run-active .mobile-stat-row:nth-child(4),
.mobile-mode.portrait.survivor-run-active .mobile-stat-row:nth-child(5) {
    display: none;
}

.mobile-mode.portrait .mobile-hud-right .mobile-inventory {
    max-height: none;
}

.mobile-mode.portrait .mobile-inventory-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-auto-rows: 32px;
    gap: 3px;
}

.mobile-mode.portrait .mobile-inv-slot {
    min-height: 32px;
}

.mobile-mode.portrait .mobile-hud-right {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-mode.portrait .mobile-hud-right .mobile-inventory,
.mobile-mode.portrait .mobile-hud-right .mobile-spells {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

.mobile-mode.portrait .mobile-tabs {
    padding: 2px 3px 3px;
}

.mobile-mode.portrait .mobile-tab {
    height: 32px;
    min-height: 32px;
    font-size: 11px;
    padding: 0 8px;
}

.mobile-mode.portrait .mobile-gold-row {
    flex: 0 0 auto;
}

.mobile-mode.portrait .mobile-gold-btn {
    flex: 1 1 auto;
    height: 40px;
    min-height: 40px;
    font-size: 11px;
}

.mobile-mode.portrait .mobile-combat-btn {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
}

/* ============================================================================
   RUN ACTIVA (body.survivor-run-active): run HUD + barra de ataques
   ============================================================================ */

/* El run HUD desktop vive en el sidebar (ao-ui.css). No ocultarlo. */

/* PORTRAIT: run HUD debajo del cuadrado del POV.
   Sin transform: si no, position:fixed del boss queda anclado al padre. */
.mobile-mode.portrait .survivor-run-hud {
    top: calc(100% + 8px);
    bottom: auto;
    left: 0;
    right: 0;
    transform: none;
    width: min(100%, 560px);
    margin-left: auto;
    margin-right: auto;
}

/* PORTRAIT con run activa: HUD arriba de la franja de ataques; POV reserva run HUD */
.mobile-mode.portrait.survivor-run-active .mobile-hud-left,
.mobile-mode.portrait.survivor-run-active .mobile-hud-right {
    bottom: calc(var(--controls-height-portrait) + var(--attack-bar-portrait) + var(--sab) + 10px);
}

.mobile-mode.portrait.survivor-run-active .game-column-left {
    bottom: calc(var(--controls-height-portrait) + var(--hud-portrait-height) + var(--attack-bar-portrait) + var(--run-hud-portrait-height) + var(--sab) + 10px) !important;
}

.mobile-mode.portrait.survivor-run-active .game-viewport {
    width: 100% !important;
    height: 100% !important;
}

/* LANDSCAPE: run HUD arriba a la derecha, en la columna de stats */
.mobile-mode.landscape .survivor-run-hud {
    position: fixed;
    top: calc(var(--sat) + 4px);
    right: calc(4px + var(--sar));
    left: auto;
    transform: none;
    width: max(calc(var(--hud-width-landscape) - 8px), 150px);
    z-index: 530;
}

.mobile-mode.landscape .run-hud-core {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mobile-mode.landscape .run-hud-metric {
    padding: 4px 6px 3px;
    border-bottom: 1px solid rgba(118, 88, 54, 0.42);
}

.mobile-mode.landscape .run-hud-metric:nth-child(n + 3) {
    border-bottom: 0;
}

/* Boss: abajo al centro del POV, compacto */
.mobile-mode .game-viewport > .run-hud-boss {
    position: absolute !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: 8px !important;
    transform: translateX(-50%) !important;
    width: min(220px, calc(100% - 20px)) !important;
    max-width: calc(100% - 20px);
    margin: 0 !important;
    z-index: 42;
    pointer-events: none;
    box-sizing: border-box;
    padding: 3px 7px 4px;
}

.mobile-mode.landscape .game-viewport > .run-hud-boss,
.mobile-mode.portrait .game-viewport > .run-hud-boss,
.mobile-mode.portrait.survivor-run-active .game-viewport > .run-hud-boss {
    bottom: 8px !important;
    width: min(220px, calc(100% - 20px)) !important;
    max-width: calc(100% - 20px);
}

.mobile-mode .run-hud-boss-copy {
    font-size: 9px;
    margin-bottom: 3px;
    gap: 8px;
}

.mobile-mode .run-hud-boss-track {
    height: 6px;
}

/* LANDSCAPE con run activa: los stats bajan para dejar lugar al run HUD y
   terminan antes de la barra de ataques + botones de acción */
.mobile-mode.landscape.survivor-run-active .mobile-hud-left {
    top: calc(var(--sat) + var(--run-hud-landscape-height));
    height: auto;
    bottom: calc(182px + var(--sab));
}

/* Durante la run, hambre y sed no aplican: liberar espacio vertical */
.mobile-mode.landscape.survivor-run-active .mobile-stat-row:nth-child(4),
.mobile-mode.landscape.survivor-run-active .mobile-stat-row:nth-child(5) {
    display: none;
}

@media (max-height: 680px) and (orientation: portrait) {
    :root {
        --controls-height-portrait: 132px;
        --hud-portrait-height: 140px;
        --mobile-console-expanded: min(22dvh, 148px);
    }

    .mobile-mode.portrait .mobile-char-meta,
    .mobile-mode.portrait .mobile-exp-label {
        display: none;
    }

    .mobile-mode.portrait .mobile-exp-bar {
        margin-top: 2px;
    }

    .mobile-mode.portrait .joystick-container {
        bottom: calc(26px + var(--sab)) !important;
        left: calc(24px + var(--sal)) !important;
    }

    .mobile-mode.portrait .joystick-base {
        width: 100px;
        height: 100px;
    }

    .mobile-mode.portrait .joystick-knob {
        width: 42px;
        height: 42px;
    }

    .mobile-mode.portrait .action-buttons-container {
        bottom: calc(18px + var(--sab)) !important;
        right: calc(4px + var(--sar)) !important;
        grid-template-columns: 44px 58px 44px;
        grid-template-rows: 44px 58px;
    }

    .mobile-mode.portrait .action-btn-primary {
        width: 58px;
        height: 58px;
        font-size: 22px;
    }

    .mobile-mode.portrait .action-btn-secondary,
    .mobile-mode.portrait .action-btn-tertiary {
        width: 44px;
        height: 44px;
        font-size: 15px;
    }

    .mobile-mode.portrait .action-btn-left,
    .mobile-mode.portrait .action-btn-right,
    .mobile-mode.portrait .action-btn-meditate {
        width: 44px;
        height: 44px;
        font-size: 13px;
    }
}

@media (max-height: 420px) and (orientation: landscape) {
    .mobile-mode.landscape .mobile-char-meta,
    .mobile-mode.landscape .mobile-exp-label {
        display: none;
    }

    .mobile-mode.landscape .mobile-hud-left,
    .mobile-mode.landscape .mobile-hud-right {
        height: min(52dvh, 200px);
    }

    .mobile-mode.landscape .joystick-base {
        width: 92px;
        height: 92px;
    }

    .mobile-mode.landscape .joystick-knob {
        width: 38px;
        height: 38px;
    }

    .mobile-mode.landscape .action-buttons-container {
        grid-template-columns: 40px 46px 40px;
        grid-template-rows: 40px 46px;
        gap: 5px;
    }

    .mobile-mode.landscape .action-btn-primary {
        width: 46px;
        height: 46px;
        font-size: 18px;
    }

    .mobile-mode.landscape .action-btn-secondary,
    .mobile-mode.landscape .action-btn-tertiary {
        width: 40px;
        height: 40px;
        font-size: 13px;
    }

    .mobile-mode.landscape .action-btn-left,
    .mobile-mode.landscape .action-btn-right,
    .mobile-mode.landscape .action-btn-meditate {
        width: 40px;
        height: 40px;
        font-size: 12px;
    }
}

/* ============================================================================
   MODAL DE OPCIONES (MÓVIL) — z-index; layout en sección OPCIONES/GUÍA/ÁRBOL
   ============================================================================ */

.mobile-mode #options-modal {
    z-index: 2147483647 !important;
}

/* ============================================================================
   MODAL DE MISIONES (MÓVIL)
   ============================================================================ */

.mobile-mode #quests-modal .modal-content {
    padding: 0 !important;
}

.mobile-mode #quests-modal .quests-layout {
    min-height: 0 !important;
}

.mobile-mode #quests-modal .quests-list {
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-mode #quests-modal .quests-detail {
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================================
   BANCO / CRAFTING / MAPA / DROP-GOLD / NEWS (MÓVIL)
   Override de especificidad ID en main.css (min-width fijos, tamaños desktop).
   ============================================================================ */

.mobile-mode #bank-window-overlay .modal-window {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.mobile-mode #bank-window-overlay .modal-header {
    flex: 0 0 auto;
    padding-top: calc(10px + var(--sat)) !important;
}

.mobile-mode #bank-window-overlay .bank-gold-section {
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 10px;
    margin: 8px 10px !important;
    padding: 10px !important;
}

.mobile-mode #bank-window-overlay .bank-gold-info {
    flex-wrap: wrap;
    gap: 12px;
}

.mobile-mode #bank-window-overlay .bank-gold-actions {
    flex-wrap: wrap;
    gap: 6px;
}

.mobile-mode #bank-window-overlay .bank-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    gap: 8px !important;
    padding: 8px 10px !important;
}

.mobile-mode.portrait #bank-window-overlay .bank-container {
    flex-direction: column;
}

.mobile-mode.landscape #bank-window-overlay .bank-container {
    flex-direction: row;
}

.mobile-mode #bank-window-overlay .bank-panel {
    flex: 1 1 0;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 8px !important;
}

.mobile-mode #bank-window-overlay .bank-items-grid {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)) !important;
}

.mobile-mode #bank-window-overlay .bank-footer {
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 8px !important;
    padding: 10px calc(10px + var(--sar)) calc(10px + var(--sab)) calc(10px + var(--sal)) !important;
}

.mobile-mode #crafting-window-overlay .modal-window {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

.mobile-mode #crafting-window-overlay .modal-header {
    flex: 0 0 auto;
    padding-top: calc(10px + var(--sat)) !important;
}

.mobile-mode #crafting-window-overlay .modal-content,
.mobile-mode #crafting-window-overlay .item-list,
.mobile-mode #crafting-window-overlay .crafting-recipe-list,
.mobile-mode #crafting-window-overlay #crafting-recipe-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

.mobile-mode #crafting-window-overlay .modal-footer {
    flex: 0 0 auto;
    padding-bottom: calc(10px + var(--sab)) !important;
}

.mobile-mode #world-map-modal {
    padding: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
}

.mobile-mode #world-map-modal .world-map-window,
.mobile-mode #world-map-modal .modal-window.world-map-window {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.mobile-mode #world-map-modal .world-map-titlebar {
    flex: 0 0 auto;
    padding-top: calc(8px + var(--sat)) !important;
}

.mobile-mode #world-map-modal .world-map-chrome {
    flex: 0 0 auto;
    flex-wrap: wrap;
    max-height: none !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-mode #world-map-modal .world-map-stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-mode #world-map-modal .world-map-canvas-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-mode #world-map-modal .world-map-canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
}

.mobile-mode #world-map-modal .world-map-hint {
    flex: 0 0 auto;
    white-space: normal !important;
    padding-bottom: calc(8px + var(--sab)) !important;
}

/* Cierres táctiles ≥40px en modales AO (banco/quests/party/etc. usaban ~24px) */
.mobile-mode .modal-overlay .modal-close,
.mobile-mode .modal-window .modal-close,
.mobile-mode #world-map-modal .modal-close,
.mobile-mode #world-map-modal .world-map-close,
.mobile-mode #bank-window-overlay .modal-close,
.mobile-mode #quests-modal .modal-close,
.mobile-mode #drop-gold-modal .modal-close,
.mobile-mode #drop-item-modal .modal-close,
.mobile-mode #news-modal .modal-close,
.mobile-mode #party-modal .modal-close,
.mobile-mode #clan-modal .modal-close,
.mobile-mode #friends-modal .modal-close,
.mobile-mode #stats-modal .modal-close,
.mobile-mode #crafting-window-overlay .modal-close,
.mobile-mode #crafting-window-overlay #crafting-close,
.mobile-mode #trade-window-overlay .modal-close,
.mobile-mode #trade-window-overlay .trade-close,
.mobile-mode #trade-window-overlay #trade-close,
.mobile-mode #tame-modal .modal-close {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 22px !important;
    line-height: 1 !important;
    padding: 0 !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mobile-mode #drop-gold-modal input,
.mobile-mode #drop-item-modal input,
.mobile-mode #drop-gold-modal input[type="number"],
.mobile-mode #drop-item-modal input[type="number"] {
    min-height: 44px !important;
    font-size: 16px !important;
    padding: 10px 12px !important;
    box-sizing: border-box !important;
}

.mobile-mode #drop-gold-modal .modal-window,
.mobile-mode #drop-item-modal .modal-window,
.mobile-mode #news-modal .modal-window,
.mobile-mode #tame-modal .modal-window {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

.mobile-mode #drop-gold-modal .modal-content,
.mobile-mode #drop-item-modal .modal-content,
.mobile-mode #news-modal .modal-content,
.mobile-mode #tame-modal .modal-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-left: calc(12px + var(--sal)) !important;
    padding-right: calc(12px + var(--sar)) !important;
    padding-bottom: calc(14px + var(--sab)) !important;
}

.mobile-mode #news-modal .news-list {
    max-height: none !important;
    overflow: visible;
}

/* RPG dialog / inactividad / duelo — safe-area + no overflow */
.mobile-mode #rpg-dialog-overlay:not(.hidden),
.mobile-mode #inactivity-modal:not(.hidden),
.mobile-mode #survivor-duel-offer-modal:not(.hidden) {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    z-index: 12000 !important;
    display: flex !important;
    padding: max(8px, var(--sat)) max(10px, var(--sar)) max(8px, var(--sab)) max(10px, var(--sal)) !important;
    box-sizing: border-box;
    align-items: center !important;
    justify-content: center !important;
}

.mobile-mode #rpg-dialog-overlay .rpg-dialog,
.mobile-mode #inactivity-modal .inactivity-modal-content,
.mobile-mode #survivor-duel-offer-modal .sv-duel-card {
    width: min(100%, 420px) !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 24px - var(--sat) - var(--sab)) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.mobile-mode.portrait #trade-window-overlay {
    align-items: stretch;
    padding-top: 0;
    padding-bottom: 0;
}

.mobile-mode.portrait #trade-window-overlay .modal-window {
    margin-top: 0 !important;
    max-height: 100% !important;
}

/* ============================================================================
   OPCIONES / GUÍA / ÁRBOL DE HABILIDADES (MÓVIL)
   Portrait + landscape: fullscreen, safe-area, scroll táctil
   ============================================================================ */

/* --- Opciones --- */
.mobile-mode #options-modal {
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
    inset: 0 !important;
    width: 100% !important;
    width: 100dvw !important;
    height: 100% !important;
    height: 100dvh !important;
    box-sizing: border-box !important;
}

.mobile-mode #options-modal .modal-window,
.mobile-mode #options-modal .modal-options-expanded {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

.mobile-mode #options-modal .modal-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: calc(10px + var(--sat)) calc(12px + var(--sar)) 10px calc(12px + var(--sal)) !important;
}

.mobile-mode #options-modal .modal-close {
    flex: 0 0 auto;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    font-size: 18px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mobile-mode #options-modal .modal-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 8px calc(12px + var(--sar)) calc(16px + var(--sab)) calc(12px + var(--sal)) !important;
}

.mobile-mode #options-modal .options-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 6px;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    position: sticky;
    top: 0;
    z-index: 3;
    margin: 0 0 12px;
    padding: 0 0 10px;
    background: linear-gradient(180deg, #14100b 70%, rgba(20, 16, 11, 0.92) 100%);
}

.mobile-mode #options-modal .options-tabs::-webkit-scrollbar {
    display: none;
}

.mobile-mode #options-modal .options-tab {
    flex: 0 0 auto !important;
    min-width: 96px;
    min-height: 40px;
    font-size: 13px;
    padding: 10px 14px;
    white-space: nowrap;
    touch-action: manipulation;
}

.mobile-mode #options-modal input[type="range"] {
    width: 100%;
    max-width: 100%;
}

.mobile-mode.landscape #options-modal .options-tab {
    min-width: 110px;
}

/* --- Guía Survivor --- */
body.mobile-mode #survivor-guide-modal.survivor-guide-overlay {
    padding: 0 !important;
    margin: 0 !important;
    inset: 0 !important;
    width: 100% !important;
    width: 100dvw !important;
    height: 100% !important;
    height: 100dvh !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    box-sizing: border-box !important;
}

body.mobile-mode #survivor-guide-modal .survivor-guide-container {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

body.mobile-mode #survivor-guide-modal .survivor-guide-container::before,
body.mobile-mode #survivor-guide-modal .survivor-guide-container::after {
    display: none !important;
}

body.mobile-mode #survivor-guide-modal .guide-header {
    flex: 0 0 auto;
    flex-shrink: 0;
    gap: 8px;
    padding: calc(10px + var(--sat)) calc(12px + var(--sar)) 10px calc(12px + var(--sal)) !important;
}

body.mobile-mode #survivor-guide-modal .guide-header h2 {
    font-size: 1.05rem !important;
    letter-spacing: 0.08em !important;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.mobile-mode #survivor-guide-modal .guide-close-btn {
    flex: 0 0 auto;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    font-size: 1.25rem !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body.mobile-mode #survivor-guide-modal .guide-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

body.mobile-mode #survivor-guide-modal .guide-nav {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 auto !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    border-right: none !important;
    border-bottom: 1px solid rgba(100, 75, 45, 0.5) !important;
    padding: 8px calc(8px + var(--sar)) 8px calc(8px + var(--sal)) !important;
    gap: 6px;
}

body.mobile-mode #survivor-guide-modal .guide-nav::-webkit-scrollbar {
    display: none;
}

body.mobile-mode #survivor-guide-modal .guide-nav-btn {
    flex: 0 0 auto !important;
    min-width: 44px !important;
    min-height: 44px !important;
    justify-content: center !important;
    padding: 10px 12px !important;
    touch-action: manipulation;
}

body.mobile-mode #survivor-guide-modal .nav-text {
    display: none !important;
}

body.mobile-mode #survivor-guide-modal .guide-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain;
    padding: 12px calc(12px + var(--sar)) calc(16px + var(--sab)) calc(12px + var(--sal)) !important;
    font-size: 14px;
    line-height: 1.45;
}

body.mobile-mode.landscape #survivor-guide-modal .guide-header h2 {
    font-size: 1.15rem !important;
}

body.mobile-mode.landscape #survivor-guide-modal .nav-text {
    display: inline !important;
    white-space: nowrap;
}

body.mobile-mode.landscape #survivor-guide-modal .guide-nav-btn {
    min-width: auto !important;
    padding: 10px 14px !important;
}

/* --- Skills modal clásico (pausa Survivor → Árbol de habilidades) --- */
body.mobile-mode #skills-modal.skills-modal-overlay.skills-modal-visible {
    inset: 0 !important;
    width: 100% !important;
    width: 100dvw !important;
    height: 100% !important;
    height: 100dvh !important;
    padding: 0 !important;
    margin: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    box-sizing: border-box !important;
    z-index: 12000 !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
}

body.mobile-mode #skills-modal .skills-modal-container {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

body.mobile-mode #skills-modal .skills-modal-header {
    flex: 0 0 auto;
    padding: calc(10px + var(--sat)) calc(12px + var(--sar)) 10px calc(12px + var(--sal)) !important;
}

body.mobile-mode #skills-modal .skills-modal-close {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    font-size: 22px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

body.mobile-mode #skills-modal .skills-modal-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 10px max(12px, var(--sar)) 12px max(12px, var(--sal)) !important;
}

body.mobile-mode #skills-modal .skills-modal-footer {
    flex: 0 0 auto;
    padding: 10px max(12px, var(--sar)) calc(12px + var(--sab)) max(12px, var(--sal)) !important;
}

/* --- Árbol de habilidades Survivor (.sst-overlay) --- */
body.mobile-mode .sst-overlay {
    padding: 0 !important;
    margin: 0 !important;
    inset: 0 !important;
    width: 100% !important;
    width: 100dvw !important;
    height: 100% !important;
    height: 100dvh !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    box-sizing: border-box !important;
    z-index: 12000 !important;
}

body.mobile-mode .sst-frame {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

body.mobile-mode .sst-header {
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 8px;
    padding: calc(10px + var(--sat)) calc(12px + var(--sar)) 10px calc(12px + var(--sal)) !important;
}

body.mobile-mode .sst-title {
    font-size: 16px !important;
}

body.mobile-mode .sst-subtitle {
    display: none;
}

body.mobile-mode .sst-brand-mark {
    width: 34px;
    height: 34px;
}

body.mobile-mode .sst-meta {
    width: 100%;
    justify-content: flex-start;
    align-items: center;
    gap: 6px;
}

body.mobile-mode .sst-chip {
    padding: 5px 8px;
    font-size: 11px;
}

body.mobile-mode .sst-close,
body.mobile-mode .sst-reset {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body.mobile-mode .sst-reset {
    width: auto !important;
    padding: 0 12px !important;
}

body.mobile-mode .sst-body {
    flex: 1 1 auto;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(0, 1fr) minmax(150px, 38%) !important;
}

body.mobile-mode.portrait .sst-body {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(0, 1fr) minmax(150px, 38%) !important;
}

body.mobile-mode .sst-canvas-wrap {
    min-height: 0 !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
}

body.mobile-mode .sst-detail {
    border-left: none !important;
    border-top: 1px solid #3a3028 !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain;
    padding: 10px calc(12px + var(--sar)) calc(12px + var(--sab)) calc(12px + var(--sal)) !important;
}

body.mobile-mode .sst-detail-icon {
    width: 64px;
    height: 64px;
}

body.mobile-mode .sst-detail-name {
    font-size: 18px;
}

body.mobile-mode .sst-action {
    min-height: 44px;
    touch-action: manipulation;
}

body.mobile-mode .sst-node {
    width: 44px;
    height: 44px;
}

body.mobile-mode .sst-branch-legend {
    max-width: calc(100% - 16px);
    left: 8px;
    bottom: 8px;
    font-size: 10px;
}

/* Landscape: split árbol | detalle */
body.mobile-mode.landscape .sst-header {
    flex-wrap: nowrap;
}

body.mobile-mode.landscape .sst-meta {
    width: auto;
    margin-left: auto;
    justify-content: flex-end;
}

body.mobile-mode.landscape .sst-body {
    grid-template-columns: minmax(0, 1fr) minmax(200px, 34%) !important;
    grid-template-rows: minmax(0, 1fr) !important;
}

body.mobile-mode.landscape .sst-detail {
    border-top: none !important;
    border-left: 1px solid #3a3028 !important;
    padding-bottom: calc(12px + var(--sab)) !important;
}

body.mobile-mode.landscape .sst-detail-icon {
    width: 56px;
    height: 56px;
}

/* ============================================================================
   PAUSA Y GAME OVER (MÓVIL)
   ============================================================================ */

body.mobile-mode .survivor-pause-overlay,
body.mobile-mode .survivor-gameover-overlay {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    z-index: 12000 !important;
}

body.mobile-mode .survivor-pause-content,
body.mobile-mode .survivor-gameover-content {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

body.mobile-mode .survivor-pause-content::before,
body.mobile-mode .survivor-pause-content::after {
    display: none !important;
}

body.mobile-mode .survivor-pause-header {
    flex: 0 0 auto;
    margin: 0 !important;
    padding: calc(14px + var(--sat)) calc(16px + var(--sar)) 10px calc(16px + var(--sal)) !important;
}

body.mobile-mode .survivor-pause-content h2,
body.mobile-mode #survivor-pause-title {
    font-size: clamp(22px, 6vw, 30px) !important;
}

body.mobile-mode .survivor-pause-info[hidden] {
    display: none !important;
}

body.mobile-mode .survivor-pause-info:not([hidden]) {
    flex: 0 0 auto;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0 !important;
    margin: 0 calc(12px + var(--sar)) 12px calc(12px + var(--sal)) !important;
}

body.mobile-mode .pause-stat {
    padding: 10px 6px 12px !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 4px !important;
}

body.mobile-mode .pause-label,
body.mobile-mode .pause-value {
    min-width: 0 !important;
    text-align: center !important;
}

body.mobile-mode .pause-value {
    font-size: 18px !important;
}

body.mobile-mode .survivor-pause-actions {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 calc(14px + var(--sar)) 8px calc(14px + var(--sal)) !important;
}

body.mobile-mode .survivor-pause-actions .pause-btn {
    width: 100% !important;
    min-height: 44px !important;
    padding: 12px 14px !important;
    font-size: 13px !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body.mobile-mode .survivor-pause-actions .pause-btn-danger {
    margin-top: 4px !important;
}

body.mobile-mode .pause-hint {
    display: none !important;
}

body.mobile-mode .survivor-gameover-overlay.go-epitaph {
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
}

body.mobile-mode .survivor-gameover-content.go-sheet {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: calc(28px + var(--sat)) calc(22px + var(--sar)) calc(20px + var(--sab)) calc(22px + var(--sal)) !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-sizing: border-box !important;
}

body.mobile-mode .survivor-gameover-content.go-sheet::-webkit-scrollbar,
body.mobile-mode .go-epitaph .go-details-body::-webkit-scrollbar,
body.mobile-mode .go-epitaph .gameover-breakdown-body::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
}

body.mobile-mode .go-epitaph #survivor-gameover-title {
    font-size: clamp(26px, 8vw, 36px) !important;
}

body.mobile-mode .go-essence-value,
body.mobile-mode .go-epitaph #gameover-essence {
    font-size: clamp(40px, 12vw, 52px) !important;
}

body.mobile-mode .go-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 0 !important;
}

body.mobile-mode .go-details-toggle {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.mobile-mode .go-actions {
    margin-top: 18px !important;
    gap: 10px !important;
}

body.mobile-mode .go-btn {
    width: 100% !important;
    min-height: 48px !important;
    font-size: 13px !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body.mobile-mode.landscape .go-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

body.mobile-mode.landscape .go-actions {
    flex-direction: row !important;
}

body.mobile-mode.landscape .go-btn-ghost {
    width: auto !important;
    flex: 1 1 160px;
}

body.mobile-mode.landscape .go-btn-primary {
    flex: 1 1 200px;
}

/* Landscape: pausa 2 cols; gameover stats 3 cols */
body.mobile-mode.landscape .survivor-pause-header {
    padding-top: calc(10px + var(--sat)) !important;
    padding-bottom: 6px !important;
}

body.mobile-mode.landscape .survivor-pause-info {
    margin-bottom: 8px !important;
}

body.mobile-mode.landscape .survivor-pause-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    align-content: start;
    gap: 8px !important;
    padding-bottom: calc(10px + var(--sab)) !important;
}

body.mobile-mode.landscape .survivor-pause-actions .pause-btn-primary,
body.mobile-mode.landscape .survivor-pause-actions .pause-btn-danger {
    grid-column: 1 / -1;
}

body.mobile-mode.landscape .survivor-pause-actions .pause-btn-danger {
    margin-top: 0 !important;
}

/* Level-up Survivor en móvil */
body.mobile-mode .survivor-levelup-overlay {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: calc(8px + var(--sat)) calc(10px + var(--sar)) calc(8px + var(--sab)) calc(10px + var(--sal)) !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    z-index: 12000 !important;
}

body.mobile-mode .survivor-levelup-overlay .survivor-levelup-content {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

body.mobile-mode .survivor-levelup-header {
    flex: 0 0 auto;
    margin-bottom: 0 !important;
}

body.mobile-mode .survivor-levelup-options {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 6px !important;
    align-content: start;
    padding: 10px !important;
}

body.mobile-mode .survivor-levelup-options .levelup-option {
    display: grid !important;
    grid-template-columns: 52px 1fr auto !important;
    grid-template-rows: auto auto auto !important;
    column-gap: 10px !important;
    row-gap: 3px !important;
    align-items: center !important;
    min-height: 56px !important;
    height: auto !important;
    padding: 8px 10px !important;
    text-align: left !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body.mobile-mode .survivor-levelup-options .levelup-option::before {
    content: none !important;
    display: none !important;
}

body.mobile-mode .survivor-levelup-options .levelup-meta {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-start;
    margin: 0;
    padding: 0;
}

body.mobile-mode .survivor-levelup-options .levelup-icon {
    grid-column: 1;
    grid-row: 1 / span 3;
    width: 52px !important;
    height: 52px !important;
    margin: 0 !important;
}

body.mobile-mode .survivor-levelup-options .levelup-name {
    grid-column: 2;
    grid-row: 2;
    padding: 0;
}

body.mobile-mode .survivor-levelup-options .levelup-desc {
    grid-column: 2;
    grid-row: 3;
    margin: 0;
    padding: 0;
}

body.mobile-mode .survivor-levelup-options .levelup-stacks {
    grid-column: 3;
    grid-row: 1 / span 3;
    align-self: center;
    justify-self: end;
    margin-top: 0 !important;
}

body.mobile-mode .survivor-levelup-overlay .levelup-footer {
    flex: 0 0 auto;
}

body.mobile-mode .survivor-levelup-body {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    gap: 2px !important;
    padding: 0 2px !important;
}

body.mobile-mode .survivor-levelup-body .survivor-levelup-options {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

body.mobile-mode .levelup-hint-desktop {
    display: none !important;
}

body.mobile-mode .levelup-hint-mobile {
    display: block !important;
    font-size: 12px !important;
    padding: 4px 8px;
}

body.mobile-mode.landscape .survivor-levelup-options {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
}

body.mobile-mode.landscape .survivor-levelup-options .levelup-option {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    min-height: 180px !important;
    padding: 8px 6px !important;
    text-align: center !important;
}

body.mobile-mode.landscape .survivor-levelup-options .levelup-meta,
body.mobile-mode.landscape .survivor-levelup-options .levelup-icon,
body.mobile-mode.landscape .survivor-levelup-options .levelup-name,
body.mobile-mode.landscape .survivor-levelup-options .levelup-desc,
body.mobile-mode.landscape .survivor-levelup-options .levelup-stacks {
    grid-column: auto;
    grid-row: auto;
}

body.mobile-mode.landscape .survivor-levelup-options .levelup-meta {
    justify-content: center;
    margin-bottom: 6px;
}

body.mobile-mode.landscape .survivor-levelup-options .levelup-icon {
    width: 48px !important;
    height: 48px !important;
    margin: 0 0 8px !important;
}

body.mobile-mode.landscape .survivor-levelup-options .levelup-name,
body.mobile-mode.landscape .survivor-levelup-options .levelup-desc {
    padding: 0 6px;
}

body.mobile-mode.landscape .survivor-levelup-options .levelup-stacks {
    justify-self: center;
    margin-top: auto !important;
}

/* Run stats overlay */
body.mobile-mode .survivor-run-stats-overlay {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    z-index: 12000 !important;
}

body.mobile-mode .survivor-run-stats-overlay .survivor-run-stats-window {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

body.mobile-mode .survivor-run-stats-header {
    flex: 0 0 auto;
    align-items: center;
    gap: 12px;
    padding: calc(12px + var(--sat)) calc(14px + var(--sar)) 12px calc(14px + var(--sal)) !important;
}

body.mobile-mode .survivor-run-stats-header h2 {
    font-size: clamp(16px, 4.5vw, 20px) !important;
}

body.mobile-mode .survivor-run-stats-close {
    flex: 0 0 auto;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body.mobile-mode .survivor-run-stats-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 12px calc(14px + var(--sar)) calc(16px + var(--sab)) calc(14px + var(--sal)) !important;
    box-sizing: border-box !important;
}

body.mobile-mode .run-stats-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
}

body.mobile-mode .run-stats-columns {
    grid-template-columns: 1fr !important;
}

body.mobile-mode.landscape .run-stats-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

body.mobile-mode.landscape .run-stats-columns {
    grid-template-columns: 1fr 1fr !important;
}