/* ==========================================================================
   LA BATALLA DE LAS TABLAS • ESTILOS (3ER GRADO)
   ========================================================================== */

:root {
    --bg-dark: #070B18;
    --primary-cyan: #06B6D4;
    --accent-gold: #F59E0B;
    --accent-red: #EF4444;
    --accent-emerald: #10B981;
    
    --card-bg: rgba(19, 27, 46, 0.9);
    --border-glow: rgba(6, 182, 212, 0.4);
    
    --font-kids: 'Fredoka', cursive, sans-serif;
    --font-pixel: 'Press Start 2P', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body.tablas-body {
    min-height: 100vh;
    background: radial-gradient(circle at 50% 10%, #1E1B4B 0%, #070B18 70%, #02040A 100%);
    color: #FFFFFF;
    font-family: var(--font-kids);
    overflow-x: hidden;
    padding-bottom: 25px;
}

#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 100;
}

/* 1. HEADER */
.tablas-header {
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.btn-tablas-nav {
    background: rgba(30, 41, 59, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    text-decoration: none;
    font-weight: 800;
    padding: 8px 18px;
    border-radius: 99px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-tablas-nav:hover {
    background: var(--primary-cyan);
    color: #000;
}

.tablas-title-group {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.badge-grade {
    background: var(--primary-cyan);
    color: #070B18;
    font-weight: 900;
    font-size: 0.8rem;
    padding: 3px 14px;
    border-radius: 99px;
}

.tablas-title {
    font-size: 1.45rem;
    font-weight: 900;
    background: linear-gradient(135deg, #FFFFFF 0%, #38BDF8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tablas-tools {
    display: flex;
    gap: 8px;
}

.btn-tool {
    background: rgba(30, 41, 59, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.btn-tool:hover {
    background: var(--primary-cyan);
    color: #070B18;
}

/* 2. SELECTOR DE TABLAS */
.table-selector-bar {
    max-width: 1100px;
    margin: 0 auto 12px auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.sel-lbl {
    font-size: 0.85rem;
    font-weight: 800;
    color: #94A3B8;
}

.table-pills-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tbl-btn {
    background: rgba(30, 41, 59, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.15);
    color: #E2E8F0;
    font-family: var(--font-kids);
    font-weight: 900;
    font-size: 0.95rem;
    padding: 6px 14px;
    border-radius: 99px;
    cursor: pointer;
    transition: all 0.2s;
}

.tbl-btn:hover {
    border-color: var(--primary-cyan);
}

.tbl-btn.active {
    background: var(--primary-cyan);
    border-color: #67E8F9;
    color: #070B18;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.6);
    transform: scale(1.08);
}

/* 3. CONTENEDOR PRINCIPAL */
.tablas-main-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Barra Monitor de CPU */
.cpu-monitor-bar {
    background: var(--card-bg);
    border: 2px solid var(--border-glow);
    border-radius: 20px;
    padding: 12px 20px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
}

.cpu-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cstat-lbl {
    font-size: 0.75rem;
    color: #94A3B8;
    font-weight: 800;
}

.temp-gauge-wrap {
    width: 140px;
    height: 10px;
    background: #0B1120;
    border-radius: 99px;
    overflow: hidden;
    margin: 4px 0;
}

.temp-gauge-fill {
    height: 100%;
    width: 45%;
    background: #10B981;
    border-radius: 99px;
    transition: width 0.3s ease, background 0.3s ease;
}

.temp-text {
    font-size: 0.85rem;
    color: #10B981;
}

.cstat-num {
    font-size: 1.4rem;
    font-weight: 900;
    color: #38BDF8;
}

/* Escenario de Batalla */
.battle-stage {
    position: relative;
    height: 160px;
    background: #060B18;
    border: 3px solid #1E293B;
    border-radius: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.8);
}

.teclita-cannon {
    position: relative;
    display: flex;
    align-items: center;
}

.teclita-gunner {
    width: 75px;
    height: 75px;
    border-radius: 50%;
    border: 3px solid #38BDF8;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.6);
}

.cannon-nozzle {
    width: 30px;
    height: 14px;
    background: #334155;
    border: 2px solid #38BDF8;
    border-radius: 4px;
}

.cpu-core-target {
    background: #1E293B;
    border: 3px solid #EF4444;
    border-radius: 18px;
    padding: 12px 18px;
    text-align: center;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
    animation: gentleBob 2s infinite;
}

.cpu-icon {
    font-size: 1.2rem;
    font-weight: 900;
    color: #F87171;
}

.bug-swarm {
    font-size: 1.6rem;
    margin-top: 4px;
}

/* Rayo Laser */
.laser-beam {
    position: absolute;
    left: 140px;
    right: 170px;
    height: 8px;
    background: #00F0FF;
    box-shadow: 0 0 15px #00F0FF, 0 0 30px #00F0FF;
    border-radius: 99px;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left;
    transition: opacity 0.1s, transform 0.2s ease-out;
}

.laser-beam.firing {
    opacity: 1;
    transform: scaleX(1);
}

/* 4. TARJETA DE DESAFÍO MATEMÁTICO */
.math-challenge-card {
    background: var(--card-bg);
    border: 3px solid var(--border-glow);
    border-radius: 28px;
    padding: 24px;
    box-shadow: 0 12px 35px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.equation-display {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 2.8rem;
    font-weight: 900;
}

.num-val {
    color: #FDE047;
    text-shadow: 0 0 15px rgba(253, 224, 71, 0.6);
}

.op-val {
    color: #94A3B8;
}

.answer-box {
    min-width: 90px;
    height: 70px;
    background: #060B18;
    border: 3.5px dashed #38BDF8;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #38BDF8;
    font-size: 2.4rem;
    padding: 0 12px;
}

/* Teclado Numérico */
.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 380px;
}

.numpad-btn {
    background: #1E293B;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 14px;
    font-family: var(--font-kids);
    font-size: 1.6rem;
    font-weight: 900;
    color: #FFFFFF;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.15s;
}

.numpad-btn:hover {
    background: #334155;
    border-color: #38BDF8;
    transform: translateY(-2px);
}

.numpad-btn:active {
    transform: scale(0.95);
}

.btn-clear-num {
    background: rgba(239, 68, 68, 0.2);
    border-color: #EF4444;
    color: #FCA5A5;
}

.btn-enter-num {
    background: linear-gradient(135deg, #059669 0%, #10B981 100%);
    border-color: #34D399;
    color: #FFFFFF;
    font-size: 1.1rem;
    grid-column: span 1;
}

.btn-enter-num:hover {
    background: linear-gradient(135deg, #047857 0%, #059669 100%);
}

/* 5. MODAL */
.tablas-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 17, 0.95);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 200;
}

.tablas-modal-overlay.active {
    display: flex;
}

.tablas-modal-card {
    background: #FFFFFF;
    color: #0F172A;
    width: 100%;
    max-width: 520px;
    border-radius: 28px;
    border: 8px solid var(--primary-cyan);
    padding: 30px;
    text-align: center;
    box-shadow: 0 25px 70px rgba(0,0,0,0.8);
    animation: zoomIn 0.3s ease;
}

.modal-badge {
    background: #0284C7;
    color: #FFFFFF;
    font-size: 0.85rem;
    font-weight: 900;
    padding: 5px 18px;
    border-radius: 99px;
    display: inline-block;
    margin-bottom: 8px;
}

.modal-title {
    font-size: 1.8rem;
    font-weight: 900;
}

.modal-mascot {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 3px solid #38BDF8;
    margin: 12px 0;
}

.results-row {
    display: flex;
    justify-content: space-around;
    background: #F8FAFC;
    border: 2px dashed #CBD5E1;
    border-radius: 16px;
    padding: 12px;
    margin: 15px 0 20px 0;
}

.rbox {
    display: flex;
    flex-direction: column;
}

.rbox span {
    font-size: 0.8rem;
    color: #64748B;
    font-weight: 800;
}

.rbox strong {
    font-size: 1.4rem;
    font-weight: 900;
    color: #0284C7;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.btn-modal {
    font-family: var(--font-kids);
    font-size: 1.05rem;
    font-weight: 900;
    padding: 12px 24px;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-again { background: #10B981; color: #FFFFFF; }
.btn-home { background: #334155; color: #FFFFFF; }
.btn-modal:hover { transform: scale(1.05); }

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

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
