* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #0d0d11; 
    color: #fff;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    width: 100vw;
    height: 92vh; 
    max-width: 450px;
    background-color: #16161f;
    position: relative;
    border: 2px solid #2d2d3d;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 1. TOPO */
#top-panel {
    height: 28%;
    background-color: #0b0b0f;
    border-bottom: 3px solid #23232f;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 6px;
    z-index: 2;
}

.result-box {
    background: #111116;
    border: 1px dashed #222;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-box.active {
    border: 2px solid #00ff88;
    background: rgba(0, 255, 136, 0.12);
    transform: scale(1.03);
}

.result-box .math-text, .result-box .mini-baskets {
    display: none;
}

.result-box.active .math-text {
    display: block;
    color: #00ff88;
    font-size: 1.15rem;
    font-weight: bold;
}

.result-box.active .mini-baskets {
    display: flex;
    gap: 2px;
    margin-bottom: 2px;
    flex-wrap: wrap;
    justify-content: center;
}

.mini-basket {
    width: 10px;
    height: 8px;
    border: 1.5px solid #ff9f43;
    border-top: none;
    border-bottom-left-radius: 2px;
    border-bottom-right-radius: 2px;
}

/* 2. ESPAÇO DE JOGO INTEGRADO */
#interactive-canvas {
    flex: 1;
    background-color: #ffffff;
    background-image: 
        linear-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
    background-size: 16px 16px;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
}

#action-area {
    flex: 1;
    position: relative;
    padding-top: 15px;
}

/* Fábrica Reorganizada para ter o botão embaixo */
#factory-zone {
    position: absolute;
    left: 8px;
    top: 40%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 125px;
}

#factory-interactive-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
}

.blue-dots-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    max-height: 140px;
    flex-wrap: wrap;
    justify-content: center;
}

.blue-dot {
    width: 14px;
    height: 14px;
    background: radial-gradient(circle at 30% 30%, #00bcff, #0055cc);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 85, 204, 0.3);
    animation: pulse 1.2s infinite alternate;
}

.times-sign {
    font-size: 2.2rem;
    font-weight: bold;
    color: #333;
}

#dynamic-number {
    font-size: 2.6rem;
    font-weight: 900;
    color: #111;
    min-width: 25px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* NOVO: Estilo do botão de ação de multiplicar */
#btn-multiplicar-acao {
    background: #ff9f43;
    border: none;
    color: #fff;
    padding: 6px 8px;
    font-size: 0.72rem;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(255,159,67,0.4);
    width: 75%;
    text-align: center;
    animation: pulse 1.5s infinite alternate;
}
#btn-multiplicar-acao:active {
    transform: scale(0.95);
}

/* Área das Cestas */
#baskets-zone {
    position: absolute;
    left: 140px;
    top: 40%;
    transform: translateY(-50%);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    max-width: 295px;
    max-height: 190px; 
    overflow: visible;
    transition: transform 0.6s cubic-bezier(0.55, 0.055, 0.675, 0.19), opacity 0.4s;
}

.basket-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.basket-counter {
    font-size: 0.75rem;
    font-weight: bold;
    color: #555;
    background: #e8e8e8;
    padding: 1px 4px;
    border-radius: 10px;
    border: 1px solid #ccc;
}

.basket {
    border: 3px solid #ff9f43;
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    background: rgba(255, 159, 67, 0.03);
    display: flex;
    flex-wrap: wrap-reverse;
    align-content: flex-start;
    justify-content: center;
    padding: 3px;
    gap: 2px;
    transition: all 0.2s;
}

.basket.pulse-target {
    animation: basketFortePulse 0.4s infinite alternate;
}

.basket[data-size="2"] { width: 44px; height: 42px; }
.basket[data-size="3"] { width: 48px; height: 46px; }
.basket[data-size="4"], 
.basket[data-size="5"], 
.basket[data-size="6"], 
.basket[data-size="7"], 
.basket[data-size="8"], 
.basket[data-size="9"], 
.basket[data-size="10"] { width: 52px; height: 50px; }

.yellow-ball {
    width: 10px;
    height: 10px;
    background: radial-gradient(circle at 30% 30%, #fff700, #ff8c00);
    border-radius: 50%;
}

.pushing-up {
    transform: translateY(-350px) scale(0.2) !important;
    opacity: 0;
}

/* 3. RODAPÉ */
#footer-panel {
    height: 140px; 
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    position: relative;
    z-index: 5;
    padding-top: 5px;
}

#action-box {
    background: #00ff88;
    color: #000;
    padding: 4px 14px;
    font-size: 0.8rem;
    font-weight: bold;
    border-radius: 4px;
    margin-bottom: 5px;
    box-shadow: 0 4px 12px rgba(0,255,136,0.3);
    animation: bounce 0.4s infinite alternate;
    cursor: pointer;
}

.controls-row {
    display: flex;
    width: 100%;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
}

.nav-group {
    display: flex;
    gap: 6px;
}

.tab-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #2d2d3d;
    background: #1c1c24;
    color: #fff;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    transition: all 0.2s;
}

.tab-btn:active {
    transform: scale(0.85);
}

.tab-btn.active-tab {
    background: #00bcff;
    border-color: #fff;
    box-shadow: 0 0 8px #00bcff;
}

#btn-ajuda-tabuada {
    margin-top: 8px;
    background: #1c1c24;
    border: 1px solid #2d2d3d;
    color: #00ff88;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: bold;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    transition: background 0.2s;
}

#interactive-trigger {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    opacity: 0.2;
    pointer-events: none;
    transition: opacity 0.3s;
}

#interactive-trigger.ready {
    opacity: 1;
    pointer-events: auto;
}

#stickman {
    width: 50px;
    height: 65px;
}

#stickman svg {
    width: 100%;
    height: 100%;
    stroke: #111116; 
    stroke-width: 5.5;
    stroke-linecap: round;
    fill: none;
}

/* POP-UPS */
.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #1c1c24;
    border: 2px solid #2d2d3d;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    max-width: 360px;
    position: relative;
}

#grid-tabuada-auxiliar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #111116;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #2d2d3d;
}
.linha-tabuada-aux {
    font-size: 0.95rem;
    color: #fff;
    padding: 2px 0;
    border-bottom: 1px solid #1c1c24;
}
.linha-tabuada-aux:last-child { border-bottom: none; }

.close-popup-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    color: #aaa;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
}

.modal-card h2 { color: #00ff88; margin-bottom: 12px; }
.modal-card p { color: #ccc; font-size: 0.95rem; margin-bottom: 20px; line-height: 1.4; }
.modal-btn {
    background: #00bcff; color: #fff; border: none; padding: 10px 22px;
    font-size: 1rem; font-weight: bold; border-radius: 6px; cursor: pointer;
}

@keyframes pulse { 0% { transform: scale(1); } 100% { transform: scale(1.05); } }
@keyframes bounce { 0% { transform: translateY(0); } 100% { transform: translateY(-4px); } }
@keyframes basketFortePulse {
    0% { border-color: #ff9f43; box-shadow: inset 0 0 4px rgba(255,159,67,0.2); }
    100% { border-color: #0088ff; background: rgba(0, 136, 255, 0.12); box-shadow: 0 0 14px rgba(0,136,255,0.7); }
}
.pushing-animation { animation: stickmanPush 0.4s ease-in-out; }
@keyframes stickmanPush { 0% { transform: scaleY(1); } 50% { transform: translateY(-6px) scaleY(0.88); } 100% { transform: scaleY(1); } }