:root {
  color-scheme: dark;
  --assignment-bg: #1e2530;
  --assignment-panel: #27313d;
  --assignment-panel-soft: #232c37;
  --assignment-blue: #1687ff;
  --bg: #080a0d;
  --panel: #151a1f;
  --panel-strong: #20272e;
  --line: #303942;
  --text: #f4f7f8;
  --muted: #9aa6ad;
  --accent: #35d07f;
  --accent-strong: #15a861;
  --warning: #ffd166;
}

.table-display-body {
  background: var(--assignment-bg);
  overflow: hidden;
}

.table-display-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  padding: clamp(10px, 1.4vh, 22px) 24px clamp(10px, 1.6vh, 24px);
}

.assignment-header {
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  display: flex;
  justify-content: space-between;
  padding-bottom: clamp(8px, 1.2vh, 16px);
}

.assignment-header h1 {
  color: #fff;
  font-size: clamp(32px, 6vh, 62px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  margin: 0;
}

.assignment-header div {
  color: rgba(255, 255, 255, .66);
  font-size: clamp(17px, 2.6vh, 28px);
  font-weight: 400;
  white-space: nowrap;
}

.carousel-shell {
  min-height: 0;
  overflow: hidden;
  padding-top: clamp(8px, 1.4vh, 18px);
  position: relative;
}

.assignment-grid {
  display: grid;
  gap: 10px 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 9), minmax(0, 1fr));
  height: 100%;
  opacity: 1;
  transform: translateX(0);
  transition: opacity 420ms ease, transform 420ms ease;
}

.assignment-grid.is-leaving {
  opacity: 0;
  transform: translateX(-18px);
}

.assignment-card {
  align-items: stretch;
  background: var(--assignment-panel);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(72px, 6vw) minmax(82px, 6.2vw) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.table-badge {
  align-items: center;
  background: var(--assignment-blue);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6px;
}

.table-badge span {
  font-size: clamp(9px, .72vw, 13px);
  font-weight: 800;
  letter-spacing: .08em;
}

.table-badge strong {
  font-size: clamp(26px, 5.5vh, 50px);
  font-weight: 900;
  line-height: .95;
}

.match-type {
  align-items: center;
  background: var(--assignment-panel-soft);
  color: rgba(255, 255, 255, .82);
  display: flex;
  flex-direction: column;
  font-size: clamp(15px, 2.5vh, 26px);
  font-weight: 800;
  gap: 3px;
  justify-content: center;
  line-height: 1.02;
  padding: 6px;
  text-align: center;
  word-break: break-word;
}

.match-tab {
  color: #fff;
  font-size: clamp(14px, 2.15vh, 21px);
  font-weight: 900;
}

.match-level {
  color: rgba(255, 255, 255, .74);
  font-size: clamp(12px, 1.75vh, 17px);
  font-weight: 800;
}

.assignment-players {
  align-content: center;
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 6px 12px;
}

.assignment-player-line {
  color: #fff;
  font-size: clamp(13px, 2.2vh, 24px);
  font-weight: 800;
  line-height: 1.02;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assignment-player-line.is-single {
  font-size: clamp(12px, 1.95vh, 22px);
}

.player-chip {
  color: #fff;
}

.player-chip.p1 {
  color: #ffffff;
}

.player-chip.p2 {
  color: #b9dcff;
}

.player-chip.p3 {
  color: #ffe6a3;
}

.assignment-vs {
  color: rgba(255, 255, 255, .5);
  font-weight: 800;
  margin: 0 .28em;
}

.carousel-page-indicator {
  bottom: 6px;
  color: rgba(255, 255, 255, .45);
  font-size: 14px;
  position: absolute;
  right: 4px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  overflow-x: hidden;
}

.screen {
  min-height: 100vh;
  padding: 22px;
}

.screen-header {
  align-items: end;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding-bottom: 16px;
}

.title {
  font-size: clamp(30px, 4vw, 58px);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  margin: 0;
}

.subtitle,
.updated {
  color: var(--muted);
  font-size: clamp(16px, 1.6vw, 24px);
}

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(var(--columns, 3), minmax(0, 1fr));
}

.table-card,
.poule-card,
.match-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.table-top,
.poule-top,
.match-top {
  align-items: center;
  background: var(--panel-strong);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 14px;
}

.table-label,
.poule-label,
.round-label,
.match-round {
  font-size: clamp(18px, 2vw, 30px);
  font-weight: 800;
}

.round-label,
.status {
  color: var(--accent);
}

.status {
  border: 1px solid rgba(53, 208, 127, .45);
  border-radius: 999px;
  font-size: clamp(13px, 1.2vw, 18px);
  padding: 4px 10px;
  white-space: nowrap;
}

.players {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.player,
.score-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.player-name,
.score-name {
  font-size: clamp(18px, 2.2vw, 34px);
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
}

.player-meta,
.score {
  color: var(--muted);
  font-size: clamp(14px, 1.5vw, 22px);
}

.score {
  color: var(--text);
  font-size: clamp(22px, 2.5vw, 38px);
  font-weight: 800;
  min-width: 1.5em;
  text-align: right;
}

.winner .score-name,
.winner .score {
  color: var(--warning);
}

.rounds {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.poules {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.round-column {
  display: grid;
  gap: 12px;
  align-content: start;
}

.round-heading {
  color: var(--accent);
  font-size: clamp(18px, 2vw, 30px);
  font-weight: 800;
}

.empty,
.error {
  color: var(--muted);
  font-size: clamp(22px, 3vw, 42px);
  padding: 8vh 0;
  text-align: center;
}

.error {
  color: #ff8a8a;
}

.ko-display-body {
  background: #1e2530;
  overflow: hidden;
}

.ko-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  padding: clamp(12px, 1.8vh, 22px);
}

.ko-header {
  align-items: center;
  margin-bottom: clamp(10px, 1.6vh, 18px);
  padding-bottom: clamp(9px, 1.4vh, 16px);
}

.ko-header .title {
  border-radius: 6px;
  display: inline-block;
  font-size: clamp(28px, 4.8vh, 52px);
  padding: 4px 12px;
}

.ko-header .subtitle,
.ko-header .updated {
  font-size: clamp(14px, 2.2vh, 24px);
}

.poule-board {
  display: grid;
  gap: clamp(7px, 1.2vh, 12px);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  min-height: 0;
  overflow: hidden;
}

.poule-tile {
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 8px;
  color: #14202b;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.poule-tile .poule-top {
  background: linear-gradient(90deg, #376fae, #244e7e);
  color: #fff;
  min-height: 0;
  padding: clamp(5px, .75vh, 9px) clamp(8px, .7vw, 12px);
}

.poule-tile:nth-child(4n+2) .poule-top {
  background: linear-gradient(90deg, #cf743a, #a8562b);
}

.poule-tile:nth-child(4n+3) .poule-top {
  background: linear-gradient(90deg, #43a66a, #247949);
}

.poule-tile:nth-child(4n+4) .poule-top {
  background: linear-gradient(90deg, #6675c8, #45549f);
}

.poule-tile .poule-label {
  font-size: clamp(14px, 1.8vh, 21px);
  line-height: 1;
}

.poule-tile .status {
  border-color: rgba(255, 255, 255, .32);
  color: rgba(255, 255, 255, .86);
  font-size: clamp(10px, 1.35vh, 16px);
  padding: 2px 7px;
}

.poule-tile .players {
  gap: 2px;
  min-height: 0;
  padding: clamp(5px, .8vh, 10px);
}

.poule-tile .player {
  gap: 6px;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 0;
}

.poule-tile .player-name {
  color: #13202b;
  font-size: clamp(13px, 1.85vh, 22px);
  font-weight: 900;
  line-height: 1.02;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poule-tile .player-meta {
  color: #536171;
  font-size: clamp(9px, 1.25vh, 14px);
  font-weight: 700;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-badge {
  align-items: center;
  background: #c7a646;
  border-radius: 999px;
  color: #17202a;
  display: inline-flex;
  font-size: clamp(10px, 1.35vh, 16px);
  font-weight: 900;
  height: clamp(18px, 2.4vh, 28px);
  justify-content: center;
  width: clamp(18px, 2.4vh, 28px);
}

.ko-board {
  display: grid;
  gap: clamp(8px, 1.1vh, 14px);
  grid-template-columns: repeat(var(--ko-units, 4), minmax(0, 1fr));
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 3px;
  scrollbar-width: none;
}

.ko-board::-webkit-scrollbar {
  display: none;
}

.ko-round {
  align-content: start;
  display: grid;
  gap: clamp(6px, .85vh, 10px);
  min-height: 0;
  grid-column: span var(--ko-span, 1);
  min-width: 0;
}

.ko-round .round-heading {
  background: #33404d;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 6px;
  color: #fff;
  font-size: clamp(13px, 1.8vh, 20px);
  line-height: 1;
  padding: 8px 10px;
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: center;
}

.ko-match {
  background: #34404c;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 6px;
  box-shadow: none;
  color: #fff;
  overflow: hidden;
}

.ko-match.ko-empty {
  background: rgba(52, 64, 76, .65);
}

.ko-match .players {
  gap: 0;
  padding: 0;
}

.ko-match .score-row {
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  grid-template-columns: minmax(0, 1fr) clamp(22px, 2vw, 36px);
  min-height: clamp(31px, 4.7vh, 50px);
  padding: 3px 6px;
}

.ko-match .score-row:first-child {
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}

.ko-match .score-row:last-child {
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
}

.ko-match .score-row:last-child {
  border-bottom: 0;
}

.ko-match .score-name {
  color: #fff;
  font-size: clamp(10px, 1.45vh, 17px);
  font-weight: 900;
  line-height: 1.02;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ko-match .player-meta {
  color: rgba(255, 255, 255, .68);
  display: block;
  font-size: clamp(8px, 1vh, 12px);
  font-weight: 800;
  line-height: 1.05;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ko-match .score {
  align-items: center;
  background: #1687ff;
  border-radius: 4px;
  color: #fff;
  display: flex;
  font-size: clamp(12px, 1.75vh, 20px);
  height: 100%;
  justify-content: center;
  min-width: 0;
  padding: 2px 0;
  text-align: center;
}

.ko-match.ko-empty .score {
  background: transparent;
  color: rgba(255, 255, 255, .6);
  font-weight: 900;
}

.ko-match.ko-empty .score-name {
  color: rgba(255, 255, 255, .72);
  font-style: italic;
}

.ko-match .winner .score-name,
.ko-match .winner .score {
  color: #ffe6a3;
}

.ko-match .exempt .score-name {
  color: rgba(255, 255, 255, .42);
  font-style: italic;
  font-weight: 800;
}

.ko-match .exempt .score {
  background: transparent;
}

@media (max-width: 900px) {
  .screen {
    padding: 14px;
  }

  .screen-header {
    align-items: start;
    flex-direction: column;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .poule-board,
  .ko-board {
    grid-auto-flow: row;
    grid-template-columns: 1fr;
    overflow: auto;
  }
}
