:root {
  --bg: #0c1118;
  --panel: #131b26;
  --panel-2: #1a2533;
  --line: #243140;
  --text: #e7eef6;
  --muted: #8aa0b6;
  --accent: #19c37d;       /* pitch green */
  --ability: #3b82f6;      /* blue */
  --hunger-lo: #ef4444;    /* red  */
  --hunger-hi: #22c55e;    /* green */
  --strength: #f59e0b;     /* amber */
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #16202d 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}
h1, h2 { margin: 0; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 22px; }
.hidden { display: none !important; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: rgba(12,17,24,.7); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 19px; letter-spacing: .2px; }
.brand .sub { color: var(--muted); font-weight: 500; font-size: 14px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px rgba(25,195,125,.18); }
.team-picker { display: flex; align-items: center; gap: 8px; }
.team-picker label { color: var(--muted); font-size: 13px; }
select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font-size: 14px;
}

/* ---- data banner ---- */
.banner {
  margin: 12px 22px 0; padding: 9px 14px; border-radius: 10px;
  background: #2a2113; border: 1px solid #5b4615; color: #f1d79a; font-size: 13px;
}
.banner.ok { background: #0f2a1c; border-color: #1c5b3a; color: #8ef0bf; }

/* ---- layout ---- */
.layout {
  display: grid; grid-template-columns: 320px 1fr; gap: 18px;
  padding: 18px 22px 40px; align-items: start;
}
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px; box-shadow: var(--shadow);
}
.sticky { position: sticky; top: 78px; }
.grow { min-height: 60vh; }

/* ---- aggregate metrics ---- */
.xi-count { font-size: 40px; font-weight: 800; line-height: 1; }
.xi-count .slash { color: var(--muted); font-size: 22px; font-weight: 600; }
.formation { display: flex; gap: 6px; margin: 10px 0 4px; flex-wrap: wrap; }
.formation .chip {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.formation .chip b { color: var(--text); }
.metrics { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.metric-label { font-size: 12px; color: var(--muted); margin-bottom: 5px; display:flex; gap:6px; }
.metric-val { text-align: right; font-weight: 700; margin-top: 3px; }
.bar { height: 10px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.fill { display: block; height: 100%; width: 0; border-radius: 6px; transition: width .35s ease; }
.fill.ability { background: linear-gradient(90deg, #1e3a8a, var(--ability)); }
.fill.hunger { background: linear-gradient(90deg, var(--hunger-lo), var(--hunger-hi)); }
.fill.strength { background: linear-gradient(90deg, #7c4a03, var(--strength)); }
.hint { cursor: help; color: var(--muted); }

/* ---- matchup ---- */
.opp label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 6px; }
.opp b { color: var(--text); }
.opp select { width: 100%; }
.mt-detail { margin-top: 8px; line-height: 1.5; }
.winprob { margin-top: 12px; }
.wp-bar {
  position: relative; height: 30px; border-radius: 8px; overflow: hidden;
  background: #3a2330; border: 1px solid var(--line);
}
.wp-fill { position: absolute; left: 0; top: 0; height: 100%; width: 50%;
  background: linear-gradient(90deg, #15803d, var(--accent)); transition: width .3s ease; }
.wp-label { position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-weight: 800; font-size: 14px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.wp-legend { display: flex; justify-content: space-between; font-size: 11px;
  color: var(--muted); margin-top: 5px; }

/* ---- squad ---- */
.squad-head { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.legend { display: flex; align-items: center; gap: 10px; }
.pill { font-size: 11px; padding: 2px 9px; border-radius: 999px; font-weight: 700; }
.pill.start { background: rgba(25,195,125,.16); color: var(--hunger-hi); border: 1px solid rgba(25,195,125,.4); }
.pill.bench { background: rgba(138,160,182,.12); color: var(--muted); border: 1px solid var(--line); }

.squad { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 12px; }
.card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; cursor: pointer; transition: border-color .15s, transform .1s;
  position: relative;
}
.card:hover { border-color: #35506b; }
.card.starting { border-color: rgba(25,195,125,.55); box-shadow: inset 0 0 0 1px rgba(25,195,125,.25); }
.card.benched { opacity: .62; }
.card-top { display: flex; align-items: center; gap: 10px; }
.num { width: 26px; height: 26px; border-radius: 7px; background: #0e1620; border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); flex: none; }
.who { min-width: 0; flex: 1; }
.who .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.posbadge { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 6px; flex: none; }
.pos-GK { background:#3b2f0e; color:#facc15; } .pos-DEF { background:#0e2a3b; color:#38bdf8; }
.pos-MID { background:#10322a; color:#34d399; } .pos-ATT { background:#33121f; color:#fb7185; }

.minis { display: flex; gap: 10px; margin-top: 10px; }
.mini { flex: 1; }
.mini .mlabel { font-size: 10px; color: var(--muted); display: flex; justify-content: space-between; }
.mini .mbar { height: 6px; border-radius: 4px; background: #0e1620; overflow: hidden; margin-top: 3px; }
.mini .mfill { height: 100%; width: 0; border-radius: 4px; }

.toggle { position: absolute; top: 12px; right: 12px; font-size: 10px; font-weight: 800;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); background: #0e1620; color: var(--muted); }
.card.starting .toggle { color: var(--hunger-hi); border-color: rgba(25,195,125,.4); }
.card.hurt { border-color: rgba(245,158,11,.55); box-shadow: inset 0 0 0 1px rgba(245,158,11,.22); }

/* injury control */
.injrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.injlbl { font-size: 11px; color: var(--muted); }
.inj { background: #0e1620; color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 4px 7px; font-size: 11px; }
.card.hurt .injlbl { color: var(--strength); }
.chip.hurt { color: var(--strength); border-color: rgba(245,158,11,.45); }

/* top nav */
.topnav { display: flex; gap: 14px; align-items: center; }
.topnav a { color: var(--muted); text-decoration: none; font-size: 13px; padding: 6px 4px; border-bottom: 2px solid transparent; }
.topnav a:hover { color: var(--text); border-bottom-color: var(--accent); }

/* ---- why panel ---- */
.why { margin-top: 11px; border-top: 1px dashed var(--line); padding-top: 10px; display: none; }
.card.open .why { display: block; }
.why ul { margin: 0 0 8px; padding-left: 16px; }
.why li { font-size: 12px; color: var(--text); margin: 2px 0; }
.comp { display: grid; grid-template-columns: 92px 1fr 30px; gap: 6px; align-items: center; margin: 3px 0; }
.comp .cname { font-size: 11px; color: var(--muted); }
.comp .cbar { height: 6px; border-radius: 4px; background: #0e1620; overflow: hidden; }
.comp .cfill { height: 100%; background: linear-gradient(90deg, var(--hunger-lo), var(--hunger-hi)); }
.comp .cval { font-size: 11px; text-align: right; color: var(--text); }
.comp.dim { opacity: .45; }

/* ---- footer ---- */
.foot { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 14px 22px 30px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

/* ====== two-team head-to-head board ====== */
.layout2 { padding: 16px 22px 40px; display: flex; flex-direction: column; gap: 16px; }

.scoreboard {
  display: grid; grid-template-columns: 1fr 1.5fr 1fr; gap: 20px; align-items: center;
  position: sticky; top: 70px; z-index: 9;
}
.sb-side { display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; }
.sb-select { width: 100%; max-width: 230px; font-weight: 700; text-align: center; }
.sb-name { font-size: 18px; font-weight: 800; }
.sb-strength { font-size: 32px; font-weight: 800; color: var(--strength); line-height: 1; transition: color .25s; }
.sb-xi { line-height: 1.2; }
.sb-mid { text-align: center; }
.sb-mid .vs { font-size: 11px; letter-spacing: 2px; color: var(--muted); margin-bottom: 7px; font-weight: 700; }
.wp-bar.big { height: 36px; border-radius: 10px; }
.wp-bar.big .wp-label { font-size: 15px; }

.board { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.teamcol-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.teamcol-head h2 { font-size: 17px; }
.teamcol .xi-count { font-size: 26px; }
.teamcol .xi-count .slash { font-size: 16px; }
.metrics.row3 { flex-direction: row; gap: 12px; margin-top: 12px; }
.metrics.row3 .metric { flex: 1; min-width: 0; }
.teamcol .legend { margin: 14px 0 10px; flex-wrap: wrap; }
.squad.onecol { grid-template-columns: 1fr; gap: 10px; }

/* click-to-pick affordances */
.card { user-select: none; }
.card:hover { border-color: #3d5d7d; box-shadow: 0 0 0 1px rgba(61,93,125,.35); }
.card:active { transform: scale(.994); }
.card.starting:hover { border-color: rgba(25,195,125,.8); }
.cardfoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 11px; }
.pickhint { font-size: 10px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  color: var(--muted); opacity: .8; }
.card.starting .pickhint { color: var(--hunger-hi); opacity: .9; }
.whybtn { background: #0e1620; border: 1px solid var(--line); color: var(--muted);
  border-radius: 7px; padding: 4px 11px; font-size: 11px; font-weight: 700; cursor: pointer; flex: none; }
.whybtn:hover { color: var(--text); border-color: #3d5d7d; }
.card.open .whybtn { color: var(--text); border-color: #3d5d7d; }
.toggle { cursor: pointer; }

@media (max-width: 980px) {
  .scoreboard { grid-template-columns: 1fr; position: static; gap: 14px; }
  .board { grid-template-columns: 1fr; }
}

/* keep the old single-column layout responsive too (howto/settings reuse vars) */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
