/* ===== Base ===== */

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(180deg, rgba(215, 247, 193, 0.9), rgba(168, 230, 207, 0.9)), url('img/fondo-agricola.jpg');
    /* 🌾 pon aquí tu imagen de campo */
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    animation: gradientShift 12s ease infinite;
    text-align: center;
    color: #0a1c4d;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 20px 0 5px;
}

#positionText {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
}


/* ===== Tablero ===== */

#board-container {
    position: relative;
    width: 95vmin;
    max-width: 650px;
    aspect-ratio: 1/1;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    background: #fff;
}

#board {
    width: 100%;
    height: 100%;
    background-image: url('TABLERO 2.jpg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}


/* ===== Dado ===== */

.dice-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dice {
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.4rem;
    font-weight: 700;
    color: #000;
    border: 3px solid #2b2b2b;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.8s ease, box-shadow 0.3s ease;
}

.dice.roll {
    animation: rollDice 0.8s ease;
}

@keyframes rollDice {
    0% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(180deg) scale(1.2);
    }
    50% {
        transform: rotate(360deg) scale(0.9);
    }
    75% {
        transform: rotate(540deg) scale(1.1);
    }
    100% {
        transform: rotate(720deg) scale(1);
    }
}

button {
    margin-top: 15px;
    background-color: #1a2e7b;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: 0.3s;
}

button:hover {
    background-color: #2741a5;
    transform: translateY(-2px);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#winner {
    font-size: 1.8rem;
    color: #00b66c;
    font-weight: bold;
    margin-top: 20px;
    display: none;
}


/* ===== Mensaje flotante ===== */

#floatingMessage {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(10, 28, 77, 0.95);
    color: white;
    padding: 30px 40px;
    border-radius: 20px;
    font-size: 1.7rem;
    font-weight: 600;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#floatingMessage.show {
    opacity: 1;
    pointer-events: auto;
}


/* ===== Overlay tarjetas (amarilla/verde) ===== */

#questionOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#questionCard {
    width: min(92vw, 540px);
    border-radius: 18px;
    overflow: hidden;
    background: #0a1c4d;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

#questionImg {
    width: 100%;
    height: auto;
    display: block;
}

.dotLoader {
    position: absolute;
    right: 18px;
    top: 18px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #ffe29a;
    opacity: 0;
    animation: blink 0.8s infinite;
}

@keyframes blink {
    0%,
    100% {
        opacity: 0.2
    }
    50% {
        opacity: 1
    }
}


/* ===== Modal de preguntas (color por categoría en TODO el fondo) ===== */

#quizModal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}

.quiz-card {
    --cat: #0a3a37;
    /* valor por defecto; JS lo reemplaza */
    background: var(--cat);
    /* ← fondo del modal según categoría */
    color: #fff;
    width: min(92vw, 560px);
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}


/* Encabezado tipográfico */

.quiz-banner {
    background: var(--cat);
    border-radius: 14px;
    padding: 10px 12px 14px;
    border: 2px solid rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.banner-title {
    text-align: center;
    font-weight: 800;
    letter-spacing: 2px;
    font-size: 1.4rem;
    color: #fff;
}

.banner-center {
    display: flex;
    justify-content: center;
    padding: 6px 0 2px;
}

.q-badge {
    width: 78px;
    height: 78px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .18);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 900;
    font-size: 2.6rem;
    line-height: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}

.banner-brand {
    text-align: center;
    margin-top: 4px;
}

.brand-scia {
    display: block;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: #fff;
}

.brand-ing {
    display: block;
    font-size: .95rem;
    letter-spacing: 3px;
    color: #fff;
    opacity: .9;
}


/* Texto y opciones */

.quiz-card h3 {
    margin: 10px 0 6px 0;
    font-size: 1rem;
    opacity: .95;
    letter-spacing: .5px;
    color: #fff;
}

.quiz-card p {
    margin: 6px 0 14px 0;
    font-size: 1.15rem;
    color: #fff;
}

#quizOptions button {
    width: 100%;
    text-align: left;
    margin: 8px 0;
    padding: 12px 14px;
    border-radius: 12px;
    border: 0;
    background: rgba(0, 0, 0, .22);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: filter .15s ease, transform .05s ease-in-out;
}

#quizOptions button:hover {
    filter: brightness(1.1);
}

#quizOptions button:active {
    transform: scale(.995);
}

#quizOptions button.correct {
    background: rgba(12, 150, 80, .9);
}

#quizOptions button.wrong {
    background: rgba(178, 0, 0, .9);
}

#quizFeedback {
    margin-top: 10px;
    min-height: 20px;
    font-weight: 700;
    color: #fff;
}

#quizContinueBtn {
    margin-top: 12px;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-weight: 800;
    border: 2px solid rgba(255, 255, 255, .35);
    padding: 10px 14px;
    border-radius: 12px;
    cursor: pointer;
}

#quizContinueBtn:hover {
    filter: brightness(1.05);
}


/* === Cards de categorías (vista inicial) === */


/* === Pantalla de selección de categoría === */

.category-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, #e6efff 0%, #cde0ff 100%);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 40px 20px;
}

.category-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 40px;
    max-width: 1200px;
    width: 100%;
}

.category-left {
    flex: 1 1 650px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.category-title {
    font-size: 2rem;
    font-weight: 800;
    color: #0a1c4d;
    text-align: center;
    margin-bottom: 30px;
    letter-spacing: 1px;
    border-bottom: 4px solid #1a2e7b;
    padding-bottom: 10px;
    width: 100%;
    max-width: 480px;
}

.category-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 25px;
    width: 95%;
    max-width: 800px;
    justify-items: center;
}


/* === Cards individuales === */


/* === Fondo general === */

.category-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, #eaf3ff 0%, #cde0ff 100%);
    display: none;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 50px 20px;
    z-index: 999;
}


/* === Contenedor general === */

.category-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}


/* === Título y subtítulo === */

.category-title {
    font-size: 2.4rem;
    font-weight: 800;
    color: #0a1c4d;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.category-subtitle {
    color: #3a4a8a;
    font-size: 1.15rem;
    margin-bottom: 30px;
    font-weight: 500;
    max-width: 700px;
}


/* === Cafeto === */

.cafeto-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 40px;
    animation: fadeIn 1s ease-in-out;
}

.cafeto-img {
    width: 220px;
    /* tamaño base */
    max-width: 35vw;
    /* para que se adapte según el ancho del viewport */
    height: auto;
    animation: cafetoFloat 3s ease-in-out infinite;
    filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.25));
    background: transparent;
    /* asegurar que fondo sea transparente */
}

@keyframes cafetoFloat {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

.cafeto-bubble {
    margin-top: 12px;
    background: #ffffff;
    border-radius: 20px;
    padding: 12px 18px;
    max-width: 260px;
    font-weight: 600;
    color: #0a1c4d;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
    border: 2px solid #0074cc;
    font-size: 0.95rem;
    position: relative;
}

.cafeto-bubble::after {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 10px 10px 10px;
    border-style: solid;
    border-color: transparent transparent #ffffff transparent;
}


/* === Cards === */


/* === Cards de Categoría (optimizadas para alta calidad) === */

.category-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 25px;
    width: 95%;
    max-width: 950px;
    justify-items: center;
}

.category-card {
    width: 100%;
    max-width: 260px;
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
}

.category-card:hover {
    transform: scale(1.06);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
}


/* 📸 Imagen de la card con calidad alta */

.category-card .card-image {
    width: 100%;
    height: 180px;
    overflow: hidden;
    position: relative;
    background-color: #f4f6fb;
}

.category-card .card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* mantiene proporciones correctas */
    object-position: center;
    transition: transform 0.5s ease, filter 0.3s ease;
    /* 💎 Mejor nitidez y calidad en pantallas retina */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    backface-visibility: hidden;
    transform: translateZ(0);
    /* fuerza renderizado en GPU */
}

.category-card:hover .card-image img {
    transform: scale(1.07);
    filter: brightness(1.08);
}


/* 🏷️ Texto inferior de la card */

.category-card .card-info {
    padding: 16px 10px;
    text-align: center;
    color: white;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-top: 2px solid rgba(255, 255, 255, 0.3);
}


/* === Animación de entrada === */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* === Responsivo === */

@media (max-width: 768px) {
    .category-title {
        font-size: 1.8rem;
    }
    .cafeto-img {
        width: 160px;
    }
    .cafeto-bubble {
        font-size: 0.85rem;
        max-width: 200px;
    }
    .category-subtitle {
        font-size: 1rem;
    }
}


/* === Pantalla de Victoria Mejorada === */

#victoryScreen {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, #a8e6cf 0%, #81c784 100%);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    text-align: center;
    padding: 30px;
    color: #fff;
    overflow: hidden;
    animation: victoryFadeIn 1s ease forwards;
}


/* 🌿 Animación de entrada */

@keyframes victoryFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}


/* 🌾 Fondo dinámico */

#victoryScreen::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url('img/fondo-agricola.jpg') center/cover no-repeat;
    opacity: 0.2;
    z-index: -2;
}

#victoryScreen::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top, rgba(255, 255, 255, 0.2), transparent 70%);
    animation: lightPulse 6s infinite ease-in-out;
    z-index: -1;
}

@keyframes lightPulse {
    0%,
    100% {
        opacity: 0.3;
    }
    50% {
        opacity: 0.7;
    }
}


/* 🎉 Título principal */

.victory-title {
    font-size: 3rem;
    font-weight: 900;
    color: #1b5e20;
    text-shadow: 0 4px 10px rgba(255, 255, 255, 0.5);
    margin-bottom: 10px;
}


/* 🌟 Subtítulo */

.victory-subtitle {
    font-size: 1.5rem;
    color: #f1f8e9;
    font-weight: 600;
    margin-bottom: 25px;
}


/* 🧍‍♂️ Cafeto animado */

.victory-cafeto {
    width: 180px;
    height: auto;
    animation: cafetoCelebrate 3s ease-in-out infinite;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.25));
}

@keyframes cafetoCelebrate {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px) rotate(3deg);
    }
}


/* 🎊 Botón final */

.victory-btn {
    background: #ffffff;
    color: #2e7d32;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.victory-btn:hover {
    transform: scale(1.05);
    background: #f1f8e9;
}