:root {
  --bg: #0b0f14;
  --card: #141a22;
  --card-2: #1b232e;
  --line: #263041;
  --text: #eef2f7;
  --muted: #8a96a8;
  --gold: #f2c94c;
  --green: #2ee59d;
  --red: #ff5d73;
  --blue: #4da3ff;
  --purple: #b18cff;
  --radius: 14px;
  --nav-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--blue); }

/* En-tête : rang + série */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: rgba(11, 15, 20, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.rank { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.rank-badge { font-size: 28px; }
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-weight: 700; font-size: 14px; }
.xp-bar { height: 6px; background: var(--card-2); border-radius: 4px; overflow: hidden; margin: 4px 0 2px; max-width: 220px; }
.xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #ffe08a); transition: width .4s; }
.xp-text { font-size: 11px; color: var(--muted); }
.club-btn { display: flex; align-items: center; gap: 4px; background: var(--card); border: 1px solid #5a4b1f; color: var(--gold); font-weight: 800; font-size: 14px; padding: 7px 10px; border-radius: 20px; }
.club-btn[hidden] { display: none; }
.streak { display: flex; align-items: center; gap: 4px; font-weight: 800; font-size: 20px; background: var(--card); padding: 6px 12px; border-radius: 20px; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
.tab { display: none; }
.tab.active { display: block; animation: fade .2s; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

h2 { font-size: 22px; margin: 4px 0 4px; }
h3 { font-size: 16px; margin: 22px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: 12px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.hero {
  background: linear-gradient(135deg, #1d2a1f 0%, #141a22 60%);
  border-color: #2b4a33;
}
.hero .big { font-size: 30px; font-weight: 800; }
.hero .row { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.progress { height: 10px; background: var(--card-2); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--green); transition: width .4s; }

/* Tâches */
.task {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px; width: 100%; text-align: left;
  transition: border-color .15s, opacity .2s;
}
.task.prio { border-left: 3px solid var(--gold); }
.task .box {
  flex: 0 0 24px; height: 24px; border-radius: 7px; border: 2px solid var(--muted);
  display: grid; place-items: center; margin-top: 1px; font-size: 14px; font-weight: 900; color: var(--bg);
}
.task.done { opacity: .55; }
.task.done .box { background: var(--green); border-color: var(--green); }
.task.done .box::after { content: "✓"; }
.task.done .t-title { text-decoration: line-through; }
.task .t-body { flex: 1; min-width: 0; }
.task .t-title { font-weight: 650; }
.task .t-detail { color: var(--muted); font-size: 13px; margin-top: 2px; }
.task .t-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--card-2); color: var(--muted); white-space: nowrap; }
.pill.sp { background: rgba(242, 201, 76, .14); color: var(--gold); font-weight: 700; }
.pill.urgent { background: rgba(255, 93, 115, .15); color: var(--red); font-weight: 700; }
.pill.mode { color: var(--blue); }

.tip-card { background: linear-gradient(135deg, #1e1a33, #141a22); border-color: #3a2f66; }
.tip-card .label { color: var(--purple); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }

/* Pass */
.levels { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-top: 12px; }
.lvl { aspect-ratio: 1; border-radius: 6px; background: var(--card-2); display: grid; place-items: center; font-size: 10px; color: var(--muted); position: relative; }
.lvl.done { background: var(--green); color: var(--bg); font-weight: 700; }
.lvl.key { outline: 2px solid var(--gold); outline-offset: -2px; }
.lvl.key.done { outline-color: #fff; }
.field { display: flex; gap: 10px; margin-top: 10px; }
.field label { flex: 1; font-size: 12px; color: var(--muted); }
.field input, .field select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font-size: 16px;
  background: var(--card-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
}
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.stat { background: var(--card-2); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.reward { display: flex; gap: 10px; align-items: center; }
.reward .lv { font-weight: 800; color: var(--gold); min-width: 52px; }

/* Évos */
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; }
.chip { padding: 6px 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); font-size: 13px; white-space: nowrap; }
.chip.on { background: var(--gold); color: var(--bg); border-color: var(--gold); font-weight: 700; }
.evo-head { display: flex; align-items: center; gap: 10px; }
.tier { flex: 0 0 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 900; font-size: 17px; color: var(--bg); }
.tier-S { background: var(--gold); }
.tier-A { background: var(--green); }
.tier-B { background: var(--blue); }
.tier-C { background: var(--muted); }
.evo-name { font-weight: 700; }
.kv { font-size: 13px; margin-top: 6px; }
.kv b { color: var(--muted); font-weight: 600; }

/* Tactiques */
.formation-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; }
.roles { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.roles td { padding: 7px 0; border-top: 1px solid var(--line); }
.roles td:first-child { color: var(--gold); font-weight: 700; width: 90px; }
.tip-list .card { display: flex; gap: 10px; }
.tip-list .cat { font-size: 11px; font-weight: 700; color: var(--purple); min-width: 72px; text-transform: uppercase; }

/* Agenda */
.countdown { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 18px; }
.deadline.soon { border-color: var(--red); }
.deadline.past { opacity: .4; }
.kind { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.kind.promo { color: var(--purple); }
.kind.reward { color: var(--gold); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.btn {
  display: inline-block; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card-2); font-weight: 650; font-size: 14px; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--gold); color: var(--bg); border-color: var(--gold); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.switch-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.switch-row:first-of-type { border-top: 0; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--green); }
.footer-note { color: var(--muted); font-size: 12px; text-align: center; margin-top: 24px; }

/* Navigation du bas */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(7, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(20, 26, 34, 0.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.bottom-nav button { background: none; border: 0; font-size: 9.5px; padding: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.bottom-nav button span { font-size: 20px; filter: grayscale(1); opacity: .7; }
.bottom-nav button.active { color: var(--text); }
.bottom-nav button.active span { filter: none; opacity: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 20px; font-weight: 650; font-size: 14px;
  transition: all .25s; max-width: calc(100% - 32px); text-align: center; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Marché */
.mood { display: flex; align-items: center; gap: 14px; }
.gauge { flex: 0 0 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 18px;
  background: conic-gradient(var(--mood-color) calc(var(--v) * 1%), var(--card-2) 0); position: relative; }
.gauge::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--card); }
.gauge span { position: relative; }
.down { color: var(--red); }
.up { color: var(--green); }
.act { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 3px 8px; border-radius: 8px; white-space: nowrap; }
.act-vendre { background: rgba(255, 93, 115, .15); color: var(--red); }
.act-acheter { background: rgba(46, 229, 157, .15); color: var(--green); }
.act-garder { background: rgba(77, 163, 255, .15); color: var(--blue); }
.act-attendre { background: rgba(242, 201, 76, .15); color: var(--gold); }
.act-éviter { background: var(--card-2); color: var(--muted); }
.act-à-faire { background: rgba(46, 229, 157, .15); color: var(--green); }
.act-si-fourrage { background: rgba(242, 201, 76, .15); color: var(--gold); }
.act-à-éviter { background: var(--card-2); color: var(--muted); }
.fodder { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.fodder th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 0 0 6px; }
.fodder td { padding: 7px 0; border-top: 1px solid var(--line); }
.fodder tr.best td { color: var(--green); font-weight: 700; }
.bar { height: 6px; border-radius: 3px; background: var(--green); opacity: .7; }
.player-line { display: flex; gap: 10px; align-items: flex-start; }
.player-line .ovr { flex: 0 0 40px; height: 44px; border-radius: 8px; background: linear-gradient(160deg, #3a3217, #1b232e); border: 1px solid #5a4b1f;
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; color: var(--gold); line-height: 1.1; }
.player-line .ovr small { font-size: 9px; color: var(--muted); font-weight: 700; }
