:root {
  color-scheme: dark;
  --bg: #121211;
  --surface-1: #1a1a19;
  --surface-2: #242423;
  --border: #33332f;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #8d8c84;
  --grid: #2c2c29;
  --accent: #f2b33d;
  --xp: #f2b33d;
  --hp: #e66767;
  --good: #0ca30c;
  /* categorical, ordem fixa: corrida, bike, calistenia */
  --series-run: #3987e5;
  --series-bike: #d95926;
  --series-strength: #199e70;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text-primary);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.err { color: var(--hp); min-height: 1.2em; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 22px 4px 10px; color: var(--text-secondary); font-weight: 600; letter-spacing: .02em; }

main { padding: calc(env(safe-area-inset-top) + 14px) 14px 96px; max-width: 560px; margin: 0 auto; }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }

/* login */
.screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.logo { font-size: 56px; }
input, select { width: 100%; background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; font-size: 16px; margin: 6px 0; }
label { display: block; font-size: .85rem; color: var(--text-secondary); margin-top: 8px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 600; cursor: pointer;
  background: var(--surface-2); color: var(--text-primary); width: 100%; margin-top: 10px; }
.btn.primary { background: var(--accent); color: #1a1408; }
.btn.small { width: auto; padding: 8px 12px; font-size: 13px; margin: 0; }
.btn:active { transform: scale(.98); }

/* nível */
.hero { background: linear-gradient(135deg, #2a2210 0%, var(--surface-1) 60%); }
.hero-top { display: flex; align-items: center; gap: 14px; }
.lvl-badge { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: radial-gradient(circle at 30% 30%, #ffd77a, #c98500); color: #2a1d00; font-weight: 800; font-size: 24px;
  box-shadow: 0 0 0 3px #3b2e0e, 0 0 24px #f2b33d44; }
.lvl-name { font-size: 1.15rem; font-weight: 700; }
.lvl-sub { color: var(--text-secondary); font-size: .85rem; }
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--xp); transition: width .8s ease; }
.bar.hp > i { background: var(--hp); }
.stats { display: flex; justify-content: space-between; margin-top: 12px; font-size: .85rem; color: var(--text-secondary); }
.stats b { color: var(--text-primary); font-size: 1rem; }

/* chefão */
.boss { display: flex; gap: 14px; align-items: center; }
.boss-emoji { font-size: 44px; filter: drop-shadow(0 0 10px #e6676755); }
.boss-name { font-weight: 700; }
.boss small { color: var(--text-muted); }

/* missões */
.mission { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); }
.mission:first-of-type { border-top: 0; padding-top: 4px; }
.m-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex-shrink: 0; background: var(--surface-2); }
.m-body { flex: 1; min-width: 0; }
.m-title { font-weight: 650; }
.m-detail { color: var(--text-secondary); font-size: .88rem; margin-top: 2px; }
.m-tip { color: var(--text-muted); font-size: .8rem; margin-top: 4px; }
.m-done { color: var(--good); font-weight: 700; font-size: .85rem; }
.mission.done .m-icon { background: #0ca30c22; }
.mission.done .m-title { text-decoration: line-through; text-decoration-color: var(--text-muted); }

.quota { display: flex; gap: 8px; }
.q { flex: 1; background: var(--surface-2); border-radius: 12px; padding: 10px; text-align: center; font-size: .8rem; color: var(--text-secondary); }
.q b { display: block; font-size: 1.2rem; color: var(--text-primary); }
.q.ok { box-shadow: inset 0 0 0 2px var(--good); }

.habit { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); cursor: pointer; }
.habit:first-child { border-top: 0; }
.check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--border); display: grid; place-items: center; flex-shrink: 0; }
.habit.on .check { background: var(--good); border-color: var(--good); }
.habit.on .check::after { content: "✓"; color: #fff; font-weight: 800; }
.habit .xp { margin-left: auto; color: var(--text-muted); font-size: .8rem; }

.feed-item { display: flex; justify-content: space-between; padding: 7px 0; font-size: .9rem; border-top: 1px solid var(--border); }
.feed-item:first-child { border-top: 0; }
.feed-item .xp { color: var(--xp); font-weight: 700; white-space: nowrap; margin-left: 10px; }
.feed-item .d { color: var(--text-muted); font-size: .78rem; }

/* semana */
.day { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.day:first-child { border-top: 0; }
.day.today { background: #f2b33d0d; margin: 0 -16px; padding: 12px 16px; }
.day-label { width: 44px; flex-shrink: 0; text-align: center; color: var(--text-secondary); font-size: .8rem; }
.day-label b { display: block; font-size: 1.1rem; color: var(--text-primary); }
.day-s { flex: 1; font-size: .9rem; }
.day-s div { margin-bottom: 4px; }
.day-s .ok { color: var(--good); }

/* troféus */
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 14px 6px; text-align: center; font-size: .78rem; color: var(--text-secondary); }
.badge span { font-size: 30px; display: block; margin-bottom: 6px; }
.badge.off { opacity: .35; filter: grayscale(1); }

/* gráficos */
.viz-root { color: var(--text-primary); }
.chart-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.chart-title span { text-align: right; }
.chart-title b { font-size: 1.4rem; }
.chart-title span { color: var(--text-secondary); font-size: .85rem; }
svg.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
svg.chart text { fill: var(--text-muted); font-size: 10px; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--text-secondary); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.viz-tip { position: fixed; pointer-events: none; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-primary);
  padding: 6px 10px; border-radius: 8px; font-size: .8rem; z-index: 50; transform: translate(-50%, -110%); white-space: nowrap; }
.empty { color: var(--text-muted); font-size: .9rem; padding: 18px 0; text-align: center; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
td, th { padding: 6px 4px; border-top: 1px solid var(--border); text-align: left; }
th { color: var(--text-muted); font-weight: 500; border-top: 0; }

/* nav */
nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #161615ee; backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
nav button { flex: 1; background: none; border: 0; color: var(--text-muted); font-size: 11px; padding: 8px 0 10px; cursor: pointer; }
nav button span { display: block; font-size: 20px; margin-bottom: 2px; filter: grayscale(1); opacity: .7; }
nav button.active { color: var(--accent); }
nav button.active span { filter: none; opacity: 1; }

/* toast & modal */
.toast { position: fixed; left: 50%; top: 20px; transform: translate(-50%, -150%); background: var(--accent); color: #1a1408;
  font-weight: 800; padding: 10px 20px; border-radius: 99px; transition: transform .35s cubic-bezier(.2,1.4,.4,1), opacity .2s; z-index: 60; opacity: 0; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.modal { position: fixed; inset: 0; background: #000b; display: grid; place-items: center; z-index: 70; padding: 24px; }
.modal-box { background: var(--surface-1); border: 1px solid var(--border); border-radius: 20px; padding: 26px; text-align: center; max-width: 340px; width: 100%;
  animation: pop .5s cubic-bezier(.2,1.5,.4,1); }
.modal-box .big { font-size: 64px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.log { font-size: .8rem; color: var(--text-secondary); }
.log div { padding: 4px 0; border-top: 1px solid var(--border); }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: .85em; word-break: break-all; }
