/* VARIABLES DE COLOR - Estilo Verde y Amarillo del Barrio */
:root {
    --verde-figueroa: #1b5e20;
    --verde-oscuro: #0d3b14;
    --verde-claro: #2e7d32;
    --amarillo-figueroa: #fdd835;
    --amarillo-brillante: #ffee58;
    --blanco: #ffffff;
    --oscuro-fondo: #091d0c;
    --oscuro-card: #122e16;
    --oscuro-panel: #193d1e;
    --dorado: #ffd700;
    --gris-texto: #c8e6c9;

    /* Paleta diferenciada para la escala de escalones superior */
    --escalon-fondo: linear-gradient(180deg, #102a38 0%, #0a1b24 100%);
    --escalon-borde: #38bdf8;
    --escalon-item: rgba(255, 255, 255, 0.05);
    --escalon-texto: #94b8c8;
    --escalon-step-fondo: rgba(56, 189, 248, 0.14);
    --escalon-step-texto: #7dd3fc;
    --escalon-step-borde: rgba(56, 189, 248, 0.45);
}

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

html,
body {
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    width: 100dvw;
    max-width: 100%;
    overflow: hidden;
    background-color: var(--oscuro-fondo);
    color: var(--blanco);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

/* CONTENEDORES */
.container {
    width: 100%;
    height: 100%;
    max-width: 1120px;
    max-height: 100vh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding-top: 8px;
    gap: 6px;
    overflow: hidden;
}

.oculto {
    display: none !important;
}

.imagen-inicio {
    height: 62vh;
    height: 62dvh;
    max-height: 62vh;
    max-height: 62dvh;
    max-width: 95%;
    width: auto;
    object-fit: contain;
    border-radius: 12px;
    flex-shrink: 0;
}

#confeti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    pointer-events: none;
    z-index: 999;
}

/* TARJETAS (CARDS) */
.card {
    background: var(--oscuro-card);
    padding: 12px;
    border-radius: 14px;
    border: 2px solid var(--amarillo-figueroa);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
    text-align: center;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
}

/* PANTALLA PRINCIPAL: ESCALONES GRANDES ARRIBA Y JUEGO DEBAJO */
.pantalla-principal {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    flex: 1;
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
}

/* ESCALONES GRANDES EN VERTICAL ARRIBA */
.sidebar {
    order: -1;
    width: 100%;
    max-height: 36vh;
    max-height: 36dvh;
    min-height: 145px;
    background: var(--escalon-fondo);
    padding: 8px 14px;
    border-radius: 12px;
    border: 2px solid var(--escalon-borde);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column-reverse;
    gap: 4px;
    width: 100%;
}

.sidebar li {
    padding: 6px 12px;
    background: var(--escalon-item);
    color: var(--escalon-texto);
    border-radius: 7px;
    font-weight: bold;
    font-size: clamp(0.8rem, 1.25vw, 1.02rem);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
    border: 1px solid rgba(56, 189, 248, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.sidebar li.step {
    background: var(--escalon-step-fondo);
    color: var(--escalon-step-texto);
    border-color: var(--escalon-step-borde);
}

.sidebar li.activo {
    background: #f97316;
    color: #ffffff !important;
    border: 1px solid #fdba74;
    box-shadow: 0 0 14px rgba(249, 115, 22, 0.7);
}

/* CAJA DE PREGUNTAS DEBAJO */
.juego-box {
    flex: 1;
    min-height: 0;
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 5px;
    overflow: hidden;
}

.header-juego {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    padding-bottom: 2px;
    border-bottom: 1px solid rgba(253, 216, 53, 0.3);
    color: var(--amarillo-figueroa);
    font-weight: bold;
    text-transform: uppercase;
    font-size: clamp(0.64rem, 0.95vw, 0.8rem);
    flex-shrink: 0;
}

.header-juego > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* BOTÓN DE AUDIO EN CABECERA */
.btn-audio {
    background: var(--verde-oscuro);
    color: var(--amarillo-figueroa);
    border: 1.5px solid var(--amarillo-figueroa);
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 0.78rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    .btn-audio:hover {
        background: var(--amarillo-figueroa);
        color: var(--verde-oscuro);
    }
}

/* CRONÓMETRO */
#cronometro-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    margin: 0;
}

#display-tiempo {
    font-size: clamp(0.8rem, 1.3vw, 1.02rem);
    font-weight: 700;
    font-family: 'Courier New', Courier, monospace;
    color: var(--amarillo-figueroa);
    background: #061408;
    padding: 3px 10px;
    border-radius: 9px;
    border: 2px solid var(--verde-claro);
    box-shadow: 0 0 10px rgba(253, 216, 53, 0.2);
    white-space: nowrap;
    text-align: center;
    transition: all 0.25s ease;
}

#display-tiempo.urgente {
    color: #ff5252;
    border-color: #ff5252;
    box-shadow: 0 0 16px rgba(255, 82, 82, 0.55);
    animation: parpadeo 0.5s infinite;
}

@keyframes parpadeo {
    0% { opacity: 1; }
    50% { opacity: 0.65; }
    100% { opacity: 1; }
}

/* CAJA DE AYUDAS Y BOTONES */
#comodines {
    margin: 0;
    padding: 0;
    height: 42px;
    min-height: 42px;
    max-height: 42px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 10px;
    flex-shrink: 0;
}

.btn-ayuda {
    background: var(--verde-oscuro);
    color: var(--amarillo-figueroa);
    border: 2px solid var(--amarillo-figueroa);
    flex: 1;
    max-width: 240px;
    min-width: 0;
    width: auto;
    height: 100%;
    padding: 0 14px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    .btn-ayuda:hover:not(:disabled) {
        background: var(--amarillo-figueroa);
        color: var(--verde-oscuro);
    }
}

.btn-ayuda.usado {
    border-color: #4b634d;
    color: #6b8e6e;
    cursor: not-allowed;
    opacity: 0.45;
}

/* CAJA DE PREGUNTA */
.pregunta-box {
    background: var(--oscuro-panel);
    padding: 8px 12px;
    border-radius: 10px;
    border-left: 5px solid var(--amarillo-figueroa);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pregunta-box h2 {
    font-size: clamp(1rem, 2.2vw, 1.65rem);
    line-height: 1.2;
    text-align: center;
}

/* GRILLA DE OPCIONES */
.opciones-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    flex: 1;
    min-height: 0;
}

.btn-opcion {
    background: var(--verde-oscuro);
    color: var(--blanco);
    border: 2px solid var(--verde-claro);
    padding: 6px 10px;
    min-height: 0;
    border-radius: 10px;
    cursor: pointer;
    font-size: clamp(0.8rem, 1.15vw, 0.96rem);
    line-height: 1.15;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    display: flex;
    align-items: center;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

@media (hover: hover) {
    .btn-opcion:hover:not(:disabled) {
        background: var(--amarillo-figueroa);
        color: var(--verde-oscuro);
        border-color: var(--amarillo-brillante);
    }
}

.btn-opcion:active:not(:disabled) {
    background: var(--amarillo-figueroa);
    color: var(--verde-oscuro);
    border-color: var(--amarillo-brillante);
}

.btn-opcion span {
    margin-left: 6px;
    font-weight: bold;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* PANTALLA INICIAL Y GAME OVER */
#pantalla-inicio,
#pantalla-gameover {
    max-width: 600px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#pantalla-inicio {
    padding: 10px 14px;
    max-width: 560px;
}

#pantalla-inicio h1 {
    font-size: clamp(1.25rem, 2.5vw, 1.8rem);
    margin-bottom: 6px;
}

#pantalla-inicio p {
    font-size: clamp(0.8rem, 1.2vw, 0.95rem);
}

.txt-rojo {
    color: var(--amarillo-figueroa);
}

input[type="text"] {
    width: 100%;
    max-width: 380px;
    padding: 10px 16px;
    margin: 10px 0;
    border-radius: 25px;
    border: 2px solid var(--verde-claro);
    background: var(--oscuro-panel);
    color: var(--blanco);
    font-size: 16px;
    outline: none;
}

input[type="text"]:focus {
    border-color: var(--amarillo-figueroa);
}

.btn-principal {
    background: var(--amarillo-figueroa);
    color: var(--verde-oscuro);
    padding: 11px 28px;
    border: none;
    border-radius: 30px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    .btn-principal:hover {
        background: var(--amarillo-brillante);
        transform: translateY(-2px);
    }
}

#pantalla-gameover h1 {
    font-size: clamp(1.8rem, 3.5vw, 2.6rem);
    margin-bottom: 14px;
    color: var(--amarillo-figueroa);
    text-shadow: 0 0 18px rgba(253, 216, 53, 0.45);
}

#mensaje-perdida {
    font-size: clamp(0.95rem, 1.5vw, 1.15rem);
    margin-bottom: 22px;
    color: var(--gris-texto);
}

/* TEXTO PEQUEÑO ABAJO DEL TODO */
.pie-web {
    flex-shrink: 0;
    font-size: 0.72rem;
    line-height: 1;
    color: var(--gris-texto);
    opacity: 0.8;
    text-align: center;
    padding: 2px 0;
    letter-spacing: 0.4px;
}

/* AJUSTES EN MÓVILES Y PANTALLAS MEDIANAS */
@media (max-width: 768px) {
    html,
    body {
        height: auto;
        min-height: 100dvh;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        overflow-y: auto;
    }

    body {
        display: block;
        padding: 6px;
    }

    .container {
        height: auto;
        min-height: 100dvh;
        max-height: none;
        width: 100%;
        max-width: 100%;
        justify-content: flex-start;
        padding-top: 6px;
        gap: 6px;
        overflow: visible;
    }

    .imagen-inicio {
        height: auto;
        max-height: 46dvh;
        width: auto;
        max-width: 92%;
    }

    .sidebar {
        max-height: 30dvh;
        min-height: 120px;
        padding: 6px 10px;
    }

    .sidebar li {
        font-size: 0.78rem;
        padding: 4px 8px;
    }

    .pregunta-box h2 {
        font-size: 1rem;
    }

    .opciones-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .btn-opcion {
        padding: 8px 10px;
        font-size: 0.86rem;
    }

    .btn-opcion:hover:not(:disabled),
    .btn-opcion:focus:not(:disabled) {
        background: var(--verde-oscuro);
        color: var(--blanco);
        border-color: var(--verde-claro);
    }

    .btn-opcion:active:not(:disabled) {
        background: var(--amarillo-figueroa);
        color: var(--verde-oscuro);
        border-color: var(--amarillo-brillante);
    }
}