/* ===========================
   ESTILOS PARA MÓVILES
   =========================== */

@media only screen and (max-width: 768px) {
    * {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    body {
        margin: 0;
        padding: 0;
        overflow: hidden;
        position: fixed;
        width: 100vw;
        height: 100vh;
    }

    #game-container {
        width: 100vw;
        height: 100vh;
        overflow: hidden;
        position: relative;
    }

    #game-canvas {
        width: 100vw !important;
        height: 60vh !important;
        display: block;
        touch-action: none;
        image-rendering: pixelated;
        image-rendering: crisp-edges;
    }

    /* Panel de UI compacto para móviles */
    #ui-layer {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 40vh;
        display: flex !important;
        flex-direction: column;
        background: rgba(10, 10, 10, 0.95);
        padding: 5px;
        box-sizing: border-box;
        overflow-y: auto;
    }

    #stats-panel {
        background: rgba(20, 20, 20, 0.9);
        border-radius: 8px;
        padding: 8px;
        margin-bottom: 5px;
        font-size: 0.75em;
        max-height: 15vh;
        overflow-y: auto;
    }

    #stats-panel h2 {
        font-size: 1em;
        margin: 0 0 5px 0;
        color: #ff9800;
    }

    #char-info {
        font-size: 0.9em;
        line-height: 1.3;
    }

    #controls {
        display: flex;
        gap: 5px;
        margin-top: 5px;
    }

    #controls button {
        flex: 1;
        padding: 8px 5px;
        font-size: 0.75em;
        border-radius: 5px;
        background: #ff9800;
        color: white;
        border: none;
        font-weight: bold;
        touch-action: manipulation;
    }

    #log-panel {
        background: rgba(20, 20, 20, 0.9);
        border-radius: 8px;
        padding: 8px;
        flex: 1;
        overflow-y: auto;
        min-height: 100px;
    }

    #log-panel h2 {
        font-size: 1em;
        margin: 0 0 5px 0;
        color: #ff9800;
    }

    #game-log {
        font-size: 0.7em;
        line-height: 1.2;
        max-height: 15vh;
        overflow-y: auto;
    }

    /* Controles táctiles virtuales */
    #mobile-controls {
        position: absolute;
        bottom: 42vh;
        left: 0;
        right: 0;
        display: flex;
        justify-content: space-between;
        padding: 10px;
        pointer-events: none;
        z-index: 1000;
    }

    .mobile-dpad {
        width: 140px;
        height: 140px;
        position: relative;
        pointer-events: auto;
    }

    .dpad-button {
        position: absolute;
        width: 45px;
        height: 45px;
        background: rgba(255, 152, 0, 0.7);
        border: 2px solid rgba(255, 152, 0, 1);
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        color: white;
        touch-action: manipulation;
        user-select: none;
        transition: all 0.1s;
    }

    .dpad-button:active {
        background: rgba(255, 152, 0, 1);
        transform: scale(0.95);
    }

    .dpad-up {
        top: 0;
        left: 50%;
        transform: translateX(-50%);
    }

    .dpad-down {
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
    }

    .dpad-left {
        left: 0;
        top: 50%;
        transform: translateY(-50%);
    }

    .dpad-right {
        right: 0;
        top: 50%;
        transform: translateY(-50%);
    }

    .dpad-center {
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 40px;
        height: 40px;
        background: rgba(50, 50, 50, 0.5);
        border: 2px solid rgba(100, 100, 100, 0.8);
        pointer-events: none;
    }

    /* Botones de acción móvil */
    .mobile-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        pointer-events: auto;
    }

    .action-button {
        width: 60px;
        height: 60px;
        background: rgba(76, 175, 80, 0.7);
        border: 2px solid rgba(76, 175, 80, 1);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        font-weight: bold;
        color: white;
        touch-action: manipulation;
        user-select: none;
        transition: all 0.1s;
    }

    .action-button:active {
        background: rgba(76, 175, 80, 1);
        transform: scale(0.95);
    }

    .action-button.inventory {
        background: rgba(33, 150, 243, 0.7);
        border-color: rgba(33, 150, 243, 1);
    }

    .action-button.inventory:active {
        background: rgba(33, 150, 243, 1);
    }

    /* Modal ajustado para móvil */
    .modal {
        padding: 10px;
    }

    .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 85vh;
        overflow-y: auto;
        padding: 15px;
        font-size: 0.85em;
    }

    .modal-content h2 {
        font-size: 1.3em;
        margin-top: 0;
    }

    .item-entry {
        padding: 8px;
        font-size: 0.85em;
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .item-entry button {
        width: 100%;
        margin-top: 5px;
        padding: 8px;
    }

    /* Campamento móvil */
    #camp-screen {
        width: 100vw !important;
        height: 100vh !important;
    }

    .camp-overlay {
        padding: 10px;
        overflow-y: auto;
        max-height: 100vh;
    }

    .moria-title {
        font-size: 3em !important;
        margin-top: -50px !important;
        letter-spacing: 5px !important;
    }

    .subtitle-text {
        font-size: 1em !important;
        margin-bottom: 20px !important;
    }

    #btn-start-game {
        font-size: 1.2em !important;
        padding: 12px 30px !important;
    }

    .camp-content {
        flex-direction: column !important;
        gap: 10px;
    }

    .camp-left,
    .camp-right {
        width: 100% !important;
        max-width: 100% !important;
    }

    .stats-box,
    .camp-actions,
    .scores-box,
    .shop-box {
        font-size: 0.85em;
        padding: 10px;
    }

    .camp-actions button {
        font-size: 0.9em;
        padding: 10px;
        margin: 5px 0;
    }

    #shop-items {
        max-height: 40vh;
        overflow-y: auto;
    }

    /* Títulos móvil */
    .camp-header h1 {
        font-size: 2em !important;
    }

    .camp-header h2 {
        font-size: 1.2em !important;
    }

    /* Minimapa pequeño en móvil */
    .minimap {
        transform: scale(0.7);
        transform-origin: top right;
    }
}

/* Orientación horizontal (landscape) en móvil */
@media only screen and (max-width: 768px) and (orientation: landscape) {
    #game-canvas {
        height: 70vh !important;
    }

    #ui-layer {
        height: 30vh;
    }

    #mobile-controls {
        bottom: 32vh;
    }

    .mobile-dpad {
        width: 120px;
        height: 120px;
    }

    .dpad-button {
        width: 38px;
        height: 38px;
        font-size: 20px;
    }

    .action-button {
        width: 50px;
        height: 50px;
        font-size: 12px;
    }
}

/* Ajustes para pantallas muy pequeñas */
@media only screen and (max-width: 375px) {
    .moria-title {
        font-size: 2.5em !important;
    }

    .mobile-dpad {
        width: 120px;
        height: 120px;
    }

    .dpad-button {
        width: 38px;
        height: 38px;
        font-size: 20px;
    }

    .action-button {
        width: 50px;
        height: 50px;
    }

    #stats-panel,
    #log-panel {
        font-size: 0.7em;
    }
}
