/* ===================== BeGame — estilo (mobile-first) ===================== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
    --bg: #0f0c29;
    --card: #241d52;
    --card2: #2c2461;
    --border: #392f7a;
    --roxo: #6c5ce7;
    --roxo2: #a29bfe;
    --gold: #ffd54a;
    --verde: #00e0a4;
    --vermelho: #ff6b6b;
    --azul: #4facfe;
    --texto: #f4f2ff;
    --suave: #b3aed6;
    --shadow: 0 8px 24px rgba(0,0,0,.35);
}

html { -webkit-text-size-adjust: 100%; }
body {
    font-family: system-ui, "Segoe UI", Arial, sans-serif;
    background: linear-gradient(160deg, #0f0c29, #302b63, #24243e);
    background-attachment: fixed;
    color: var(--texto);
    min-height: 100vh;
    line-height: 1.5;
    overscroll-behavior-y: none;
}
a { color: var(--roxo2); }
img { max-width: 100%; display: block; }

/* ---------- Barra superior ---------- */
.topbar { background: rgba(15,12,41,.92); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; backdrop-filter: blur(8px); }
.topbar .inner { max-width: 1080px; margin: 0 auto; padding: 10px 14px; display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 800; font-size: 1.15rem; text-decoration: none; color: #fff; white-space: nowrap; }
.brand span { color: var(--roxo2); }
.spacer { flex: 1; }

/* nav desktop escondida no mobile (usa bottom nav) */
.nav { display: none; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--suave); text-decoration: none; padding: 7px 11px; border-radius: 8px; font-weight: 600; font-size: .9rem; }
.nav a:hover, .nav a.active { background: var(--roxo); color: #fff; }
.topbar .sair { color: var(--suave); text-decoration: none; font-size: .82rem; padding: 6px 8px; }

/* pílulas de status */
.pills { display: flex; gap: 6px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 5px; background: var(--card); border: 1px solid var(--border); padding: 5px 10px; border-radius: 999px; font-weight: 800; font-size: .82rem; }
.pill.coins { color: var(--gold); }
.pill.xp { color: var(--roxo2); }
.pill.streak { color: #ff9f43; }

/* ---------- Bottom nav (mobile) ---------- */
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: rgba(20,16,52,.97); border-top: 1px solid var(--border);
    display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    backdrop-filter: blur(8px); }
.bottomnav a { flex: 1; text-align: center; text-decoration: none; color: var(--suave); font-size: .62rem; font-weight: 700; padding: 4px 2px; border-radius: 10px; }
.bottomnav a .ic { display: block; font-size: 1.25rem; line-height: 1.1; }
.bottomnav a.active { color: #fff; background: rgba(108,92,231,.28); }

/* ---------- Conteúdo ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 16px 14px 96px; }
.page-title { font-size: 1.35rem; margin-bottom: 2px; }
.subtitle { color: var(--suave); margin-bottom: 16px; font-size: .92rem; }

/* ---------- Cards / grid ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(2, 1fr); }

.stat { text-align: center; }
.stat .big { font-size: 1.5rem; font-weight: 800; }
.stat .lbl { color: var(--suave); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }

/* barra de progresso */
.bar { background: #171338; border-radius: 999px; height: 16px; overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--roxo), var(--roxo2)); transition: width .6s cubic-bezier(.2,.8,.2,1); }

/* ---------- Matérias / botões de mundo ---------- */
.materias { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.materia { text-decoration: none; color: inherit; border-radius: 16px; padding: 16px 14px; position: relative;
    background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow); transition: transform .12s; overflow: hidden; }
.materia:active { transform: scale(.96); }
.materia .em { font-size: 2.2rem; }
.materia .nm { font-weight: 800; margin-top: 4px; }
.materia .sb { color: var(--suave); font-size: .74rem; }
.materia .glow { position: absolute; top: -30px; right: -30px; width: 90px; height: 90px; border-radius: 50%; opacity: .35; filter: blur(6px); }

/* ---------- Loja / recompensas ---------- */
.reward { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.reward .thumb { width: 100%; aspect-ratio: 400/260; background: #1b1642; }
.reward .body { padding: 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.reward h3 { font-size: 1rem; }
.reward .desc { color: var(--suave); font-size: .82rem; flex: 1; }
.reward .price { color: var(--gold); font-weight: 800; font-size: 1.05rem; }
.reward .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.tag { display: inline-block; font-size: .68rem; font-weight: 800; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--suave); background: #1b1642; }
.tag.curto { color: #55efc4; border-color: #1e5c4a; }
.tag.medio { color: #ffeaa7; border-color: #6b5a1e; }
.tag.longo { color: #ff9f9f; border-color: #6b1e1e; }
.tag.cond  { color: #ffd54a; border-color: #6b5a1e; }

/* ---------- Botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; cursor: pointer;
    background: var(--roxo); color: #fff; font-weight: 800; padding: 12px 16px; border-radius: 12px; text-decoration: none; font-size: .92rem;
    box-shadow: 0 4px 0 #4b3fb0; transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #4b3fb0; }
.btn.gold { background: var(--gold); color: #2b2100; box-shadow: 0 4px 0 #b99500; }
.btn.gold:active { box-shadow: 0 1px 0 #b99500; }
.btn.verde { background: var(--verde); color: #003a2c; box-shadow: 0 4px 0 #009e73; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--texto); box-shadow: none; }
.btn.danger { background: var(--vermelho); box-shadow: 0 4px 0 #c23b3b; }
.btn.small { padding: 8px 12px; font-size: .82rem; box-shadow-height: 3px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ---------- Formulários ---------- */
label { display: block; margin: 12px 0 6px; font-weight: 700; font-size: .88rem; }
input, select, textarea { width: 100%; background: #171338; border: 1px solid var(--border); color: var(--texto); padding: 12px; border-radius: 12px; font-size: 16px; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--roxo); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 140px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: .85rem; white-space: nowrap; }
th { color: var(--suave); font-size: .72rem; text-transform: uppercase; }

/* ---------- Avisos ---------- */
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 700; }
.alert.ok { background: rgba(0,224,164,.14); border: 1px solid #1e6b52; color: var(--verde); }
.alert.err { background: rgba(255,107,107,.14); border: 1px solid #6b1e1e; color: var(--vermelho); }

.badge-status { font-weight: 800; padding: 3px 9px; border-radius: 999px; font-size: .74rem; }
.s-solicitado,.s-enviado { background:#3a2f00; color:#ffd54a; }
.s-aprovado { background:#00304d; color:#74c0ff; }
.s-entregue { background:#04352a; color:#55efc4; }
.s-recusado { background:#3a0f0f; color:#ff9f9f; }

/* ---------- Login ---------- */
.login-box { max-width: 420px; margin: 6vh auto; padding: 0 16px; }
.login-logo { text-align: center; font-size: 2.2rem; font-weight: 800; }
.login-logo span { color: var(--roxo2); }
.muted { color: var(--suave); font-size: .84rem; }
.center { text-align: center; }

/* ---------- Quiz / exercícios ---------- */
.quiz { max-width: 620px; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.quiz-progress { flex: 1; }
.timer { font-weight: 800; font-size: 1.05rem; min-width: 62px; text-align: center; padding: 6px 8px; border-radius: 10px; background: var(--card); border: 1px solid var(--border); }
.timer.low { color: var(--vermelho); animation: pulse .6s infinite; }
.q-enunciado { font-size: 1.15rem; font-weight: 700; margin: 8px 0 16px; }
.opcoes { display: grid; gap: 10px; }
.opcao { text-align: left; background: var(--card); border: 2px solid var(--border); color: var(--texto); padding: 14px; border-radius: 14px; font-size: 1rem; cursor: pointer; font-family: inherit; transition: transform .08s; }
.opcao:active { transform: scale(.98); }
.opcao.sel { border-color: var(--roxo2); background: var(--card2); }
.opcao.certa { border-color: var(--verde); background: rgba(0,224,164,.16); }
.opcao.errada { border-color: var(--vermelho); background: rgba(255,107,107,.16); }
.no-select { -webkit-user-select: none; user-select: none; }

/* ---------- Overlays / efeitos ---------- */
#confetti-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9999; }
.overlay { position: fixed; inset: 0; z-index: 9000; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: rgba(8,6,24,.82); backdrop-filter: blur(3px); }
.overlay .box { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 26px; text-align: center; max-width: 380px; width: 100%; box-shadow: var(--shadow); animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.overlay .big-emoji { font-size: 3.4rem; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--card); border: 1px solid var(--border);
    padding: 12px 18px; border-radius: 999px; font-weight: 800; box-shadow: var(--shadow); z-index: 9500; animation: pop .3s; }
.toast.gold { color: var(--gold); }

@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pulse { 50% { transform: scale(1.12); } }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }
.shake { animation: shake .3s; }

/* ---------- Desktop ---------- */
@media (min-width: 760px) {
    .nav { display: flex; }
    .bottomnav { display: none; }
    .wrap { padding: 24px 18px 60px; }
    .page-title { font-size: 1.8rem; }
    .grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
    .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
    .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
    .materias { grid-template-columns: repeat(3, 1fr); }
    .reward-grid { grid-template-columns: repeat(3, 1fr) !important; }
    .stat .big { font-size: 2rem; }
}
.reward-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
