:root {
  --bg: #0b1a2b;
  --bg-accent: #102a43;
  --text: #f5f8fc;
  --muted: #9fb3c8;

  --wit-bg: #ffffff;
  --wit-text: #0b1a2b;
  --zwart-bg: #111417;
  --zwart-text: #ffffff;

  --ok: #4caf50;
  --bad: #e57373;

  --gap: clamp(0.3rem, 1vw, 0.8rem);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: clamp(0.4rem, 1.2vw, 1rem);
  gap: var(--gap);
}

/* --- top bar: clock left, compact status right --- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex: none;
}

#clock {
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15em;
  flex: 1;
  min-width: 0;
  text-align: right;
}
.status-line {
  display: flex;
  align-items: center;
  gap: 0.5em;
  min-width: 0;
}

#service-name {
  font-size: clamp(0.95rem, 2.4vw, 1.6rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-meta {
  font-size: clamp(0.7rem, 1.5vw, 1.05rem);
  color: var(--muted);
}

.dot {
  width: 0.8em;
  height: 0.8em;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}
.dot.ok {
  background: var(--ok);
}
.dot.bad {
  background: var(--bad);
}

/* --- board --- */
#board {
  flex: 1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: var(--gap);
  min-height: 0;
}
#board[hidden] {
  display: none;
}

.field-column {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
}

.team-panel {
  flex: 1;
  border-radius: clamp(0.3rem, 1vw, 0.8rem);
  padding: clamp(0.3rem, 1vw, 0.7rem);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.team-wit {
  background: var(--wit-bg);
  color: var(--wit-text);
}
.team-zwart {
  background: var(--zwart-bg);
  color: var(--zwart-text);
  border: 2px solid #2b3137;
}
.team-baan {
  background: var(--bg-accent);
  color: var(--text);
}

/* Team identity is conveyed by the panel colour; only the headcount remains,
   tucked in the corner so it never steals a name row. */
.team-count {
  position: absolute;
  top: 0.15em;
  right: 0.4em;
  font-size: clamp(0.8rem, 1.6vw, 1.2rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  opacity: 0.45;
  z-index: 1;
}

/* Player names in a grid. app.js (fitList) sets the font size and column count
   per panel so the names fill the panel as large as possible without clipping;
   the values below are just the pre-fit fallback. */
.player-list {
  list-style: none;
  flex: 1;
  min-height: 0;
  font-size: 1.5rem; /* fallback; overwritten inline by fitList() */
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.05em 0.8em;
  align-content: start;
  overflow: hidden;
}

.player-list li {
  font-size: inherit;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-list li.empty {
  opacity: 0.4;
  font-weight: 400;
}

/* --- formation panels ---
   app.js (fitFormation) sets one font size on the panel; everything inside
   scales with em so the shape survives any size. */
.team-panel.has-formation .formation {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 0.1em;
  overflow: hidden;
}

.formation-row {
  display: flex;
  justify-content: space-evenly;
  align-items: flex-start;
  gap: 0.35em;
}

.pos {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 0.06em 0.15em;
  border-radius: 0.3em;
  background: rgba(127, 148, 170, 0.14);
}

.pos-name {
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* A sub shown in each position it floats between: dashed outline + ⇄ marker
   (in the text) so it reads as one roaming player, not a duplicate. */
.pos-name.is-sub {
  font-weight: 600;
  font-style: italic;
  opacity: 0.85;
  border: 1px dashed currentColor;
  border-radius: 0.3em;
  padding: 0 0.25em;
}

/* Team members without a position: a small strip under the formation. */
.bench {
  list-style: none;
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.1em 0.7em;
  margin-top: 0.15em;
  padding-top: 0.1em;
  border-top: 1px solid rgba(127, 148, 170, 0.35);
  font-size: 0.7em;
  opacity: 0.85;
}

.bench li {
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
}

/* --- centered message (idle / connecting) --- */
#message {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
#message[hidden] {
  display: none;
}
#message-text {
  font-size: clamp(1.6rem, 3.6vw, 3.6rem);
  font-weight: 700;
  color: var(--muted);
}

/* --- tournament mode: a page of the tournament app over the whole screen --- */
#tournament {
  position: fixed;
  inset: 0;
  z-index: 10;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
}
#tournament[hidden] {
  display: none;
}

.state-loading #board,
.state-loading #status {
  visibility: hidden;
}
