/* Same palette as the display screen */
:root {
  --blue: #1666b0;
  --dark: #1c2532;
  --green: #63c466;
  --yellow: #fff176;
  --red: #ff0000;
  --grey: #b8b8b8;
  --gold: #f5c518;
  --amber: #f0a020;

  --bg: #eef1f5;
  --card: #ffffff;
  --soft: #f4f6f8;
  --text: #1c2532;
  --muted: #66707c;
  --line: #d5dae0;
  --corner2: #b8b8b8;
}

/* Dark theme: the brackets tab, made to be projected */
body.dark {
  --bg: #1c2532;
  --card: #263142;
  --soft: #303c4f;
  --text: #ffffff;
  --muted: #a9b4c2;
  --line: #3d4a5d;
  --corner2: #ffffff;
  font-size: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
}

button, select, input { font: inherit; }

button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

button:hover { border-color: var(--muted); }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.gold { background: var(--gold); border-color: var(--gold); color: #000; }
button.red { background: var(--red); border-color: var(--red); color: #fff; }

select, input {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
}

/* ---------- Top bar of the tablet remote and of the public pages ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 24px;
  min-height: 56px;
  padding: 0 20px;
  background: var(--dark);
  color: #fff;
}

.brand { font-size: 18px; font-weight: 700; white-space: nowrap; }

/* The controller has the sidebar instead */
body:not(.remote) > .remote-bar { display: none; }

/* ---------- Sidebar ---------- */

.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100vh;
  padding: 16px 0;
  overflow-y: auto;
  background: var(--dark);
  color: #fff;
}

.sidebar .brand { padding: 0 18px; }

.side-tournament { padding: 0 18px; color: #a9b4c2; font-size: 13px; line-height: 1.5; }
#tournamentName { color: #fff; font-size: 16px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
#saveStatus.problem { color: var(--yellow); }

.side-back {
  margin: 0 0 10px -6px;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: #a9b4c2;
  font-size: 13px;
}
.side-back:hover { color: #fff; }

.tabs { display: flex; flex-direction: column; }

.tab {
  width: 100%;
  padding: 11px 18px;
  border: 0;
  border-left: 4px solid transparent;
  border-radius: 0;
  background: none;
  color: #a9b4c2;
  font-size: 15px;
  text-align: left;
}

.tab:hover { color: #fff; }
.tab.active { border-left-color: var(--green); background: rgba(255, 255, 255, 0.07); color: #fff; }

.side-title {
  margin-bottom: 2px;
  color: #7f8b9b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.side-actions { display: flex; flex-direction: column; gap: 6px; padding: 0 18px; }

.side-actions button, .side-user button, .clock-controls button {
  background: transparent;
  border-color: #5a6779;
  color: #fff;
}

.side-actions button { padding: 7px 10px; font-size: 13px; text-align: left; }
.side-actions button:hover, .side-user button:hover, .clock-controls button:hover { background: rgba(255, 255, 255, 0.1); }

/* The account, at the bottom */
.side-account { margin-top: auto; padding-top: 10px; border-top: 1px solid #303c4f; }
.side-user { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 18px 0; color: #a9b4c2; font-size: 13px; }
.side-user span { overflow: hidden; text-overflow: ellipsis; }
.side-user button { padding: 5px 10px; font-size: 13px; white-space: nowrap; }

.menu-toggle { display: none; }

/* Home: the tournaments of the account, without what belongs to one tournament */
.home #tournamentLabel, .home #tournamentNav, .home #screenActions, .home #guide { display: none !important; }
body:not(.home) #tournamentsTab { display: none; }

main { width: 100%; max-width: 1500px; margin: 0 auto; padding: 20px; }

.page-title { margin: 0 0 16px; font-size: 24px; }

.tournament-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 20px; }

.tournament-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

.tournament-card.current { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.tournament-card h3 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.tournament-card .when { color: var(--muted); font-weight: 600; }
.tournament-card .numbers { color: var(--muted); font-size: 13px; }
.tournament-card .card-buttons { display: flex; gap: 8px; margin-top: 8px; }
.tournament-card .card-buttons .primary { flex: 1; }

/* Narrow screens: the sidebar becomes a bar at the top that opens as a menu */
@media (max-width: 900px) {
  .app { display: block; }

  .sidebar {
    z-index: 6;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 12px;
    height: auto;
    padding: 10px 14px;
    overflow: visible;
  }

  .sidebar .brand { flex: 1; padding: 0; font-size: 16px; }
  .menu-toggle {
    display: block;
    padding: 6px 12px;
    border-color: #5a6779;
    background: transparent;
    color: #fff;
  }

  .side-tournament, .sidebar .tabs, .side-actions { display: none; width: 100%; padding-left: 0; padding-right: 0; }
  .menu-open .side-tournament { display: block; margin-top: 10px; }
  .menu-open .sidebar .tabs, .menu-open .side-actions { display: flex; }
  .side-actions { margin-top: 10px; }
  .side-account { margin-top: 10px; }
  .side-user { padding: 10px 0 0; }
  .tab { padding: 11px 8px; }

  main { padding: 14px; }
}

.panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

.panel h3 { margin: 0 0 12px; font-size: 16px; }

/* ---------- Match tab: scoreboard like the display ---------- */

.match-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

/* Beside the sidebar there is room for the list only on wide screens */
@media (max-width: 1500px) {
  .match-layout { grid-template-columns: 1fr; }
  #queue { max-height: none; }
}

.scoreboard {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.fighter-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 20px;
}

.fighter-row.blue { background: var(--blue); color: #fff; }
.fighter-row.white { background: #fff; color: #000; }
.fighter-row.red { background: #c62828; color: #fff; }

.fighter { flex: 1; min-width: 220px; }
.fighter .name { font-size: 30px; line-height: 1.15; }
.fighter .school { min-height: 20px; margin-top: 4px; font-size: 16px; opacity: 0.85; }

.win-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 4px;
  background: var(--gold);
  color: #000;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.win-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.win-buttons select { font-weight: 600; }
.undo { margin: 8px 0 0 8px; padding: 3px 10px; font-size: 13px; }

.score-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }

.caption {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.8;
}

.box {
  width: 120px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 64px;
  font-weight: 700;
}

/* Points box turns green for whoever is ahead */
.box.points { background: var(--grey); color: #fff; }
.box.points.lead { background: var(--green); }
.box.adv { background: var(--yellow); color: #000; }
.box.pen { background: var(--red); color: #fff; }

/* Judo and wrestling: the score in the colour of its corner, the leader framed in green */
.box.tally { background: rgba(0, 0, 0, 0.25); }
.fighter-row.white .box.tally, .fighter-row.white .box.cards { background: #e3e7ec; }
.box.tally.lead { box-shadow: inset 0 0 0 5px var(--green); }

/* Judo: one yellow card per shido; the third one is red */
.box.cards { gap: 8px; background: rgba(0, 0, 0, 0.25); }
.card { width: 24px; height: 44px; border: 1px solid rgba(0, 0, 0, 0.5); border-radius: 3px; background: #ffd600; }
.card.red { background: #e53935; }

.score-buttons { display: grid; gap: 4px; width: 120px; }
.score-buttons button { padding: 6px 0; color: #1c2532; background: #fff; }
.score-col.wide .box, .score-col.wide .score-buttons { width: 168px; }

.clock-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px 6px;
  background: var(--dark);
  color: #fff;
}

#matchDivision { font-size: 22px; }
#matchRound { min-height: 28px; margin-top: 4px; color: var(--red); font-size: 22px; font-weight: 700; }

#timer { font-size: 84px; line-height: 1; font-variant-numeric: tabular-nums; }

@media (max-width: 700px) {
  .clock-bar { flex-wrap: wrap; padding: 12px 16px 6px; }
  #timer { font-size: 60px; }
  #matchDivision, #matchRound { font-size: 18px; }
  .clock-controls { padding: 10px 16px 14px; }
  .fighter-row { gap: 10px; padding: 14px 16px; }
  .fighter .name { font-size: 24px; }
  .box { width: 96px; height: 80px; font-size: 50px; }
  .score-buttons { width: 96px; }
  .score-col.wide .box, .score-col.wide .score-buttons { width: 150px; }
  .remote-access, .public-access { flex-direction: column; align-items: flex-start; }
  .field-label { min-width: 0; width: 100%; }
}

/* Golden score and osaekomi in judo, the period in wrestling */
#clockNotes { margin-left: auto; font-size: 22px; font-weight: 700; text-align: right; white-space: nowrap; }
#matchExtra { color: var(--gold); }
#holdClock { color: var(--green); }
#timer.time-up { color: var(--red); }

.clock-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 24px 18px;
  background: var(--dark);
}

.clock-controls .green { border-color: var(--green); color: var(--green); }
.clock-controls .amber { border-color: var(--amber); color: var(--amber); }
.clock-controls .gap { width: 10px; }
.clock-controls .push { margin-left: auto; }
.button-group { display: flex; flex-wrap: wrap; gap: 8px; }
.sport-controls { width: 100%; padding-top: 10px; border-top: 1px solid #3d4a5d; }

/* ---------- Mats: one button per mat above the scoreboard ---------- */

.mat-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.mat-tab { padding: 8px 14px; text-align: left; font-weight: 400; }
.mat-tab.active { border-color: var(--blue); box-shadow: inset 0 0 0 2px var(--blue); }
.mat-tab b { margin-right: 10px; }
.mat-tab span { font-variant-numeric: tabular-nums; }
.mat-tab small { display: block; margin-top: 2px; color: var(--muted); }

/* ---------- Next matches ---------- */

#queue { display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow-y: auto; }

.queue-item { padding: 10px 12px; border-radius: 8px; text-align: left; font-weight: 400; }
.queue-item:hover { border-color: var(--blue); }
.queue-item:first-child { border-left: 5px solid var(--green); }
.queue-item.busy { opacity: 0.5; }

.queue-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }

/* Estimated time of a match, in the list and in the brackets */
.eta { color: var(--text); font-weight: 600; white-space: nowrap; }
.queue-names { margin-top: 4px; font-size: 15px; font-weight: 600; }

/* Belt colour of the division's rank */
.belt {
  flex: none;
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 3px;
  vertical-align: -2px;
}

body.dark .belt, .division summary .belt { border-color: rgba(255, 255, 255, 0.6); }

/* ---------- Brackets ---------- */

.division {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  overflow: hidden;
}

.division summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--dark);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

body.dark .division summary { background: #111823; }

.division summary::before { content: "\25B8"; }
.division[open] summary::before { content: "\25BE"; }

.division-count { color: #a9b4c2; font-size: 14px; font-weight: 400; }
.division-champion { margin-left: auto; color: var(--gold); font-size: 14px; }

.division-body { padding: 14px 16px; }
.division-tools { display: flex; gap: 8px; margin-bottom: 12px; }

.bracket-row {
  position: relative; /* the connector lines are placed against it */
  display: flex;
  gap: 44px;
  overflow-x: auto;
  margin-bottom: 8px;
  padding: 4px 4px 12px;
}

.bracket-round { flex: none; display: flex; flex-direction: column; min-width: 240px; }

.bracket-round h4 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.round-matches {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 14px;
}

/* Drawn as overflow of a 1px svg so the lines never add scrollbars */
svg.connectors { position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
svg.connectors path { fill: none; stroke: var(--muted); stroke-width: 1.5; }

.match {
  position: relative;
  z-index: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  overflow: hidden;
}

.match.playable { cursor: pointer; }
.match.playable:hover { border-color: var(--blue); }
.match.current { outline: 3px solid var(--gold); }

.match-number { padding: 2px 8px; background: var(--soft); color: var(--muted); font-size: 11px; }

.slot { padding: 7px 10px; border-left: 5px solid var(--blue); }
.slot + .slot { border-top: 1px solid var(--line); border-left-color: var(--corner2); }
.slot.empty { color: var(--muted); }
.slot.won { background: rgba(99, 196, 102, 0.28); font-weight: 700; }
.slot small { color: var(--muted); font-weight: 400; }

.results-table { width: 100%; border-collapse: collapse; }

.results-table th {
  padding: 6px 14px 6px 0;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
}

.results-table td { padding: 8px 14px 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
.results-table td.number { font-weight: 700; }
.results-table small { color: var(--muted); }

.standings { margin: 4px 0 12px; border-collapse: collapse; }

.standings th {
  padding: 4px 18px 4px 0;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
}

.standings td { padding: 5px 18px 5px 0; border-top: 1px solid var(--line); }

.podium { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }

.place {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 5px;
  border-radius: 20px;
  background: var(--soft);
  font-weight: 600;
}

.place b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #000;
}

.place-1 b { background: var(--gold); }
.place-2 b { background: #c0c7cf; }
.place-3 b { background: #cd8f52; }

/* Competitors of a division, each with the changes it can get */
.manage { margin-bottom: 12px; }
.manage summary { color: var(--muted); font-weight: 600; cursor: pointer; }
.manage-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.manage-name { min-width: 240px; }
.manage-name small { color: var(--muted); }
.manage-row select, .manage-row button { padding: 4px 8px; font-size: 13px; }

.tab-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

/* Wide tables scroll inside their panel instead of widening the page */
#ranking, #winners, #accountList, #regList, #staffList { overflow-x: auto; }

/* ---------- First steps ---------- */

.guide { margin-bottom: 20px; }
.guide ol { margin: 0; padding-left: 20px; line-height: 1.9; }
.guide button { padding: 2px 10px; font-size: 13px; }

/* ---------- Setup tab ---------- */

.setup-grid { display: grid; gap: 16px; }

.field-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.field-row:last-child { margin-bottom: 0; }
.field-label { min-width: 120px; font-weight: 600; }
.hint { margin: 0 0 12px; color: var(--muted); }

#matchTimes { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
#matchTimes input { width: 64px; }

input[type=checkbox], input[type=range] { padding: 0; border: 0; }

.remote-access { display: flex; align-items: center; gap: 18px; margin-top: 20px; }
.remote-access h3 { margin-bottom: 6px; }
.remote-access .hint { margin: 6px 0 0; }
#remoteQr svg { display: block; width: 140px; height: 140px; }

.public-access { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.public-access > div:last-child { flex: 1; min-width: 260px; }
.public-access .hint { margin: 0; }
.public-address { margin: 8px 0 12px; font-size: 17px; word-break: break-all; }
#publicQr svg { display: block; width: 170px; height: 170px; }

/* ---------- Public brackets: the page competitors open on their phones ---------- */

.public-view .topbar { gap: 0 12px; padding: 0 14px; }
.public-view .brand { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#publicStatus { color: var(--yellow); font-size: 13px; }
#publicLang { padding: 5px 10px; border-color: #5a6779; background: transparent; color: #fff; font-size: 13px; }

main.public { max-width: 1100px; padding: 14px; }
main.public > .panel, #publicFound { margin-bottom: 14px; }
main.public .hint { margin: 10px 0 0; font-size: 14px; }
#publicSearch { width: 100%; padding: 12px 14px; font-size: 18px; }

#publicFound { display: grid; gap: 10px; }
.found-card button { margin-top: 10px; }
.found-name { font-size: 18px; font-weight: 700; }
.found-name small { color: var(--muted); font-weight: 400; }
.found-division { margin: 4px 0 10px; color: var(--muted); }

.found-match {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
  padding: 8px 12px;
  border-left: 5px solid var(--blue);
  border-radius: 6px;
  background: var(--soft);
}

.found-match b { font-size: 17px; }
.found-match.now { border-left-color: var(--green); background: rgba(99, 196, 102, 0.22); }
.found-match.place-1 { border-left-color: var(--gold); font-weight: 700; }
.found-match.place-2 { border-left-color: #c0c7cf; font-weight: 700; }
.found-match.place-3 { border-left-color: #cd8f52; font-weight: 700; }

.slot.found { box-shadow: inset 0 0 0 2px var(--gold); font-weight: 700; }

/* Brackets or bullpen */
.public-tabs { display: flex; background: var(--dark); padding: 0 6px; }
.public-tabs button {
  flex: 1;
  max-width: 220px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: none;
  color: #a9b4c2;
  font-size: 16px;
}
.public-tabs button.active { color: #fff; border-bottom-color: var(--green); }

/* Bullpen: one column per mat with the matches coming up */
main.public:has(#bullpen:not([hidden])) { max-width: none; }
.bullpen-mats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.bullpen-mats:empty { display: none; }
.bullpen-mats button { color: var(--muted); }
.bullpen-mats button.active { border-color: var(--blue); background: var(--blue); color: #fff; }

.bullpen-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; align-items: start; }
.bullpen-column h3 { font-size: 20px; }
.bullpen-match {
  margin-top: 8px;
  padding: 10px 12px;
  border-left: 5px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}
.bullpen-match.next { border-left-color: var(--gold); }
.bullpen-match.now { border-left-color: var(--green); background: rgba(99, 196, 102, 0.22); }
.bullpen-when { display: block; margin-bottom: 4px; font-size: 15px; }
.bullpen-match.now .bullpen-when { color: #2e8b34; text-transform: uppercase; letter-spacing: 0.5px; }
.bullpen-names { font-size: 17px; font-weight: 600; line-height: 1.35; }
.bullpen-names small { color: var(--muted); font-weight: 400; }
.bullpen-names .pending { color: var(--muted); font-weight: 400; }
.bullpen-division { margin-top: 6px; color: var(--muted); font-size: 13px; }

/* As a screen in the warm-up area: the bullpen alone, dark, to be read from far */
.bullpen-screen .public-tabs, .bullpen-screen #publicLang { display: none; }
.bullpen-screen .bullpen-column h3 { font-size: 26px; }
.bullpen-screen .bullpen-names { font-size: 22px; }
.bullpen-screen .bullpen-when { font-size: 19px; }
.bullpen-screen .bullpen-division { font-size: 15px; }
.bullpen-screen .bullpen-match.now .bullpen-when { color: var(--green); }

.public-view .division summary { flex-wrap: wrap; gap: 4px 10px; font-size: 16px; }
.public-view .division-champion { margin-left: 0; }
.public-view .division-body { padding: 12px; }
.public-view .bracket-round { min-width: 210px; }
.public-view .bracket-row { gap: 30px; }

/* ---------- Registration ---------- */

#regQr svg { display: block; width: 170px; height: 170px; }
#regStatus { font-size: 17px; color: var(--muted); }
#regStatus.open { color: #2e8b34; }
.reg-field { display: block; margin-bottom: 4px; }
.reg-field span { display: block; margin-bottom: 4px; font-weight: 600; }
.reg-field input, .reg-field textarea, .register-field input, .register-field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font: inherit;
}
.reg-field textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; white-space: pre; overflow-x: auto; }
#regInfo, #regTerms { font: inherit; white-space: pre-wrap; }
#regList { overflow-x: auto; }

/* One row per group of weight classes */
.weight-group { display: grid; grid-template-columns: 110px 1fr 1fr 2.4fr auto; gap: 6px; margin-bottom: 6px; }
.weight-group input { min-width: 0; padding: 7px 9px; font-size: 13px; }
.weight-group button { padding: 4px 10px; font-size: 13px; }
@media (max-width: 900px) {
  .weight-group { grid-template-columns: 1fr 1fr; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .weight-group .group-list { grid-column: 1 / 3; }
}

/* The form people fill in */
main.register { max-width: 560px; }
main.register h2 { margin: 0 0 8px; }
.register-event { margin: 0 0 4px; font-size: 26px; line-height: 1.15; }
.register-when { margin: 0 0 10px; color: var(--muted); font-weight: 600; }
.register-when::first-letter { text-transform: uppercase; }
.register-info { margin: 0 0 16px; padding: 10px 12px; border-radius: 6px; background: var(--soft); white-space: pre-wrap; }
.register-field { display: block; margin-bottom: 12px; }
.register-field span { display: block; margin-bottom: 4px; font-weight: 600; }
.register-field input, .register-field select { padding: 11px 12px; font-size: 17px; }
.register-terms { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; white-space: pre-wrap; }
.register-terms input { width: 22px; height: 22px; flex: none; }
.register-problem { min-height: 20px; margin: 0 0 8px; color: #c62828; font-weight: 600; }
main.register button.primary { width: 100%; padding: 13px; font-size: 18px; }
.register-done { font-size: 18px; font-weight: 600; }

/* The addresses of the screens, in Setup */
.screen-link { display: grid; grid-template-columns: 190px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.screen-link span { overflow-wrap: anywhere; color: var(--muted); }
.screen-link button { padding: 4px 10px; font-size: 13px; }
@media (max-width: 700px) {
  .screen-link { grid-template-columns: 1fr auto auto; }
  .screen-link b { grid-column: 1 / 4; }
}

/* Temporary codes of the table staff */
.staff-code { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.staff-code b { font: 700 22px ui-monospace, Menlo, Consolas, monospace; letter-spacing: 3px; }
.staff-code span { color: var(--muted); }
.staff-code button { padding: 4px 10px; font-size: 13px; }
#remoteMat { margin-left: auto; padding: 6px 8px; font-weight: 600; }
#remoteMat:not([hidden]) + #topClock { margin-left: 16px; }

/* The printed page with the QR code of the public brackets */
#poster { text-align: center; }
#poster h1 { margin: 0 0 4mm; font-size: 30pt; }
#poster h2 { margin: 4mm 0 2mm; font-size: 22pt; }
#poster p { margin: 0 0 2mm; font-size: 14pt; }
#posterQr svg { display: block; width: 105mm; height: 105mm; margin: 0 auto; }

/* ---------- Tablet remote: the Match tab alone, with bigger touch targets ---------- */

#topClock { margin-left: auto; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
#remoteStatus { margin-left: 16px; color: #a9b4c2; font-size: 14px; }

/* The clock and its buttons go first, in view without scrolling */
.remote .scoreboard { display: flex; flex-direction: column; }
.remote .clock-bar { order: -2; }
.remote .clock-controls { order: -1; }
.remote .clock-bar { padding: 10px 20px 2px; }
.remote #timer { font-size: 56px; }
.remote .clock-controls { gap: 6px; padding: 8px 20px 12px; }
.remote .clock-controls button { padding: 10px 11px; }
.remote .clock-controls .gap { width: 2px; }
.remote .fighter-row { padding: 10px 16px; }
.remote .fighter .name { font-size: 26px; }
.remote .box { height: 84px; font-size: 54px; }
#remoteStatus.online { color: var(--green); }

.remote .sidebar { display: none; }
.remote .app { display: block; }
.remote button { padding: 12px 16px; }
.remote .box, .remote .score-buttons { width: 130px; }
.remote .score-col.wide .box, .remote .score-col.wide .score-buttons { width: 190px; }
.remote #clockNotes { font-size: 18px; }
.remote .score-buttons button { padding: 10px 0; font-size: 18px; }

/* ---------- Dialogs and notices ---------- */

dialog {
  max-width: 440px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

dialog::backdrop { background: rgba(28, 37, 50, 0.6); }
dialog form { padding: 22px; }

#dialogMessage { margin-bottom: 18px; font-size: 16px; line-height: 1.4; }
#dialogFields { display: grid; gap: 8px; margin-bottom: 18px; }
#dialogFields:empty { display: none; }

/* OK comes first in the markup so Enter confirms; shown on the right */
.dialog-buttons { display: flex; flex-direction: row-reverse; justify-content: flex-start; gap: 8px; }

#toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateX(-50%);
}

.toast {
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--dark);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

/* ---------- Printing: the open tab alone, one division per page ---------- */

@media print {
  @page { size: landscape; margin: 10mm; }

  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .topbar, .sidebar, .guide, #toasts, .tab-actions, .division-tools, .manage, .no-print { display: none !important; }
  .app { display: block; }

  .panel { border: 0; padding: 0; }
  .division { margin: 0; border: 0; border-radius: 0; break-after: page; break-inside: avoid; }
  .division.no-bracket { display: none; }
  .division summary { padding: 0 0 10px; background: none; color: #000; font-size: 20px; }
  .division summary::before, .division[open] summary::before { content: none; }
  .division-count, .division-champion { color: #444; }
  .division-body { padding: 0; }
  .bracket-row { overflow: visible; }
  .match.current { outline: 0; }
  .belt, .slot, .match-number, .place, .place b { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .eta { display: none; } /* on paper an estimate would only get old */

  body.print-poster > *:not(#poster) { display: none !important; }
}
