:root {
  --ink: #181512;
  --muted: #6d655c;
  --paper: #f7f0e2;
  --panel: #fffaf0;
  --line: #d8c8aa;
  --red: #b3261e;
  --green: #0f6b4f;
  --blue: #174b8a;
  --gold: #c69214;
  --shadow: 0 22px 60px rgba(38, 28, 15, .14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(179, 38, 30, .08), transparent 30%),
    linear-gradient(315deg, rgba(15, 107, 79, .10), transparent 34%),
    repeating-linear-gradient(0deg, rgba(24,21,18,.03) 0 1px, transparent 1px 6px),
    var(--paper);
  font-family: Georgia, "Times New Roman", serif;
}

button, input, select {
  font: inherit;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(24, 21, 18, .88), rgba(15, 107, 79, .80)),
    var(--paper);
}

.login-screen.hidden {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 3.2rem;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.login-card input,
.login-card select {
  min-height: 44px;
  border: 1px solid var(--line);
  background: white;
  padding: 0 10px;
  color: var(--ink);
}

.login-card button,
.quiet-button {
  min-height: 42px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--panel);
  cursor: pointer;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
}

.shell.locked {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

.shell {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  min-height: 300px;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 28px;
  align-items: end;
  padding: 34px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 84% 18%, rgba(198, 146, 20, .26), transparent 24%),
    linear-gradient(125deg, rgba(255,250,240,.96), rgba(255,250,240,.78)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%23181512' stroke-opacity='.08'%3E%3Cpath d='M80 22c32 0 58 26 58 58s-26 58-58 58-58-26-58-58 26-58 58-58Z'/%3E%3Cpath d='M80 22c12 15 18 34 18 58s-6 43-18 58M80 22C68 37 62 56 62 80s6 43 18 58M22 80h116M34 45c13 8 28 12 46 12s33-4 46-12M34 115c13-8 28-12 46-12s33 4 46 12'/%3E%3C/g%3E%3C/svg%3E");
  box-shadow: var(--shadow);
}

.kicker {
  margin: 0 0 12px;
  color: var(--red);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .85rem;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.6rem, 6vw, 5.8rem);
  line-height: .92;
  letter-spacing: 0;
}

.intro {
  max-width: 650px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.18rem;
  line-height: 1.45;
}

.pot {
  display: grid;
  gap: 8px;
  padding: 20px;
  color: white;
  background: var(--green);
  border: 2px solid rgba(255,255,255,.5);
  outline: 1px solid var(--green);
}

.pot span, .pot small {
  opacity: .82;
}

.pot strong {
  font-size: 2.4rem;
}

.controls {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 22px 0;
}

.segmented {
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  background: rgba(255,250,240,.76);
}

.segmented button, .segmented a, .player-picker select, .match-card button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
}

.segmented a {
  display: grid;
  place-items: center;
  text-decoration: none;
}

.quiet-button {
  padding: 0 14px;
}

.segmented button.active, .segmented a.active {
  background: var(--ink);
  color: var(--panel);
}

.player-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.player-picker select {
  border-color: var(--line);
  background: var(--panel);
}

.view { display: none; }
.view.active { display: block; }

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin: 0 0 14px;
}

.section-title h2, .rules h2 {
  margin: 0;
  font-size: 1.6rem;
}

.section-title p {
  margin: 0;
  color: var(--muted);
}

.round-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 0 0 18px;
  padding: 7px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,250,240,.92), rgba(247,240,226,.82));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.72), 0 8px 22px rgba(38, 28, 15, .07);
}

.round-tabs a {
  position: relative;
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 0 16px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: .92rem;
  line-height: 1;
}

.round-tabs a.active {
  background: linear-gradient(180deg, #211c17, var(--ink));
  color: var(--panel);
  border-color: var(--ink);
  box-shadow: 0 8px 16px rgba(24, 21, 18, .18);
}

.round-tabs a:not(.active):hover {
  color: var(--ink);
  border-color: rgba(216, 200, 170, .9);
  background: rgba(255,255,255,.45);
}

.match-list {
  display: grid;
  gap: 12px;
}

.match-card, .leader-row, .rules article {
  border: 1px solid var(--line);
  background: rgba(255,250,240,.9);
  box-shadow: 0 8px 24px rgba(38, 28, 15, .08);
}

.match-card {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 16px;
}

.knockout-card {
  grid-template-columns: 150px minmax(260px, 1fr) minmax(340px, auto);
}

.pending-knockout-card .bet-controls {
  opacity: .72;
}

.meta {
  color: var(--muted);
  font-size: .92rem;
}

.teams {
  display: grid;
  gap: 4px;
}

.teams strong {
  font-size: 1.26rem;
}

.admin-teams {
  grid-template-columns: repeat(2, minmax(160px, 1fr));
}

.admin-teams label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: .9rem;
}

.admin-teams input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  background: white;
  padding: 0 10px;
  color: var(--ink);
}

.winner-select {
  display: flex;
  justify-content: flex-end;
}

.winner-select label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: .9rem;
}

.winner-select select {
  min-height: 42px;
  border: 1px solid var(--line);
  background: white;
  padding: 0 10px;
  color: var(--ink);
  max-width: 260px;
}

.bet-controls, .score-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.bet-controls button {
  width: 44px;
  padding: 0;
  border-color: var(--line);
  background: var(--panel);
  font-weight: 700;
}

.bet-controls button.active,
.sign-choice.active,
.sign-choice:has(input:checked) {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.sign-choice {
  width: 44px;
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  font-weight: 700;
  cursor: pointer;
}

.winner-choice {
  width: auto;
  min-width: 150px;
  max-width: 260px;
  min-height: 48px;
  padding: 6px 14px;
  text-align: center;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.sign-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.bet-controls button:disabled,
.score-inputs input:disabled,
.bonus-card input:disabled,
.player-picker select:disabled {
  cursor: not-allowed;
  opacity: .62;
}

.score-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.score-inputs input {
  width: 54px;
  min-height: 42px;
  border: 1px solid var(--line);
  background: white;
  text-align: center;
}

.leaderboard {
  display: grid;
  gap: 10px;
}

.leader-row {
  display: grid;
  grid-template-columns: 48px 1fr auto auto auto auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.leader-row.ai-row {
  border-color: rgba(23, 75, 138, .55);
  background:
    linear-gradient(90deg, rgba(23, 75, 138, .14), rgba(255,250,240,.94) 42%),
    rgba(255,250,240,.9);
}

.leader-row.ai-row .rank {
  background: var(--blue);
}

.rank {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--red);
  font-weight: 700;
}

.points {
  font-size: 1.5rem;
  font-weight: 700;
}

.split {
  color: var(--muted);
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.bonus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.bonus-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255,250,240,.9);
  box-shadow: 0 8px 24px rgba(38, 28, 15, .08);
}

.bonus-card span {
  font-weight: 700;
  font-size: 1.08rem;
}

.bonus-card input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  background: white;
  padding: 0 10px;
}

.bonus-card small {
  color: var(--muted);
  line-height: 1.35;
}

.primary-action {
  margin-top: 16px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--green);
  background: var(--green);
  color: white;
  cursor: pointer;
  font-weight: 700;
}

.notice {
  margin: 0 0 16px;
  color: var(--green);
  font-weight: 700;
}

.bracket-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(190px, 1fr));
  gap: 12px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 8px;
}

.bracket-column {
  min-width: 190px;
}

.bracket-column h3 {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.bracket-stack {
  display: grid;
  gap: 10px;
}

.bracket-match {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(255,250,240,.9);
  box-shadow: 0 8px 20px rgba(38, 28, 15, .07);
}

.bracket-match.pending {
  opacity: .66;
}

.bracket-time {
  color: var(--muted);
  font-size: .78rem;
}

.bracket-team {
  min-height: 30px;
  display: flex;
  align-items: center;
  padding: 5px 7px;
  border: 1px solid rgba(216, 200, 170, .78);
  background: white;
  font-weight: 700;
  line-height: 1.15;
}

.bracket-team.winner {
  border-color: var(--green);
  background: rgba(15, 107, 79, .12);
}

.bracket-match small {
  color: var(--muted);
  line-height: 1.25;
}

.inline-admin-action {
  margin-top: 12px;
}

.rules article {
  padding: 18px;
}

.rules h3 {
  margin: 0 0 10px;
}

.rules p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 820px) {
  .hero, .match-card, .leader-row, .rule-grid {
    grid-template-columns: 1fr;
  }

  .controls, .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    overflow-x: auto;
  }

  .match-card {
    gap: 12px;
  }

  .leader-row {
    gap: 8px;
  }

  .knockout-card {
    grid-template-columns: 1fr;
  }

  .bet-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .winner-choice {
    max-width: none;
    width: 100%;
  }

  .bracket-board {
    grid-template-columns: 1fr;
    overflow-x: visible;
  }

  .bracket-column {
    min-width: 0;
  }
}
