/*
  Design notes:
  Palette: "Pitch & Brass" - peat green, worn leather, trophy brass,
  chalk cream, oxblood, and mud brown. The look is built around a damp
  rugby pitch, club shield metalwork, stitched ball leather, and scoreboard
  contrast rather than a SaaS neon gradient.
  Typography: a slab/serif display stack for headings and crests, backed by
  sturdy system sans for dense controls and fixture data.
  Details: chunky 2px borders, jersey-hoop striping, chalk pitch markings,
  brass badges, compact scoreboard rows, and leather-toned controls.
*/

:root {
  color-scheme: dark;

  --bg: #11150c;
  --bg-deep: #07120b;
  --pitch: #12351f;
  --pitch-2: #1d4a2c;
  --mud: #2a2116;
  --panel: #211a12;
  --panel-2: #2b2418;
  --panel-3: #342b1d;
  --slot: #151d12;
  --border: #6a552d;
  --border-soft: rgba(210, 170, 72, .28);
  --line: #f1e6c8;
  --text: #f7eddb;
  --muted: #b9aa89;
  --muted-2: #8d7f64;
  --accent: #d2aa48;
  --accent-2: #8b2f21;
  --accent-3: #315f3b;
  --leather: #a8542c;
  --win: #6f9f55;
  --danger: #b34a35;
  --warning: #e2bd59;

  --line-rgb: 241, 230, 200;
  --accent-rgb: 210, 170, 72;
  --oxblood-rgb: 139, 47, 33;
  --win-rgb: 111, 159, 85;

  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Roboto Slab", Rockwell, "Rockwell Extra Bold", Georgia, ui-serif, serif;
  --font-score: "Arial Narrow", "Roboto Condensed", var(--font-body);

  --radius: 8px;
  --shadow: 0 18px 40px rgba(0, 0, 0, .42);
  --inset-line: inset 0 0 0 1px rgba(var(--line-rgb), .05);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  position: relative;
  background:
    radial-gradient(circle at 12% -10%, rgba(var(--oxblood-rgb), .23), transparent 34rem),
    radial-gradient(circle at 86% 4%, rgba(210, 170, 72, .14), transparent 28rem),
    linear-gradient(140deg, var(--bg-deep) 0%, #101c10 48%, #24180f 100%);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.45;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg,
      transparent 0,
      transparent calc(12.5vw - 1px),
      rgba(var(--line-rgb), .035) calc(12.5vw - 1px),
      rgba(var(--line-rgb), .035) calc(12.5vw + 1px)
    ),
    repeating-linear-gradient(0deg,
      rgba(255, 255, 255, .018) 0 1px,
      transparent 1px 7px
    ),
    linear-gradient(90deg,
      rgba(18, 53, 31, .58),
      rgba(16, 24, 14, .34) 42%,
      rgba(42, 33, 22, .48)
    );
  opacity: .8;
}

body > * {
  position: relative;
  z-index: 1;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 16px 28px 18px;
  border-bottom: 2px solid var(--border);
  background:
    linear-gradient(90deg, rgba(139, 47, 33, .18) 0 12px, transparent 12px 24px, rgba(210, 170, 72, .16) 24px 36px, transparent 36px),
    linear-gradient(180deg, rgba(37, 27, 16, .98), rgba(17, 21, 12, .96));
  box-shadow: 0 12px 30px rgba(0, 0, 0, .38);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--pitch-2), var(--accent));
  opacity: .9;
}

.brand {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(20px, 2.2vw, 29px);
  line-height: 1;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--line);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .38);
}

.brand .subtitle {
  margin: 5px 0 0;
  max-width: 760px;
  color: var(--muted);
  font-size: 12.5px;
}

.logo {
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  display: block;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: #11150c;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, .36),
    0 0 0 3px rgba(210, 170, 72, .1);
  object-fit: contain;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.controls button,
.auth-controls .auth-signin,
.perm-actions button {
  min-height: 38px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(0, 0, 0, .1)),
    var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-decoration: none;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .28);
  transition: transform .08s ease, background .16s ease, border-color .16s ease, color .16s ease;
}

.controls button {
  padding: 8px 14px;
}

.controls button:hover,
.auth-controls .auth-signin:hover,
.perm-actions button:hover {
  border-color: var(--accent);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .075), rgba(0, 0, 0, .08)),
    var(--panel-3);
}

.controls button:active,
.perm-actions button:active {
  transform: translateY(1px);
}

.controls .primary,
.perm-actions button.primary {
  border-color: #ead083;
  background:
    linear-gradient(180deg, #e0bf61, #b9892c);
  color: #17130b;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .22);
}

.controls .primary:hover,
.perm-actions button.primary:hover {
  background: linear-gradient(180deg, #edd17d, #c5983a);
  color: #100d08;
}

.auth-controls {
  display: flex;
  align-items: center;
  min-width: 0;
}

.auth-controls .auth-signin {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
}

.auth-controls .auth-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  max-width: 180px;
  padding: 4px 9px 4px 4px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25);
}

.auth-controls .auth-avatar {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(var(--line-rgb), .34);
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 36%, #e0bd65, #8b2f21 70%);
  color: #100d08;
  font-weight: 900;
  font-size: 12px;
}

.auth-controls .auth-avatar img,
.auth-controls img.auth-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.auth-controls .auth-name {
  max-width: 84px;
  overflow: hidden;
  color: var(--line);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-controls .auth-signout {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .16);
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}

.auth-controls .auth-signout:hover {
  background: rgba(var(--oxblood-rgb), .28);
  color: var(--line);
}

.layout {
  display: grid;
  grid-template-columns: minmax(330px, 376px) minmax(0, 1fr);
  gap: 24px;
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 24px 28px 42px;
}

.teams-panel,
.bracket-wrap,
.perm-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(0, 0, 0, .07)),
    var(--panel);
  box-shadow: var(--shadow), var(--inset-line);
}

.teams-panel {
  position: sticky;
  top: 96px;
  align-self: start;
  max-height: calc(100vh - 122px);
  overflow-y: auto;
  padding: 16px 16px 14px;
  scrollbar-color: var(--accent) rgba(0, 0, 0, .22);
}

.teams-panel::before {
  content: "";
  display: block;
  height: 6px;
  margin: -16px -16px 14px;
  background:
    linear-gradient(90deg, var(--accent-2) 0 18%, var(--line) 18% 22%, var(--pitch-2) 22% 58%, var(--accent) 58% 100%);
}

.teams-panel h2 {
  margin: 0 0 5px;
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--line);
}

.teams-panel .hint,
.teams-panel .updated {
  margin: 0 0 11px;
  color: var(--muted);
  font-size: 12px;
}

.teams-panel .updated {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(var(--line-rgb), .12);
  color: var(--muted-2);
}

.teams-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.team {
  display: grid;
  grid-template-columns: 28px 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  margin: 7px 0;
  padding: 8px 10px;
  border: 2px solid rgba(106, 85, 45, .8);
  border-left: 7px solid var(--team-color, var(--accent));
  border-radius: 7px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .04), transparent 44%),
    linear-gradient(180deg, #2b2418, #221b12);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .22);
  cursor: grab;
  user-select: none;
  transition: transform .08s ease, background .16s ease, border-color .16s ease, opacity .2s;
}

.team:hover {
  border-color: var(--accent);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--team-color, var(--accent)) 20%, transparent), transparent 52%),
    linear-gradient(180deg, #332a1c, #241d13);
  transform: translateY(-1px);
}

.team:active {
  cursor: grabbing;
}

.team.used {
  opacity: .55;
  cursor: not-allowed;
}

.team.used .form {
  cursor: pointer;
}

.team.dragging {
  opacity: .52;
}

.team.bubble {
  border-style: dashed;
  background:
    linear-gradient(90deg, rgba(226, 189, 89, .1), transparent 50%),
    var(--panel-2);
}

.team .rank,
.tb-head .rank {
  color: var(--accent);
  font-family: var(--font-score);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.team .crest,
.slot .crest,
.champion .crest {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #f7edd7;
  border: 1px solid rgba(var(--line-rgb), .52);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .22);
}

.team .crest {
  width: 34px;
  height: 34px;
  border-radius: 6px;
}

.team .crest img,
.slot .crest img,
.champion .crest img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.team .crest img,
.slot .crest img {
  padding: 2px;
}

.team .name {
  min-width: 0;
  overflow: hidden;
  color: var(--line);
  font-weight: 850;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team .pts {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.team .form {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(var(--line-rgb), .1);
  border-radius: 50%;
  background: rgba(0, 0, 0, .18);
  cursor: pointer;
  font-size: 15px;
  opacity: .34;
  filter: grayscale(.95);
  transition: opacity .15s, transform .12s, filter .15s, background .15s;
}

.team .form:hover {
  opacity: .68;
  transform: scale(1.06);
}

.team .form.on {
  opacity: 1;
  filter: drop-shadow(0 0 7px #e68a2e) saturate(1.35);
  background: rgba(166, 82, 38, .26);
}

.team .form.on.auto {
  filter: drop-shadow(0 0 7px #7fb56c) saturate(1.25);
}

.team .form.on.manual {
  filter: drop-shadow(0 0 7px #e68a2e) saturate(1.35);
}

.bracket-wrap {
  position: relative;
  overflow-x: auto;
  padding: 24px 28px 28px;
  background:
    linear-gradient(90deg, rgba(var(--line-rgb), .055) 0 2px, transparent 2px calc(50% - 1px), rgba(var(--line-rgb), .06) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .028) 0 1px, transparent 1px 18px),
    linear-gradient(115deg, #12351f, #10180f 58%, #2a2116);
}

.bracket-wrap::before,
.bracket-wrap::after {
  content: "";
  position: absolute;
  inset-block: 18px;
  width: 2px;
  background: rgba(var(--line-rgb), .16);
  pointer-events: none;
}

.bracket-wrap::before { left: 18%; }
.bracket-wrap::after { right: 18%; }

.bracket {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.08fr 1fr 1fr .92fr;
  gap: 34px;
  min-width: 960px;
}

.round {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.round h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 15px;
  color: var(--line);
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.round h3::after {
  content: "";
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

.round-qf { gap: 19px; }
.round-sf { justify-content: space-around; }
.round-final,
.round-champ { justify-content: center; }

.match {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 12px 10px 10px;
  border: 2px solid var(--border);
  border-radius: 7px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .04), transparent),
    linear-gradient(180deg, rgba(37, 31, 20, .95), rgba(20, 24, 16, .95));
  box-shadow:
    0 10px 22px rgba(0, 0, 0, .32),
    inset 0 -2px 0 rgba(0, 0, 0, .26);
}

.match::before {
  content: attr(data-label);
  position: absolute;
  top: -12px;
  left: 12px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #18140d;
  color: var(--accent);
  font-family: var(--font-score);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.slot {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 5px 8px;
  border: 2px dashed rgba(var(--line-rgb), .2);
  border-radius: 6px;
  background:
    repeating-linear-gradient(90deg, rgba(var(--line-rgb), .035) 0 1px, transparent 1px 9px),
    var(--slot);
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s, transform .08s;
}

.slot:hover {
  border-color: rgba(var(--line-rgb), .42);
}

.slot.empty .slot-name {
  color: var(--muted-2);
  font-style: italic;
}

.slot.filled {
  border-style: solid;
  border-color: rgba(106, 85, 45, .95);
  border-left: 7px solid var(--team-color, var(--accent));
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--team-color, var(--accent)) 18%, transparent), transparent 56%),
    linear-gradient(180deg, #2b2418, #1c1b12);
  color: var(--text);
}

.slot.filled .slot-name {
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot.winner {
  border-color: var(--win);
  background:
    linear-gradient(90deg, rgba(var(--win-rgb), .3), rgba(var(--accent-rgb), .09) 82%),
    #172114;
  box-shadow: inset 0 0 0 1px rgba(var(--win-rgb), .16), 0 0 0 2px rgba(var(--win-rgb), .1);
}

.slot.winner .slot-name {
  color: #fff8e9;
}

.slot.loser {
  opacity: .5;
}

.slot.drag-over {
  border-color: var(--accent);
  background:
    linear-gradient(90deg, rgba(var(--accent-rgb), .24), rgba(var(--line-rgb), .03)),
    #1d2916;
  transform: translateY(-1px);
}

.slot .crest {
  width: 28px;
  height: 28px;
  border-radius: 5px;
}

.slot .crest.empty {
  background: transparent;
  border: 1px dashed rgba(var(--line-rgb), .25);
  box-shadow: none;
}

.slot .clear {
  justify-self: end;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .18);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.slot .clear:hover {
  background: rgba(var(--oxblood-rgb), .3);
  color: #fff2de;
}

.vs {
  color: var(--accent);
  font-family: var(--font-score);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .22em;
  text-align: center;
  text-transform: uppercase;
}

.champion {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 126px;
  padding: 22px 16px;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0, rgba(var(--accent-rgb), .25), transparent 54%),
    linear-gradient(180deg, #302414, #151b10);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .36), inset 0 -3px 0 rgba(0, 0, 0, .24);
  color: var(--line);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 900;
  text-align: center;
}

.champion::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(var(--line-rgb), .12);
  border-radius: 5px;
  pointer-events: none;
}

.champion.empty {
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 700;
  font-style: italic;
}

.champion.set {
  border-color: var(--accent);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--team-color, var(--accent)) 18%, transparent), transparent 58%),
    radial-gradient(circle at 50% 0, rgba(var(--accent-rgb), .34), transparent 54%),
    linear-gradient(180deg, #332717, #151b10);
  box-shadow:
    0 0 0 2px rgba(var(--accent-rgb), .14),
    0 18px 44px rgba(0, 0, 0, .42);
}

.champion .crest {
  width: 66px;
  height: 66px;
  margin-bottom: 10px;
  border-radius: 10px;
}

.champion .crest img {
  padding: 4px;
}

.champion .label {
  margin-top: 3px;
  color: var(--accent);
  font-family: var(--font-score);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.teams-panel h2 .badge {
  display: inline-block;
  margin-left: 7px;
  padding: 3px 7px;
  border: 1px solid rgba(var(--line-rgb), .22);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), #a87927);
  color: #17130b;
  font-family: var(--font-score);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .12em;
  vertical-align: middle;
}

.delta {
  margin-left: 5px;
  font-family: var(--font-score);
  font-size: 10px;
  font-weight: 900;
  vertical-align: middle;
}

.delta.up { color: #9cca74; }
.delta.down { color: #de765e; }

.fixtures-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 2px solid rgba(var(--line-rgb), .13);
}

.fixtures-panel h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  color: var(--accent);
  font-family: var(--font-score);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.fixtures-panel h3 .clear-picks {
  padding: 0;
  border: 0;
  background: none;
  color: #d97a63;
  cursor: pointer;
  font: inherit;
  font-size: 10px;
}

.fixtures-panel h3 .clear-picks:hover {
  color: #ffb39f;
}

.team-blocks {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.team-block {
  padding: 7px 8px 5px;
  border: 1px solid rgba(106, 85, 45, .8);
  border-left: 5px solid var(--team-color, var(--accent));
  border-radius: 6px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--team-color, var(--accent)) 12%, transparent), transparent 55%),
    rgba(17, 21, 12, .55);
}

.tb-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11.5px;
}

.tb-head .rank {
  min-width: 18px;
}

.tb-head .name {
  min-width: 0;
  overflow: hidden;
  color: var(--line);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fixture-card {
  display: grid;
  grid-template-columns: 28px 52px 12px 34px 62px 16px 16px 24px;
  align-items: center;
  column-gap: 4px;
  row-gap: 2px;
  padding: 5px 2px;
  border-bottom: 1px solid rgba(var(--line-rgb), .08);
  cursor: help;
  font-variant-numeric: tabular-nums;
}

.fixture-card:hover {
  background: rgba(255, 255, 255, .025);
}

.team-block .fixture-card:last-child {
  border-bottom: none;
}

.fc-rail {
  grid-row: 1 / 3;
  grid-column: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted-2);
  font-family: var(--font-score);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
}

.fc-rail .reset-pick {
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid rgba(var(--line-rgb), .12);
  border-radius: 50%;
  background: rgba(0, 0, 0, .15);
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
}

.fc-rail .reset-pick:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pick-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 20px;
  padding: 2px 4px;
  border: 1px solid rgba(106, 85, 45, .9);
  border-left: 4px solid var(--c, var(--accent));
  border-radius: 4px;
  background: rgba(0, 0, 0, .18);
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-score);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
  text-align: center;
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
}

.pick-chip:hover {
  border-color: var(--accent);
  color: var(--line);
  background: rgba(255, 255, 255, .05);
}

.pick-chip.winning {
  border-color: rgba(var(--accent-rgb), .64);
  background:
    linear-gradient(90deg, rgba(var(--accent-rgb), .25), rgba(var(--accent-rgb), .06));
  color: var(--line);
}

.pick-chip.user-pick {
  border-color: #d06d55;
  background:
    linear-gradient(90deg, rgba(var(--oxblood-rgb), .58), rgba(var(--oxblood-rgb), .18));
  color: #fff4e2;
  box-shadow: inset 0 0 0 1px rgba(255, 211, 166, .14);
}

.pick-chip .chip-flame {
  font-size: 8px;
  line-height: 1;
}

.ha-tag {
  color: var(--muted-2);
  font-family: var(--font-score);
  font-size: 9px;
  font-weight: 900;
  text-align: center;
}

.ha-tag.home { color: #8fc577; }
.ha-tag.away { color: #e3c36a; }

.fixture-card .score-input {
  width: 34px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(106, 85, 45, .9);
  border-radius: 4px;
  outline: none;
  background: rgba(0, 0, 0, .18);
  color: var(--line);
  cursor: text;
  font-family: var(--font-score);
  font-size: 11px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
  transition: background .12s, border-color .12s;
}

.fixture-card .score-input::-webkit-inner-spin-button,
.fixture-card .score-input::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.fixture-card .score-input:hover {
  border-color: var(--accent);
}

.fixture-card .score-input:focus {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), .12);
}

.fixture-card .score-input.overridden {
  border-color: #d06d55;
  background: rgba(var(--oxblood-rgb), .18);
}

.tries-stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 20px;
  padding: 0 1px;
  border: 1px solid transparent;
  border-radius: 4px;
}

.tries-stepper.overridden {
  border-color: rgba(208, 109, 85, .72);
  background: rgba(var(--oxblood-rgb), .11);
}

.tries-stepper .t-step {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1px solid rgba(106, 85, 45, .9);
  border-radius: 3px;
  background: rgba(0, 0, 0, .22);
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-score);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  transition: background .12s, color .12s, border-color .12s;
}

.tries-stepper .t-step:hover {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), .16);
  color: var(--line);
}

.tries-stepper .t-count {
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

.tries-stepper .t-count b {
  margin-left: 1px;
  color: var(--line);
  font-family: var(--font-score);
  font-weight: 900;
}

.tries-stepper .t-count.bonus,
.tries-stepper .t-count.bonus b {
  color: #a9dc8d;
}

.fixture-card .bp {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 15px;
  border: 1px solid rgba(106, 85, 45, .65);
  border-radius: 3px;
  background: rgba(0, 0, 0, .12);
  color: rgba(185, 170, 137, .38);
  font-family: var(--font-score);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: .04em;
}

.fixture-card .bp.tb.on {
  border-color: rgba(var(--win-rgb), .75);
  background: rgba(var(--win-rgb), .22);
  color: #cff0bf;
}

.fixture-card .bp.lb.on {
  border-color: rgba(var(--accent-rgb), .8);
  background: rgba(var(--accent-rgb), .2);
  color: #ffe29d;
}

.fixture-card .pts {
  padding-right: 2px;
  color: var(--muted);
  font-family: var(--font-score);
  font-size: 11px;
  font-weight: 900;
  text-align: right;
}

.perm-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 50% 16%, rgba(var(--accent-rgb), .16), transparent 34rem),
    rgba(4, 7, 4, .78);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: perm-fade-in .16s ease-out;
}

.perm-modal.hidden {
  display: none;
}

@keyframes perm-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.perm-card {
  width: min(720px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 24px;
  animation: perm-rise .2s ease-out;
}

@keyframes perm-rise {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.perm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 15px;
  padding-bottom: 13px;
  border-bottom: 2px solid rgba(var(--line-rgb), .13);
}

.perm-head h2 {
  margin: 0;
  color: var(--line);
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1.15;
}

.perm-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(var(--line-rgb), .14);
  border-radius: 50%;
  background: rgba(0, 0, 0, .18);
  color: var(--muted);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.perm-close:hover {
  background: rgba(var(--oxblood-rgb), .22);
  color: var(--line);
}

.perm-stage.hidden {
  display: none;
}

.perm-hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.perm-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--accent);
  font-family: var(--font-score);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.perm-label select {
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--line);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
}

.perm-fixtures {
  max-height: 330px;
  margin-bottom: 12px;
  overflow: auto;
}

.perm-fixtures .team-block {
  margin: 0;
}

.perm-empty {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

.perm-stats,
.perm-summary {
  margin: 0 0 16px;
  padding: 10px 13px;
  border-left: 5px solid var(--accent);
  border-radius: 5px;
  background:
    linear-gradient(90deg, rgba(var(--accent-rgb), .12), rgba(0, 0, 0, .08));
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.perm-stats b,
.perm-summary b {
  color: var(--line);
}

.perm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.perm-actions button {
  padding: 8px 18px;
}

.perm-running-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  color: var(--line);
  font-size: 13px;
}

.perm-counter {
  font-family: var(--font-score);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.perm-mode {
  color: var(--accent);
  font-family: var(--font-score);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.perm-progress {
  height: 8px;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid rgba(var(--line-rgb), .12);
  border-radius: 999px;
  background: rgba(0, 0, 0, .32);
}

.perm-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--win));
  transition: width .12s ease-out;
}

.perm-flicker {
  max-height: 360px;
  margin: 0;
  padding: 7px;
  overflow: hidden;
  border: 1px solid rgba(106, 85, 45, .8);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(18, 53, 31, .38), rgba(0, 0, 0, .22));
  font-family: var(--font-score);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  list-style: none;
}

.perm-flick-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 34px;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 4px;
}

.perm-flick-row.qualified { color: #bce4a8; }
.perm-flick-row.bubble { color: #efd073; }

.perm-flick-row.mine {
  background: rgba(var(--oxblood-rgb), .35);
  box-shadow: inset 4px 0 0 var(--accent);
  color: #fff7e9;
  font-weight: 900;
}

.perm-flick-pos {
  color: var(--muted);
  text-align: right;
}

.perm-flick-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.perm-flick-pts {
  text-align: right;
}

.perm-current {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.perm-distribution {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.perm-dist-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 60px 64px;
  align-items: center;
  gap: 9px;
  padding: 3px 4px;
  border-radius: 4px;
  font-family: var(--font-score);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.perm-dist-row.clickable {
  cursor: pointer;
  transition: background .12s, box-shadow .12s;
}

.perm-dist-row.clickable:hover,
.perm-dist-row.clickable:focus {
  background: rgba(255, 255, 255, .04);
  outline: none;
}

.perm-dist-row.active {
  background: rgba(var(--oxblood-rgb), .18);
  box-shadow: inset 4px 0 0 var(--accent-2);
}

.perm-dist-pos {
  color: var(--line);
  font-weight: 900;
}

.perm-dist-row.forecast .perm-dist-pos {
  color: var(--accent);
}

.perm-dist-mark {
  color: var(--accent);
  font-size: 10px;
  vertical-align: middle;
}

.perm-dist-track {
  height: 15px;
  overflow: hidden;
  border: 1px solid rgba(var(--line-rgb), .1);
  border-radius: 999px;
  background: rgba(0, 0, 0, .25);
}

.perm-dist-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .3s ease-out;
}

.perm-dist-row.qualified .perm-dist-fill { background: linear-gradient(90deg, #4f7f3f, #9cca74); }
.perm-dist-row.qualified .perm-dist-pos { color: #bce4a8; }
.perm-dist-row.bubble .perm-dist-fill { background: linear-gradient(90deg, #a87927, #e2bd59); }
.perm-dist-row.bubble .perm-dist-pos { color: #efd073; }
.perm-dist-row.out .perm-dist-fill { background: linear-gradient(90deg, #813124, #d06d55); }
.perm-dist-row.out .perm-dist-pos { color: #e3917d; }

.perm-dist-pct,
.perm-dist-count {
  text-align: right;
}

.perm-dist-pct {
  color: var(--line);
  font-weight: 900;
}

.perm-dist-count {
  color: var(--muted);
  font-size: 11px;
}

.perm-example {
  margin-top: 15px;
  padding-top: 13px;
  border-top: 2px solid rgba(var(--line-rgb), .12);
}

.perm-example.hidden {
  display: none;
}

.perm-example-head h4 {
  margin: 0 0 4px;
  color: var(--line);
  font-family: var(--font-display);
  font-size: 14px;
}

.perm-example-hint {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.perm-example-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 300px;
  overflow: auto;
  padding: 7px;
  border: 1px solid rgba(106, 85, 45, .65);
  border-radius: 6px;
  background: rgba(0, 0, 0, .22);
}

.perm-example-fix {
  display: grid;
  grid-template-columns: 38px minmax(90px, 1fr) 96px 12px 96px minmax(90px, 1fr);
  align-items: center;
  column-gap: 5px;
  min-width: 620px;
  padding: 4px 6px;
  border-radius: 4px;
  font-family: var(--font-score);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.perm-example-fix:hover {
  background: rgba(255, 255, 255, .035);
}

.perm-example-fix.mine {
  background: rgba(var(--accent-rgb), .12);
  font-weight: 900;
}

.perm-example-fix.mine:hover {
  background: rgba(var(--accent-rgb), .18);
}

.perm-example-fix .ex-date {
  color: var(--muted);
  font-size: 10px;
}

.perm-example-fix .ex-team {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.perm-example-fix .ex-team.home { text-align: right; }
.perm-example-fix .ex-team.away { text-align: left; }
.perm-example-fix .ex-team.won {
  color: var(--line);
  font-weight: 900;
}

.perm-example-fix .ex-team:not(.won) {
  color: var(--muted);
}

.perm-example-fix .ex-side {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.perm-example-fix .ex-side.home { justify-content: flex-end; }
.perm-example-fix .ex-side.away { justify-content: flex-start; }

.perm-example-fix .ex-chips {
  display: inline-flex;
  gap: 2px;
  min-width: 32px;
}

.perm-example-fix .ex-side.home .ex-chips { justify-content: flex-end; }
.perm-example-fix .ex-side.away .ex-chips { justify-content: flex-start; }

.perm-example-fix .ex-pts {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
}

.perm-example-fix .ex-score {
  min-width: 19px;
  color: var(--line);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.perm-example-fix .ex-dash {
  color: var(--muted);
  text-align: center;
}

.perm-example-fix .ex-bp {
  display: inline-grid;
  place-items: center;
  height: 14px;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .04em;
}

.perm-example-fix .ex-bp-tb {
  border: 1px solid rgba(var(--win-rgb), .75);
  background: rgba(var(--win-rgb), .22);
  color: #cff0bf;
}

.perm-example-fix .ex-bp-lb {
  border: 1px solid rgba(var(--accent-rgb), .8);
  background: rgba(var(--accent-rgb), .2);
  color: #ffe29d;
}

.perm-standings-section {
  margin-top: 10px;
}

.perm-standings-section h5 {
  margin: 0 0 5px;
  color: var(--accent);
  font-family: var(--font-score);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.perm-standings-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 5px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, .24);
  font-family: var(--font-score);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  list-style: none;
}

.perm-standings-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 36px 50px;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 3px;
}

.perm-standings-row.qualified { color: #bce4a8; }
.perm-standings-row.bubble { color: #efd073; }
.perm-standings-row.out { color: var(--muted); }

.perm-standings-row.mine {
  background: rgba(var(--accent-rgb), .16);
  box-shadow: inset 3px 0 0 var(--accent);
  color: var(--line);
  font-weight: 900;
}

.perm-standings-row .rank {
  padding-right: 4px;
  color: var(--muted);
  font-weight: 900;
  text-align: right;
}

.perm-standings-row .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.perm-standings-row .pts,
.perm-standings-row .diff {
  text-align: right;
}

.perm-standings-row .pts {
  font-weight: 900;
}

.site-footer {
  margin-top: 8px;
  padding: 20px 16px 30px;
  border-top: 2px solid rgba(106, 85, 45, .78);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

.site-footer .dot {
  padding: 0 8px;
  opacity: .6;
}

@media (max-width: 1120px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls {
    justify-content: flex-start;
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .teams-panel {
    position: static;
    max-height: none;
  }

  .bracket {
    min-width: 900px;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 14px 16px 16px;
  }

  .brand {
    align-items: flex-start;
  }

  .logo {
    flex-basis: 48px;
    width: 48px;
    height: 48px;
  }

  .brand .subtitle {
    font-size: 11.5px;
  }

  .layout {
    padding: 16px 14px 32px;
  }

  .controls {
    width: 100%;
  }

  .controls button,
  .auth-controls .auth-signin {
    flex: 1 1 auto;
  }

  .bracket-wrap {
    padding: 20px 16px 22px;
  }

  .perm-card {
    padding: 18px 16px;
  }

  .perm-label {
    align-items: flex-start;
    flex-direction: column;
  }

  .perm-label select {
    width: 100%;
  }

  .perm-actions {
    flex-wrap: wrap;
  }

  .perm-actions button {
    flex: 1 1 160px;
  }

  .perm-dist-row {
    grid-template-columns: 40px minmax(0, 1fr) 50px;
  }

  .perm-dist-count {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
