/* main.css is a production bundle that concatenates the modules in this order:
    variables.css, base.css, layout.css, components/cards.css, components/buttons.css,
    components/progress-score.css, components/keyboard.css, components/achievements.css,
    components/fractions.css, components/curiosidade.css, components/narrative.css,
    components/footer-nav.css, components/panels.css */

/* CONCAT START: variables.css */
:root {
    /* === COLORS === */
    --bg-color: #f0f4f8;
    --main-bg-color: white;
    --text-color: #1f2937;
    --primary-color: #4338ca;
    --primary-hover-color: #3730a3;
    --secondary-color: #9ca3af;
    --border-color: #d1d5db;
    --score-bg-color: #e0e7ff;
    --progress-bar-bg: #d1d5db;
    --correct-color: #047857;
    --incorrect-color: #b91c1c;

    --card-bg: linear-gradient(135deg, #e6f0ff 0%, #cfe0ff 100%);
    --card-text: #0b3a66;

    /* === ANIMATIONS === */
    --transition-fast: 180ms;
    --transition-medium: 240ms;
    --transition-slow: 480ms;
    --easing-standard: cubic-bezier(.2,.9,.2,1);

    /* === DIMENSIONS - CENTRALIZED === */
    --max-width-main: 60rem;
    --header-height: 3rem;
    --btn-theme-size: 2.5rem;
    --btn-min-height: 44px;
    
    /* === BUTTON THEME-TOGGLE CENTRALIZATION === */
    --btn-theme-padding: 0;
    --btn-theme-font-size: 1.2rem;
    --btn-theme-line-height: 1;
}

.dark-mode {
    --bg-color: #0f172a;
    --main-bg-color: #1e293b;
    --text-color: #f1f5f9;
    --primary-color: #6366f1;
    --primary-hover-color: #818cf8;
    --secondary-color: #64748b;
    --border-color: #475569;
    --score-bg-color: #334155;
    --progress-bar-bg: #475569;
    --correct-color: #34d399;
    --incorrect-color: #fca5a5;
    --card-bg: var(--primary-color);
    --card-text: #0f172a;
}
/* CONCAT END: variables.css */

/* CONCAT START: base.css */
/* box model */
* { box-sizing: border-box; }

/* body e tipografia base */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    word-wrap: break-word;           /* Quebra texto longo */
    overflow-wrap: break-word;       /* Suporte moderno */
    position: relative;              /* Contexto de posicionamento para elementos absolute */
}

/* headings */
h1,h2,h3,h4,h5,h6 {
    color: var(--text-color);
    font-weight: 700;
    word-wrap: break-word;           /* Quebra texto longo */
    overflow-wrap: break-word;       /* Suporte moderno */
    word-break: break-word;          /* Fallback */
    hyphens: auto;                   /* Hífenes se suportado */
}

/* Garante herança de cor */
p, span, div {
    color: inherit;
}

/* selection */
::selection { background-color: var(--primary-color); color: white; }
.dark-mode ::selection { background-color: var(--primary-color); color: white; }

/* helpers */
.hidden { display: none !important; }

/* Animation classes para transições entre menus */
.animating-in {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity var(--transition-medium) var(--easing-standard), 
                transform var(--transition-medium) var(--easing-standard);
}

.animating-out {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity var(--transition-medium) var(--easing-standard), 
                transform var(--transition-medium) var(--easing-standard);
}

/* Classe para main durante transição entre seções */
main.transitioning {
    height: var(--preserved-height, auto);
    overflow: hidden;
}

/* Botão close-section sempre responsivo, mesmo durante transições */
.close-section {
    pointer-events: auto !important;
    z-index: 100;
    position: relative;
}

/* Botão back-to-menu sempre responsivo, mesmo durante transições */
#back-to-menu {
    pointer-events: auto !important;
    z-index: 100;
    position: relative;
}

/* placeholders */
input::placeholder { color: #6b7280; opacity: 1; }
.dark-mode input::placeholder { color: #9ca3af; }

/* Material Symbols (Google) local font setup */
@font-face {
    font-family: 'Material Symbols Outlined Local';
    src: url('../fonts/MaterialSymbolsOutlined.woff2') format('woff2');
    font-weight: 100 700;
    font-style: normal;
    font-display: swap;
}

/* Define a família que o CSS usa: primeiro a local (se existir), depois a remote family name.
   Mantemos a entrada genérica 'Material Symbols Outlined' como fallback para compatibilidade.
*/
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined Local', 'Material Symbols Outlined', sans-serif;
}

/* ==============================
    Utility classes (spacing, text, flex)
    Small, safe set of helpers to reduce duplication
    ============================== */
.u-p-0 {
    padding: 0 !important;
}

.u-p-1 {
    padding: .25rem !important;
}

.u-p-2 {
    padding: .5rem !important;
}

.u-p-3 {
    padding: 1rem !important;
}

.u-m-0 {
    margin: 0 !important;
}

.u-m-1 {
    margin: .25rem !important;
}

.u-m-2 {
    margin: .5rem !important;
}

.u-m-3 {
    padding: 1rem !important;
}

.u-gap-1 {
    gap: .25rem !important;
}

.u-gap-2 {
    gap: .5rem !important;
}

.u-gap-3 {
    gap: 1rem !important;
}

.u-flex {
    display: flex !important;
}

.u-inline-flex {
    display: inline-flex !important;
}

.u-center {
    align-items: center !important;
    justify-content: center !important;
}

.text-sm {
    font-size: .875rem !important;
}

.text-base {
    font-size: 1rem !important;
}

.text-lg {
    font-size: 1.2rem !important;
}

.text-bold {
    font-weight: 700 !important;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* CONCAT END: base.css */

/* CONCAT START: layout.css */
main {
    position: relative;
    text-align: center;
    background-color: var(--main-bg-color);
    padding: 2rem;
    margin: 1rem auto;
    width: 90%;
    max-width: var(--max-width-main);
    border-radius: 15px;
    box-shadow: 0 4px 15px rgb(0 0 0 / 10%);
    min-height: 25rem;
    transition: min-height var(--transition-medium) var(--easing-standard);
}

/* Header / topbar */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--main-bg-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 14px rgb(0 0 0 / 6%);
    min-height: 2.75rem;  /* Evita layout shift */
}

.header-inner {
    max-width: var(--max-width-main);
    margin: 0 auto;
    padding: .5rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    justify-content: space-between;
}

/* Estilos para points-pill */
.points-pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .5rem;
    background: var(--score-bg-color);
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* theme button dentro do header */
.app-header #theme-toggle { 
    position: static; 
    width: var(--btn-theme-size); 
    height: var(--btn-theme-size); 
    border-radius: 50%; 
    margin: 0; 
    padding: var(--btn-theme-padding);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--btn-theme-font-size);
    line-height: var(--btn-theme-line-height);
}

/* gamification bar (navbar group) */
.app-header .gamification-bar {
    position: static;
    top: auto;
    z-index: auto;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    display: flex;
    align-items: center;
    gap: .75rem;
}

/* Ajustes responsivos do header */
@media (max-width: 768px) {
    .header-inner {
        max-width: 100% !important;
        width: 100%;
        margin: 0;
        padding: .35rem .5rem;  /* Reduzido de .5rem .75rem para economizar espaço em mobile */
        box-sizing: border-box;
        display: flex;
        align-items: center;
        gap: .35rem;  /* Reduzido de .5rem */
    }

    /* header sem padding extra que limite a barra */
    .app-header {
        padding: 0;
        width: 100%; /* garante largura total */
        min-height: 2.5rem;  /* Mobile mais compacto que desktop */
    }

    /* gamification bar ocupa toda a largura disponível */
    .gamification-bar {
        width: 100%;
        flex: 1; /* expande para ocupar espaço restante */
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .35rem;  /* Reduzido de .5rem */
        min-width: 0; /* permite shrinking dos elementos filhos */
    }

    /* botão tema com largura fixa */
    #theme-toggle {
        flex-shrink: 0; /* não reduz */
        width: var(--btn-theme-size);
        height: var(--btn-theme-size);
    }

    /* botão utilizador com largura flexível mas com mínimo */
    .user-btn {
        flex-shrink: 1;
        min-width: 60px; /* mínimo para manter legível */
        max-width: 120px; /* máximo para não dominar */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        word-break: break-word;  /* Quebra como fallback */
    }

    /* pontos e badges ocupam espaço restante */
    .points-badges {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: flex-end; /* alinha à direita */
        gap: .35rem;  /* Reduzido de .5rem */
        min-width: 0;
    }
    
    /* Reduzir pontos-pill em mobile */
    .points-pill {
        padding: .2rem .4rem;
        font-size: 0.8rem;
    }
}

/* Tablets pequenos e phones grandes (481px a 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .header-inner {
        padding: .5rem .75rem;
        gap: .5rem;
    }

    .user-btn {
        font-size: 0.9rem;
        padding: .35rem .6rem;
        max-width: 110px;
    }
}

/* Para ecrãs muito pequenos */
@media (max-width: 480px) {
    .header-inner {
        padding: .25rem .4rem; /* Reduzido ainda mais para ecrãs muito pequenos */
        gap: .25rem;  /* Reduzido */
    }

    .user-btn {
        font-size: 0.85rem;
        padding: .2rem .35rem;  /* Reduzido de .3rem .5rem */
        max-width: 100px;
    }
    
    .points-pill {
        padding: .15rem .3rem;
        font-size: 0.75rem;
    }
}
/* CONCAT END: layout.css */

/* CONCAT START: cards.css */
.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(150px, 100%, 180px), 1fr));
    grid-auto-rows: minmax(9.375rem, auto);  /* Reserva altura mínima dos cards antes da animação */
    gap: 1rem;
    margin-top: 2rem;
    padding: 0.5rem;                 /* Espaço para hover effect não cortar cards */
    overflow-x: auto;                /* Scroll horizontal em mobile se necessário */
    -webkit-overflow-scrolling: touch;
}

.card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg, linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover-color) 100%));
    color: var(--card-text, #fff);
    padding: 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: transform var(--transition-medium) var(--easing-standard), box-shadow var(--transition-medium) var(--easing-standard), filter var(--transition-medium) var(--easing-standard);
    text-align: center;
    min-height: 9.375rem;
    border: 2px solid transparent;
    box-shadow: 0 4px 12px rgb(67 56 202 / 15%);
}

.card-text { font-size: 0.95rem; line-height: 1.3; font-weight: 600; text-shadow: 0 1px 2px rgb(0 0 0 / 20%); }
.card-emoji { font-size: 2.5rem; margin-top: 0.5rem; filter: drop-shadow(0 2px 4px rgb(0 0 0 / 20%)); }

.card:hover { transform: translateY(-6px); box-shadow: 0 10px 30px rgb(67 56 202 / 22%); filter: brightness(1.04); border-color: rgb(255 255 255 / 12%); }
.card:active { transform: translateY(-2px); }
.card:focus { outline: 3px solid #fff; outline-offset: 3px; }

/* Material Symbols card icons */
.material-symbols-outlined.card-icon {
    /* Use clamp to scale between mobile and desktop nicely */
    font-family: 'Material Symbols Outlined', sans-serif;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 48;
    font-size: clamp(32px, 6.5vw, 64px); /* min 32px on small screens, scales with viewport, max 64px on large screens */
    line-height: 1;
    display: inline-block;
    vertical-align: middle;
    width: auto;
    height: auto;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizelegibility;
}

@media (max-width: 480px) {
    .material-symbols-outlined.card-icon {
        font-size: clamp(28px, 9vw, 40px); /* slightly smaller caps on very small screens */
    }
}

/* Imagens SVG externas usadas como ícones devem herdar a cor do texto e ter 75px */
img.card-icon {
    width: 4.6875rem;
    height: 4.6875rem;
    vertical-align: middle;
    color: inherit; /* tenta garantir que currentColor no SVG resolve corretamente */
}

/* CORREÇÃO: garantir contraste dentro dos cartões */
.card .card-icon {
    /* herda a cor do texto do cartão (o .card define color: white) */
    color: inherit;           /* herda a cor do texto do cartão */
    display: inline-block;
    vertical-align: middle;
}

/* As formas dentro do SVG que usam 'currentColor' seguirão .card color */
.card .card-icon [fill="currentColor"],
.card .card-icon path,
.card .card-icon rect,
.card .card-icon circle {
    fill: currentcolor;
}

/* Forçar todos os shapes dentro do svg a usar currentColor por defeito.
   Usa !important para sobrepor fills/strokes inline que não sejam desejados. */
.card-icon * {
    fill: currentcolor !important;
    stroke: currentcolor !important;
    stroke-width: 1 !important;
}
/* CONCAT END: cards.css */

/* CONCAT START: buttons.css */
/* Botões modernos (flat, acessíveis) */
button {
    appearance: none;
    border: 2px solid var(--border-color);
    background: var(--main-bg-color);
    color: var(--text-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .04s ease, box-shadow .2s ease, background-color .2s ease, border-color .2s ease;
    box-shadow: 0 2px 4px rgb(0 0 0 / 10%);
    min-height: var(--btn-min-height);
}

button:hover { box-shadow: 0 4px 14px rgb(0 0 0 / 12%); border-color: var(--primary-color); transform: translateY(-1px); }
button:active { transform: translateY(1px); box-shadow: 0 1px 2px rgb(0 0 0 / 10%); }
button:disabled { opacity: .6; cursor: not-allowed; transform: none; }
button:focus { outline: 3px solid var(--primary-color); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }
button:focus-visible { outline: 3px solid var(--primary-color); outline-offset: 2px; }

.btn.primary, #check-button, #next-button, #next-level-button {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    font-weight: 700;
}
.btn.primary:hover, #check-button:hover, #next-button:hover, #next-level-button:hover {
    background: var(--primary-hover-color);
    border-color: var(--primary-hover-color);
    box-shadow: 0 6px 18px rgb(67 56 202 / 25%);
}

#back-to-menu {
    background: var(--secondary-color);
    color: var(--text-color);
    border-color: var(--secondary-color);
    font-weight: 600;
}
#back-to-menu:hover {
    background: var(--text-color);
    color: #fff;
    border-color: var(--text-color);
}
.btn.secondary {
    background: var(--secondary-color);
    color: var(--text-color) !important;
    border-color: var(--secondary-color);
}
/* CONCAT END: buttons.css */

/* CONCAT START: progress-score.css */
#score-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    background-color: var(--score-bg-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 2px 5px rgb(0 0 0 / 5%);
    z-index: 999;
    max-width: calc(100% - 2rem);  /* Previne overflow fora do viewport */
    overflow: hidden;              /* Garante conteúdo contido */
    text-overflow: ellipsis;       /* Trunca com elipsis se necessário */
}
#score-container span { white-space: nowrap; }
#correct-count { color: var(--correct-color); font-weight: bold; text-shadow: 0 0 2px rgb(255 255 255 / 80%); }
#incorrect-count { color: var(--incorrect-color); font-weight: bold; text-shadow: 0 0 2px rgb(255 255 255 / 80%); }

#feedback { font-weight: 600; padding: 1rem; border-radius: 8px; margin: 1rem 0; }
#feedback.correct { background-color: rgb(5 150 105 / 10%); color: var(--correct-color); border: 2px solid var(--correct-color); }
#feedback.incorrect { background-color: rgb(220 38 38 / 10%); color: var(--incorrect-color); border: 2px solid var(--incorrect-color); }

.dark-mode #correct-count { text-shadow: 0 0 2px rgb(0 0 0 / 80%); }
.dark-mode #incorrect-count { text-shadow: 0 0 2px rgb(0 0 0 / 80%); }
.dark-mode #feedback.correct { background-color: rgb(16 185 129 / 15%); border-color: var(--correct-color); }
.dark-mode #feedback.incorrect { background-color: rgb(248 113 113 / 15%); border-color: var(--incorrect-color); }

#progress-section {
    width: 100%;
    max-width: 600px;
    margin: 1.5rem auto 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 10;
}

#level-badge { background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: white; padding: 0.5rem 1rem; border-radius: 20px; font-weight: 600; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 0.3rem; box-shadow: 0 2px 8px rgb(0 0 0 / 15%); border: 2px solid rgb(255 255 255 / 20%); }
#current-level { background: rgb(255 255 255 / 20%); padding: 0.2rem 0.6rem; border-radius: 12px; font-weight: 700; min-width: 1.5rem; text-align: center; }

#progress-bar-container { flex: 1; background-color: var(--progress-bar-bg); border-radius: 10px; overflow: hidden; }
#progress-bar { height: 15px; width: 0%; background-color: var(--correct-color); border-radius: 10px; transition: width 0.5s ease-in-out; }

#summary-area { padding: 2rem 1rem; }
#summary-area h2 { color: var(--primary-color); margin-top: 0; }
#summary-record-message { color: var(--primary-hover-color); font-weight: bold; font-size: 1.2rem; min-height: 1.5rem; }
/* CONCAT END: progress-score.css */

/* CONCAT START: keyboard.css */
.custom-keyboard { 
    margin-top: 1rem; 
    width: 100%; 
    max-width: 18.75rem; 
    margin-left: auto; 
    margin-right: auto; 
    overflow-x: auto;                /* Scroll se necessário em mobile */
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.keyboard-row { 
    display: flex; 
    justify-content: center; 
    gap: 0.5rem; 
    margin-bottom: 0.5rem; 
    min-width: min-content;           /* Garante que não encolhe demais */
}

.key {
    flex: 1;
    min-width: 3.125rem;
    max-width: 4.5rem;                /* Evita que cresça demais */
    height: 3.125rem;
    border: 1px solid var(--border-color);
    background: var(--main-bg-color);
    color: var(--text-color);
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgb(0 0 0 / 10%);
    overflow: hidden;                 /* Evita que texto saia */
    text-overflow: ellipsis;          /* Trunca se necessário */
}

/* Mobile-specific keyboard adjustments kept in responsive.css */

/* Delete button specific styles */
.delete {
    background-color: #ef4444;
    color: white;
    border-color: #ef4444;
}

.delete:hover {
    background-color: #dc2626;
}
/* CONCAT END: keyboard.css */

/* CONCAT START: fractions.css */
/* ========================================
   SISTEMA DE FRAÇÕES - REPRESENTAÇÃO VISUAL
   ======================================== */

/* Container principal para exercícios de frações */
.fraction-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin: 1rem 0;
    padding: 1rem;
}

/* Representação visual individual de uma fração */
.fraction-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* Notação matemática da fração (numerador/denominador) */
.fraction-notation {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0.5rem;
}

.fraction-numerator {
    padding: 0.25rem 0.5rem;
    text-align: center;
    min-width: 2rem;
}

.fraction-line {
    width: 100%;
    height: 2px;
    background-color: var(--text-color);
    margin: 0.1rem 0;
}

.fraction-denominator {
    padding: 0.25rem 0.5rem;
    text-align: center;
    min-width: 2rem;
}

/* Representação visual em barras */
.fraction-bar-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.fraction-bar {
    display: flex;
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    height: 2.5rem;
    min-width: 12.5rem;
    overflow: hidden;
}

.fraction-segment {
    flex: 1;
    border-right: 1px solid var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background-color var(--transition-fast) var(--easing-standard);
}

.fraction-segment:last-child {
    border-right: none;
}

.fraction-segment.filled {
    background-color: var(--primary-color);
    color: white;
}

.fraction-segment.empty {
    background-color: var(--main-bg-color);
    color: var(--text-color);
}

/* Representação circular */
.fraction-circle-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.fraction-circle {
    width: 7.5rem;
    height: 7.5rem;
    border-radius: 50%;
    border: 3px solid var(--primary-color);
    position: relative;
    overflow: hidden;
    background-color: var(--main-bg-color);
}

.fraction-circle-segment {
    position: absolute;
    width: 50%;
    height: 50%;
    transform-origin: 100% 100%;
    border: 1px solid var(--primary-color);
}

.fraction-circle-segment.filled {
    background-color: var(--primary-color);
    opacity: 0.8;
}

/* Container para operações entre frações */
.fraction-operation {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.fraction-operator {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    padding: 0 0.5rem;
}

.fraction-equals {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-color);
    padding: 0 0.5rem;
}

/* Destaque para frações equivalentes */
.fraction-equivalent {
    border: 2px dashed var(--correct-color);
    border-radius: 8px;
    padding: 1rem;
    background-color: rgb(var(--correct-color), 0.05);
}

/* Interface especial para exercícios de equivalência com input inline */
.fraction-equivalent-with-input {
    background-color: var(--score-bg-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1rem 0;
    border: 1px solid var(--border-color);
}

.fraction-operation-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.fraction-visual-help {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.fraction-help-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--secondary-color);
    margin: 0 0 0.5rem;
    text-align: center;
}

/* Animação para demonstrar simplificação */
.fraction-simplify-animation {
    position: relative;
    transition: all var(--transition-medium) var(--easing-standard);
}

.fraction-simplify-animation::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, transparent 40%, var(--correct-color) 45%, var(--correct-color) 55%, transparent 60%);
    opacity: 0;
    animation: simplify-strike 2s ease-in-out;
}

@keyframes simplify-strike {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.6; }
}

/* Input inline para frações em falta */
.fraction-missing-input {
    border: 2px dashed var(--primary-color);
    background: var(--main-bg-color);
    border-radius: 4px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    padding: 0.25rem 0.5rem;
    min-width: 2.5rem;
    max-width: 3.5rem;
    outline: none;
    transition: all var(--transition-fast) var(--easing-standard);
}

.fraction-missing-input:focus {
    border-color: var(--primary-hover-color);
    box-shadow: 0 0 0 3px rgb(var(--primary-color), 0.2);
    background-color: var(--score-bg-color);
    position: relative;
}

/* Input ativo (quando usando teclado personalizado) */
.fraction-missing-input[data-active="true"] {
    border-color: var(--primary-hover-color);
    box-shadow: 0 0 0 2px rgb(var(--primary-color), 0.4);
    background-color: var(--score-bg-color);
}

.fraction-missing-input:focus::after {
    content: "Use o teclado abaixo";
    position: absolute;
    top: -2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: normal;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    animation: fade-in-out 2s ease-in-out;
}

@keyframes fade-in-out {
    0% { opacity: 0; transform: translateX(-50%) translateY(5px); }
    20%, 80% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-5px); }
}

.fraction-missing-input::placeholder {
    color: var(--secondary-color);
    font-style: italic;
}

/* Remover botões de incremento/decremento (spinners) dos inputs numéricos */
.fraction-missing-input::-webkit-outer-spin-button,
.fraction-missing-input::-webkit-inner-spin-button {
    appearance: none;
    margin: 0;
}

/* Para Firefox */
.fraction-missing-input[type="number"] {
    appearance: textfield;
    appearance: textfield;
}

/* Legenda para auxiliar na compreensão */
.fraction-legend {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--secondary-color);
}

.fraction-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fraction-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.fraction-legend-color.filled {
    background-color: var(--primary-color);
}

.fraction-legend-color.empty {
    background-color: var(--main-bg-color);
    border: 1px solid var(--border-color);
}

/* Destaque de operações aritméticas (adição/subtração) acessível */
.op-add {
    background: #e0fce4;
    color: #065f46; /* contraste ~6:1 */
}

.op-sub {
    background: #fde2e1;
    color: #7f1d1d; /* contraste ~6:1 */
}

.dark-mode .op-add {
    background: #064e3b;
    color: #d1fae5;
}

.dark-mode .op-sub {
    background: #7f1d1d;
    color: #fee2e2;
}

/* Term boxes para exercícios com termo em falta */
.term-box {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    margin: 0.25rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--main-bg-color);
    color: var(--text-color);
    font-size: 1.1em;
    font-weight: bold;
    text-align: center;
    min-width: 2.5rem;
    min-height: 2.5rem;
    vertical-align: middle;
    box-shadow: 0 2px 4px rgb(0 0 0 / 10%);
    transition: all 0.2s ease;
}

.term-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgb(0 0 0 / 15%);
}

/* Elementos específicos para layouts inline melhorados */
.op {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0 0.5rem;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    display: inline-block;
}

.op-multiply, .op-divide, .op-add, .op-sub {
    font-size: 1.4em;
}

.equals {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--text-color);
    margin: 0 0.5rem;
}

.label {
    font-size: 1em;
    color: var(--text-color);
    font-weight: 500;
}

.comma {
    font-size: 1em;
    color: var(--text-color);
    margin: 0 0.2rem;
}

.fraction-display {
    font-size: 1.2em;
    color: var(--text-color);
    margin: 0 0.5rem;
}

/* Adaptações responsivas para frações */
@media (max-width: 768px) {
    .fraction-notation {
        font-size: 1.2rem;
    }

    .fraction-bar {
        min-width: 9.375rem;
        height: 1.875rem;
        max-width: 100%;              /* Garante fit em mobile */
        overflow-x: auto;             /* Scroll se necessário */
        -webkit-overflow-scrolling: touch;
    }

    .fraction-circle {
        width: 5rem;
        height: 5rem;
        max-width: 100%;              /* Responsive */
    }

    .fraction-operation {
        gap: 0.5rem;
    }

    .fraction-operation-inline {
        gap: 0.8rem;
        margin: 0.8rem 0;

        /* Manter layout horizontal em vez de vertical */
        flex-flow: row nowrap;
    }

    .fraction-operator, .fraction-equals {
        font-size: 1.3rem;
        margin: 0.2rem 0;
    }

    .fraction-missing-input {
        font-size: 1.1rem;
        min-width: 2rem;
        max-width: 2.8rem;
        padding: 0.4rem 0.5rem;
    }

    .fraction-equivalent-with-input {
        padding: 0.8rem;
        margin: 0.3rem 0;
        border-radius: 8px;
    }

    .fraction-visual-help {
        margin-top: 1rem;
        padding-top: 0.8rem;
    }

    /* Teclado personalizado otimizado para frações em tablets */
    .custom-keyboard {
        margin-top: 0.8rem;
        max-width: 18.75rem;
    }

    .key {
        min-width: 2.8125rem;
        height: 2.8125rem;
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .fraction-container {
        gap: 0.8rem;
        padding: 0.4rem;
    }

    .fraction-operation {
        gap: 0.4rem;

        /* Layout horizontal para simplicação */
        flex-flow: row nowrap;
        align-items: center;
        justify-content: center;
    }

    .fraction-operation-inline {
        gap: 0.5rem;
        margin: 0.6rem 0;

        /* Layout horizontal compacto */
        flex-flow: row nowrap;
        justify-content: center;
    }

    .fraction-bar {
        min-width: 6.25rem;
        height: 1.25rem;
        max-width: 100%;              /* Garante fit em mobile muito pequeno */
        overflow-x: auto;             /* Scroll se necessário */
        -webkit-overflow-scrolling: touch;
    }

    .fraction-circle {
        width: 3.125rem;
        height: 3.125rem;
        max-width: 100%;              /* Responsive em extra-small */
    }

    .fraction-legend {
        flex-direction: column;
        gap: 0.4rem;
        font-size: 0.8rem;
    }

    .fraction-missing-input {
        font-size: 1rem;
        min-width: 1.8rem;
        max-width: 2.5rem;
        padding: 0.3rem 0.4rem;
    }

    .fraction-operator, .fraction-equals {
        font-size: 1.3rem;
        padding: 0 0.3rem;
    }

    .fraction-equivalent-with-input {
        padding: 0.6rem;
        margin: 0.2rem 0;
        border-radius: 6px;
    }

    .fraction-operator, .fraction-equals {
        font-size: 1.1rem;
        margin: 0.1rem 0;
    }

    .inline-missing-input {
        font-size: 1rem;
        min-width: 2rem;
        max-width: 5rem;
        padding: 0.2rem 0.3rem;
    }

    .fraction-visual-help {
        margin-top: 0.8rem;
        padding-top: 0.6rem;
    }

    .fraction-help-title {
        font-size: 0.8rem;
    }

    /* Teclado personalizado otimizado para frações em móveis pequenos */
    .custom-keyboard {
        margin-top: 0.5rem;
        max-width: 16.25rem;
        padding: 0 0.3rem;
    }

    .keyboard-row {
        gap: 0.3rem;
        margin-bottom: 0.3rem;
    }

    .key {
        min-width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
        border-radius: 6px;
    }
}
/* CONCAT END: fractions.css */

/* CONCAT START: curiosidade.css */
/* Curiosidade Matemática - Melhorada com altura dinâmica */
.curiosidade-matematica {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.2rem;
    border-radius: 12px;
    margin: 1.5rem 0;
    font-size: 1rem;
    line-height: 1.6;
    box-shadow: 0 4px 12px rgb(102 126 234 / 30%);
    border-left: 4px solid #4facfe;
    transition: transform var(--transition-fast) var(--easing-standard),
                min-height var(--transition-medium) var(--easing-standard);
    position: relative;

    /* Adicionar padding para os controlos */
    padding-right: 4rem;

    /* Altura dinâmica - previne layout shift */
    min-height: 5.6rem; /* Altura fixa para ~2 linhas (padding + 2 * line-height) para evitar layout shift */
    max-height: 8rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;  /* Smooth scroll iOS */
    word-wrap: break-word;              /* Quebra texto longo */
    overflow-wrap: break-word;          /* Suporte moderno */

    /* Smooth scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: rgb(255 255 255 / 30%) transparent;
}

/* Webkit scrollbar styling */
.curiosidade-matematica::-webkit-scrollbar {
    width: 6px;
}

.curiosidade-matematica::-webkit-scrollbar-track {
    background: rgb(255 255 255 / 10%);
    border-radius: 3px;
}

.curiosidade-matematica::-webkit-scrollbar-thumb {
    background: rgb(255 255 255 / 30%);
    border-radius: 3px;
}

.curiosidade-matematica::-webkit-scrollbar-thumb:hover {
    background: rgb(255 255 255 / 50%);
}

.curiosidade-matematica:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgb(102 126 234 / 40%);
}

.curiosidade-controls {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    display: flex;
    gap: 0.5rem;
}

.nova-curiosidade-btn,
.toggle-rotacao-btn {
    background: rgb(255 255 255 / 20%);
    border: none;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast) var(--easing-standard);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nova-curiosidade-btn:hover {
    background: rgb(255 255 255 / 30%);
    transform: rotate(180deg);
}

.toggle-rotacao-btn:hover {
    background: rgb(255 255 255 / 30%);
    transform: scale(1.1);
}

.toggle-rotacao-btn.paused {
    background: rgb(255 255 255 / 40%);
}

.curiosidade-icon {
    font-size: 1.2em;
    margin-right: 0.5rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.dark-mode .curiosidade-matematica {
    background: linear-gradient(135deg, #4338ca 0%, #5b21b6 100%);
    border-left-color: #6366f1;
    box-shadow: 0 4px 12px rgb(67 56 202 / 40%);

    /* Dark mode scrollbar */
    scrollbar-color: rgb(255 255 255 / 40%) transparent;
}

.dark-mode .curiosidade-matematica:hover {
    box-shadow: 0 6px 16px rgb(67 56 202 / 50%);
}

.dark-mode .curiosidade-matematica::-webkit-scrollbar-track {
    background: rgb(255 255 255 / 5%);
}

.dark-mode .curiosidade-matematica::-webkit-scrollbar-thumb {
    background: rgb(255 255 255 / 40%);
}

.dark-mode .curiosidade-matematica::-webkit-scrollbar-thumb:hover {
    background: rgb(255 255 255 / 60%);
}

/* Responsividade móvel para curiosidade */
@media (max-width: 768px) {
    .curiosidade-matematica {
        margin: 1rem 0;
        padding: 1rem;
        padding-right: 3.5rem;
        font-size: 0.9rem;
        min-height: 5.2rem; /* padding (1*2) + line-height (1.6 * 0.9 * 2) */
        max-height: 7rem;
    }

    .curiosidade-controls {
        top: 0.6rem;
        right: 0.6rem;
        gap: 0.4rem;
    }

    .nova-curiosidade-btn,
    .toggle-rotacao-btn {
        width: 1.8rem;
        height: 1.8rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .curiosidade-matematica {
        padding: 0.8rem;
        padding-right: 3rem;
        font-size: 0.85rem;
        min-height: 4.5rem; /* padding (0.8*2) + line-height (1.6 * 0.85 * 2) */
        max-height: 6rem;
    }

    /* Esconder a curiosidade no layout principal em mobile */
    .curiosidade-matematica {
        display: none;
    }
}

/* Otimizações de acessibilidade para redução de movimento */
@media (prefers-reduced-motion: reduce) {
    .curiosidade-matematica {
        transition: height 0.1s ease;
    }

    .curiosidade-matematica::-webkit-scrollbar-thumb {
        transition: none;
    }
}

/* Estado de foco melhorado para teclado */
.curiosidade-matematica:focus-within {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
/* CONCAT END: curiosidade.css */

/* CONCAT START: narrative.css */
/* Popup da Narrativa (Mobile) */
.narrative-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgb(0 0 0 / 60%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
    opacity: 0;
    transition: opacity var(--transition-medium) var(--easing-standard);
}

.narrative-popup:not(.hidden) {
    opacity: 1;
}

.narrative-popup-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 1.5rem 1.5rem;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    position: relative;
    border: 1px solid rgb(255 255 255 / 10%);
    box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
    transform: scale(0.95);
    transition: transform var(--transition-medium) var(--easing-standard);
}

.narrative-popup:not(.hidden) .narrative-popup-content {
    transform: scale(1);
}

#narrative-popup-text-container {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 1.1rem;
    line-height: 1.6;
}

/* Remover a sombra de texto do ícone do popup para evitar artefactos visuais */
#narrative-popup-text-container .curiosidade-icon {
    text-shadow: none;
}

.close-narrative-popup {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: white;

    /* Remover sombra herdada de botões globais */
    box-shadow: none;
}

.dark-mode .narrative-popup-content {
    background: linear-gradient(135deg, #4338ca 0%, #5b21b6 100%);
    border-color: rgb(255 255 255 / 20%);
}
/* CONCAT END: narrative.css */

/* CONCAT START: footer-nav.css */
/* Bottom Navigation Tab Bar (Mobile Only) */

.app-footer {
    display: none;  /* Hidden on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--main-bg-color);
    border-top: 1px solid var(--border-color);
    z-index: 999;
    box-shadow: 0 -2px 8px rgb(0 0 0 / 8%);
    align-items: stretch;
    justify-content: space-around;
    padding: 0;
    margin: 0;
}

/* Show footer on mobile only */
@media (max-width: 768px) {
    .app-footer {
        display: flex;
    }
    
    /* Add padding to body to accommodate footer (60px) */
    body {
        padding-bottom: 60px;
    }
    
    /* Adjust main to not have bottom margin in mobile */
    main {
        margin-bottom: 0;
    }
    
    /* Hide header on mobile */
    .app-header {
        display: none;
    }
}

/* Ultra-compact para mini phones (320px) - Footer 56px */
@media (max-width: 480px) {
    .app-footer {
        height: 56px;
    }
    
    body {
        padding-bottom: 56px;  /* Ajustar para 56px */
    }
}

/* Tab Button */
.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-color);
    cursor: pointer;
    transition: color 200ms, background-color 200ms, border-color 200ms;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.5rem 0;
    text-align: center;
}

.tab-btn:hover {
    background-color: var(--primary-color) / 10%;
}

.tab-btn:active {
    background-color: var(--primary-color) / 15%;
}

/* Active Tab */
.tab-btn.tab-btn-active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Material Symbols Icon */
.tab-btn .material-symbols-outlined {
    font-size: 24px;
    line-height: 1;
}

/* Tab Label */
.tab-label {
    font-size: 0.65rem;
    line-height: 1;
    font-weight: 500;
}

/* Ultra-compact for mini phones (320px) */
@media (max-width: 480px) {
    .app-footer {
        height: 56px;
    }
    
    body {
        padding-bottom: 56px;
    }
    
    .tab-btn {
        padding: 0.35rem 0;
    }
    
    .tab-label {
        display: none;  /* Hide labels on very small screens */
    }
    
    .tab-btn .material-symbols-outlined {
        font-size: 22px;
    }
}

/* Placeholder panels for different tabs */
/* Note: #menu-container is shown by default as the game content */

/* ===== MAIN CONTENT VISIBILITY ===== */
/* Main element visibility is controlled by JavaScript (tab-navigation.js) */
main {
    display: block;  /* Visible by default */
}

main.hidden {
    display: none !important;
}

/* ===== PANELS VISIBILITY ===== */
/* Visibilidade dos painéis controlada em components/panels.css
   para evitar duplicação com o bundle/main.css. Mantemos aqui
   apenas a referência às transições para o caso mobile.
*/
@media (max-width: 768px) {
    /* Smooth transitions between panels - panels.css define comportamento/visibilidade */
    main,
    #menu-container,
    #player-panel,
    #achievements-panel,
    #settings-panel {
        transition: opacity 200ms;
    }
}

/* CONCAT END: footer-nav.css */

/* CONCAT START: panels.css */
/* Estilos para painéis do footer (player, settings) */

/* Base para todos os painéis */
.player-panel,
.settings-panel,
.achievements-panel {
    display: none;
    /* Posicionamento e espaçamento */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 60px;  /* Altura do footer (60px em mobile) */
    padding: 1rem;
    padding-top: calc(var(--header-height, 3rem) + 1rem);  /* Após header */
    overflow-y: auto;  /* Permitir scroll se conteúdo exceder */
    /* Estilos visuais */
    background: var(--main-bg-color);
    color: var(--main-text-color);
    z-index: 100;  /* Acima do conteúdo principal */
}

.player-panel:not(.hidden),
.settings-panel:not(.hidden),
.achievements-panel:not(.hidden) {
    display: block;
}

.player-panel.hidden,
.settings-panel.hidden,
.achievements-panel.hidden {
    display: none !important;
}

/* Cabeçalho dos painéis */
.panel-header {
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1rem;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Corpo do painel */
.panel-body {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    height: 100%;  /* Expande para preencher o espaço disponível */
    min-height: 0;  /* Reset para permitir que flexbox funcione correctamente */
}

/* ===== PAINEL DO JOGADOR ===== */

.player-info {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Secção do nome do jogador */
.player-name-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.player-name-section label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--main-text-color);
}

.player-name-section input {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    /* Melhor contraste: fundo mais claro/escuro que o texto */
    background: var(--card-bg-color, #f8f9fa);  /* Branco/cinza claro */
    color: var(--main-text-color);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 240ms ease, background-color 240ms ease;
}

.player-name-section input::placeholder {
    color: var(--secondary-text-color, #999);
    opacity: 0.7;
}

.player-name-section input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: #ffffff;  /* Fundo branco ao focar */
}

/* Botão guardar */
.save-btn {
    align-self: flex-start;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 240ms ease, transform 240ms ease;
}

.save-btn:hover {
    background: var(--primary-color-hover, var(--primary-color));
    transform: translateY(-2px);
}

.save-btn:active {
    transform: translateY(0);
}

/* Estatísticas do jogador */
.player-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--card-bg-color, rgba(99, 102, 241, 0.05));
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.player-stats p {
    margin: 0;
    font-size: 1rem;
    color: var(--main-text-color);
}

.player-stats strong {
    color: var(--primary-color);
    font-weight: 700;
}

/* ===== PAINEL DE CONQUISTAS ===== */

#achievements-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ===== PAINEL DE CONFIGURAÇÕES ===== */

.settings-options {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Grupos de configurações */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.setting-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--main-text-color);
}

/* Divisor entre grupos */
.settings-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

/* Botão de toggle de tema */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--card-bg-color, rgba(99, 102, 241, 0.05));
    border: 2px solid var(--border-color);
    border-radius: 6px;
    color: var(--main-text-color);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 240ms ease;
    max-width: fit-content;
}

.theme-toggle-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-color-hover, rgba(99, 102, 241, 0.1));
}

.theme-toggle-btn:active {
    transform: scale(0.98);
}

.theme-icon {
    font-size: 1.5rem;
}

.theme-label {
    font-weight: 600;
}

.theme-toggle-btn.theme-dark .theme-icon::before {
    content: "☀️";
}

.theme-toggle-btn.theme-light .theme-icon::before {
    content: "🌙";
}

/* Informações de configurações */
.settings-info {
    margin: 0;
    padding: 1rem;
    background: var(--info-bg-color, rgba(99, 102, 241, 0.05));
    border-radius: 6px;
    color: var(--secondary-text-color, var(--main-text-color));
    font-size: 0.95rem;
    text-align: center;
    font-style: italic;
}

/* ===== RESPONSIVE ===== */

/* Ultra-compact para mini phones (320px) - Footer 56px */
@media (max-width: 480px) {
    .player-panel,
    .settings-panel,
    .achievements-panel {
        bottom: 56px;  /* Footer height em 320px */
        padding: 0.75rem;
        padding-top: calc(var(--header-height, 2.5rem) + 0.75rem);
    }

    .panel-header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }

    .panel-header h2 {
        font-size: 1.25rem;
    }

    .player-name-section input,
    .save-btn,
    .theme-toggle-btn {
        font-size: 0.9rem;
    }

    .player-stats {
        padding: 0.75rem;
    }

    .player-stats p {
        font-size: 0.95rem;
    }

    #achievements-container {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 0.75rem;
    }
}

/* Tablets e acima - Footer 60px (padrão) */
@media (min-width: 481px) and (max-width: 768px) {
    .player-panel,
    .settings-panel,
    .achievements-panel {
        bottom: 60px;  /* Footer height normal */
        padding: 1rem;
        padding-top: calc(var(--header-height, 2.75rem) + 1rem);
    }
}

/* Desktop - Sem footer (desaparece) */
@media (min-width: 769px) {
    .player-panel,
    .settings-panel,
    .achievements-panel {
        position: static;  /* Volta ao flow normal */
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        overflow-y: visible;
        padding: 1rem;
        padding-top: 1rem;
    }
}

/* ===== ACHIEVEMENTS PANEL CONTENT ===== */

#achievements-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
    flex: 1;  /* Ocupa espaço restante do painel */
    align-content: start;
    min-height: 0;  /* Permite que o grid se adapte dentro do flexbox */
}

.ach-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
    background: var(--card-bg-color);
    border-radius: 8px;
    border: 2px solid var(--border-color);
    transition: all 240ms ease;
    text-align: center;
    min-height: 120px;
}

.ach-badge:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.ach-badge .emoji {
    font-size: 2.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
}

.ach-badge .label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--main-text-color);
    line-height: 1.2;
}

.no-achievements {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    min-height: 150px;
    color: var(--secondary-text-color);
    font-size: 1.1rem;
    text-align: center;
    padding: 2rem 1rem;
    background: var(--card-bg-color, rgba(99, 102, 241, 0.05));
    border-radius: 8px;
    border: 2px dashed var(--border-color);
}

.no-achievements .emoji {
    font-size: 3rem;
}

.no-achievements .message {
    font-size: 0.95rem;
    max-width: 200px;
}

/* ===== ACHIEVEMENTS RESPONSIVE ===== */

@media (max-width: 480px) {
    #achievements-container {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 0.75rem;
        margin-top: 1rem;
    }

    .ach-badge {
        padding: 0.75rem 0.5rem;
        min-height: 100px;
    }

    .ach-badge .emoji {
        font-size: 2rem;
        min-height: 40px;
    }

    .ach-badge .label {
        font-size: 0.75rem;
    }

    .no-achievements {
        min-height: 120px;
        padding: 1.5rem 1rem;
    }

    .no-achievements .emoji {
        font-size: 2rem;
    }
}

@media (min-width: 769px) {
    #achievements-container {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* ===== TEMA ESCURO ===== */

@media (prefers-color-scheme: dark) {
    .player-name-section input {
        background: #1a202c;  /* Fundo escuro para contraste */
        border-color: #4a5568;
        color: #e2e8f0;  /* Texto mais claro */
    }

    .player-name-section input::placeholder {
        color: #a0aec0;  /* Placeholder em cor intermediária */
        opacity: 0.8;
    }

    .player-name-section input:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
        background: #2d3748;  /* Fundo ainda mais claro ao focar */
    }

    .player-stats {
        background: rgba(99, 102, 241, 0.1);
    }

    .theme-toggle-btn {
        background: rgba(99, 102, 241, 0.08);
        border-color: #4a5568;
    }

    .theme-toggle-btn:hover {
        background: rgba(99, 102, 241, 0.15);
    }

    .ach-badge {
        background: rgba(99, 102, 241, 0.08);
        border-color: #4a5568;
    }

    .ach-badge:hover {
        background: rgba(99, 102, 241, 0.12);
        border-color: var(--primary-color);
    }

    .no-achievements {
        background: rgba(99, 102, 241, 0.05);
        border-color: #4a5568;
    }
}

/* CONCAT END: panels.css */
