:root {
  --bg: #0f1114;
  --panel: #1a1d23;
  --panel2: #22262e;
  --line: #2e333d;
  --text: #eceff4;
  --muted: #9aa3b2;
  --red: #e10600;           /* F1 red */
  --t3: #2dc653;            /* exact */
  --t2: #ffd60a;            /* called the exit */
  --t1: #ff8800;            /* misread the move */
  --t0: #555c68;            /* off grid */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- chrome ---------- */
header {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1rem;
  background: var(--panel);
  border-bottom: 3px solid var(--red);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 1.05rem; white-space: nowrap; }
nav { display: flex; gap: .25rem; flex: 1; }
nav a {
  color: var(--muted); text-decoration: none;
  padding: .35rem .8rem; border-radius: 999px;
}
nav a.active { background: var(--red); color: #fff; }
nav a:hover:not(.active) { background: var(--panel2); color: var(--text); }
#userbox { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .9rem; }

main { max-width: 1100px; margin: 0 auto; padding: 1rem; }

/* ---------- panels & bits ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 1rem 1.2rem; margin-bottom: 1rem;
}
.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }
.hero h1 { margin: .2rem 0 .6rem; }
.muted { color: var(--muted); }
h2 { margin: .2rem 0 .6rem; font-size: 1.25rem; }
h3 { margin: 0 0 .5rem; font-size: 1rem; border-bottom: 2px solid var(--red); padding-bottom: .3rem; }

button, .button {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .5rem .9rem; font-size: .95rem; cursor: pointer;
  text-decoration: none; display: inline-block;
}
button:hover, .button:hover { border-color: var(--muted); }
button.primary, .button.primary { background: var(--red); border-color: var(--red); color: #fff; }
button.primary:hover { filter: brightness(1.15); }
button.danger { border-color: #7a2020; color: #ff8a8a; }

input, select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .5rem .6rem; font-size: .95rem; max-width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--red); border-color: transparent; }
form { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin: .8rem 0; }
.inline-form { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: .6rem 0; }

.badge {
  display: inline-block; padding: .15rem .6rem; border-radius: 999px;
  font-size: .8rem; background: var(--panel2); border: 1px solid var(--line);
}
.badge.ok { background: #14361f; border-color: var(--t3); color: var(--t3); }
.badge.warn { background: #3a2a10; border-color: var(--t1); color: var(--t1); }
.badge.ai { background: #102a3a; border-color: #4aa8d8; color: #4aa8d8; font-size: .7rem; }

.chip {
  display: inline-block; padding: .1rem .55rem; border-radius: 6px;
  font-size: .85rem; font-weight: 600; color: #111;
}
.chip.t3 { background: var(--t3); }
.chip.t2 { background: var(--t2); }
.chip.t1 { background: var(--t1); }
.chip.t0 { background: var(--t0); color: #ddd; }
.chip.tp { background: transparent; border: 1px dashed var(--muted); color: var(--muted); }

/* ---------- picks grid ---------- */
.picks-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.lock-info { text-align: right; }
.rules { margin-top: .6rem; }
.rules summary { cursor: pointer; color: var(--muted); }
.rules li { margin: .35rem 0; }

.grid-editor, .stats-grid {
  display: grid; gap: .8rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  margin-bottom: 1rem;
}
.team-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: .8rem 1rem;
}
.seat { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .5rem; }
.seat select, .seat input { width: 100%; }
.seat.dupe select, .seat.dupe input { border-color: var(--red); outline: 1px solid var(--red); }

.actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: 1rem 0; }

/* ---------- stats ---------- */
.statrow { display: grid; grid-template-columns: 1fr 2fr auto; gap: .5rem; align-items: center; margin: .3rem 0; }
.statname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.statbar { background: var(--panel2); border-radius: 999px; height: 10px; overflow: hidden; }
.statbar span { display: block; height: 100%; background: var(--red); border-radius: 999px; }
.statpct { font-size: .8rem; color: var(--muted); white-space: nowrap; }

/* ---------- tables / results ---------- */
table.leaderboard { width: 100%; border-collapse: collapse; }
.leaderboard th, .leaderboard td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); }
.leaderboard .rank { font-weight: 700; color: var(--muted); }
.leaderboard .total { font-weight: 700; }
.keyrow { display: flex; gap: .6rem; padding: .25rem 0; align-items: baseline; flex-wrap: wrap; }
.keyrow b { min-width: 7.5rem; }

/* ---------- toast ---------- */
#toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%) translateY(120%);
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: .7rem 1.2rem; max-width: 90vw;
  transition: transform .25s; z-index: 50;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { border-color: var(--red); }

@media (max-width: 640px) {
  header { gap: .5rem; }
  nav { order: 3; width: 100%; justify-content: space-around; }
  .lock-info { text-align: left; }
}
