:root {
    /* ============================================================
       DESIGN TOKENS — NEUBLOCKS
       Paleta 5-core + neutrals + escala tipográfica + espaçamentos
       Alias antigos preservados apontando para tokens semânticos.
       ============================================================ */

    /* --- Paleta principal (5 cores core) --- */
    --c-mat:        #1cb0f6;        /* Matemática — azul */
    --c-mat-85:     #1599d8;
    --c-mat-65:     #1080b0;
    --c-mat-40:     #0a5a78;
    --c-mat-20:     rgba(28, 176, 246, 0.20);

    --c-por:        #ffc800;        /* Português — amarelo */
    --c-por-85:     #d9aa00;
    --c-por-65:     #b38f00;
    --c-por-40:     #7d6300;
    --c-por-20:    rgba(255, 200, 0, 0.20);

    --c-ing:        #ff4b4b;        /* Inglês — vermelho */
    --c-ing-85:     #d83f3f;
    --c-ing-65:     #b53333;
    --c-ing-40:     #802424;
    --c-ing-20:     rgba(255, 75, 75, 0.20);

    --c-success:    #06ffa5;        /* Combo / acerto / raridade */
    --c-success-85: #05d88c;
    --c-success-20: rgba(6, 255, 165, 0.20);

    --c-legendary:  #8338ec;        /* Lootbox lendário / nível / destaque */
    --c-legendary-85: #6e2ec8;
    --c-legendary-20: rgba(131, 56, 236, 0.20);

    /* --- Cor de alerta especial (gate pendente / erro) --- */
    --c-special:    #ff006e;
    --c-special-85: #d8005e;
    --c-special-20: rgba(255, 0, 110, 0.20);

    /* --- Accents secundários (mantidos para componentes existentes) --- */
    --c-cyan:       #00fff9;        /* Glass border / highlights */
    --c-amber:       #ffbe0b;        /* Dicas / feedback secundário */
    --c-orange:      #fb5607;        /* Acento item raro */

    /* --- Neutrals (superfícies levemente azuladas, não puras) --- */
    --surface-1:    #0a0a14;        /* Fundo app (era --dark-bg) */
    --surface-2:    #1a1a2e;        /* Cards / tabuleiro secundário */
    --surface-3:    #232342;        /* Hover / elevado */
    --text-1:       #ffffff;        /* Texto principal */
    --text-2:       #b0b0c0;        /* Texto secundário */
    --text-3:       #7a7a8f;        /* Texto terciário / placeholder */
    --glass-bg:             rgba(255, 255, 255, 0.05);
    --glass-border:         rgba(255, 255, 255, 0.10);
    --glass-border-strong:  rgba(255, 255, 255, 0.18);
    --card-bg: rgba(26, 26, 46, 0.80);

    /* --- Escala tipográfica --- */
    --fs-caption:   0.75rem;        /* 12px — labels small */
    --fs-body:      0.95rem;        /* 15px — corpo */
    --fs-lg:        1.10rem;        /* 18px — destaque */
    --fs-h1:        1.50rem;        /* 24px — título tela */
    --fs-display:   2.20rem;        /* 35px — logo / hero */
    --nunito:       'Nunito', sans-serif;

    /* --- Escala de espaçamento (4px base) --- */
    --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
    --space-5: 24px; --space-6: 32px; --space-7: 48px;

    /* --- Raios --- */
    --radius-sm: 8px;  --radius-md: 14px;  --radius-lg: 20px;

    /* --- Sombras --- */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.35);
    --shadow-glow-cyan:  0 0 18px rgba(0, 255, 249, 0.35);
    --shadow-glow-success: 0 0 18px rgba(6, 255, 165, 0.35);

    /* ============================================================
       ALIAS LEGADOS — preservados para não quebrar seletores
       existentes em styles.css, index.html, script.js etc.
       ============================================================ */

    /* Cores das disciplinas (NÃO alterar — usadas em HTML inline) */
    --ing-red:      var(--c-ing);
    --mat-blue:     var(--c-mat);
    --por-yellow:   var(--c-por);
    --math-blue:    var(--c-mat);           /* duplicado removido → alias */

    /* Cores futuristas (still referenced em CSS) */
    --duo-green:    #58cc02;                /* verde Duolingo, mantém para fb-correct */
    --duo-gray:     #e5e5e5;                /* track de progresso */
    --text:         var(--text-2);          /* alias para legado */
    --neon-pink:    var(--c-special);
    --neon-cyan:    var(--c-cyan);
    --neon-yellow:  var(--c-amber);
    --neon-purple:  var(--c-legendary);
    --neon-green:   var(--c-success);
    --neon-orange:  var(--c-orange);
    --neon-border:  var(--c-cyan);          /* duplicado removido → alias */

    /* Backgrounds / cards */
    --dark-bg:       var(--surface-1);
    --dark-secondary: var(--surface-2);
    --dark-card:     var(--card-bg);

    /* Texto */
    --text-primary:   var(--text-1);
    --text-secondary: var(--text-2);

    /* Gradientes (mantêm valor direto — usados em backgrounds) */
    --gradient-dopamine: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    --gradient-error:  linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-family: 'Nunito', sans-serif; margin: 0; padding: 0; }
html, body { background: var(--dark-bg); color: var(--text-primary); height: 100%; width: 100%; overflow: hidden; overflow: clip; padding: 0; font-family: 'Nunito', sans-serif; overscroll-behavior: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
body { background-image: radial-gradient(900px 480px at 50% -160px, rgba(0, 255, 249, 0.07), transparent 70%), radial-gradient(700px 420px at 110% 115%, rgba(255, 0, 110, 0.05), transparent 70%), radial-gradient(700px 420px at -10% 115%, rgba(102, 126, 234, 0.05), transparent 70%); background-attachment: fixed; }
input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; }
@supports (padding: env(safe-area-inset-bottom)) {
    body { padding-bottom: env(safe-area-inset-bottom); }
}

/* Scrollbars globais (tema dark) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 255, 249, 0.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 255, 249, 0.45); }
html, body { scrollbar-width: thin; scrollbar-color: rgba(0, 255, 249, 0.35) transparent; }

/* Botões de tempo (seletor com classe CSS compartilhada) */
.time-btn {
    padding: 8px 15px; border-radius: 20px; font-weight: bold; font-size: 0.9rem;
    border: 1px solid; color: #fff; cursor: pointer; backdrop-filter: blur(5px);
    font-family: 'Nunito', sans-serif; transition: transform 0.15s ease, box-shadow 0.3s ease;
}
.time-btn:hover { transform: translateY(-1px); }
.time-btn[data-time="60"] { background: rgba(255, 107, 107, 0.2); border-color: #ff6b6b; }
.time-btn[data-time="120"] { background: rgba(78, 205, 196, 0.2); border-color: #4ecdc4; }
.time-btn[data-time="180"] { background: rgba(69, 183, 209, 0.2); border-color: #45b7d1; }
.time-btn[data-time="300"] { background: rgba(102, 126, 234, 0.2); border-color: #667eea; }

/* Animações */
@keyframes slideInDown {
    from { transform: translateX(-50%) translateY(-100%); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(88, 204, 2, 0.5); }
    50% { box-shadow: 0 0 20px rgba(88, 204, 2, 0.8), 0 0 30px rgba(88, 204, 2, 0.6); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes progressPulse {
    0% { box-shadow: 0 0 10px rgba(28, 176, 246, 0.5); }
    50% { box-shadow: 0 0 20px rgba(28, 176, 246, 0.8), 0 0 30px rgba(28, 176, 246, 0.6); }
    100% { box-shadow: 0 0 10px rgba(28, 176, 246, 0.5); }
}

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

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

#toast {
    position: fixed; top: -100px; left: 50%; transform: translateX(-50%);
    padding: 15px 30px; border-radius: 15px; color: white; font-weight: 900;
    z-index: 4000; transition: 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); text-align: center; width: 85%; max-width: 400px;
}
#toast.active { top: 20px; animation: slideInDown 0.5s ease-out; }
#toast.success { animation: pulse 0.3s ease-in-out; }
#toast.error { animation: shake 0.5s ease-in-out; }

/* Toast container para múltiplos toasts simultâneos */
#toast-container > div {
    position: relative !important;
    animation: slideInDown 0.3s ease-out !important;
}

.screen { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: var(--dark-bg); display: flex; flex-direction: column; align-items: center; z-index: 2000; padding: 5px; padding-bottom: max(15px, env(safe-area-inset-bottom)); overflow-y: auto; animation: fadeIn 0.3s ease-out; }
.brain-icon { font-size: clamp(3rem, 9vw, 5rem); margin-bottom: 4px; filter: drop-shadow(3px 3px 0px var(--duo-gray)); transition: transform 0.3s ease; }
.brain-icon:hover { transform: scale(1.1) rotate(5deg); }
.main-logo { color: var(--neon-cyan); font-size: clamp(1.5rem, 5.5vw, 2.2rem); font-weight: 900; text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan); margin-bottom: 4px; }
.main-logo#lvl-title { margin-bottom: clamp(15px, 4vh, 30px); }
.tagline { color: var(--text-secondary); font-size: clamp(0.9rem, 3vw, 1.1rem); font-weight: 700; margin-bottom: clamp(10px, 2.5vh, 20px); text-align: center; }
.menu-container { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; max-width: 300px; gap: 8px; min-height: 0; padding-bottom: max(15px, env(safe-area-inset-bottom)); }
#subject-menu > .menu-container { flex: 0 0 auto; max-height: clamp(180px, 35vh, 250px); overflow-y: auto; margin: auto 0; }
#lvl-list { max-height: clamp(250px, 45vh, 400px); overflow-y: auto; width: 100%; max-width: 350px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; margin-top: -20px; }
#lvl-list button { width: 100%; max-width: 300px; min-height: 50px; padding: 8px 12px; font-size: 0.85rem; text-transform: none; white-space: normal; word-wrap: break-word; line-height: 1.2; display: flex; align-items: center; justify-content: center; text-align: center; }
#level-menu { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 15px; }
#level-menu > button { margin-top: 30px; }

/* Teste do Portão - divisor informativo entre blocos */
.gate-divider { width: 100%; max-width: 300px; margin: 4px 0; padding: 8px 12px; border-radius: 14px; text-align: center; font-weight: 900; font-size: 0.75rem; letter-spacing: 1px; text-transform: uppercase; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px dashed; flex-shrink: 0; cursor: help; }
.gate-divider.pending { color: var(--neon-pink); border-color: rgba(255, 0, 110, 0.6); background: rgba(255, 0, 110, 0.12); animation: gateBlink 1.2s ease-in-out infinite; box-shadow: 0 0 12px rgba(255, 0, 110, 0.35), inset 0 0 8px rgba(255, 0, 110, 0.15); }
.gate-divider.passed { color: var(--neon-green); border-color: rgba(6, 255, 165, 0.6); background: rgba(6, 255, 165, 0.1); box-shadow: 0 0 12px rgba(6, 255, 165, 0.3), inset 0 0 8px rgba(6, 255, 165, 0.12); }
@keyframes gateBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.btn-duo { width: 100%; padding: clamp(10px, 3vw, 14px); font-size: clamp(0.9rem, 3vw, 1rem); border: 2px solid var(--glass-border); border-radius: 16px; color: white; font-weight: 800; cursor: pointer; text-transform: uppercase; min-height: 38px; background: var(--glass-bg); backdrop-filter: blur(10px); box-shadow: 0 4px 15px rgba(0, 255, 249, 0.2), inset 0 0 10px rgba(0, 255, 249, 0.1); transition: all 0.3s ease; }
.btn-duo:active { transform: scale(0.98); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.btn-duo:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 255, 249, 0.4), inset 0 0 15px rgba(0, 255, 249, 0.2); border-color: var(--neon-cyan); }

#main-grid { display: none; flex-direction: column; height: 100%; max-width: 500px; margin: 0 auto; width: 100%; background: var(--dark-card); border: 1px solid var(--glass-border); border-radius: 16px; overflow: hidden; overflow: clip; box-shadow: 0 8px 32px rgba(0, 255, 249, 0.2), 0 0 30px rgba(0, 255, 249, 0.1); animation: fadeIn 0.4s ease-out; }
.header { display: flex; align-items: center; padding: 6px 8px; background: var(--glass-bg); border-bottom: 1px solid var(--neon-cyan); gap: 8px; border-radius: 16px 16px 0 0; backdrop-filter: blur(10px); }
.progress-bg { flex: 1; height: 8px; background: var(--duo-gray); border-radius: 8px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.1); }
#progress-fill { width: 0%; height: 100%; background: var(--gradient-success); transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 0 15px rgba(6, 255, 165, 0.6); }
#progress-fill.pulse { animation: progressPulse 1s ease-in-out infinite; }

.question-box { background: transparent; padding: 2px 4px; text-align: center; font-size: clamp(0.8rem, 2.5vw, 1.1rem); font-family: 'Nunito', sans-serif; font-weight: 900; border: none; min-height: clamp(35px, 8vh, 45px); display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; color: var(--text-primary); }
.question-box.correct { animation: glow 0.5s ease-in-out; background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%); }
.question-box.wrong { animation: shake 0.5s ease-in-out; background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%); }
.q-row { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; }
.speak-btn { display: none; background: rgba(0, 255, 249, 0.15); border: 1px solid #00fff9; border-radius: 50%; width: 32px; height: 32px; font-size: 1rem; cursor: pointer; align-items: center; justify-content: center; transition: all 0.2s; box-shadow: 0 0 8px rgba(0, 255, 249, 0.2); flex-shrink: 0; }
.speak-btn:hover { background: rgba(0, 255, 249, 0.3); box-shadow: 0 0 15px rgba(0, 255, 249, 0.4); transform: scale(1.1); }
.speak-btn:active { transform: scale(0.95); }
#game-row { position: relative; flex: none; }
#game-container { position: relative; width: 100%; height: 100%; background: var(--dark-secondary); contain: paint; }
/* Geometria do canvas 100% controlada por canvas-fit.js (px inline). CSS só define visual. */
canvas { position: absolute; margin: 0; background: var(--glass-bg); border: 2px solid var(--neon-cyan); border-radius: 12px; box-shadow: 0 8px 25px rgba(0, 255, 249, 0.3), 0 0 20px rgba(0, 255, 249, 0.2); transition: box-shadow 0.15s ease, border-color 0.15s ease; z-index: 10; }
canvas.canvas-correct { border-color: var(--neon-green) !important; box-shadow: 0 0 30px rgba(6, 255, 165, 0.8), 0 0 60px rgba(6, 255, 165, 0.4) !important; }
canvas.canvas-wrong { border-color: var(--neon-pink) !important; box-shadow: 0 0 30px rgba(255, 0, 110, 0.8), 0 0 60px rgba(255, 0, 110, 0.4) !important; }
#particles-canvas { will-change: transform; backface-visibility: hidden; }

.bottom-panel { background: var(--glass-bg); padding: 5px 8px 10px 8px; border-top: 1px solid var(--neon-cyan); padding-bottom: max(10px, env(safe-area-inset-bottom)); border-radius: 0 0 16px 16px; backdrop-filter: blur(10px); display: flex; flex-direction: column; align-items: center; gap: 5px; }
.ans-grid { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 8px; width: 100%; max-width: 400px; }

.side-ctrl-btn, .action-btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
}

/* Linha de botões de controle (todos juntos abaixo das perguntas) */
.controls-row {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 350px;
}
.ans-btn { background: var(--glass-bg); border: 2px solid var(--glass-border); padding: clamp(10px, 2.5vw, 12px) clamp(8px, 2vw, 10px); border-radius: 12px; font-family: 'Nunito', sans-serif; font-weight: 800; cursor: pointer; min-height: clamp(40px, 6vh, 50px); font-size: clamp(0.9rem, 2.5vw, 1.1rem); box-shadow: 0 4px 8px rgba(0, 255, 249, 0.2); transition: all 0.2s ease; color: var(--text-primary); text-shadow: 0 0 3px var(--neon-cyan); width: 100%; display: flex; align-items: center; justify-content: center; text-align: center; word-wrap: break-word; line-height: 1.2; backdrop-filter: blur(5px); }

/* Fonte adaptativa para respostas longas */
.ans-btn.text-large { font-size: clamp(1rem, 3vw, 1.2rem); }
.ans-btn.text-medium { font-size: clamp(0.8rem, 2.5vw, 1rem); }
.ans-btn.text-small { font-size: clamp(0.7rem, 2vw, 0.9rem); }
.ans-btn:active { transform: scale(0.97); }
.ans-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0, 255, 249, 0.4); border-color: var(--neon-cyan); }
.ans-btn.correct { animation: bounce 0.5s ease; background: var(--gradient-success); border-color: var(--neon-green); box-shadow: 0 0 20px rgba(6, 255, 165, 0.6); }
.ans-btn.wrong { animation: shake 0.5s ease; background: var(--gradient-error); border-color: var(--neon-pink); box-shadow: 0 0 20px rgba(255, 0, 110, 0.6); }

.controls { display: flex; gap: 6px; justify-content: center; position: relative; }
.ctrl-btn { width: clamp(40px, 10vw, 48px); height: clamp(40px, 10vw, 48px); border-radius: 12px; border: 2px solid var(--glass-border); background: var(--glass-bg); font-size: clamp(0.9rem, 2.5vw, 1.1rem); cursor: pointer; min-height: 40px; box-shadow: 0 4px 8px rgba(0, 255, 249, 0.2); transition: all 0.2s ease; color: var(--text-primary); font-weight: 900; backdrop-filter: blur(5px); }
.ctrl-btn:active { transform: scale(0.97); }
.ctrl-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0, 255, 249, 0.4); border-color: var(--neon-cyan); }

.item-btn { padding: 10px 14px; border: 1px solid var(--glass-border); border-radius: 10px; background: var(--glass-bg); font-size: clamp(0.9rem, 2.5vw, 1.1rem); font-weight: 700; cursor: pointer; min-height: 42px; min-width: 52px; box-shadow: 0 2px 4px rgba(0, 255, 249, 0.2); transition: all 0.2s ease; flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-primary); backdrop-filter: blur(5px); }
.item-btn:active { transform: scale(0.97); }
.item-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
.item-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* =============================================
   BUILD / MOCHILA — barra de slots compacta no gutter direito.
   Nunca cobre o canvas: o canvas-fit centraliza a peça 1:2 e o
   "gutter" direito é reservado para esta barra.
   ============================================= */
#itemButtons {
    z-index: 30;
    align-items: stretch;
}
/* Botões nunca esticam: tamanho compacto fixo, sem overlap e sem invadir o pet */
#itemButtons > * { flex: 0 0 auto; }
.loadout-slot {
    position: relative;
    flex-direction: column;
    padding: 2px 3px;
    min-height: 30px;
    min-width: 44px;
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(248,249,250,0.95) 100%);
    border-width: 2px;
    border-radius: 8px;
}
.loadout-slot:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
.loadout-slot-empty {
    opacity: 0.35;
    cursor: default;
    border-style: dashed;
    border-color: var(--glass-border);
    background: rgba(255,255,255,0.4);
    box-shadow: none;
}
.loadout-slot-empty:hover { transform: none; box-shadow: none; }
.slot-key {
    position: absolute;
    top: 1px;
    left: 3px;
    font-size: 0.5rem;
    font-weight: 900;
    color: var(--text-secondary);
    line-height: 1;
}
.slot-emoji { font-size: 0.8rem; line-height: 1.1; }
.slot-count { font-size: 0.55rem; font-weight: 900; color: var(--text-secondary); }
.slot-name { font-size: 0.55rem; font-weight: 800; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60px; }
.inventory-btn {
    position: relative;
    background: var(--gradient-dopamine);
    color: white;
    font-size: 0.85rem;
    border-width: 2px;
    border-color: var(--neon-purple);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    min-height: 30px;
}
.inventory-btn .slot-count {
    position: absolute;
    top: 1px;
    right: 3px;
    font-size: 0.6rem;
    color: white;
}
.loadout-slot.pop { animation: slotPop 0.45s ease; }
@keyframes slotPop {
    0% { transform: scale(1); }
    30% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* Tooltip leve por atributo data-tip (hover/foco) */
[data-tip] { position: relative; }
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(10, 10, 20, 0.96);
    color: #e8e8f0;
    border: 1px solid var(--neon-cyan);
    border-radius: 8px;
    padding: 6px 9px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: normal;
    width: max-content;
    max-width: 190px;
    z-index: 60;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    box-shadow: 0 6px 16px rgba(0,0,0,0.5);
}
/* Tooltip só no hover: clique/foco não gera balão sobre o canvas */
[data-tip]:hover::after { opacity: 1; }

/* Barra lateral fica colada à direita: tooltip abre para a esquerda */
#itemButtons [data-tip]::after {
    left: auto;
    right: calc(100% + 8px);
}

/* =============================================
   MODAIS DE BUILD E MOCHILA
   ============================================= */
.build-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 12, 0.86);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    padding: 12px;
    animation: fadeIn 0.2s ease-out;
}
.build-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.045) 0%, rgba(255,255,255,0.015) 100%), var(--dark-card);
    border: 1px solid rgba(102, 126, 234, 0.5);
    border-radius: 22px;
    max-width: 560px;
    width: 100%;
    max-height: calc(100vh - 24px);
    overflow: hidden;
    padding: 20px 22px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 24px 70px rgba(0, 0, 0, 0.55), 0 0 46px rgba(102, 126, 234, 0.35);
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.build-header {
    font-family: 'Orbitron', 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(1rem, 3.2vw, 1.3rem);
    letter-spacing: 0.14em;
    text-align: center;
    color: #f8f9fa;
    text-shadow: 0 0 16px rgba(102, 126, 234, 0.85);
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.build-pet {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    font-size: 0.8rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.16), rgba(6, 255, 165, 0.08));
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 12px;
    padding: 8px 12px;
}
.build-slots { display: flex; gap: 10px; justify-content: center; align-items: stretch; flex-wrap: wrap; }
.build-slot {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 56px;
    max-width: 84px;
    min-height: 76px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    padding: 4px;
    gap: 2px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.build-slot-empty { border-style: dashed; opacity: 0.5; }
.build-slot .slot-name { max-width: 58px; }
.build-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
    max-height: min(40vh, 300px);
    min-height: 0;
    overflow-y: auto;
    align-content: start;
    overscroll-behavior: contain;
    padding: 2px 4px 4px 2px;
}
.build-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    border: 2px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    padding: 12px 6px 10px;
    cursor: pointer;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.build-grid-item:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35); }
.build-grid-item.equipped {
    border-color: rgba(6, 255, 165, 0.85);
    box-shadow: 0 0 0 1px rgba(6, 255, 165, 0.35), 0 0 18px rgba(6, 255, 165, 0.35);
    background: radial-gradient(circle at 50% 0%, rgba(6, 255, 165, 0.16), rgba(255, 255, 255, 0.02) 70%);
}
.bp-emoji { font-size: 1.55rem; line-height: 1.2; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); }
.bp-name { font-size: 0.72rem; font-weight: 800; text-align: center; line-height: 1.15; color: var(--text-primary); }
.bp-rarity { font-size: 0.58rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.9; }
.bp-count { font-size: 0.66rem; font-weight: 800; color: var(--text-secondary); }
.bp-use {
    margin-top: 4px;
    border: 1px solid var(--neon-cyan);
    background: rgba(0, 255, 249, 0.12);
    color: var(--text-primary);
    font-weight: 900;
    font-size: 0.68rem;
    border-radius: 8px;
    padding: 4px 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.bp-use:hover { background: rgba(0, 255, 249, 0.3); transform: scale(1.05); }
.build-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 12px;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 12px;
}
.build-hint {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-secondary);
    opacity: 0.85;
    padding: 0 4px;
}
.build-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}
.backpack-tools { display: flex; justify-content: center; }
.go-btn { border-radius: 10px; cursor: pointer; font-weight: 800; font-family: 'Nunito', sans-serif; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.build-overlay .go-btn { width: auto; padding: 12px 20px; border-radius: 12px; flex: 1 1 auto; min-width: 130px; }

/* Responsivo: modais e barra para telas estreitas/baixas */
@media (max-width: 768px) {
    #itemButtons {
        display: flex !important;
        flex-direction: column !important;
        gap: 3px !important;
        padding: 3px !important;
        min-width: 46px !important;
        flex-shrink: 0 !important;
    }
    .loadout-slot { min-height: 28px; min-width: 44px; padding: 2px 3px; }
    .loadout-slot .slot-emoji { font-size: 0.75rem; }
    .loadout-slot .slot-count { font-size: 0.5rem; }
    .inventory-btn { min-height: 28px; }
    .build-card { padding: 16px 14px 18px; gap: 12px; border-radius: 18px; max-height: calc(100vh - 16px); }
    .build-slot { min-height: 62px; max-width: 72px; }
    .build-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; max-height: 38vh; }
    .build-overlay { padding: 8px; }
    .build-overlay .go-btn { width: 100%; min-width: 0; }
}
@media (max-height: 640px) {
    .build-card { padding: 12px 14px; gap: 8px; }
    .build-slot { width: auto; min-height: 54px; min-width: 44px; max-width: 62px; }
    .build-pet { padding: 6px 10px; font-size: 0.72rem; }
}

/* Painéis de estatísticas do jogo — empilhados à esquerda */
.stats-stack {
    position: absolute;
    left: 6px;
    top: 6px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    z-index: 15;
}
.stats-panel, .stats-right {
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(248,249,250,0.95) 100%);
    border: 2px solid var(--neon-purple);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    backdrop-filter: blur(10px);
    min-width: 80px;
    font-size: 0.8rem;
    color: #333;
    font-weight: 800;
    text-align: center;
}
.stat-row { margin: 4px 0; line-height: 1.6; }
@media (max-width: 768px) {
    .stats-stack { left: 4px; top: 4px; }
    .stats-panel { font-size: 0.7rem; padding: 6px 8px; min-width: 60px; }
    .stats-right { font-size: 0.7rem; padding: 6px 8px; min-width: 60px; }
    #mascote-stack { right: 4px; bottom: 10px; }
    #mascote-stack #mascote-emoji { font-size: clamp(2.4rem, 8.5vw, 3rem); }
    #mascote-balloon { max-width: min(180px, calc(100vw - 24px)); }
    #itemButtons { bottom: auto !important; }
    .speak-btn { width: 26px; height: 26px; font-size: 0.8rem; }
}

/* Botões laterais para combo e dicas */
.combo-panel {
    position: absolute;
    left: 10px;
    bottom: 10px;
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(248,249,250,0.95) 100%);
    border: 2px solid var(--neon-purple);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    backdrop-filter: blur(10px);
    z-index: 20;
    min-width: 80px;
    text-align: center;
}

.hint-panel {
    position: absolute;
    left: 10px;
    bottom: 60px; /* Posicionado acima do combo */
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(248,249,250,0.95) 100%);
    border: 2px solid var(--neon-yellow);
    border-radius: 12px;
    padding: 8px 12px;
    box-shadow: 0 4px 15px rgba(255, 190, 11, 0.3);
    backdrop-filter: blur(10px);
    z-index: 20;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    font-weight: 800;
    color: var(--text);
    max-width: 120px;
}

/* Botões de controle laterais (direcionais) */
.left-controls {
    position: absolute;
    left: 10px;
    bottom: 20px;
    display: flex;
    flex-direction: row;
    gap: 8px;
    z-index: 20;
}

.right-controls {
    position: absolute;
    right: 10px;
    bottom: 20px;
    display: flex;
    flex-direction: row;
    gap: 8px;
    z-index: 20;
}

.side-ctrl-btn {
    width: clamp(64px, 15vw, 85px);
    height: clamp(64px, 15vw, 85px);
    border-radius: 12px;
    border: 2px solid var(--neon-purple);
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(248,249,250,0.95) 100%);
    font-size: clamp(1.5rem, 3.5vw, 1.8rem);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
    color: var(--text);
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.side-ctrl-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

/* Botões de ação (rotação e descida) */
.action-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}

.action-btn {
    width: clamp(64px, 15vw, 85px);
    height: clamp(64px, 15vw, 85px);
    border-radius: 12px;
    border: 2px solid var(--neon-green);
    background: var(--gradient-success);
    font-size: clamp(1.5rem, 3.5vw, 1.8rem);
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(6, 255, 165, 0.4);
    transition: all 0.2s ease;
    color: white;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 255, 165, 0.6);
}

.action-btn.rotate {
    border-color: var(--neon-orange);
    background: linear-gradient(135deg, var(--neon-orange) 0%, #fb5607 100%);
    box-shadow: 0 4px 15px rgba(251, 86, 7, 0.4);
}

.action-btn.rotate:hover {
    box-shadow: 0 6px 20px rgba(251, 86, 7, 0.6);
}

/* Efeitos 3D para peças */
@keyframes pieceGlow {
    0%, 100% { filter: drop-shadow(0 0 5px rgba(102, 126, 234, 0.6)); }
    50% { filter: drop-shadow(0 0 15px rgba(102, 126, 234, 0.9)); }
}

@keyframes pieceFall {
    0% { transform: translateY(-10px) rotate(0deg); opacity: 0.8; }
    100% { transform: translateY(0) rotate(360deg); opacity: 1; }
}

/* === MASCOTE === */
.mascote-activate {
    animation: mascoteActivate 0.6s ease-out !important;
}

@keyframes mascoteActivate {
    0% { transform: scale(1); box-shadow: 0 0 0 rgba(102,126,234,0.3); }
    30% { transform: scale(1.4); box-shadow: 0 0 30px rgba(102,126,234,0.8), 0 0 50px rgba(102,126,234,0.4); }
    100% { transform: scale(1); box-shadow: 0 0 10px rgba(102,126,234,0.3); opacity: 0.5; }
}

/* Keyframes de animação idle por patente — usados pelo perfil (profile.html) */
@keyframes mascoteIdlePintinho {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}
@keyframes mascoteIdleCao {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
@keyframes mascoteIdleAguia {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-4px) rotate(-3deg); }
    75% { transform: translateY(-4px) rotate(3deg); }
}
@keyframes mascoteIdleLobo {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(2px); }
}
@keyframes mascoteIdlePantera {
    0%, 100% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.05) translateY(-2px); }
}
@keyframes mascoteIdleTigre {
    0%, 100% { box-shadow: 0 2px 8px rgba(255,107,107,0.3); }
    50% { box-shadow: 0 2px 20px rgba(255,107,107,0.7), 0 0 30px rgba(255,107,107,0.3); }
}
@keyframes mascoteIdleLeao {
    0%, 100% { box-shadow: 0 2px 8px rgba(255,193,7,0.3); }
    50% { box-shadow: 0 2px 25px rgba(255,193,7,0.8), 0 0 40px rgba(255,193,7,0.3); }
}
@keyframes mascoteIdleUrso {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}
@keyframes mascoteIdleDragao {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-5px) scale(1.1); box-shadow: 0 2px 30px rgba(255,0,0,0.6); }
}
@keyframes mascoteIdleCaveira {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Ajuste para telas muito pequenas (altura) — sem alterar max-height do game-container */
@media (max-height: 700px) {
    .bottom-panel { padding: 2px 4px 4px 4px !important; gap: 2px !important; }
    .question-box { font-size: clamp(0.65rem, 2vw, 0.85rem) !important; min-height: 24px !important; padding: 1px 4px !important; }
    .ans-btn { padding: 4px 4px !important; min-height: 28px !important; font-size: clamp(0.65rem, 2vw, 0.8rem) !important; }
    .ans-grid { gap: 4px !important; }
    .controls-row { gap: 3px !important; }
    .side-ctrl-btn,
    .action-btn { width: clamp(44px, 9vw, 52px) !important; height: clamp(44px, 9vw, 52px) !important; font-size: clamp(1.1rem, 2.8vw, 1.4rem) !important; }
    .stats-stack { gap: 4px; }
    .stats-right { padding: 4px 6px; font-size: 0.65rem; min-width: 60px; }
    .stats-panel { padding: 4px 6px; font-size: 0.7rem; }
}

/* Media query para mobile */
@media (max-width: 768px) {
    #itemButtons {
        display: flex !important;
        flex-direction: column !important;
        gap: 3px !important;
        padding: 5px 0 !important;
        min-width: 44px !important;
        width: 80px !important;
        right: 4px !important;
        align-items: center !important;
        flex-shrink: 0 !important;
    }
    .item-btn {
        font-size: 0.75rem;
        padding: 2px 3px;
        min-height: 28px;
        min-width: 44px;
        flex: 0 0 auto !important;
    }
    
    .combo-panel {
        left: 5px;
        min-width: 60px;
        font-size: 0.7rem;
        padding: 6px 8px;
    }
    
    .hint-panel {
        left: 5px;
        top: 30%; /* Mantido acima do combo no mobile */
        transform: translateY(-50%);
        font-size: 0.7rem;
        padding: 6px 8px;
        max-width: 90px;
    }
    
    .left-controls {
        left: 5px;
        bottom: 15px;
    }
    
    .right-controls {
        right: 5px;
        bottom: 15px;
    }
    
    .side-ctrl-btn,
    .action-btn {
        width: clamp(58px, 13vw, 72px);
        height: clamp(58px, 13vw, 72px);
        font-size: clamp(1.4rem, 3.2vw, 1.6rem);
    }

    .question-box { font-size: clamp(0.95rem, 3vw, 1.1rem) !important; }
    .ans-btn { font-size: clamp(0.95rem, 3vw, 1.2rem) !important; }
    
    /* Aumentar botões de controle no mobile */
    .ctrl-btn {
        width: clamp(40px, 10vw, 48px) !important;
        height: clamp(40px, 10vw, 48px) !important;
        font-size: clamp(1rem, 2.5vw, 1.2rem) !important;
        min-height: 40px !important;
    }
    
    /* Canvas e container: geometria controlada por canvas-fit.js; aqui só empilhamento */
    #game-container {
        z-index: 1 !important;
    }

    canvas {
        z-index: 10 !important;
    }
    
    /* Impedir seleção de texto nos botões de controle */
    .ctrl-btn {
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
        -webkit-touch-callout: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    /* Ajustar bottom panel para não cortar botões */
    .bottom-panel {
        padding-bottom: max(20px, env(safe-area-inset-bottom)) !important;
    }
    
    }

/* =============================================
   MASCOTE STACK + MASCOTE STAGE — Palco vivo ancorado no canto inferior direito.
   Balão de fala abre ACIMA do pet. Clicável, sempre animado.
   ============================================= */
#mascote-stack {
    position: absolute;
    right: 6px;
    bottom: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 16;
}
#mascote-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: 80px;
    min-height: 50px;
    cursor: pointer;
    pointer-events: auto;               /* é o gatilho do poder */
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
#mascote-stage:hover #mascote-emoji {
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.55)) drop-shadow(0 0 16px rgba(0,255,249,0.45));
}
#mascote-stage:hover #mascote-emoji,
#mascote-stage:active #mascote-emoji {
    /* O transform do emoji é controlado pelo JS (animação de vida).
       O hover dá feedback pelo brilho + leve impulso no balão. */
}
#mascote-stage:focus-visible {
    outline: 2px solid var(--neon-cyan);
    outline-offset: 2px;
    border-radius: 12px;
}
/* Poder já usado nesta partida — desabilitado visualmente */
#mascote-stage.mascote-stage-used {
    cursor: default;
    pointer-events: auto;
    opacity: 0.85;
}
#mascote-stage.mascote-stage-used #mascote-emoji {
    opacity: 0.45;
    filter: grayscale(0.85);
}
#mascote-emoji {
    font-size: clamp(2.4rem, 7.5vw, 3.2rem);
    line-height: 1;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5)) drop-shadow(0 0 12px rgba(0,255,249,0.25));
    transform-origin: bottom center;
    will-change: transform;
    /* A animação de vida (respiração/balanço) é feita via JS
       (requestAnimationFrame) para funcionar em qualquer navegador. */
}

/* --- Balão de fala --- */
/* Aberto ACIMA do pet, no vão entre a coluna de itens (bottom: 150px)
   e o palco, com a borda direita alinhada à borda direita do pet.
   Estende para a esquerda sobre o canto inferior do canvas.
   Nunca cobre a barra de itens: z-index abaixo de #itemButtons (30). */
#mascote-balloon {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    max-width: min(300px, calc(100vw - 24px));
    min-width: 84px;
    max-height: min(200px, 28vh);
    background: rgba(26, 26, 46, 0.95);
    border: 2px solid var(--neon-cyan);
    color: var(--text-1);
    font-size: clamp(0.75rem, 2.6vw, 0.9rem);
    font-weight: 800;
    line-height: 1.3;
    padding: 8px 12px;
    border-radius: 12px;
    text-align: center;
    overflow-wrap: anywhere;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    pointer-events: none;
    white-space: normal;
    z-index: 1;
}
/* Seta inferior apontando para o centro do pet */
#mascote-balloon::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 40px;
    transform: translateX(50%);
    border: 7px solid transparent;
    border-top: 7px solid var(--neon-cyan);
    border-bottom: 0;
}
#mascote-balloon.active {
    opacity: 1;
    transform: translateY(-4px);
}

/* --- Reações (classes aplicadas via JS) --- */
#mascote-emoji.mascote-stage-happy    { animation: mascoteStageHappy 0.7s ease-in-out; }
#mascote-emoji.mascote-stage-sad      { animation: mascoteStageSad 1s ease-in-out; }
#mascote-emoji.mascote-stage-think    { animation: mascoteStageThink 1.2s ease-in-out infinite; }
#mascote-emoji.mascote-stage-celebrate{ animation: mascoteStageCelebrate 1s ease-in-out infinite; }
#mascote-emoji.mascote-stage-danger   { animation: mascoteStageDanger 0.5s ease-in-out infinite; }

@keyframes mascoteStageHappy {
    0%, 100% { transform: scale(1) translateY(0) rotate(0); }
    30% { transform: scale(1.45) translateY(-12px) rotate(-4deg); }
    60% { transform: scale(0.95) translateY(2px) rotate(3deg); }
}
@keyframes mascoteStageSad {
    0%, 100% { transform: scale(1) translateY(0) rotate(0); }
    30% { transform: scale(0.9) translateY(4px) rotate(-6deg); }
    60% { transform: scale(0.95) translateY(2px) rotate(4deg); }
}
@keyframes mascoteStageThink {
    0%, 100% { transform: rotate(-4deg); }
    50% { transform: rotate(4deg); }
}
@keyframes mascoteStageCelebrate {
    0%, 100% { transform: scale(1) translateY(0) rotate(-5deg); }
    25% { transform: scale(1.25) translateY(-16px) rotate(6deg); }
    50% { transform: scale(1) translateY(0) rotate(-5deg); }
    75% { transform: scale(1.25) translateY(-16px) rotate(6deg); }
}
@keyframes mascoteStageDanger {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
    /* Reduz a intensidade em vez de eliminar: o mascote continua "vivo"
       em qualquer configuração do sistema. */
    #mascote-emoji.mascote-stage-happy    { animation-duration: 1.2s; }
    #mascote-emoji.mascote-stage-sad      { animation-duration: 1.8s; }
    #mascote-emoji.mascote-stage-think    { animation-duration: 2.4s; }
    #mascote-emoji.mascote-stage-celebrate{ animation-duration: 2s; }
    #mascote-emoji.mascote-stage-danger   { animation-duration: 1.6s; }
}

/* Feedback Card */
#feedback-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8); backdrop-filter: blur(8px);
    z-index: 9999; display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.3s ease-out; padding: 16px;
}
#feedback-card {
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid var(--neon-cyan); border-radius: 20px;
    box-shadow: 0 0 40px rgba(0,255,249,0.3), 0 0 80px rgba(0,255,249,0.1);
    max-width: 440px; width: 100%; max-height: 90vh; overflow-y: auto;
    animation: fadeIn 0.4s ease-out;
}
.fb-header {
    background: var(--gradient-error); padding: 16px 20px;
    border-radius: 18px 18px 0 0; font-size: 1.3rem; font-weight: 900;
    text-align: center; color: white; text-shadow: 0 2px 8px rgba(0,0,0,0.3);
    letter-spacing: 1px;
}
.fb-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.fb-section { display: flex; flex-direction: column; gap: 2px; }
.fb-label { font-size: 0.7rem; font-weight: 800; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }
.fb-value { font-size: 0.95rem; font-weight: 800; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,0.05); line-height: 1.3; }
.fb-question { color: var(--text-primary); font-size: 1rem; background: rgba(255,255,255,0.08); }
.fb-wrong { color: #ff6b6b; background: rgba(255,75,75,0.15); border-left: 3px solid #ff6b6b; text-decoration: line-through; }
.fb-correct { color: #51cf66; background: rgba(88,204,2,0.15); border-left: 3px solid var(--duo-green); }
.fb-concept { color: var(--text-primary); background: rgba(0,255,249,0.08); border-left: 3px solid var(--neon-cyan); }
.fb-tip { color: var(--neon-yellow); background: rgba(255,190,11,0.1); border-left: 3px solid var(--neon-yellow); font-size: 0.85rem; }
.fb-steps { list-style: none; padding: 0; margin: 4px 0 0 0; display: flex; flex-direction: column; gap: 4px; }
.fb-steps li { font-size: 0.85rem; color: var(--text-primary); padding: 4px 8px 4px 20px; background: rgba(255,255,255,0.04); border-radius: 6px; position: relative; line-height: 1.3; }
.fb-steps li::before { content: '\25B8'; position: absolute; left: 6px; color: var(--neon-cyan); font-size: 0.8rem; }
.fb-footer { padding: 12px 16px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.fb-timer { font-size: 2.2rem; font-weight: 900; color: var(--neon-cyan); text-shadow: 0 0 20px rgba(0,255,249,0.5); font-variant-numeric: tabular-nums; }
.fb-btn { width: 100%; padding: 14px; border: none; border-radius: 14px; font-size: 1.1rem; font-weight: 900; cursor: not-allowed; opacity: 0.4; text-transform: uppercase; letter-spacing: 2px; background: var(--glass-bg); color: var(--text-secondary); border: 2px solid var(--glass-border); transition: all 0.3s ease; }
.fb-btn-active { opacity: 1; cursor: pointer; background: var(--gradient-success); color: white; border-color: var(--neon-green); box-shadow: 0 0 25px rgba(6,255,165,0.4); animation: pulse 1s ease-in-out infinite; }
.fb-btn-active:hover { transform: translateY(-2px); box-shadow: 0 0 35px rgba(6,255,165,0.6); }
.fb-btn-active:active { transform: scale(0.97); }

.fb-compare { display: flex; flex-direction: column; gap: 6px; margin: 4px 0; }
.fb-compare-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; font-size: 0.95rem; font-weight: 800; }
.fb-compare-wrong { background: rgba(255,75,75,0.12); border: 1px solid rgba(255,75,75,0.3); color: #ff6b6b; }
.fb-compare-right { background: rgba(88,204,2,0.12); border: 1px solid rgba(88,204,2,0.3); color: #51cf66; }
.fb-compare-icon { font-size: 1.1rem; flex-shrink: 0; }
.fb-compare-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.7; flex-shrink: 0; }
.fb-compare-value { flex: 1; }

/* ONBOARDING */
#onboarding-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 99999; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
#onboarding-card { background: var(--card-bg); border: 2px solid var(--glass-border); border-radius: 20px; padding: 32px 28px 24px; max-width: 400px; width: 90%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.6); animation: onbFadeIn 0.3s ease; position: absolute; z-index: 100000; }
@keyframes onbFadeIn { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.onb-title { font-size: 1.3rem; font-weight: 900; color: var(--text-primary); margin-bottom: 12px; }
.onb-text { font-size: 0.95rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 20px; }
.onb-dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 20px; }
.onb-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--glass-border); transition: all 0.3s; }
.onb-dot-active { background: var(--neon-cyan); box-shadow: 0 0 10px rgba(0,255,249,0.5); width: 28px; border-radius: 5px; }
.onb-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.onb-nav > div { flex: 1; }
.onb-prev, .onb-next { padding: 10px 24px; border: none; border-radius: 12px; font-size: 0.9rem; font-weight: 800; cursor: pointer; transition: all 0.2s; text-transform: uppercase; letter-spacing: 1px; }
.onb-prev { background: var(--glass-bg); color: var(--text-secondary); border: 1px solid var(--glass-border); }
.onb-prev:hover { background: rgba(255,255,255,0.1); }
.onb-next { background: var(--gradient-success); color: white; box-shadow: 0 4px 15px rgba(6,255,165,0.3); }
.onb-next:hover { transform: translateY(-2px); box-shadow: 0 6px 25px rgba(6,255,165,0.5); }
.onb-next:active { transform: scale(0.97); }
#onboarding-skip { position: fixed; top: 16px; right: 16px; z-index: 100001; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: var(--text-secondary); padding: 6px 16px; border-radius: 8px; font-size: 0.8rem; cursor: pointer; transition: all 0.2s; }
#onboarding-skip:hover { background: rgba(255,255,255,0.2); color: var(--text-primary); }
.onb-highlight { position: relative; z-index: 99998; animation: onbPulse 2s ease-in-out infinite; box-shadow: 0 0 0 3px var(--neon-cyan), 0 0 25px rgba(0,255,249,0.3); border-radius: 8px; }
@keyframes onbPulse { 0%, 100% { box-shadow: 0 0 0 3px var(--neon-cyan), 0 0 25px rgba(0,255,249,0.3); } 50% { box-shadow: 0 0 0 6px var(--neon-cyan), 0 0 40px rgba(0,255,249,0.5); } }

/* =============================================
   STREAK SYSTEM — Combo de Acertos (Etapa 2)
   Classes aplicadas ao #combo-counter existente
   ============================================= */
.streak-tier-bronze { color: var(--c-por) !important; text-shadow: 0 0 10px var(--c-por), 0 0 20px var(--c-por-20); }
.streak-tier-silver { color: var(--c-mat) !important; text-shadow: 0 0 10px var(--c-mat), 0 0 20px var(--c-mat-20); }
.streak-tier-gold { color: var(--c-amber) !important; text-shadow: 0 0 10px var(--c-amber), 0 0 20px rgba(255,190,11,0.4); }
.streak-tier-legendary { color: var(--c-legendary) !important; text-shadow: 0 0 12px var(--c-legendary), 0 0 28px var(--c-legendary); animation: streakLegendary 0.8s ease-in-out infinite; }
@keyframes streakLegendary {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.15); filter: brightness(1.4); }
}
.streak-pulse { animation: streakPulse 0.4s ease-out; }
@keyframes streakPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.6); }
    100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .streak-tier-legendary, .streak-pulse { animation: none; }
}

/* =============================================
   PWA FLOATING BUTTON — instalação.
   Aparece via classe .nb-install-visible quando o
   navegador permite (beforeinstallprompt).
   ============================================= */
#nb-install-btn {
    position: fixed;
    left: 50%;
    transform: translateX(-50%) translateY(200%);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(26,26,46,0.95) 0%, rgba(22,33,62,0.95) 100%);
    color: var(--text-1, #ffffff);
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    font-weight: 900;
    letter-spacing: 0.5px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    white-space: nowrap;
    max-width: calc(100% - 32px);
}

/* Botão de instalação: neon ciano */
#nb-install-btn {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border: 2px solid var(--neon-cyan, #00fff9);
    box-shadow: 0 8px 30px rgba(0, 255, 249, 0.35), 0 0 20px rgba(0, 255, 249, 0.15);
}
#nb-install-btn:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 255, 249, 0.5), 0 0 30px rgba(0, 255, 249, 0.25);
}
#nb-install-btn:active {
    transform: translateX(-50%) scale(0.97);
}

#nb-install-btn.nb-install-visible {
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 600px) {
    #nb-install-btn {
        width: calc(100% - 32px);
        justify-content: center;
        left: 50%;
        transform: translateX(-50%) translateY(200%);
    }
    #nb-install-btn {
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
    #nb-install-btn.nb-install-visible,
    #nb-install-btn:hover {
        transform: translateX(-50%) translateY(0);
    }
}

/* ============================================================
   COMPONENTES DE AUTENTICACAO (login / cadastro / estudante / admin)
   Consolidados a partir do CSS inline historico. Usa tokens do
   design system. Escopado sob `body.nb-auth-page` para nao colidir
   com o jogo. As telas de form importam styles.css, marcam o <body>
   com `nb-auth-page` e removem o proprio CSS inline duplicado.
   ============================================================ */

body.nb-auth-page *,
body.nb-auth-page *::before,
body.nb-auth-page *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body.nb-auth-page {
    font-family: var(--nunito);
    background: var(--surface-1);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-1);
    overflow-y: auto;
}

/* --- Container --- */
body.nb-auth-page .container {
    max-width: 420px;
    width: 100%;
    padding: 20px;
}

/* --- Card --- */
body.nb-auth-page .card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 255, 249, 0.2), 0 0 30px rgba(0, 255, 249, 0.1);
    text-align: center;
    border: 1px solid rgba(0, 255, 249, 0.3);
    backdrop-filter: blur(10px);
}

/* --- Logo / titulo / subtitulo --- */
body.nb-auth-page .logo {
    font-size: 3rem;
    margin-bottom: 30px;
    text-align: center;
}
body.nb-auth-page .logo img {
    max-width: 280px;
    height: auto;
    display: block;
    margin: 0 auto;
}
body.nb-auth-page .title {
    color: var(--neon-cyan);
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 10px;
    text-shadow: 0 0 10px var(--neon-cyan);
}
body.nb-auth-page .subtitle {
    color: var(--text-2);
    margin-bottom: 30px;
}

/* --- Inputs --- */
body.nb-auth-page .input-group {
    margin-bottom: 20px;
}
body.nb-auth-page .input-group input {
    width: 100%;
    padding: 15px;
    border: 1px solid rgba(0, 255, 249, 0.3);
    border-radius: var(--radius-sm);
    font-size: 16px;
    text-align: center;
    background: var(--glass-bg);
    color: var(--text-1);
    backdrop-filter: blur(5px);
}
body.nb-auth-page .input-group input:focus {
    outline: none;
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 255, 249, 0.3);
}

/* --- Botao primario --- */
body.nb-auth-page .btn {
    width: 100%;
    padding: 15px;
    background: rgba(0, 255, 249, 0.2);
    color: var(--text-1);
    border: 1px solid var(--neon-cyan);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(5px);
}
body.nb-auth-page .btn:hover {
    background: rgba(0, 255, 249, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 255, 249, 0.4);
}
body.nb-auth-page .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- Erro --- */
body.nb-auth-page .error {
    color: var(--neon-pink);
    margin-top: 15px;
    display: none;
}

/* --- Links --- */
body.nb-auth-page .links {
    margin-top: 20px;
}
body.nb-auth-page .links a {
    color: var(--neon-cyan);
    text-decoration: none;
    font-weight: bold;
}
body.nb-auth-page .links a:hover {
    text-decoration: underline;
}

/* --- Notificacoes (painel estilo portal) --- */
body.nb-auth-page .notifications {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 350px;
    z-index: 1000;
}
body.nb-auth-page .notification {
    background: rgba(26, 26, 46, 0.95);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    animation: slideIn 0.3s ease-out;
    border: 1px solid rgba(0, 255, 249, 0.3);
    backdrop-filter: blur(10px);
}
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
body.nb-auth-page .notification-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}
body.nb-auth-page .notification-icon { font-size: 1.5rem; margin-right: 10px; }
body.nb-auth-page .notification-title { font-weight: bold; color: var(--text-1); }
body.nb-auth-page .notification-content {
    font-size: 0.9rem;
    color: var(--text-2);
    margin-bottom: 10px;
}
body.nb-auth-page .notification-actions { display: flex; gap: 10px; }
body.nb-auth-page .notification-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}
body.nb-auth-page .notification-btn.accept {
    background: rgba(0, 255, 249, 0.2);
    color: var(--text-1);
    border-color: var(--neon-cyan);
}
body.nb-auth-page .notification-btn.reject {
    background: rgba(255, 0, 110, 0.2);
    color: var(--text-1);
    border-color: var(--neon-pink);
}
body.nb-auth-page .notification-btn:hover { opacity: 0.9; }
body.nb-auth-page .notification-badge {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--neon-pink);
    color: var(--text-1);
    padding: 10px 15px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.1); }
}
body.nb-auth-page .notification-panel {
    display: none;
    position: fixed;
    top: 60px;
    right: 20px;
    max-width: 350px;
    z-index: 1000;
}
body.nb-auth-page .notification-panel.show { display: block; }

/* --- Alturas reduzidas (telas menores em altura) --- */
@media (max-height: 700px) {
    body.nb-auth-page { align-items: flex-start; }
    body.nb-auth-page .card { padding: 20px; }
    body.nb-auth-page .logo { margin-bottom: 15px; }
    body.nb-auth-page .logo img { max-width: 180px; }
    body.nb-auth-page .subtitle { margin-bottom: 15px; font-size: 0.85rem; }
    body.nb-auth-page .input-group { margin-bottom: 12px; }
    body.nb-auth-page .input-group input { padding: 10px; }
    body.nb-auth-page .btn { padding: 10px; }
    body.nb-auth-page .links { margin-top: 12px; }
}

/* --- Largura pequena (mobile) --- */
@media (max-width: 480px) {
    body.nb-auth-page { padding: 10px; }
    body.nb-auth-page .container { padding: 10px; }
    body.nb-auth-page .card { padding: 28px 20px; }
    body.nb-auth-page .logo img { max-width: 200px; }
    body.nb-auth-page .notifications,
    body.nb-auth-page .notification-panel { left: 12px; right: 12px; max-width: none; }
    body.nb-auth-page .notification-badge { top: 12px; right: 12px; }
}

/* ============================================================
   PERFORMANCE MOBILE (touch)
   `backdrop-filter: blur()` e custoso na GPU de celulares em
   elementos grandes sempre visiveis. Em telas touch, removemos o
   desfoque dos paineis do jogo e compensamos com fundo mais solido
   para manter legibilidade. Desktop/estilos de auth nao mudam.
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
    .header,
    .bottom-panel {
        background: rgba(10, 10, 20, 0.96);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    .ans-btn,
    .ctrl-btn,
    .item-btn,
    .btn-duo {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

/* ============================================================
   GAME OVER OVERLAY
   ============================================================ */
.gameover-overlay { display:none; position:fixed; inset:0; z-index:9999; background:rgba(0,0,0,0.88); align-items:center; justify-content:center; backdrop-filter:blur(8px); }
.gameover-overlay.show { display:flex; }
.gameover-card { background:linear-gradient(145deg,rgba(20,20,40,0.97),rgba(10,10,25,0.99)); border:2px solid rgba(0,255,249,0.4); border-radius:20px; padding:28px 22px; max-width:380px; width:92%; text-align:center; box-shadow:0 0 50px rgba(0,255,249,0.25); animation:goPop 0.35s ease-out; }
@keyframes goPop { 0%{transform:scale(0.6) translateY(30px);opacity:0} 100%{transform:scale(1) translateY(0);opacity:1} }
.gameover-card .go-icon { font-size:3rem; margin-bottom:6px; }
.gameover-card .go-title { font-family:'Orbitron',monospace; font-size:1.25rem; font-weight:900; margin-bottom:4px; text-shadow:0 0 12px currentColor; }
.gameover-card .go-title.win { color:#00fff9; }
.gameover-card .go-title.lose { color:#ff4b4b; }
.gameover-card .go-subtitle { color:#b0b0c0; font-size:0.8rem; margin-bottom:14px; }
.gameover-card .go-score { font-family:'Orbitron',monospace; font-size:2rem; font-weight:900; color:#ffd700; text-shadow:0 0 18px rgba(255,215,0,0.5); margin:6px 0; }
.gameover-card .go-stats { display:grid; grid-template-columns:1fr 1fr 1fr; gap:6px; margin:14px 0; }
.gameover-card .go-stat { background:rgba(255,255,255,0.06); border-radius:8px; padding:8px 4px; }
.gameover-card .go-stat-val { font-size:1.2rem; font-weight:800; color:#00fff9; }
.gameover-card .go-stat-lbl { font-size:0.65rem; color:#888; margin-top:2px; }
.gameover-card .go-buttons { display:flex; gap:10px; margin-top:16px; }
.gameover-card .go-btn { flex:1; padding:11px 0; border:none; border-radius:10px; font-size:0.9rem; font-weight:800; cursor:pointer; font-family:'Nunito',sans-serif; }
.go-btn.primary { background:linear-gradient(135deg,#00fff9,#00b8d4); color:#0a0a0f; }
.go-btn.secondary { background:rgba(255,255,255,0.1); color:#ccc; border:1px solid rgba(255,255,255,0.2); }
.go-btn:hover { transform:scale(1.04); }
