/* Variables de Diseño y Colores */
:root {
    --bg-primary: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --bg-card: rgba(255, 255, 255, 0.9);
    --color-text: #2c3e50;
    --color-muted: #57606f;
    --color-white: #ffffff;
    
    /* Colores infantiles */
    --color-yellow: #ffa502;
    --color-pink: #ff6b81;
    --color-blue: #1e90ff;
    --color-purple: #9b59b6;
    --color-border: #ced6e0;
    --color-shadow: rgba(0, 0, 0, 0.12);
    
    --font-main: 'Fredoka', 'Nunito', sans-serif;
}

/* Reset y Estilos Generales */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    overflow-x: hidden;
}

/* Contenedor Principal (Optimizado para Proyectores) */
#app-container {
    width: 98vw;
    max-width: 1250px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 40px;
    border: 8px solid var(--color-white);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Encabezado */
header {
    background: linear-gradient(90deg, #11998e 0%, #38ef7d 100%);
    padding: 18px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 6px solid #28b463;
    color: var(--color-white);
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo i {
    font-size: 2.8rem;
    color: var(--color-yellow);
    filter: drop-shadow(2px 2px 0px rgba(0,0,0,0.2));
}

.logo h1 {
    font-size: 2.3rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.25);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.score-box {
    font-size: 1.5rem;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 22px;
    border-radius: 20px;
    border: 2px solid rgba(255,255,255,0.4);
    display: flex;
    align-items: center;
    gap: 10px;
}

.text-yellow {
    color: var(--color-yellow);
}

/* Botón de control del docente */
.teacher-toggle-btn {
    font-family: var(--font-main);
    font-size: 1.25rem;
    font-weight: 700;
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    background-color: var(--color-yellow);
    color: var(--color-white);
    box-shadow: 0 5px 0px #b87b00;
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.teacher-toggle-btn:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0px #b87b00;
}

/* --- PANEL FLOTANTE DEL DOCENTE --- */
.teacher-panel {
    position: absolute;
    top: 90px;
    right: -420px; /* Escondido a la derecha */
    width: 400px;
    background: rgba(44, 62, 80, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-left: 5px solid var(--color-yellow);
    border-top: 2px solid rgba(255,255,255,0.1);
    border-bottom: 2px solid rgba(255,255,255,0.1);
    border-radius: 0 0 0 25px;
    box-shadow: -10px 10px 30px rgba(0,0,0,0.3);
    z-index: 500;
    transition: right 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: var(--color-white);
}

.teacher-panel.open {
    right: 0;
}

.teacher-panel-header {
    padding: 15px 20px;
    background: #1a252f;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0 0 0 0;
}

.teacher-panel-header h3 {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-yellow);
}

.close-panel-btn {
    background: none;
    border: none;
    color: var(--color-white);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.teacher-panel-body {
    padding: 20px;
    max-height: 520px;
    overflow-y: auto;
}

.panel-intro {
    font-size: 0.95rem;
    color: #bdc3c7;
    margin-bottom: 15px;
    line-height: 1.4;
}

.phases-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.phase-item {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: 15px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.phase-item.active {
    border-color: var(--color-yellow);
    background: rgba(255, 165, 2, 0.1);
}

.phase-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.phase-title {
    font-weight: 700;
    font-size: 1.05rem;
}

.phase-timer {
    font-family: monospace;
    font-size: 1.35rem;
    font-weight: bold;
    color: var(--color-yellow);
    background: #111;
    padding: 2px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
}

.phase-item.finished .phase-timer {
    color: var(--color-pink);
    text-decoration: line-through;
}

.phase-desc {
    font-size: 0.9rem;
    color: #ecf0f1;
    line-height: 1.4;
    margin-bottom: 10px;
}

.phase-controls {
    display: flex;
    gap: 10px;
}

.phase-controls button {
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 6px 12px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background-color: var(--color-white);
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: transform 0.1s;
}

.phase-controls button:active {
    transform: scale(0.95);
}

/* --- MAPA DE PROGRESO --- */
.progress-map-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f1f2f6;
    padding: 15px 40px;
    border-bottom: 4px dashed #bdc3c7;
    position: relative;
}

.progress-line {
    position: absolute;
    top: 50%;
    left: 80px;
    right: 80px;
    height: 6px;
    background: #dcdde1;
    transform: translateY(-50%);
    z-index: 1;
}

.map-node {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.node-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--color-white);
    border: 4px solid var(--color-border);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.2rem;
    box-shadow: 0 4px 6px var(--color-shadow);
    transition: all 0.2s ease;
}

.node-label {
    margin-top: 8px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-muted);
}

.map-node.active .node-icon {
    border-color: #38ef7d;
    background-color: #e8fdf0;
    transform: scale(1.15);
    box-shadow: 0 0 15px rgba(56, 239, 125, 0.4);
}

.map-node.active .node-label {
    color: #2e86de;
}

.map-node.completed .node-icon {
    background-color: #38ef7d;
    border-color: #11998e;
    color: var(--color-white);
}

/* --- TABLERO DE JUEGO --- */
main {
    padding: 30px;
    flex-grow: 1;
}

#game-board {
    width: 100%;
}

.board-card {
    background: var(--color-white);
    border-radius: 30px;
    padding: 30px;
    display: none;
    flex-direction: column;
    align-items: center;
    border: 5px dashed #28b463;
    min-height: 480px;
    animation: fadeIn 0.4s ease;
}

.board-card.active {
    display: flex;
}

/* Pantalla de Intro */
#game-intro {
    text-align: center;
    gap: 20px;
    border-color: var(--color-purple);
}

.intro-emoji {
    font-size: 6rem;
    animation: bounce 2s infinite;
}

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

#game-intro h2 {
    font-size: 2.8rem;
    color: var(--color-purple);
}

#game-intro p {
    font-size: 1.5rem;
    color: var(--color-muted);
    max-width: 800px;
    line-height: 1.6;
}

.start-btn {
    font-family: var(--font-main);
    font-size: 1.7rem;
    font-weight: 700;
    padding: 18px 45px;
    border: none;
    border-radius: 35px;
    cursor: pointer;
    background-color: var(--color-purple);
    color: var(--color-white);
    box-shadow: 0 8px 0px #7b3d9c;
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
}

.start-btn:active {
    transform: translateY(6px);
    box-shadow: 0 2px 0px #7b3d9c;
}

/* Indicaciones y Text-To-Speech */
.level-instructions {
    width: 100%;
    background: #f4f6f7;
    border-left: 6px solid #38ef7d;
    border-radius: 15px;
    padding: 15px 25px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.instruction-text {
    font-size: 1.45rem;
    font-weight: 600;
    color: var(--color-text);
    flex-grow: 1;
    text-align: left;
}

.tts-btn {
    background: var(--color-blue);
    color: var(--color-white);
    padding: 8px 16px;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    box-shadow: 0 4px 0px #1565c0;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.1s;
}

.tts-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0px #1565c0;
}

.tts-btn.speaking {
    background: var(--color-pink);
    box-shadow: 0 4px 0px #c83949;
}

/* Contenedor de Opciones Generales */
.options-container {
    display: flex;
    justify-content: center;
    gap: 25px;
    width: 100%;
    margin-top: 25px;
}

.option-num-btn {
    font-family: var(--font-main);
    font-size: 3.5rem;
    font-weight: 700;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 5px solid var(--color-text);
    background-color: var(--color-white);
    color: var(--color-text);
    cursor: pointer;
    box-shadow: 0 8px 0px var(--color-text);
    transition: all 0.1s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.option-num-btn:active {
    transform: translateY(6px);
    box-shadow: 0 2px 0px var(--color-text);
}

.option-num-btn.btn-red {
    border-color: #ff4757; color: #ff4757; box-shadow: 0 8px 0px #c83949;
}
.option-num-btn.btn-red:active { box-shadow: 0 2px 0px #c83949; }

.option-num-btn.btn-blue {
    border-color: #1e90ff; color: #1e90ff; box-shadow: 0 8px 0px #1565c0;
}
.option-num-btn.btn-blue:active { box-shadow: 0 2px 0px #1565c0; }

.option-num-btn.btn-green {
    border-color: #2ed573; color: #2ed573; box-shadow: 0 8px 0px #1e924d;
}
.option-num-btn.btn-green:active { box-shadow: 0 2px 0px #1e924d; }


/* --- NIVEL 1: CONTEO DE ANIMALES --- */
#level-1 { border-color: var(--color-blue); }

.counting-forest-area {
    width: 100%;
    min-height: 280px;
    background: linear-gradient(180deg, #dff9fb 0%, #c7ecee 100%);
    border-radius: 25px;
    border: 5px solid #81ecec;
    padding: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 30px;
}

.animal-svg-card {
    width: 90px;
    height: 90px;
    filter: drop-shadow(0 6px 8px rgba(0,0,0,0.1));
    animation: sway 3s infinite ease-in-out;
}

@keyframes sway {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(5deg) scale(1.05); }
}


/* --- NIVEL 2: EL TREN DE LOS NÚMEROS --- */
#level-2 { border-color: #eccc68; }

.train-wrapper {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: 100%;
    min-height: 180px;
    background: #fdfefe;
    border-radius: 25px;
    padding: 20px;
    margin-bottom: 25px;
}

.train-wagon {
    position: relative;
    width: 110px;
    height: 90px;
    background-color: var(--color-blue);
    border: 4px solid #0f52ba;
    border-radius: 12px;
    margin-right: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--color-white);
    box-shadow: inset 0 -10px 0 rgba(0,0,0,0.15), 0 5px 10px rgba(0,0,0,0.1);
}

.train-wagon::before, .train-wagon::after {
    content: '';
    position: absolute;
    bottom: -15px;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background-color: #2c3e50;
    border: 3px solid var(--color-white);
}

.train-wagon::before { left: 10px; }
.train-wagon::after { right: 10px; }

.train-locomotive {
    width: 120px;
    height: 110px;
    background-color: #ff4757;
    border: 4px solid #c83949;
    border-radius: 12px 30px 12px 12px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 15px;
    margin-right: 0;
    box-shadow: inset 0 -12px 0 rgba(0,0,0,0.15);
}

.train-locomotive-cabin {
    position: absolute;
    top: -20px;
    left: 10px;
    width: 50px;
    height: 35px;
    background-color: #ffa502;
    border: 4px solid #cc8400;
    border-radius: 6px;
}

.train-locomotive-chimney {
    position: absolute;
    top: -25px;
    right: 15px;
    width: 16px;
    height: 30px;
    background-color: #57606f;
    border-radius: 4px;
}

.train-wagon-empty {
    background-color: #ced6e0;
    border: 4px dashed #7f8c8d;
    color: #7f8c8d;
    box-shadow: none;
}

.train-wagon-empty.hover {
    background-color: #fff2cc;
    border-color: var(--color-yellow);
}

.train-options {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.train-option-box {
    font-size: 2.8rem;
    font-weight: 700;
    width: 80px;
    height: 80px;
    background-color: #eccc68;
    border: 4px solid #b89312;
    color: #2c3e50;
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    box-shadow: 0 6px 0px #b89312;
    transition: transform 0.15s;
    user-select: none;
}

.train-option-box:hover {
    transform: scale(1.05);
}

.train-option-box:active {
    cursor: grabbing;
}

.train-option-box.selected {
    border-color: #ff4757;
    box-shadow: 0 0 12px rgba(255, 71, 87, 0.4);
    background-color: #ffe3e3;
}


/* --- NIVEL 3: BURBUJAS EN ORDEN --- */
#level-3 { border-color: var(--color-pink); }

.bubble-pop-arena {
    position: relative;
    width: 100%;
    height: 340px;
    background: linear-gradient(180deg, #fbc53120 0%, #fbc53150 100%);
    border-radius: 25px;
    border: 5px solid #fbc531;
    overflow: hidden;
}

.num-bubble {
    position: absolute;
    width: 85px;
    height: 85px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.9) 0%, rgba(255,107,129,0.3) 70%, rgba(255,71,87,0.6) 100%);
    box-shadow: inset -5px -5px 15px rgba(0,0,0,0.1), 0 5px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.6rem;
    font-weight: 700;
    color: #2c3e50;
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s ease;
}

.num-bubble:active {
    transform: scale(0.9);
}

.num-bubble.pop-effect {
    position: absolute;
    width: 85px;
    height: 85px;
    border-radius: 50%;
    border: 3px solid rgba(255, 107, 129, 0.8);
    animation: bubblePop 0.3s forwards ease-out;
}

@keyframes bubblePop {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.6); opacity: 0; }
}

.bubble-order-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    background: #f1f2f6;
    padding: 12px 25px;
    border-radius: 20px;
    width: 100%;
}

.bubble-order-bar span {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-muted);
}

.ordered-slots {
    display: flex;
    gap: 12px;
}

.ordered-slot-item {
    font-size: 1.8rem;
    font-weight: 700;
    width: 48px;
    height: 48px;
    background-color: var(--color-white);
    border: 3px solid #ff6b81;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ff6b81;
    animation: scaleUp 0.2s forwards;
}

@keyframes scaleUp {
    from { transform: scale(0); }
    to { transform: scale(1); }
}


/* --- NIVEL 4: LA CESTA DE FRUTAS (SUMAS) --- */
#level-4 { border-color: var(--color-purple); }

.addition-visual-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.basket-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.basket-card {
    background: #fafaf0;
    border: 4px solid #d9a760;
    border-radius: 20px;
    padding: 15px;
    width: 320px;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 6px 12px var(--color-shadow);
}

.basket-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #7d5628;
    margin-bottom: 12px;
}

.basket-fruits {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    min-height: 80px;
}

.fruit-item {
    font-size: 2.2rem;
    animation: dropIn 0.3s forwards ease-out;
}

@keyframes dropIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.math-operator {
    font-size: 4rem;
    font-weight: bold;
    color: var(--color-purple);
}

.math-equation-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    background: #f1f2f6;
    border: 3px solid var(--color-purple);
    padding: 10px 30px;
    border-radius: 20px;
    margin-top: 25px;
    width: 100%;
    max-width: 500px;
}

.equation-num {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-purple);
}

.equation-operator {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--color-muted);
}

.equation-result {
    font-size: 2.5rem;
    font-weight: 700;
    color: #ff4757;
    background-color: var(--color-white);
    padding: 0 20px;
    border-radius: 12px;
    border: 2px dashed #ff4757;
}


/* --- DIPLOMA FINAL --- */
#game-win {
    border-color: var(--color-yellow);
    background: linear-gradient(135deg, #fffcf0 0%, #fff7d6 100%);
}

.magic-diploma {
    background: var(--color-white);
    padding: 25px;
    border-radius: 25px;
    box-shadow: 0 12px 24px rgba(0,0,0,0.06);
    width: 100%;
    max-width: 700px;
    border: 8px double var(--color-yellow);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 15px;
}

.diploma-sparkles {
    font-size: 2rem;
}

.magic-diploma h2 {
    font-size: 2.4rem;
    color: #b38f00;
}

.magic-diploma p {
    font-size: 1.3rem;
    color: var(--color-muted);
    line-height: 1.5;
}

.winner-name {
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--color-pink);
    text-shadow: 1px 1px 0px #ced6e0;
}

.diploma-seal {
    font-size: 5rem;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.diploma-footer {
    margin-top: 15px;
    font-style: italic;
    font-weight: 700;
    color: #747d8c;
}


/* --- CONFETTI DE VICTORIA --- */
#confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 12px;
    height: 12px;
    opacity: 0.8;
    animation: confettiFall 3s infinite linear;
}

@keyframes confettiFall {
    0% { transform: translateY(-50px) rotate(0deg); }
    100% { transform: translateY(600px) rotate(360deg); }
}
