:root {
  --bg: #0f1720;
  --panel: #17212c;
  --panel2: #1e2a37;
  --line: #2a3848;
  --text: #e8eef4;
  --muted: #8a9bad;
  --accent: #33d17a;
  --accent2: #2ec4b6;
  --warn: #f5a524;
  --bad: #ef4f5a;
  --d1: #1f9d55;
  --d2: #5cb85c;
  --d3: #6b7785;
  --d4: #e6892e;
  --d5: #d64550;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 17px; }
.meta { display: flex; gap: 10px; align-items: center; font-size: 13px; flex-wrap: wrap; }
#round { background: var(--panel2); padding: 2px 8px; border-radius: 99px; }

.tabs {
  display: flex; gap: 4px; padding: 8px 16px 0; overflow-x: auto; background: var(--panel);
  border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.tabs button {
  background: none; border: 0; padding: 8px 12px 10px; color: var(--muted); white-space: nowrap;
  border-bottom: 3px solid transparent; font-weight: 600;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

.horizon {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; flex-wrap: wrap;
  background: var(--bg); border-bottom: 1px solid var(--line); font-size: 14px;
}
.seg { display: inline-flex; background: var(--panel2); border-radius: 99px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 99px; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--accent); color: #062b16; }

main { max-width: 1100px; margin: 0 auto; padding: 12px 16px 40px; }
.tab { display: none; }
.tab.active { display: block; }
h2 { font-size: 16px; margin: 22px 0 10px; }
.help { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.notice { background: var(--panel); border: 1px dashed var(--line); padding: 14px; border-radius: var(--radius); color: var(--muted); margin: 12px 0; }
.ghost { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.ghost:hover { border-color: var(--accent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
input[type=search], input[type=number], select {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
.budget input { width: 90px; margin-left: 6px; }

/* search-to-add */
.adder { position: relative; margin-bottom: 12px; }
.adder input { width: 100%; padding: 11px 12px; font-size: 16px; }
.results {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 4; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 0 0 10px 10px; max-height: 340px; overflow-y: auto;
}
.results:empty { display: none; }
.results button {
  display: flex; width: 100%; gap: 10px; align-items: center; text-align: left; padding: 8px 12px;
  background: none; border: 0; border-bottom: 1px solid var(--line);
}
.results button:hover, .results button:focus { background: var(--panel); }
.results .in { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }

/* login */
.auth {
  position: fixed; inset: 0; z-index: 20; background: rgba(8, 12, 18, .92);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px;
}
.auth-card h2 { margin: 0; font-size: 20px; }
.auth-card .help { margin: 0; }
.auth-card .seg { align-self: flex-start; }
.auth-card input { width: 100%; padding: 10px 12px; font-size: 16px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; }
.pw { display: flex; gap: 6px; }
.pw input { flex: 1; }
.primary { background: var(--accent); color: #062b16; border: 0; border-radius: 8px; padding: 10px; font-weight: 700; }
.primary:disabled { opacity: .6; }
.auth-msg { min-height: 1.2em; font-size: 14px; color: var(--warn); }
#auth-guest { font-size: 13px; }
.auth-note { font-size: 12px; margin: 0; text-align: center; }

/* release clauses (squad cards) and bids (market / explore cards) */
.clause, .bid {
  margin: 8px 0 2px; padding: 8px 10px; background: var(--panel2); border-radius: 8px; font-size: 13px;
  display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;
}
.clause .muted, .bid .muted { flex-basis: 100%; font-size: 12px; }
.clause-in, .rival-clause-in { width: 70px; padding: 4px 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }

/* admin: friends' teams */
.viewing {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: #2b2350; border-bottom: 1px solid #6a5acd; padding: 8px 16px; font-size: 14px;
}
.friends th, .friends td { padding: 6px 8px; font-size: 13px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.friends tr.demo td { background: rgba(106, 90, 205, .12); }
.friends .small { font-size: 11px; }
/* the unfolded squad stays in view and wraps, even though the table scrolls sideways */
.friends .squadrow { position: sticky; left: 8px; max-width: min(1060px, calc(100vw - 64px)); }
.friends button { font-size: 12px; padding: 3px 8px; }

.debt {
  background: #3a1d22; border: 1px solid var(--bad); border-radius: var(--radius); padding: 10px 12px;
  margin: 0 0 12px; font-size: 14px;
}
.debt .reasons { padding-left: 18px; }
.budget input { width: 110px; }

/* summary cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.card .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.card .v { font-size: 20px; font-weight: 700; margin-top: 2px; }
.card .s { font-size: 12px; color: var(--muted); }

/* lineup pitch */
.pitch {
  background: linear-gradient(#17482f, #12391f); border-radius: var(--radius); padding: 12px 8px;
  display: flex; flex-direction: column-reverse; gap: 10px; border: 1px solid #1f5a3a;
}
.line { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.spot {
  background: rgba(0,0,0,.35); border-radius: 10px; padding: 5px 8px; text-align: center; min-width: 74px; max-width: 110px;
  font-size: 12px; line-height: 1.25;
}
.spot b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spot.risk { outline: 2px solid var(--warn); }
.bench { margin-top: 8px; font-size: 13px; color: var(--muted); }
.formation { font-weight: 700; color: var(--accent); }

/* planner grid */
.planner-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { border-collapse: collapse; width: 100%; }
.planner th, .planner td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: center; font-size: 13px; white-space: nowrap; }
.planner th:first-child, .planner td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); z-index: 1; }
.planner td.name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.planner .cell { border-radius: 6px; padding: 2px 4px; display: inline-block; min-width: 54px; color: #fff; }
.planner .cell small { display: block; font-size: 11px; opacity: .9; }
.planner .cell.out { background: #3a1d22 !important; color: var(--bad); }
.planner .cell.dim { opacity: .35; }
.planner .xi { box-shadow: inset 0 0 0 2px #fff; }
.planner tfoot td { font-weight: 700; }
.planner .total { color: var(--accent); }
.legend { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* midweek cup / European match near a league game */
.mw { position: relative; }
.mw::after {
  content: ""; position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; border-radius: 50%;
  background: #ffd23f; box-shadow: 0 0 0 1px rgba(0,0,0,.6);
}
.mwtag { display: block; font-style: normal; font-size: 10px; font-weight: 700; color: #ffd23f; line-height: 1.1; }
.midweek { margin: 6px 0; }
.midweek div { color: var(--muted); }

.d1 { background: var(--d1); } .d2 { background: var(--d2); } .d3 { background: var(--d3); }
.d4 { background: var(--d4); } .d5 { background: var(--d5); }

/* player cards */
.sortbar { display: flex; gap: 8px; align-items: center; margin: 4px 0 10px; color: var(--muted); font-size: 14px; }
.list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.pc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.pc.sell { border-left: 4px solid var(--bad); }
.pc.maybe { border-left: 4px solid var(--warn); }
.pc.good { border-left: 4px solid var(--accent); }
.pc.over { opacity: .55; }
.pc-head { display: flex; gap: 10px; align-items: center; }
.pc-head img { width: 44px; height: 44px; border-radius: 50%; background: var(--panel2); object-fit: cover; flex: none; }
.pc-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-sub { color: var(--muted); font-size: 13px; }
.pc-val { margin-left: auto; text-align: right; flex: none; }
.pc-val b { font-size: 16px; }
.up { color: var(--accent); } .down { color: var(--bad); } .flat { color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 6px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); white-space: nowrap; }
.chip.ok { border-color: var(--accent); color: var(--accent); }
.chip.mid { border-color: var(--warn); color: var(--warn); }
.chip.no { border-color: var(--bad); color: var(--bad); }
.chip.solid-bad { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 700; }
.chip.solid-warn { background: var(--warn); border-color: var(--warn); color: #2b1a00; font-weight: 700; }
.chip.solid-ok { background: var(--accent); border-color: var(--accent); color: #062b16; font-weight: 700; }
.fx { display: flex; gap: 4px; margin: 6px 0; }
.fx span { flex: 1; text-align: center; font-size: 11px; padding: 3px 0; border-radius: 5px; color: #fff; min-width: 0; }
.fx span.out { background: #3a1d22; color: var(--bad); text-decoration: line-through; }
.fx span.dim { opacity: .35; }
.reasons { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.reasons li { margin: 2px 0; }
.reasons.bad li::marker { color: var(--bad); }
.reasons li.keep { color: var(--accent); }
.reasons li.keep::marker { color: var(--accent); }
.reasons.good li::marker { color: var(--accent); }
.valrow { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.valrow svg { flex: none; }
details { margin-top: 6px; font-size: 13px; }
details summary { color: var(--muted); cursor: pointer; }
.pts { display: flex; gap: 3px; flex-wrap: wrap; margin: 6px 0; }
.pts span { min-width: 24px; text-align: center; border-radius: 4px; padding: 1px 3px; background: var(--panel2); font-size: 12px; }
.pts .hi { background: #1f6f43; } .pts .md { background: #4b5a2a; } .pts .lo { background: #5a2a2a; } .pts .no { color: var(--muted); }
.actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.actions button { font-size: 13px; padding: 4px 10px; }
.news-mini a { display: block; margin: 3px 0; }

/* match odds + position battle in player cards */
table.odds { margin: 8px 0; font-size: 12px; }
table.odds th, table.odds td { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
table.odds th { color: var(--muted); font-weight: 600; }
table.odds .cell { display: inline-block; min-width: 38px; border-radius: 4px; color: #fff; padding: 1px 3px; }
.ok-t { color: var(--accent); } .mid-t { color: var(--warn); } .no-t { color: var(--bad); }
.depthbox { margin: 8px 0; }
.rivals { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.fxtable .cell small { display: block; font-size: 10px; opacity: .9; }

/* fixtures + standings */
.fxtable td, .fxtable th, .standings td, .standings th { padding: 5px 6px; font-size: 13px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.fxtable td:first-child, .standings td:nth-child(2) { text-align: left; }
.fxtable .cell { display: inline-block; min-width: 44px; border-radius: 5px; padding: 2px 4px; color: #fff; }
.form span { display: inline-block; width: 16px; height: 16px; line-height: 16px; border-radius: 3px; font-size: 10px; margin-right: 1px; color: #fff; }
.form .W { background: var(--d1); } .form .D { background: var(--d3); } .form .L { background: var(--d5); }

/* filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 180px; }
.filters label { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.filters input[type=number] { width: 80px; }
.more { display: block; margin: 14px auto; }

/* news */
.news { display: grid; gap: 8px; }
.news a.item { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; color: var(--text); text-decoration: none; }
.news a.item:hover { border-color: var(--accent2); }
.news .src { font-size: 12px; color: var(--muted); }
.news .tag { font-size: 12px; color: var(--accent); margin-left: 6px; }

.foot { text-align: center; font-size: 12px; padding: 0 16px 24px; }

/* ---------- position badges (same colours everywhere) ---------- */
.pos {
  display: inline-block; min-width: 30px; text-align: center; font-size: 10px; font-weight: 800; letter-spacing: .03em;
  padding: 1px 4px; border-radius: 4px; color: #0b1118; vertical-align: 1px;
}
.pos-GK { background: #f5c542; } .pos-DEF { background: #5aa9f5; } .pos-MID { background: #4fd18b; } .pos-FWD { background: #f2726b; }
.results .pos { flex: none; }

/* ---------- header countdown ---------- */
#round.soon { background: var(--warn); color: #2b1a00; font-weight: 700; }

/* ---------- tabs with icons; on phones they become a bottom bar ---------- */
.tabs button i { font-style: normal; margin-right: 6px; }

/* ---------- pitch with photos ---------- */
.pitch { position: relative; overflow: hidden; }
.pitch::before {  /* halfway line and centre circle */
  content: ""; position: absolute; left: 50%; top: 50%; width: 120px; height: 120px; margin: -60px 0 0 -60px;
  border: 2px solid rgba(255,255,255,.08); border-radius: 50%; pointer-events: none;
}
.pitch::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 2px solid rgba(255,255,255,.08); pointer-events: none; }
.line { position: relative; z-index: 1; }
.spot-photo { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: rgba(255,255,255,.08); display: block; margin: 0 auto 2px; }

/* ---------- compact squad list ---------- */
#squad.as-list { display: block; }
.squadlist th, .squadlist td { padding: 6px 8px; font-size: 13px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.squadlist th { color: var(--muted); font-weight: 600; }
.fx.mini { margin: 0; min-width: 190px; }
.fx.mini span { font-size: 10px; padding: 2px 0; }
.chip.tiny { font-size: 11px; padding: 1px 6px; }

/* ---------- best moves ---------- */
.moves { display: grid; gap: 8px; }
.move {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px;
  padding: 8px 12px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 14px;
}
.move.over { border-left-color: var(--warn); opacity: .75; }

/* ---------- compare ---------- */
.ghost.on { border-color: var(--accent); color: var(--accent); }
.compare-bar {
  position: fixed; right: 16px; bottom: calc(16px + var(--badge-h, 0px)); z-index: 15; display: flex; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 99px; padding: 6px 8px 6px 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4); font-size: 14px; max-width: calc(100vw - 32px);
}
.compare-bar .primary { padding: 6px 12px; }
.compare-bar .primary:disabled { opacity: .5; }
.cmp-card {
  width: 100%; max-width: 900px; max-height: calc(100vh - 32px); overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; position: relative;
}
.cmp-card h2 { margin-top: 0; }
.cmp-close { position: absolute; right: 12px; top: 12px; }
.cmp th, .cmp td { padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: 13px; text-align: center; vertical-align: top; }
.cmp tbody th { text-align: left; color: var(--muted); font-weight: 600; white-space: nowrap; }
.cmp td.best { background: rgba(51, 209, 122, .14); color: var(--accent); font-weight: 700; }
.cmp-photo { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: var(--panel2); }
.cmp .fx.mini { min-width: 150px; }

@media (max-width: 600px) {
  .list { grid-template-columns: 1fr; }
  .brand span { display: none; }
  .spot { min-width: 58px; padding: 4px 4px; }
  .spot-photo { width: 28px; height: 28px; }
  /* app-style bottom tab bar */
  .tabs {
    position: fixed; left: 0; right: 0; bottom: var(--badge-h, 0px); z-index: 12; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    justify-content: space-around; border-top: 1px solid var(--line); border-bottom: 0; overflow: hidden;
  }
  .tabs button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 4px; font-size: 11px;
                 border-bottom: 0; border-top: 3px solid transparent; flex: 1; min-width: 0; }
  .tabs button.active { border-top-color: var(--accent); }
  .tabs button i { margin: 0; font-size: 18px; }
  body { padding-bottom: calc(64px + var(--badge-h, 0px) + env(safe-area-inset-bottom)); }
  .compare-bar { bottom: calc(72px + var(--badge-h, 0px) + env(safe-area-inset-bottom)); right: 8px; }
  .meta { gap: 6px; }
  #updated { display: none; }  /* keeps the header on one line; the data age is in the Reload button's tooltip */
}

/* ---------- message at the bottom (with Undo) ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--badge-h, 0px)); transform: translate(-50%, 140%); z-index: 30;
  display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 32px);
  background: #24313f; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,.45); transition: transform .2s ease; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); pointer-events: auto; }
.toast button { color: var(--accent); border-color: var(--accent); }
.results button:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (max-width: 600px) { .toast { bottom: calc(76px + var(--badge-h, 0px) + env(safe-area-inset-bottom)); } }
