/* Estilos base y reseteo */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
body, html {
    height: 100%;
    font-family: 'Courier New', Courier, monospace;
    background-color: #000;
    color: #fff;
}

html.game-page,
body.game-page {
    overflow: hidden; /* Evita scrolls globales de pantalla durante el juego */
}

.game-orientation-notice,
.game-menu-toggle {
    display: none;
}

.game-fullscreen-prompt {
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(460px, calc(100% - 32px));
    max-height: calc(100dvh - 24px);
    overflow: auto;
    padding: 16px;
    border: 1px solid #666;
    border-radius: 8px;
    background: #171717;
    color: #fff;
}

.game-fullscreen-prompt::backdrop {
    background: rgb(0 0 0 / 75%);
}

.game-fullscreen-prompt h2 {
    margin-bottom: 8px;
    font-size: 1.125rem;
}

.game-fullscreen-prompt p {
    line-height: 1.4;
}

.game-fullscreen-prompt__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.game-fullscreen-option {
    grid-column: 1 / -1;
    min-height: 44px;
    padding: 4px 8px;
    border: 1px solid #666;
    border-radius: 6px;
    background: #333;
    color: #fff;
    font: inherit;
    font-size: 0.875rem;
    cursor: pointer;
}

/* Contenedor Principal en pantalla completa */
.game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background-size: cover;
    background-position: center;
    position: relative;
}

/* Capa superior para forzar que la imagen de fondo sea escala de grises */
.game-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: grayscale(100%);
    z-index: 1;
}

/* Título superior centrado y transparente, con Flexbox para el botón */
.game-header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center; /* Centra el h1 horizontalmente */
    padding: 20px;
    background-color: transparent; 
    border-bottom: none;          
}

.game-header h1 {
    font-size: 1.8rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 2px 2px 4px #000000, 
                -2px -2px 4px #000000, 
                2px -2px 4px #000000, 
                -2px 2px 4px #000000;
}

/* Modificación del estilo Noir para usar iconos PNG transparentes */
.icon-buttons {
    position: absolute;
    right: 20px;
    top: 20px; 
    background: transparent; 
    border: none;            
    width: 400px;
    height: 60px;
    cursor: pointer;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Sombra de filtro dura para destacar la silueta del dibujo frente al fondo */
    filter: drop-shadow(2px 2px 0px #000) drop-shadow(-1px -1px 0px #000);
    transition: transform 0.1s;
}
.toggle-ui-btn {
    background: transparent; 
    border: none;            
    width: 60px;
    height: 60px;
    cursor: pointer;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Sombra de filtro dura para destacar la silueta del dibujo frente al fondo */
    filter: drop-shadow(2px 2px 0px #000) drop-shadow(-1px -1px 0px #000);
    transition: transform 0.1s;
}

.toggle-ui-btn:not(:disabled):hover {
    transform: scale(1.1); /* Efecto cómic sutil */
}

.toggle-ui-btn:not(:disabled):active {
    transform: scale(0.95) translate(1px, 1px);
}

.toggle-ui-btn:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none; /* Esto asegura que el ratón no interactúe con él en absoluto */
}

/* Imagen dentro del botón para que ocupe todo el espacio */
.toggle-ui-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.btn-bloc img, .btn-reinit img {
    width: 68%;
    height: 68%;
}

.separador-lapiz {
  width: 4px;
  height: 24px;
  background-repeat: no-repeat;
  background-position: center;
  /* Cambiado stroke="%23222222" por stroke="%23D1D5DB" (gris claro) */
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 24" fill="none"><path d="M2 1C1.8 5 2.3 10 1.9 15C1.6 18 2.2 21 2 23" stroke="%23D1D5DB" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" opacity="0.85"/></svg>');
  /* Opcional: reducir o quitar la sombra para que se aprecie mejor el tono claro */
  filter: drop-shadow(0.5px 0.5px 0px rgba(0, 0, 0, 0.05));
}

/* Ajuste para el cuerpo del juego */
.game-body {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: row; /* Coloca los paneles uno al lado del otro */
    gap: 20px; /* Separación clara entre ambos paneles */
    flex: 1;
    width: 100%;
    height: calc(100vh - 70px);
    padding: 20px;
    box-sizing: border-box;
}

.game-body--mirrored > .inventario-panel {
    order: 2;
}

.game-body--mirrored > .panel-right {
    order: 1;
    margin-left: 0;
}

/* Panel derecho sin posicionamiento absoluto interno para el botón */
.panel-left, .panel-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: transparent;
    padding: 20px;
    gap: 15px;
    height: 95%;
    z-index: 3; 
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

/* El panel derecho ocupa la mitad derecha de la pantalla */
.panel-right {
    flex: 0 0 50%;
    max-width: 50%;
    margin-left: auto;
}

/* El panel izquierdo no tiene input, por lo que su contenedor de texto ocupará el 100% de la altura de este panel */
.panel-left .text-area-container {
    height: 100%;
    flex: 1;
}

/* El panel derecho distribuye su espacio: el área de texto ocupa un 75% aprox */
.panel-right .text-area-container {
    height: 90%;
    flex: none; /* Evitamos que flex-grow distorsione el 75% */
}

/* El formulario del panel derecho ocupa la proporción restante */
.panel-right .input-form {
    height: calc(25% - 15px); /* Restamos el gap para ajustar */
}

/* Clase utilitaria mejorada para el Fade Out / Fade In */
.ui-oculta {
    opacity: 0 !important;
    visibility: hidden !important;
    /* Desplaza ligeramente los elementos hacia abajo al ocultarse */
    transform: translateY(20px) !important; 
    pointer-events: none; /* Evita interacciones accidentales mientras está oculto */
}

/* Cuadro de texto principal (Historial) */
.text-area-container {
    flex: 1;
    display: flex;
    /* Transición suave para opacidad, posición y visibilidad */
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                visibility 0.6s;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.text-area-output {
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75); 
    color: #fff;
    border: 1px solid #333;
    border-radius: 6px; /* ¡Bordes redondeados añadidos aquí! */
    padding: 15px;
    font-size: 1.1rem;
    line-height: 1.6;
    overflow-y: auto;
    font-family: inherit;
    text-shadow: 1px 1px 2px #000000, 
                -1px -1px 2px #000000;
    white-space: pre-wrap;
}

.text-area-output::-webkit-scrollbar {
    width: 8px;
}
.text-area-output::-webkit-scrollbar-track {
    background: #111;
}
.text-area-output::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

/* Formulario e Input inferior */
.input-form {
    display: flex;
    gap: 10px;
    /* Misma transición suave para ir en sintonía con el historial */
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                visibility 0.6s;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.command-input {
    flex: 1;
    background-color: #000;
    color: #fff;
    border: 1px solid #444;
    padding: 12px;
    font-size: 1.3rem;
    font-family: inherit;
    border-radius: 8px; /* ¡Bordes redondeados añadidos aquí! */
}
.command-input:focus {
    outline: none;
    border-color: #888;
}
.btn-submit {
    background-color: #222;
    color: #fff;
    border: 1px solid #444;
    padding: 0 20px;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
    font-size: 1.3rem;
    transition: background 0.2s;
    border-radius: 8px; /* ¡Bordes redondeados añadidos aquí! */
}
.btn-submit:hover {
    background-color: #444;
}

/* Panel lateral de inventario */
.inventario-panel {
    /* calc(50% - 20px) deja espacio exacto para el gap del game-body */
    flex: 0 0 calc(50% - 20px);
    max-width: calc(50% - 20px);
    /* alinea el borde superior con el textarea del historial (padding-top del panel-right) */
    margin-top: 20px;
    height: calc(95% - 40px);
    align-self: flex-start;
    background-color: rgba(10, 10, 10, 0.93);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    padding: 15px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
    overflow: hidden;
    transition: opacity 0.4s ease,
                visibility 0.4s,
                max-width 0.4s ease,
                padding 0.4s ease;
    opacity: 1;
    visibility: visible;
}

/* Al ocultarse, colapsa el ancho para no desplazar el panel-right */
.inventario-panel.ui-oculta {
    max-width: 0 !important;
    padding: 0 !important;
    transform: none !important;
}

.inventario-panel .inventario-panel__titulo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #aaa;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
    flex-shrink: 0;
}

.inventario-panel__cerrar {
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
}

.inventario-panel__cerrar:hover {
    color: #fff;
}

.inventario-panel__lista {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inventario-panel__lista::-webkit-scrollbar {
    width: 6px;
}
.inventario-panel__lista::-webkit-scrollbar-track {
    background: #111;
}
.inventario-panel__lista::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

.inventario-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background-color: rgba(255, 255, 255, 0.04);
    transition: background-color 0.2s;
    cursor: default;
}

.inventario-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.inventario-item__img {
    width: 150px;
    height: 150px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(1px 1px 2px #000);
}

.inventario-item__nombre {
    font-size: 1.1rem;
    color: #ddd;
    line-height: 1.6;
    text-shadow: 1px 1px 2px #000;
}

/* Modal de ayuda centrado sobre el resto de la interfaz */
.ayuda-modal, .bloc-modal {
    position: fixed;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    width: 60vw;
    height: calc((130vh - 110px) * 2 / 3);
    max-height: calc((130vh - 110px) * 2 / 3);
    background-color: #f5f0e8;
    background-image:
        repeating-linear-gradient(
            transparent,
            transparent 27px,
            rgba(180, 160, 120, 0.35) 28px
        );
    border: 1px solid #c8b89a;
    border-radius: 4px;
    box-shadow: 3px 4px 18px rgba(0, 0, 0, 0.7), inset 0 0 40px rgba(200, 180, 140, 0.15);
    padding: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: opacity 0.4s ease,
                transform 0.4s ease,
                visibility 0.4s;
    opacity: 1;
    visibility: visible;
}

.bloc-modal {
    top: 70px;
    left: 50%;
    width: 40vw;
    height: calc((140vh - 110px) * 2 / 3);
    max-height: calc((140vh - 110px) * 2 / 3);
}

/* Ajusta el título al fondo claro del modal */
.ayuda-modal .inventario-panel__titulo, 
.bloc-modal .bloc-panel__titulo {
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #5a3e1b;
    border-bottom: 1px solid #c8b89a; /* Añadimos el borde base visible */
    padding-bottom: 4px;             /* Ajustamos padding para encajar en el patrón de 28px */
    margin-bottom: 0;
    line-height: 23px;               /* 23px contenido + 4px padding + 1px borde = 28px exactos */
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-panel__cerrar {
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
}

.modal-panel__cerrar:hover {
    color: #b08a5a;
}

/* Sobreescribimos el transform de .ui-oculta para mantener el centrado horizontal */
.ayuda-modal.ui-oculta, .bloc-modal.ui-oculta {
    transform: translateX(-50%) translateY(20px) !important;
}

.ayuda-modal__texto, .bloc-modal__texto {
    cursor: text;
    flex: 1;
    min-height: 200px;
    background-color: transparent !important;
    border: none !important;
    color: #2a1f0e;
    font-size: 1rem;
    line-height: 1.75rem; /* coincide con el alto de línea del rayado */
    text-shadow: none;
    caret-color: #2a1f0e;
    white-space: pre-wrap;
    overflow-y: auto;
    outline: none;
}

/*************** MODAL REINICIAR *****************/

/* Overlay oscuro que bloquea la pantalla */
.overlay-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.75); /* Oscurece el juego */
    z-index: 999; /* Por encima de todos los demás elementos */
    display: flex;
    align-items: center;
    justify-content: center;
    /* Transición de aparición/desaparición */
    transition: opacity 0.4s ease, visibility 0.4s;
    opacity: 1;
    visibility: visible;
}

/* Aprovechamos ui-oculta para quitar el overlay entero */
.overlay-modal.ui-oculta {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none;
}

/* Caja modal estilo papel (similar al bloc/ayuda pero más pequeña) */
.reinit-modal {
    position: relative;
    width: 450px;
    max-width: 90vw;
    background-color: #f5f0e8;
    background-image:
        repeating-linear-gradient(
            transparent,
            transparent 27px,
            rgba(180, 160, 120, 0.35) 28px
        );
    border: 1px solid #c8b89a;
    border-radius: 4px;
    box-shadow: 3px 4px 18px rgba(0, 0, 0, 0.9), inset 0 0 40px rgba(200, 180, 140, 0.15);
    padding: 20px 30px;
    display: flex;
    flex-direction: column;
    text-align: center;
    /* Ligero rebote al aparecer, igual que los otros modales */
    transform: translateY(0);
    transition: transform 0.4s ease;
}

/* Efecto de desplazamiento al ocultar */
.overlay-modal.ui-oculta .reinit-modal {
    transform: translateY(20px);
}

.reinit-modal__titulo {
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #5a3e1b;
    border-bottom: 1px solid #c8b89a;
    padding-bottom: 4px;
    margin-top: 5px;
    margin-bottom: 20px;
    line-height: 23px;
}

.reinit-modal__contenido p {
    color: #2a1f0e;
    font-size: 1rem;
    line-height: 1.75rem; /* Alineado a las líneas del papel (28px) */
    margin: 0;
}

.reinit-modal__botones {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    margin-bottom: 10px;
}

.btn-modal {
    background-color: #5a3e1b;
    color: #f5f0e8;
    border: 2px solid #2a1f0e;
    padding: 8px 30px;
    font-size: 1.2rem;
    font-family: inherit;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 2px 2px 0px #2a1f0e;
}

.btn-modal:hover {
    background-color: #3e2a12;
}

.btn-modal:active {
    transform: translate(2px, 2px);
    box-shadow: 0px 0px 0px #2a1f0e;
}

.reinit-modal__cerrar {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #5a3e1b;
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: #333; /* El color principal de tu tema */
    animation: spin 1s linear infinite;
    margin: 10px auto;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/******************* FIN MODAL REINICIAR **********************/

/*************** MODAL FIN DE JUEGO *****************/
.fin-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    /* Lo centramos exactamente en el medio de la pantalla */
    transform: translate(-50%, -50%);
    width: 50vw;
    height: 80vh; /* <-- Cambiado: de 40vh a 80vh (el doble de alto) */
    z-index: 300; 
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Transición suave y consistente con el resto de la interfaz */
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                visibility 0.6s;
    opacity: 1;
    visibility: visible;
}

.fin-modal__titulo {
    flex: 0 0 auto;
    margin: 0;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.75);
    border: 1px solid #333;
    border-radius: 6px;
    color: #fff;
    font-size: 2rem;
    font-weight: bold;
    line-height: 1.2;
    text-align: center;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px #000;
}

/* Sobreescribimos el transform al ocultarse para que se desplace hacia abajo sin perder el centrado horizontal */
.fin-modal.ui-oculta {
    transform: translate(-50%, calc(-50% + 20px)) !important;
}

/* Modificadores para el textarea final */
.fin-modal__texto {
    flex: 1;
    min-height: 0;
    height: auto;
    /* Al quitar el font-size, padding-top y text-align, hereda 
       automáticamente el estilo de .text-area-output (igual que el historial) */
    cursor: default;
}

/************** FIN MODAL DE FIN DE JUEGO ***********/

/***************** ESTILOS PARA TEXTOS EN EL HISTÓRICO Y FIN JUEGO ***************/

.entrada-historico {
    color: rgb(202, 200, 170); /* color-sepia */
}

.texto-carga {
    text-align: center;
    color: rgb(178, 217, 226); /* color-verde-gris */
}

.texto-titulo {
    text-align: center;
    font-size: 1.3rem;
    margin-bottom: 15px;
    font-weight: bold;
    color: rgb(202, 200, 170); /* color-sepia */
}

/****************** ESTILOS AYUDA *********************/

.ayuda-modal p {
    margin-bottom: 15px;
    margin-top: 15px;
}

.ayuda-modal ul {
    margin-left: 30px;
}

.ayuda-modal table th {
    text-align: left;
}

.ayuda-modal .tabla-lapiz {
  /* Usamos separate en lugar de collapse para que los bordes irregulares de cada celda no se anulen entre sí */
  border-collapse: separate; 
  border-spacing: 0;
  width: 100%;
  max-width: 1000px;
  color: #333; /* Color grafito para el texto */
  /* Opcional: una fuente que parezca manuscrita */
  font-family: "Caveat", "Comic Sans MS", cursive, sans-serif; 
}

.ayuda-modal .tabla-lapiz th, 
.ayuda-modal .tabla-lapiz td {
  padding: 12px 15px;
  border-style: solid;
  border-color: #4a4a4a; /* Gris oscuro simulando el trazo del lápiz */
  
  /* Grosores ligeramente distintos en cada lado para simular la presión irregular de la mano */
  border-width: 1px 2px 2px 1px;
  
  /* El truco principal: radios de borde asimétricos */
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
}

/* Alterar los bordes de las filas pares rompe el patrón para que parezca más natural y menos generado por ordenador */
.ayuda-modal .tabla-lapiz tbody tr:nth-child(even) td {
  border-width: 2px 1px 1px 2px;
  border-radius: 15px 255px 15px 225px / 255px 15px 225px 15px;
}

.ayuda-modal .tabla-lapiz th {
  /* La línea separadora del encabezado un poco más gruesa */
  border-bottom-width: 3px;
  font-weight: bold;
  background-color: rgba(0, 0, 0, 0.02); /* Un sombreado ínfimo */
}

.ayuda-modal .tabla-verbos th:nth-child(1),
.ayuda-modal .tabla-verbos td:nth-child(1) {
  width: 15%;
}

.ayuda-modal .tabla-verbos th:nth-child(2),
.ayuda-modal .tabla-verbos td:nth-child(2) {
  width: 15%;
}

.ayuda-modal .tabla-verbos th:nth-child(3),
.ayuda-modal .tabla-verbos td:nth-child(3) {
  width: 40%;
}

.ayuda-modal .tabla-verbos th:nth-child(4),
.ayuda-modal .tabla-verbos td:nth-child(4) {
  width: 30%;
}

.ayuda-modal .destacado {
  font-weight: bold;
  font-size: 1.3rem;
}

@media (max-width: 1000px), (pointer: coarse) and (max-height: 600px) {
    .game-container {
        --game-left: max(8px, env(safe-area-inset-left));
        --game-right: max(8px, env(safe-area-inset-right));
        --game-top: env(safe-area-inset-top, 0px);
        --game-bottom: max(6px, env(safe-area-inset-bottom));
        top: var(--game-viewport-top, 0px);
        width: 100%;
        height: 100dvh;
        height: var(--game-viewport-height, 100dvh);
    }

    .game-header {
        z-index: 350;
        justify-content: space-between;
        gap: 8px;
        padding: var(--game-top) var(--game-right) 0 var(--game-left);
        flex: 0 0 auto;
    }

    .game-header h1 {
        min-width: 0;
        font-size: clamp(0.9rem, 3vw, 1.25rem);
        line-height: 1.15;
        letter-spacing: 1px;
        overflow-wrap: anywhere;
    }

    .game-menu-toggle {
        display: block;
        flex-shrink: 0;
        min-height: 44px;
        padding: 0 10px;
        border: 1px solid #666;
        border-radius: 6px;
        background: #222;
        color: #fff;
        font: inherit;
        font-size: 0.875rem;
        cursor: pointer;
    }

    .icon-buttons {
        display: none;
        grid-template-columns: repeat(3, 44px);
        gap: 4px;
        top: 100%;
        right: var(--game-right);
        width: auto;
        height: auto;
        padding: 4px;
        border: 1px solid #666;
        border-radius: 6px;
        background: #222;
        box-shadow: 0 3px 8px #000;
        filter: none;
    }

    .game-menu-toggle[aria-expanded="true"] + .icon-buttons {
        display: grid;
    }

    .icon-buttons .separador-lapiz {
        display: none;
    }

    .toggle-ui-btn {
        width: 44px;
        height: 44px;
    }

    .toggle-ui-btn img {
        width: 32px;
        height: 32px;
    }

    .btn-bloc img,
    .btn-reinit img {
        width: 26px;
        height: 26px;
    }

    .game-body {
        height: auto;
        min-height: 0;
        gap: 8px;
        padding: 4px var(--game-right) var(--game-bottom) var(--game-left);
    }

    .panel-right {
        flex: 0 0 56%;
        max-width: 56%;
        height: 100%;
        min-width: 0;
        padding: 0;
        gap: 4px;
    }

    .panel-right .text-area-container {
        flex: 1 1 0;
        height: auto;
        min-height: 0;
    }

    .text-area-output {
        padding: 8px;
        font-size: clamp(0.875rem, 2.5dvh, 1rem);
        line-height: 1.4;
        overflow-wrap: anywhere;
    }

    .texto-titulo,
    .ayuda-modal .destacado {
        font-size: 1rem;
        margin-bottom: 6px;
    }

    .panel-right .input-form {
        height: auto;
        gap: 4px;
        flex-shrink: 0;
    }

    .command-input {
        min-width: 0;
        min-height: 44px;
        padding: 4px 8px;
        font-size: 1rem;
    }

    .btn-submit {
        padding: 0 8px;
        font-size: 0.8125rem;
    }

    .inventario-panel {
        flex-basis: calc(44% - 8px);
        max-width: calc(44% - 8px);
        height: 100%;
        margin-top: 0;
        padding: 4px 8px;
        gap: 4px;
    }

    .inventario-panel .inventario-panel__titulo,
    .ayuda-modal .inventario-panel__titulo,
    .bloc-modal .bloc-panel__titulo {
        font-size: 1rem;
        letter-spacing: 1px;
        padding-bottom: 0;
    }

    .modal-panel__cerrar,
    .inventario-panel__cerrar {
        min-width: 44px;
        min-height: 44px;
    }

    .inventario-panel__lista {
        gap: 4px;
    }

    .inventario-item {
        gap: 6px;
        padding: 4px;
    }

    .inventario-item__img {
        width: clamp(28px, 13dvh, 70px);
        height: auto;
        aspect-ratio: 1;
    }

    .inventario-item__nombre,
    .inventario-panel__vacio {
        font-size: 0.875rem;
        line-height: 1.3;
        overflow-wrap: anywhere;
    }

    .ayuda-modal,
    .bloc-modal {
        position: absolute;
        inset: 0;
        width: auto;
        height: auto;
        max-height: none;
        padding: var(--game-top) var(--game-right) var(--game-bottom) var(--game-left);
        border: 0;
        border-radius: 0;
        transform: none;
        z-index: 400;
        cursor: auto;
    }

    .ayuda-modal.ui-oculta,
    .bloc-modal.ui-oculta {
        transform: none !important;
    }

    .ayuda-modal__texto,
    .bloc-modal__texto {
        min-height: 0;
        height: auto;
    }

    .bloc-modal__texto {
        font-size: 1rem;
        line-height: 1.75rem;
        padding-block: 0;
    }

    .ayuda-modal p {
        margin-block: 8px;
    }

    .ayuda-modal .tabla-lapiz th,
    .ayuda-modal .tabla-lapiz td {
        padding: 4px;
    }

    .overlay-modal {
        position: absolute;
        inset: 0;
        width: auto;
        height: auto;
        padding: max(4px, var(--game-top)) var(--game-right) var(--game-bottom) var(--game-left);
    }

    .reinit-modal {
        max-width: 100%;
        max-height: 100%;
        overflow-y: auto;
        padding: 8px 12px;
    }

    .reinit-modal__titulo {
        margin: 0 0 6px;
        padding: 0 44px 4px;
        font-size: 1rem;
        letter-spacing: 1px;
    }

    .reinit-modal__cerrar {
        top: 0;
        right: 0;
        font-size: 1rem;
    }

    .reinit-modal__contenido p {
        font-size: 0.875rem;
        line-height: 1.4;
    }

    .reinit-modal__botones {
        margin: 8px 0 0;
    }

    .btn-modal {
        min-height: 44px;
        padding: 4px 20px;
        font-size: 1rem;
    }

    .fin-modal {
        position: absolute;
        inset: calc(var(--game-top) + 48px) var(--game-right) var(--game-bottom) var(--game-left);
        width: auto;
        height: auto;
        gap: 4px;
        transform: none;
    }

    .fin-modal.ui-oculta {
        transform: none !important;
    }

    .fin-modal__titulo {
        padding: 6px;
        font-size: 1.25rem;
    }
}

@media (orientation: portrait) and (pointer: coarse) {
    .game-page .game-container {
        display: none;
    }

    .game-orientation-notice {
        display: grid;
        min-height: 100dvh;
        place-items: center;
        padding: 24px;
        text-align: center;
    }
}

