:root {
  --bg: #0b0f1a;
  --panel: #131a2c;
  --panel-2: #1a2238;
  --border: #263050;
  --text: #e9eef9;
  --muted: #8a98b8;
  --accent: #4cc9f0;
  --accent-2: #f72585;
  --win: #2ecc71;
  --slot: #1f2740;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #0e1424, #0b0f1a);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: .3px; }
.brand .subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.logo {
  display: inline-grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 800;
  font-size: 14px;
  color: #0b0f1a;
  box-shadow: 0 4px 18px rgba(76, 201, 240, .25);
}

.controls { display: flex; gap: 10px; }
.controls button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.controls button:hover { background: #232c48; border-color: #364370; }
.controls button:active { transform: translateY(1px); }
.controls .primary {
  background: linear-gradient(135deg, var(--accent), #6a8cff);
  color: #0b0f1a;
  border-color: transparent;
}
.controls .primary:hover { filter: brightness(1.05); }

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 22px;
  padding: 22px 28px 40px;
  max-width: 1500px;
  margin: 0 auto;
}

.teams-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 16px 14px;
  position: sticky;
  top: 90px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.teams-panel h2 { margin: 0 0 4px; font-size: 15px; }
.teams-panel .hint, .teams-panel .updated {
  margin: 0 0 10px; font-size: 12px; color: var(--muted);
}
.teams-panel .updated { margin-top: 12px; }

.teams-list { list-style: none; padding: 0; margin: 0; }
.team {
  display: grid;
  grid-template-columns: 28px 36px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin: 6px 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--team-color, #444);
  border-radius: 10px;
  cursor: grab;
  user-select: none;
  transition: transform .06s ease, background .15s ease, opacity .2s;
}
.team:hover { background: #1f2842; }
.team:active { cursor: grabbing; }
.team.used {
  opacity: .55;         /* dimmed but still clearly readable */
  cursor: not-allowed;
}
.team.used .form { cursor: pointer; }   /* form toggle stays clickable */
.team.dragging { opacity: .55; }

.team .rank { font-weight: 800; color: var(--muted); text-align: center; }
.team .crest {
  width: 32px; height: 32px;
  background: #fff;
  border-radius: 6px;
  display: grid; place-items: center;
  overflow: hidden;
}
.team .crest img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.team .name { font-weight: 600; font-size: 14px; }
.team .pts { font-size: 12px; color: var(--muted); }

.team.bubble { border-style: dashed; }

.bracket-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 26px;
  overflow-x: auto;
}

.bracket {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr 0.9fr;
  gap: 32px;
  min-width: 950px;
  position: relative;
}

.round { display: flex; flex-direction: column; }
.round h3 {
  margin: 0 0 14px;
  font-size: 12.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
}
.round-qf { gap: 18px; }
.round-sf { justify-content: space-around; }
.round-final, .round-champ { justify-content: center; }

.match {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
.match::before {
  content: attr(data-label);
  position: absolute;
  top: -10px; left: 12px;
  font-size: 10.5px;
  letter-spacing: 1px;
  color: var(--muted);
  background: var(--panel);
  padding: 0 6px;
  border-radius: 4px;
}

.slot {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 10px;
  background: var(--slot);
  border: 1px dashed #364370;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.slot:hover { border-color: #4a5a8c; }
.slot.empty .slot-name { color: var(--muted); font-style: italic; }
.slot.filled {
  background: #1d263f;
  border-style: solid;
  border-left: 4px solid var(--team-color, #444);
  color: var(--text);
}
.slot.filled .slot-name { font-weight: 600; }
.slot.winner {
  background: linear-gradient(90deg, rgba(46, 204, 113, .14), transparent 80%);
  border-color: var(--win);
  color: var(--text);
}
.slot.winner .slot-name { font-weight: 700; }
.slot.loser { opacity: .45; }

.slot.drag-over { border-color: var(--accent); background: #1f2c46; }

.slot .crest {
  width: 26px; height: 26px;
  background: #fff;
  border-radius: 5px;
  overflow: hidden; display: grid; place-items: center;
}
.slot .crest img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.slot .crest.empty { background: transparent; border: 1px dashed #3a4670; }

.slot .clear {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
}
.slot .clear:hover { color: var(--accent-2); }

.vs {
  text-align: center;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
}

.champion {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 22px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1c2849, #1a2238);
  border: 1px solid var(--border);
  font-size: 16px;
  font-weight: 700;
  min-height: 110px;
}
.champion.empty { color: var(--muted); font-weight: 500; font-style: italic; }
.champion.set {
  border-color: #f4c430;
  box-shadow: 0 0 0 2px rgba(244, 196, 48, .15), 0 12px 40px rgba(244, 196, 48, .12);
}
.champion .crest {
  width: 64px; height: 64px;
  background: #fff;
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden; display: grid; place-items: center;
}
.champion .crest img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.champion .label { font-size: 10px; color: var(--muted); letter-spacing: 1.5px; margin-top: 2px; }

/* Projection extras */
.teams-panel h2 .badge {
  font-size: 9.5px;
  letter-spacing: 1.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b0f1a;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 800;
}
.delta {
  font-size: 10.5px;
  margin-left: 6px;
  font-weight: 700;
  vertical-align: middle;
}
.delta.up   { color: var(--win); }
.delta.down { color: #ff5e7e; }

.fixtures-panel { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.fixtures-panel h3 {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.fixtures-panel h3 .clear-picks {
  background: none;
  border: none;
  color: var(--accent-2);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
}

.team-blocks { display: flex; flex-direction: column; gap: 8px; }
.team-block {
  background: rgba(255, 255, 255, .02);
  border: 1px solid var(--border);
  border-left: 3px solid var(--team-color, #444);
  border-radius: 7px;
  padding: 6px 8px 4px;
}
.tb-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  font-size: 11.5px;
}
.tb-head .rank { color: var(--muted); font-weight: 700; min-width: 16px; }
.tb-head .name { font-weight: 700; }

.fixture-row {
  display: grid;
  grid-template-columns: 36px 14px 1fr 78px 1fr 14px;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
  font-size: 11px;
  cursor: help;
}
.fixture-row .date { color: var(--muted); font-variant-numeric: tabular-nums; }
.fixture-row .ha {
  font-size: 9px; font-weight: 800;
  color: var(--muted);
  text-align: center;
}
.fixture-row .ha.home { color: #5fdcff; }
.fixture-row .ha.away { color: #c9a4ff; }
.fixture-row .score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  text-align: center;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.fixture-row .score .dash { color: var(--muted); padding: 0 1px; }
.fixture-row .score-input {
  width: 28px;
  height: 18px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 0 2px;
  outline: none;
  cursor: text;
  transition: background .12s, border-color .12s;
  /* Hide default number-input spinners */
  -moz-appearance: textfield;
  appearance: textfield;
}
.fixture-row .score-input::-webkit-inner-spin-button,
.fixture-row .score-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.fixture-row .score-input:focus { border-color: var(--accent); background: rgba(76, 201, 240, .08); }
.fixture-row .score-input:hover { border-color: #4a5a8c; }
.fixture-row .score-input.overridden {
  border-color: var(--accent-2);
  background: rgba(247, 37, 133, .08);
}
.fixture-row .reset-pick {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 0; font-size: 12px;
}
.fixture-row .reset-pick:hover { color: var(--accent); }

.pick-btn {
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  border-left: 3px solid var(--c, #444);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: background .12s, color .12s, border-color .12s;
}
.pick-btn.opp-pick { border-left: none; border-right: 3px solid var(--c, #444); }
.pick-btn:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.pick-btn.predicted {
  background: rgba(76, 201, 240, .12);
  color: var(--text);
  border-color: rgba(76, 201, 240, .35);
}
.pick-btn.user-pick {
  background: linear-gradient(90deg, rgba(247, 37, 133, .25), rgba(247, 37, 133, .08));
  color: #fff;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px var(--accent-2) inset;
}

.flame-mini { font-size: 9px; margin-left: 2px; vertical-align: middle; }

/* Form-toggle button on each team card */
.team .form {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  opacity: .22;
  transition: opacity .15s, transform .12s, filter .15s;
  filter: grayscale(0.8);
}
.team .form:hover { opacity: .55; transform: scale(1.1); }
.team .form.on {
  opacity: 1;
  filter: drop-shadow(0 0 6px #ff8c1a) saturate(1.4);
}
.team .form.on.auto {
  filter: drop-shadow(0 0 5px #5fdcff) saturate(1.2);   /* auto-detected: cool blue */
}
.team .form.on.manual {
  filter: drop-shadow(0 0 6px #ff8c1a) saturate(1.4);   /* user override: warm orange */
}

/* Try-count row beneath each fixture row.
   Steppers (− N +) for each side, with "🏉 N" in the middle.
   Glow + border-pulse if a side has reached the 4-try bonus threshold. */
.tries-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 1px 0 4px 36px;            /* indent past the date column */
  font-size: 10px;
  color: var(--muted);
  margin-top: -2px;
}
.tries-side {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
}
.tries-side.bonus {
  color: var(--text);
  background: rgba(46, 204, 113, .12);
  border-color: rgba(46, 204, 113, .35);
}
.tries-side.overridden { box-shadow: 0 0 0 1px var(--accent-2) inset; }
.tries-side .t-count { font-variant-numeric: tabular-nums; }
.tries-side .t-count b { margin-left: 2px; font-weight: 700; }
.tries-row .t-step {
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 16px; height: 16px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 0;
  font-family: inherit;
  display: inline-grid; place-items: center;
  transition: background .12s, color .12s, border-color .12s;
}
.tries-row .t-step:hover { background: rgba(255, 255, 255, .12); color: var(--text); border-color: #4a5a8c; }
.tries-row .tries-vs { color: var(--muted); opacity: .55; padding: 0 2px; }
.tries-row .t-reset {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 0 2px; font-size: 12px;
  margin-left: 4px;
}
.tries-row .t-reset:hover { color: var(--accent); }

/* Bonus-point badges (TB = try bonus, LB = losing bonus) shown next to each
   side's tries-stepper. Off state is muted; on state is colour-coded so
   awarded bonuses pop. The pt total appears alongside as a quick reference. */
.bonus-badges {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
}
.bonus-badges .bp {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 14px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .3px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: rgba(138, 152, 184, .55);
  background: transparent;
  transition: background .12s, color .12s, border-color .12s;
}
.bonus-badges .bp.tb.on {
  background: rgba(46, 204, 113, .22);
  color: #b9efcf;
  border-color: rgba(46, 204, 113, .55);
}
.bonus-badges .bp.lb.on {
  background: rgba(244, 196, 48, .18);
  color: #ffe28a;
  border-color: rgba(244, 196, 48, .55);
}
.bonus-badges .bp-pts {
  font-size: 9px;
  color: var(--muted);
  margin-left: 3px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .teams-panel { position: static; max-height: none; }
}
