:root {
  --bg: #0a1410;
  --bg-2: #0d1a14;
  --surface: #13231c;
  --surface-2: #182b22;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e9f1ea;
  --muted: #8aa297;
  --grass: #54d36a;
  --grass-bright: #7cf08c;
  --amber: #f4b740;
  --danger: #ff6f6f;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -200px, #16291f 0%, var(--bg) 60%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: 660px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.muted-line { color: var(--muted); font-size: 14px; margin: 4px 0 16px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(10, 20, 16, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { display: flex; align-items: center; gap: 9px; font-family: 'Space Grotesk', sans-serif; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--grass), #2f9d49);
  color: #04130a; font-size: 16px; box-shadow: 0 4px 14px rgba(84, 211, 106, 0.35);
}
.brand-text { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand-year { color: var(--grass); }
.user-area { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.user-chip { color: var(--muted); }
.user-chip b { color: var(--text); font-weight: 600; }

/* Tabs */
.tabs { border-bottom: 1px solid var(--line); position: sticky; top: 58px; z-index: 15; background: var(--bg); }
.tabs-in { display: flex; gap: 4px; }
.tab {
  appearance: none; background: none; border: none; cursor: pointer;
  color: var(--muted); font: 600 15px 'Inter', sans-serif; padding: 14px 14px 12px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--text); border-bottom-color: var(--grass); }

.main { padding: 20px 16px 64px; }
.view-title { font-family: 'Space Grotesk', sans-serif; font-size: 20px; margin: 0 0 2px; }

/* Cards & layout */
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-tight { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .grid2 { grid-template-columns: 1fr; } }

/* Auth */
.auth-card { margin-top: 8px; }
.auth-title { font-family: 'Space Grotesk', sans-serif; font-size: 26px; margin: 0 0 6px; letter-spacing: -0.02em; }
.auth-sub { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 18px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.seg-btn { flex: 1; appearance: none; border: none; background: none; color: var(--muted); font: 600 14px 'Inter'; padding: 9px; border-radius: 9px; cursor: pointer; }
.seg-btn.active { background: var(--surface-2); color: var(--text); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; background: var(--bg); border: 1px solid var(--line-strong); color: var(--text);
  border-radius: 11px; padding: 12px 13px; font: 500 15px 'Inter'; outline: none;
}
.field input:focus { border-color: var(--grass); box-shadow: 0 0 0 3px rgba(84, 211, 106, 0.15); }

.btn {
  appearance: none; border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--text); font: 600 15px 'Inter'; padding: 12px 18px; border-radius: 12px; cursor: pointer;
  transition: transform 0.05s ease, filter 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--grass), #2f9d49); border-color: transparent; color: #04130a; font-weight: 700; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 13px; font-size: 14px; border-radius: 10px; }
.btn-ghost { background: transparent; }
.link-btn { display: block; width: 100%; margin-top: 12px; background: none; border: none; color: var(--muted); font: 500 14px 'Inter'; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.msg { min-height: 18px; font-size: 13.5px; margin: 2px 0 10px; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--grass-bright); }

/* Game card */
.game {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.game-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.tag { font: 700 11px 'Space Grotesk'; letter-spacing: 0.06em; text-transform: uppercase; color: var(--grass); background: rgba(84, 211, 106, 0.12); padding: 4px 8px; border-radius: 6px; }
.kick { font-size: 12.5px; color: var(--muted); }
.kick.live { color: var(--amber); }

.match { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.team { display: flex; align-items: center; gap: 8px; min-width: 0; }
.team.home { justify-content: flex-end; text-align: right; }
.team.away { justify-content: flex-start; text-align: left; }
.team-name { font-weight: 600; font-size: 15px; line-height: 1.15; }
.score-box { display: flex; align-items: center; gap: 8px; }
.score-in {
  width: 48px; height: 50px; text-align: center; background: var(--bg);
  border: 1px solid var(--line-strong); color: var(--text); border-radius: 12px;
  font: 700 22px 'Inter'; font-variant-numeric: tabular-nums; outline: none;
}
.score-in:focus { border-color: var(--grass); box-shadow: 0 0 0 3px rgba(84, 211, 106, 0.15); }
.score-in:disabled { opacity: 0.9; -webkit-text-fill-color: var(--text); }
.score-x { color: var(--muted); font-weight: 600; }

.game-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; min-height: 22px; }
.foot-note { font-size: 12.5px; color: var(--muted); }
.result-line { font-size: 13px; color: var(--muted); }
.result-line b { color: var(--text); font-variant-numeric: tabular-nums; }
.pts { font: 700 12px 'Space Grotesk'; padding: 4px 9px; border-radius: 7px; letter-spacing: 0.03em; }
.pts.p3 { background: rgba(244, 183, 64, 0.16); color: var(--amber); }
.pts.p1 { background: rgba(84, 211, 106, 0.14); color: var(--grass-bright); }
.pts.p0 { background: rgba(255, 255, 255, 0.06); color: var(--muted); }
.locked-badge { font-size: 11.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }

.day-head { font: 600 13px 'Space Grotesk'; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 18px 2px 2px; }
.day-head:first-child { margin-top: 0; }

/* Ranking */
.ranking { list-style: none; margin: 0; padding: 0; }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: none; }
.rank-pos { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); font: 700 14px 'Space Grotesk'; color: var(--muted); }
.rank-row.top1 .rank-pos { background: linear-gradient(135deg, var(--amber), #d6932a); color: #1a1205; }
.rank-row.top2 .rank-pos { background: #c7d0cb; color: #11201a; }
.rank-row.top3 .rank-pos { background: #b9824e; color: #160d04; }
.rank-name { flex: 1; font-weight: 600; }
.rank-meta { font-size: 12px; color: var(--muted); }
.rank-pts { font: 700 18px 'Inter'; font-variant-numeric: tabular-nums; }
.rank-pts span { font-size: 12px; color: var(--muted); font-weight: 500; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* Admin rows */
.admin-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 11px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.admin-match { font-size: 14px; font-weight: 600; }
.admin-match small { display: block; color: var(--muted); font-weight: 500; font-size: 11.5px; margin-top: 2px; }
.admin-controls { display: flex; align-items: center; gap: 6px; }
.admin-controls input { width: 42px; height: 38px; text-align: center; background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text); border-radius: 9px; font: 700 16px 'Inter'; font-variant-numeric: tabular-nums; }
.admin-controls .score-x { font-size: 13px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text);
  padding: 11px 18px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); z-index: 40;
}
.toast.ok { border-color: rgba(84, 211, 106, 0.5); }
.toast.err { border-color: rgba(255, 111, 111, 0.5); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Avatar pixel + humor + selos ---------- */
.me-avatar { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; }
.me-avatar svg { display: block; }

.ava { position: relative; flex: 0 0 auto; width: 52px; height: 52px; display: inline-block; transition: transform 0.2s ease, filter 0.2s ease; }
.ava svg { box-shadow: 0 2px 8px rgba(0,0,0,0.35); }
.ava-tag { position: absolute; font-size: 15px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.5)); }
.ava-tag.crown { top: -11px; left: 50%; transform: translateX(-50%) rotate(-8deg); }
.ava-tag.dead, .ava-tag.sad { bottom: -4px; right: -4px; font-size: 14px; }

/* estados de humor pela posicao */
.mood-king { transform: scale(1.1); filter: saturate(1.25); animation: bob 1.8s ease-in-out infinite; }
.mood-king svg { box-shadow: 0 0 0 2px var(--amber), 0 0 16px rgba(244,183,64,0.55); }
.mood-happy { filter: saturate(1.1) brightness(1.05); }
.mood-ok { }
.mood-sad { filter: saturate(0.8) brightness(0.92); opacity: 0.9; }
.mood-dead { filter: grayscale(0.45) brightness(0.85); opacity: 0.7; transform: skewX(-6deg) rotate(-3deg); }
@keyframes bob { 0%,100% { transform: scale(1.1) translateY(0); } 50% { transform: scale(1.1) translateY(-3px); } }

/* selos */
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.badge {
  font: 600 11px 'Inter', sans-serif; padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--line); color: var(--text);
  white-space: nowrap; cursor: default;
}
.rank-row.top1 .badge { border-color: rgba(244,183,64,0.4); }

/* o avatar precisa de espaco no topo pra coroa nao cortar */
.rank-row { overflow: visible; }
.ranking { overflow: visible; }
@media (prefers-reduced-motion: reduce) { .mood-king { animation: none; } }
