/* ============================================================ */
/*  BEEBOT · ESTILOS COMPLETOS                                  */
/*  Pantallas: Presentación · Cómo jugar · Selección · Juego    */
/*  Cruceta con imágenes · Responsive · Primaveral              */
/* ============================================================ */

/* ---------- RESET Y GLOBAL ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100dvh;
    font-family: 'Segoe UI', 'Comic Sans MS', 'Chalkboard SE', cursive, sans-serif;
    background: linear-gradient(180deg, #87CEEB 0%, #B0E0E6 40%, #90C695 70%, #6B8E6B 100%);
    user-select: none;
    overflow-x: hidden;
    color: #1F2A36;
}

body {
    position: relative;
    min-height: 100dvh;
}

button {
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

img {
    -webkit-user-drag: none;
    user-select: none;
}

/* ============================================================ */
/*  PÉTALOS CAYENDO                                              */
/* ============================================================ */
.petals-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.petal {
    position: absolute;
    top: -10%;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle at 30% 30%, #FFB7C5, #FF69B4);
    border-radius: 50% 0 50% 50%;
    opacity: 0.7;
    animation: caerPetalo linear infinite;
    box-shadow: 0 0 10px rgba(255, 182, 193, 0.3);
}

.petal:nth-child(1) { left: 5%;  animation-duration: 12s; animation-delay: 0s;   width: 18px; height: 24px; background: #FFB7C5; }
.petal:nth-child(2) { left: 15%; animation-duration: 14s; animation-delay: 2s;   width: 14px; height: 18px; background: #FFD1DC; }
.petal:nth-child(3) { left: 25%; animation-duration: 10s; animation-delay: 4s;   width: 22px; height: 28px; background: #FFB6C1; opacity: 0.5; }
.petal:nth-child(4) { left: 40%; animation-duration: 16s; animation-delay: 1s;   width: 16px; height: 16px; background: #FFC0CB; }
.petal:nth-child(5) { left: 55%; animation-duration: 11s; animation-delay: 3s;   width: 20px; height: 26px; background: #FF69B4; opacity: 0.6; }
.petal:nth-child(6) { left: 70%; animation-duration: 13s; animation-delay: 5s;   width: 18px; height: 22px; background: #FFB7C5; }
.petal:nth-child(7) { left: 85%; animation-duration: 15s; animation-delay: 0.5s; width: 24px; height: 20px; background: #FFDAB9; }
.petal:nth-child(8) { left: 95%; animation-duration: 9s;  animation-delay: 3.5s; width: 15px; height: 20px; background: #FFA07A; opacity: 0.5; }

@keyframes caerPetalo {
    0%   { transform: translateY(0) rotate(0deg) scale(1);           opacity: 0.8; }
    100% { transform: translateY(110dvh) rotate(720deg) scale(0.4);  opacity: 0.2; }
}

/* ============================================================ */
/*  SISTEMA DE PANTALLAS                                        */
/* ============================================================ */
.pantalla {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
    width: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 3vh 3vw;
}

.pantalla.activa {
    display: flex;
    animation: fadeInPantalla 0.45s ease both;
}

@keyframes fadeInPantalla {
    from { opacity: 0; transform: translateY(15px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================ */
/*  PANELES ESTILO VIDEOJUEGO                                   */
/* ============================================================ */
.panel {
    background: rgba(255, 248, 235, 0.96);
    backdrop-filter: blur(14px);
    border-radius: 3rem;
    border: 6px solid #FFD700;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.35),
        inset 0 4px 12px rgba(255, 255, 255, 0.8),
        inset 0 -6px 20px rgba(184, 134, 11, 0.15);
    padding: 3.5rem 3.5rem;
    position: relative;
    max-width: 920px;
    width: 100%;
}

.panel::before {
    content: '';
    position: absolute;
    inset: -14px;
    border-radius: 3.5rem;
    border: 3px dashed rgba(46, 74, 46, 0.35);
    pointer-events: none;
}

/* ============================================================ */
/*  PANTALLA 1 · PRESENTACIÓN                                   */
/* ============================================================ */
.panel-presentacion {
    max-width: 900px;
    text-align: center;
}

.presentacion-hero {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.hero-abeja,
.hero-panal {
    height: 150px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.25));
    animation: flotar 3s ease-in-out infinite;
}

.hero-abeja { animation-delay: 0s; }
.hero-panal { animation-delay: 0.8s; }

@keyframes flotar {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-12px); }
}

.hero-texto {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.titulo-juego {
    font-size: clamp(3rem, 7vmin, 5.5rem);
    color: #2E4A2E;
    text-shadow:
        3px 3px 0 #FFD700,
        6px 6px 0 rgba(46, 74, 46, 0.25),
        0 12px 25px rgba(0, 0, 0, 0.15);
    letter-spacing: 2px;
    line-height: 1;
}

.subtitulo {
    font-size: clamp(1rem, 2.2vmin, 1.5rem);
    color: #4A5D4A;
    font-weight: 600;
    font-style: italic;
    line-height: 1.4;
}

.presentacion-elementos {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.2rem;
    margin-bottom: 2.5rem;
}

.elemento {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 1.2rem 0.8rem;
    background: linear-gradient(180deg, #FFF9E8 0%, #FFF1CE 100%);
    border-radius: 1.5rem;
    border: 3px solid #E8C46A;
    box-shadow: 0 6px 0 #D4A93C, inset 0 2px 6px rgba(255, 255, 255, 0.9);
    transition: transform 0.2s ease;
}

.elemento:hover {
    transform: translateY(-4px);
}

.elemento img {
    height: 70px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.2));
}

.elemento span {
    font-size: clamp(0.85rem, 1.5vmin, 1.05rem);
    font-weight: 700;
    color: #4A3B1F;
    text-align: center;
}

/* ============================================================ */
/*  PANTALLA 2 · CÓMO JUGAR                                     */
/* ============================================================ */
.panel-reglas {
    max-width: 950px;
}

.panel-reglas h2 {
    font-size: clamp(1.8rem, 4vmin, 2.8rem);
    color: #2E4A2E;
    text-align: center;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 0 #FFD700;
}

.lista-reglas {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-bottom: 2rem;
}

.lista-reglas li {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(46, 74, 46, 0.07);
    border-left: 6px solid #6FCF97;
    padding: 1rem 1.3rem;
    border-radius: 1.2rem;
    font-size: clamp(0.9rem, 1.7vmin, 1.15rem);
    color: #22321F;
    line-height: 1.45;
}

.lista-reglas .num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.4rem;
    height: 2.4rem;
    background: linear-gradient(180deg, #FFE55C 0%, #FFD700 100%);
    color: #2E4A2E;
    border-radius: 50%;
    font-weight: 800;
    font-size: 1.1rem;
    border: 3px solid #B38F2C;
    box-shadow: 0 3px 0 #B38F2C;
}

.lista-reglas strong {
    color: #1E7A5E;
}

.leyenda {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.3rem 1rem;
    background: #FFF6DC;
    border-radius: 1.5rem;
    border: 3px dashed #E8C46A;
}

.leyenda-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: #4A3B1F;
    font-size: clamp(0.75rem, 1.4vmin, 1rem);
    text-align: center;
}

.leyenda-item img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

/* ============================================================ */
/*  PANTALLA 3 · SELECCIÓN                                      */
/* ============================================================ */
.panel-config {
    max-width: 880px;
}

.panel-config h2 {
    font-size: clamp(1.8rem, 4vmin, 2.8rem);
    color: #2E4A2E;
    text-align: center;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 0 #FFD700;
}

.etiqueta-seccion {
    font-size: clamp(1rem, 2vmin, 1.3rem);
    font-weight: 700;
    color: #2E4A2E;
    margin-bottom: 0.9rem;
    text-align: center;
}

#selector-dificultad {
    background: rgba(46, 74, 46, 0.08);
    padding: 1.5rem 1.5rem 1.3rem;
    border-radius: 1.8rem;
    margin-bottom: 1.5rem;
    border: 3px dashed rgba(46, 74, 46, 0.35);
}

.botones-dificultad {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-dificultad {
    flex: 1;
    min-width: 130px;
    padding: 1rem 1.2rem;
    border-radius: 1.3rem;
    border: 3px solid #2E4A2E;
    background: #F5EFE6;
    color: #2E4A2E;
    font-weight: 800;
    font-size: clamp(1rem, 1.9vmin, 1.35rem);
    transition: all 0.18s ease;
    box-shadow: 0 6px 0 #B0A18A;
}

.btn-dificultad:hover {
    transform: translateY(-3px);
    box-shadow: 0 9px 0 #B0A18A;
    background: #FFF8E7;
}

.btn-dificultad:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #B0A18A;
}

.btn-dificultad.seleccionado {
    background: linear-gradient(180deg, #FFE55C 0%, #FFD700 100%);
    border-color: #B38F2C;
    box-shadow: 0 6px 0 #B38F2C, 0 0 25px rgba(255, 215, 0, 0.6);
    transform: scale(1.05);
}

.descripcion {
    text-align: center;
    margin-top: 1rem;
    font-size: clamp(0.85rem, 1.5vmin, 1.05rem);
    color: #4A5D4A;
    font-weight: 600;
    font-style: italic;
    min-height: 1.4em;
}

#selector-cuadricula {
    background: rgba(86, 204, 242, 0.12);
    padding: 1.5rem;
    border-radius: 1.8rem;
    margin-bottom: 1.5rem;
    border: 3px dashed rgba(31, 122, 156, 0.4);
}

.botones-cuadricula {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.9rem;
}

.btn-cuadricula {
    padding: 1.1rem 0.5rem;
    border-radius: 1.2rem;
    border: 3px solid #1F7A9C;
    background: #EAF7FC;
    color: #0F4C63;
    font-weight: 800;
    font-size: clamp(0.95rem, 1.7vmin, 1.25rem);
    transition: all 0.18s ease;
    box-shadow: 0 5px 0 #1F7A9C;
    letter-spacing: 1px;
}

.btn-cuadricula:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 0 #1F7A9C;
    background: #F5FBFF;
}

.btn-cuadricula:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #1F7A9C;
}

.btn-cuadricula.seleccionado {
    background: linear-gradient(180deg, #6FD3F5 0%, #56CCF2 100%);
    border-color: #0F4C63;
    color: #062C3A;
    box-shadow: 0 5px 0 #0F4C63, 0 0 25px rgba(86, 204, 242, 0.7);
    transform: scale(1.05);
}

/* ============================================================ */
/*  BOTONES DE MENÚ                                             */
/* ============================================================ */
.botones-menu {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.btn-panel {
    flex: 1;
    min-width: 180px;
    padding: 1.1rem 1.5rem;
    border-radius: 1.5rem;
    border: none;
    font-weight: 800;
    font-size: clamp(1rem, 2vmin, 1.4rem);
    background: #E8DCCC;
    color: #2E4A2E;
    box-shadow: 0 6px 0 #B0A18A;
    transition: all 0.12s ease;
    letter-spacing: 0.5px;
}

.btn-panel:hover {
    transform: translateY(-3px);
    box-shadow: 0 9px 0 #B0A18A;
    background: #F5EFE6;
}

.btn-panel:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #B0A18A;
}

.btn-panel.btn-primario {
    background: linear-gradient(180deg, #7FE0A8 0%, #6FCF97 100%);
    color: #0F3D2A;
    box-shadow: 0 6px 0 #2D7A4E;
}

.btn-panel.btn-primario:hover {
    background: linear-gradient(180deg, #8FE8B4 0%, #5BBF87 100%);
    box-shadow: 0 9px 0 #2D7A4E;
}

.btn-panel.btn-primario:active {
    box-shadow: 0 2px 0 #2D7A4E;
}

.btn-empezar {
    flex: 1;
    min-width: 180px;
    padding: 1.1rem 1.5rem;
    border-radius: 1.5rem;
    border: 4px solid #1E7A5E;
    background: linear-gradient(180deg, #FFE55C 0%, #FFC93C 100%);
    color: #0F3D2A;
    font-weight: 900;
    font-size: clamp(1.2rem, 2.3vmin, 1.6rem);
    box-shadow: 0 7px 0 #B38F2C, 0 0 30px rgba(255, 215, 0, 0.55);
    transition: all 0.12s ease;
    letter-spacing: 1px;
    animation: pulsoEmpezar 2.2s ease-in-out infinite;
}

@keyframes pulsoEmpezar {
    0%, 100% { box-shadow: 0 7px 0 #B38F2C, 0 0 20px rgba(255, 215, 0, 0.5); }
    50%      { box-shadow: 0 7px 0 #B38F2C, 0 0 40px rgba(255, 215, 0, 0.9); }
}

.btn-empezar:hover {
    transform: translateY(-3px);
    background: linear-gradient(180deg, #FFEF8A 0%, #FFD54F 100%);
}

.btn-empezar:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #B38F2C;
}

/* ============================================================ */
/*  PANTALLA 4 · JUEGO                                          */
/* ============================================================ */
#pantalla-juego {
    padding: 1.5vh 1.5vw;
}

#contenedor-juego {
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: 1800px;
    height: calc(100dvh - 3vh);
    gap: 1.5vw;
    align-items: center;
    justify-content: center;
}

#area-tablero {
    flex: 0 0 auto;
    background: rgba(222, 210, 190, 0.9);
    border-radius: 2rem;
    padding: 1rem;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.4),
        inset 0 0 0 5px #FFD700,
        inset 0 0 0 8px #B38F2C;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lienzo-juego {
    display: block;
    width: min(80vh, 62vw, 720px);
    height: min(80vh, 62vw, 720px);
    border-radius: 1.2rem;
    background: #b7ad97;
    box-shadow: inset 0 0 0 4px #8c7e64;
    image-rendering: pixelated;
    touch-action: none;
}

#panel-derecho {
    flex: 1;
    min-width: 260px;
    max-width: 480px;
    height: min(80vh, 62vw, 720px);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(255, 248, 235, 0.96);
    backdrop-filter: blur(12px);
    border-radius: 2rem;
    padding: 1.5rem 1.5rem 1.2rem;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.35),
        inset 0 3px 10px rgba(255, 255, 255, 0.8),
        inset 0 -6px 18px rgba(184, 134, 11, 0.12);
    border: 5px solid #FFD700;
}

/* --- Barra superior del panel --- */
#barra-superior-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

#barra-superior-panel h1 {
    flex: 1;
    font-size: clamp(1.3rem, 2.6vmin, 1.9rem);
    color: #2E4A2E;
    text-shadow: 2px 2px 0 #FFD700;
    text-align: center;
    line-height: 1;
    margin: 0;
}

.btn-mini {
    background: #E8DCCC;
    border: 2px solid #B0A18A;
    border-radius: 0.8rem;
    padding: 0.45rem 0.75rem;
    font-size: clamp(0.9rem, 1.6vmin, 1.1rem);
    font-weight: 700;
    color: #2E4A2E;
    box-shadow: 0 3px 0 #B0A18A;
    transition: all 0.1s ease;
    white-space: nowrap;
    line-height: 1;
}

.btn-mini:hover {
    background: #F5EFE6;
    transform: translateY(-2px);
    box-shadow: 0 5px 0 #B0A18A;
}

.btn-mini:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #B0A18A;
}

/* ============================================================ */
/*  INDICADORES DEL JUEGO                                       */
/* ============================================================ */
#info-nivel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(180deg, #FFE55C 0%, #FFD700 100%);
    padding: 0.55rem 1rem;
    border-radius: 1.2rem;
    font-size: clamp(0.85rem, 1.6vmin, 1.15rem);
    font-weight: 800;
    color: #2E4A2E;
    border: 3px solid #B38F2C;
    box-shadow: 0 4px 0 #B38F2C;
    flex-wrap: wrap;
}

#nivel-actual,
#dificultad-actual {
    background: white;
    padding: 0.1rem 0.7rem;
    border-radius: 0.6rem;
    color: #2E4A2E;
}

#temporizador {
    background: #FF6B6B;
    color: white;
    padding: 0.25rem 0.8rem;
    border-radius: 0.6rem;
    font-weight: 800;
    font-size: clamp(0.85rem, 1.6vmin, 1.15rem);
    display: none;
    border: 2px solid #B13E3E;
}

#estadisticas {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 0.4rem;
    background: #2E4A2E;
    padding: 0.7rem 0.6rem;
    border-radius: 1.2rem;
    border: 3px solid #FFD700;
    box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.35);
}

.stat-item {
    color: #F5EFE6;
    font-size: clamp(0.75rem, 1.4vmin, 1.05rem);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 0.7rem;
    white-space: nowrap;
}

.stat-item strong {
    color: #FFD966;
    font-size: clamp(0.9rem, 1.8vmin, 1.35rem);
}

#total-cajas {
    color: #6fcf97;
    font-weight: 800;
}

#estado-robot {
    background: #3A5A3A;
    color: white;
    padding: 0.55rem 1rem;
    border-radius: 1.2rem;
    font-size: clamp(0.85rem, 1.6vmin, 1.15rem);
    font-weight: 600;
    text-align: center;
    box-shadow: 0 4px 0 #1A2A1A;
}

#estado-robot span {
    background: #FFD966;
    color: #1F2E1F;
    padding: 0.1rem 0.7rem;
    border-radius: 0.6rem;
    margin: 0 0.15rem;
    font-weight: 700;
}

#carga-actual {
    background: #F4B942 !important;
    font-weight: 800;
}

#mensaje-accion {
    background: #E8DCCC;
    padding: 0.7rem 1rem;
    border-radius: 1.2rem;
    border: 3px dashed #8C7E64;
    text-align: center;
    min-height: 3.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

#mensaje-flotante {
    font-size: clamp(0.85rem, 1.6vmin, 1.15rem);
    font-weight: 700;
    color: #1E2B39;
    line-height: 1.3;
}

/* ============================================================ */
/*  CRUCETA DE CONTROLES (BOTONES CON IMÁGENES)                 */
/* ============================================================ */
#cruceta-controles {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0.7rem;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    aspect-ratio: 3 / 2;
    flex-shrink: 0;
}

.btn-cruz {
    background: linear-gradient(180deg, #FFF9E8 0%, #F5E6C0 100%);
    border: 3px solid #B38F2C;
    border-radius: 1rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.1s ease;
    box-shadow: 0 5px 0 #B38F2C, 0 8px 16px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.btn-cruz img {
    width: 75%;
    height: 75%;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}

.btn-cruz:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 7px 0 #B38F2C, 0 10px 20px rgba(0, 0, 0, 0.22);
    background: linear-gradient(180deg, #FFFBEE 0%, #FCEEC8 100%);
}

.btn-cruz:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #B38F2C;
}

.btn-cruz:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 0 #B38F2C;
    filter: grayscale(0.5);
}

/* Posiciones en la cruceta */
.btn-cruz-arriba    { grid-column: 2; grid-row: 1; }
.btn-cruz-izquierda { grid-column: 1; grid-row: 2; }
.btn-cruz-derecha   { grid-column: 3; grid-row: 2; }
.btn-cruz-abajo     { grid-column: 2; grid-row: 2; }

#ayuda-teclado {
    text-align: center;
    font-size: clamp(0.7rem, 1.2vmin, 0.95rem);
    color: #3F3A30;
    background: rgba(255, 255, 255, 0.55);
    padding: 0.4rem 0.8rem;
    border-radius: 1rem;
    font-weight: 600;
}

/* ============================================================ */
/*  MODAL                                                       */
/* ============================================================ */
#modal-fin {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    animation: aparecerModal 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 2vh 2vw;
}

@keyframes aparecerModal {
    0%   { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

#modal-contenido {
    background: #FFFBF2;
    max-width: 560px;
    width: 92%;
    padding: 2.5rem 2.5rem;
    border-radius: 2.5rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 0 6px #FFD700;
    text-align: center;
    animation: latidoSuave 2.5s infinite ease-in-out;
    max-height: 95dvh;
    overflow-y: auto;
}

@keyframes latidoSuave {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.01); }
}

#modal-titulo {
    font-size: clamp(1.8rem, 4vmin, 2.8rem);
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 0 #FFE49E;
    color: #1E7A5E;
}

#modal-mensaje-refuerzo {
    font-size: clamp(1rem, 2vmin, 1.4rem);
    font-weight: 700;
    color: #1F4B6E;
    background: #F6E9D2;
    padding: 0.7rem 1rem;
    border-radius: 1.2rem;
    margin: 0.6rem 0 1.4rem;
    border: 3px solid #D9B382;
}

#modal-estadisticas {
    background: #ECDFCD;
    border-radius: 1.3rem;
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: clamp(0.9rem, 1.6vmin, 1.15rem);
    line-height: 2;
    margin: 1rem 0;
    border: 3px solid #B7A084;
}

#modal-estadisticas p {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px dashed #B7A084;
}

#modal-estadisticas p:last-child {
    border-bottom: none;
}

#modal-estadisticas span {
    font-weight: 800;
    color: #A33327;
    background: white;
    padding: 0 0.9rem;
    border-radius: 0.6rem;
}

#modal-consejo {
    background: #D4E3FD;
    border-radius: 1.3rem;
    padding: 0.9rem 1.3rem;
    margin: 1rem 0 1.5rem;
    border-left: 8px solid #1E6F9F;
    text-align: left;
    font-size: clamp(0.85rem, 1.4vmin, 1.05rem);
    color: #10354B;
}

#modal-consejo strong {
    display: block;
    font-size: clamp(0.95rem, 1.7vmin, 1.2rem);
    margin-bottom: 0.3rem;
    color: #003153;
}

#boton-reiniciar {
    background: linear-gradient(180deg, #FFC966 0%, #FFB347 100%);
    border: none;
    font-size: clamp(1.2rem, 2.4vmin, 1.7rem);
    font-weight: 800;
    color: #1F2A36;
    padding: 1rem 1.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 6px 0 #B16D1A;
    cursor: pointer;
    transition: all 0.07s ease;
    width: 100%;
    letter-spacing: 0.5px;
}

#boton-reiniciar:hover {
    background: linear-gradient(180deg, #FFD27F 0%, #FCA130 100%);
    transform: translateY(-3px);
    box-shadow: 0 9px 0 #B16D1A;
}

#boton-reiniciar:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #B16D1A;
}

/* ============================================================ */
/*  RESPONSIVE                                                  */
/* ============================================================ */

/* --- Tablets grandes y portátiles --- */
@media (max-width: 1200px) {
    #contenedor-juego {
        gap: 1vw;
    }

    #panel-derecho {
        max-width: 420px;
        padding: 1.2rem;
    }

    .hero-abeja,
    .hero-panal {
        height: 120px;
    }
}

/* --- Apilado vertical --- */
@media (max-width: 950px) {
    #pantalla-juego {
        padding: 1vh 2vw;
        align-items: flex-start;
    }

    #contenedor-juego {
        flex-direction: column;
        height: auto;
        gap: 1rem;
        padding: 1vh 0 2vh;
    }

    #area-tablero {
        padding: 0.8rem;
        border-radius: 1.5rem;
    }

    #lienzo-juego {
        width: min(72vh, 90vw, 560px);
        height: min(72vh, 90vw, 560px);
    }

    #panel-derecho {
        width: 100%;
        max-width: 620px;
        height: auto;
        border-radius: 1.5rem;
        padding: 1rem;
        gap: 0.75rem;
    }

    .panel {
        padding: 2.5rem 2rem;
        border-radius: 2rem;
    }

    .presentacion-hero {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .hero-abeja,
    .hero-panal {
        height: 100px;
        margin: 0 auto;
    }

    .hero-texto {
        order: -1;
    }

    .leyenda {
        grid-template-columns: repeat(2, 1fr);
    }

    #cruceta-controles {
        max-width: 280px;
    }
}

/* --- Móviles --- */
@media (max-width: 600px) {
    .pantalla {
        padding: 2vh 3vw;
    }

    .panel {
        padding: 1.8rem 1.3rem;
        border-radius: 1.5rem;
        border-width: 4px;
    }

    .panel::before {
        inset: -8px;
        border-radius: 1.8rem;
    }

    .titulo-juego {
        font-size: clamp(2rem, 10vmin, 3rem);
    }

    .subtitulo {
        font-size: 0.95rem;
    }

    .presentacion-hero {
        gap: 0.7rem;
        margin-bottom: 1.5rem;
    }

    .hero-abeja,
    .hero-panal {
        height: 80px;
    }

    .presentacion-elementos {
        grid-template-columns: 1fr;
        gap: 0.7rem;
        margin-bottom: 1.5rem;
    }

    .elemento {
        flex-direction: row;
        justify-content: flex-start;
        gap: 1rem;
        padding: 0.8rem 1rem;
    }

    .elemento img {
        height: 45px;
    }

    .panel-reglas h2,
    .panel-config h2 {
        font-size: 1.5rem;
        margin-bottom: 1.2rem;
    }

    .lista-reglas li {
        font-size: 0.85rem;
        padding: 0.7rem 0.9rem;
        gap: 0.7rem;
    }

    .lista-reglas .num {
        width: 1.9rem;
        height: 1.9rem;
        font-size: 0.9rem;
    }

    .leyenda {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.7rem;
        padding: 0.8rem;
    }

    .leyenda-item img {
        width: 40px;
        height: 40px;
    }

    .botones-cuadricula {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .btn-cuadricula {
        padding: 0.9rem 0.4rem;
        font-size: 0.95rem;
    }

    .btn-dificultad {
        min-width: 90px;
        padding: 0.8rem 0.6rem;
        font-size: 0.9rem;
    }

    .botones-menu {
        flex-direction: column;
        gap: 0.7rem;
    }

    .btn-panel,
    .btn-empezar {
        min-width: 100%;
        padding: 0.9rem 1rem;
        font-size: 1.05rem;
    }

    /* Juego en móvil */
    #barra-superior-panel h1 {
        font-size: 1.1rem;
    }

    .btn-mini {
        padding: 0.35rem 0.55rem;
        font-size: 0.85rem;
    }

    #info-nivel {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
        gap: 0.3rem;
    }

    #estadisticas {
        padding: 0.5rem 0.4rem;
        gap: 0.3rem;
    }

    .stat-item {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }

    #estado-robot {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }

    #mensaje-accion {
        min-height: 2.6rem;
        padding: 0.5rem 0.7rem;
    }

    #mensaje-flotante {
        font-size: 0.78rem;
    }

    #cruceta-controles {
        max-width: 240px;
        gap: 0.5rem;
    }

    .btn-cruz {
        border-radius: 0.8rem;
        box-shadow: 0 4px 0 #B38F2C, 0 6px 12px rgba(0, 0, 0, 0.18);
    }

    #ayuda-teclado {
        font-size: 0.65rem;
        padding: 0.3rem 0.5rem;
    }

    #modal-contenido {
        padding: 1.8rem 1.3rem;
        border-radius: 1.5rem;
    }

    #modal-titulo {
        font-size: 1.5rem;
    }

    #modal-estadisticas {
        font-size: 0.85rem;
        padding: 0.8rem 1rem;
        line-height: 1.9;
    }

    #boton-reiniciar {
        font-size: 1.1rem;
        padding: 0.9rem 1rem;
    }
}

/* --- Landscape móvil --- */
@media (max-height: 520px) and (orientation: landscape) {
    #pantalla-juego {
        padding: 0.8vh 1.5vw;
    }

    #contenedor-juego {
        flex-direction: row;
        height: calc(100dvh - 1.6vh);
        gap: 1vw;
    }

    #lienzo-juego {
        width: min(94vh, 62vw);
        height: min(94vh, 62vw);
    }

    #panel-derecho {
        height: min(94vh, 62vw);
        padding: 0.8rem;
        gap: 0.5rem;
    }

    #barra-superior-panel h1 {
        font-size: 1rem;
    }

    #estadisticas {
        padding: 0.4rem;
    }

    .stat-item {
        font-size: 0.7rem;
        padding: 0.15rem 0.4rem;
    }

    #estado-robot {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }

    #mensaje-accion {
        min-height: 2rem;
        padding: 0.4rem;
    }

    #cruceta-controles {
        max-width: 220px;
        gap: 0.4rem;
    }

    #ayuda-teclado {
        display: none;
    }
}

/* --- Pantallas grandes 1920x1080 --- */
@media (min-width: 1600px) and (min-height: 900px) {
    #lienzo-juego {
        width: min(82vh, 62vw, 780px);
        height: min(82vh, 62vw, 780px);
    }

    #panel-derecho {
        height: min(82vh, 62vw, 780px);
        max-width: 520px;
        padding: 1.8rem 1.8rem 1.5rem;
        gap: 1.15rem;
    }

    #cruceta-controles {
        max-width: 340px;
    }

    .panel {
        padding: 4rem 4rem;
    }

    .lista-reglas li {
        padding: 1.1rem 1.5rem;
    }
}