:root {
    --green: #16a34a;
    --green-d: #0b3d24;
    --green-l: #22c55e;
    --bg: #0f1115;
    --card: #1a1d23;
    --card-2: #22262e;
    --line: #2c313a;
    --text: #e8eaed;
    --muted: #9aa3b2;
    --accent: #facc15;
    --danger: #ef4444;
    --radius: 16px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(12px + var(--safe-t)) 16px 12px;
    background: linear-gradient(160deg, var(--green-d), #0a2a19);
    border-bottom: 1px solid #0a241629;
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: .2px; }
.topbar-points {
    display: flex; align-items: center; gap: 6px;
    background: #ffffff14; padding: 6px 12px; border-radius: 999px;
    font-weight: 700; font-size: 14px;
}
.topbar-points .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* ---------- Layout ---------- */
.container { max-width: 680px; margin: 0 auto; padding: 16px 16px 96px; }
body.auth .container { padding-top: calc(24px + var(--safe-t)); min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; }
.has-nav .container { padding-bottom: calc(92px + var(--safe-b)); }

h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 16px; margin: 24px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 700; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.card.tight { padding: 12px 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Stat tiles ---------- */
.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; }
.tile .num { font-size: 26px; font-weight: 800; color: var(--green-l); }
.tile .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--green); color: #fff; border: none;
    padding: 12px 18px; border-radius: 12px; font-size: 15px; font-weight: 700;
    cursor: pointer; width: 100%; transition: transform .05s, filter .15s;
}
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 8px 12px; font-size: 13px; width: auto; }
.btn-inline { width: auto; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], select {
    width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text);
    padding: 12px 14px; border-radius: 12px; font-size: 16px; outline: none;
}
input:focus, select:focus { border-color: var(--green-l); }
input[type=color] { width: 48px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 2px; }

/* ---------- Avatar ---------- */
.avatar {
    width: 38px; height: 38px; border-radius: 50%; flex: none;
    display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
}
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }

/* ---------- Match card ---------- */
.match { padding: 14px 16px; }
.match .meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 10px; }
.match .teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.match .team { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.match .team .code { font-weight: 700; font-size: 15px; }
.match .team .full { font-size: 11px; color: var(--muted); }
.match .score { font-size: 22px; font-weight: 800; min-width: 60px; text-align: center; }
.match .vs { color: var(--muted); font-weight: 700; }
.team-logo { width: 36px; height: 36px; object-fit: contain; }
.team-badge { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--card-2); }

/* tip mini form */
.tipform { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 8px; align-items: center; margin-top: 12px; }
.tipform input { text-align: center; font-size: 18px; font-weight: 700; padding: 10px; }
.tipform .colon { font-weight: 800; color: var(--muted); }
.tipform .btn { width: auto; padding: 10px 14px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.ok { background: #16a34a2e; color: #4ade80; }
.badge.zero { background: #ef44442b; color: #fca5a5; }
.badge.pend { background: #facc1524; color: var(--accent); }
.badge.tip { background: #3b82f626; color: #93c5fd; }

/* ---------- Leaderboard ---------- */
.lb-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.lb-row:last-child { border-bottom: none; }
.lb-rank { width: 26px; text-align: center; font-weight: 800; color: var(--muted); }
.lb-rank.top { color: var(--accent); }
.lb-name { flex: 1; font-weight: 600; }
.lb-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.lb-pts { font-weight: 800; color: var(--green-l); }

/* ---------- Misc ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--card-2); color: var(--muted); }
.code-chip { font-family: ui-monospace, monospace; letter-spacing: 2px; font-weight: 800; background: var(--bg); border: 1px dashed var(--line); padding: 8px 14px; border-radius: 10px; display: inline-block; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty .em { font-size: 40px; display: block; margin-bottom: 8px; }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 16px 0; }

/* form-grade win/lose dots */
.form-dots { display: flex; gap: 6px; }
.fdot { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.fdot.w { background: #16a34a; color: #fff; }
.fdot.l { background: #3a3f49; color: var(--muted); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(70px + var(--safe-t)); z-index: 50; width: calc(100% - 32px); max-width: 648px; }
.toast { padding: 12px 16px; border-radius: 12px; margin-bottom: 8px; font-weight: 600; font-size: 14px; box-shadow: 0 8px 24px #0008; animation: toastIn .25s ease; }
.toast-success { background: #16a34a; color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

/* ---------- Tabbar ---------- */
.tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    display: flex; justify-content: space-around;
    background: #15181ee6; backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 8px 6px calc(8px + var(--safe-b));
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 10px; font-weight: 600; padding: 4px 10px; flex: 1; }
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--green-l); }

/* ---------- Auth ---------- */
.auth-logo { text-align: center; font-size: 52px; margin-bottom: 8px; }
.auth-title { text-align: center; font-size: 26px; font-weight: 800; margin: 0 0 4px; }
.auth-sub { text-align: center; color: var(--muted); margin: 0 0 24px; }
.auth-switch { text-align: center; margin-top: 18px; color: var(--muted); }
.auth-switch a { color: var(--green-l); font-weight: 700; }
.feature { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0; }
.feature .ico { font-size: 24px; }
