:root {
  --board: #0a2933;
  --tile: #123e4c;
  --tile-edge: #0d3138;
  --cream: #eef7f3;
  --cream-dim: #8fb3ba;
  --ball: #d7ef3f;
  --up: #7cc47f;
  --down: #ff7a59;
  --line: #1c4753;
  --captain: #d7ef3f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(circle at 15% 0%, #164a58 0%, transparent 55%),
    var(--board);
  color: var(--cream);
  font-family: 'Fredoka', sans-serif;
  min-height: 100vh;
  padding: 32px 20px 20px;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
}

/* header */
header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  flex-wrap: wrap;
}

.title-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.title-block h1 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: clamp(28px, 5vw, 40px);
  text-transform: uppercase;
}

.title-block h1 span {
  color: var(--ball);
}

.title-block p {
  margin: 4px 0 0;
  color: var(--cream-dim);
  font-size: 20px;
  letter-spacing: 0.04em;
}

.pagenav {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.pagenav a {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12.8px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--tile);
  color: var(--cream-dim);
  padding: 8px 14px;
  text-decoration: none;
  transition: border-color .15s, color .15s;
}

.pagenav a:hover {
  border-color: var(--ball);
  color: var(--ball);
}

.pagenav a.active {
  border-color: rgba(215, 239, 63, 0.4);
  color: var(--ball);
}

.toolbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

#lastUpdated {
  font-family: 'Space Mono', monospace;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--cream-dim);
}

button {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12.8px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--tile);
  color: var(--cream);
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

button:hover {
  border-color: var(--ball);
  color: var(--ball);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#refreshBtn {
  border-color: rgba(215, 239, 63, 0.4);
}

#refreshBtn:hover {
  border-color: var(--ball);
  color: var(--ball);
}

/* board */
.board {
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: #082129;
}

.board-head,
.row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 60px 48px 48px 76px 84px;
  align-items: center;
  padding-left: 14px;
  padding-right: 14px;
}

.board-head {
  padding-top: 10px;
  padding-bottom: 10px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--cream-dim);
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

.board-head>div {
  text-align: center;
  padding: 0 8px;
}

.board-head>div.col-label.team {
  text-align: left;
}

.board.teams .board-head,
.board.teams .row {
  grid-template-columns: minmax(0, 1fr) 140px;
}

.board-head button.sortcol {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--cream-dim);
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  text-align: inherit;
}

.board-head button.sortcol:hover {
  color: var(--ball);
}

.board-head button.sortcol.active {
  color: var(--ball);
}

.row {
  padding-top: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.row:last-child {
  border-bottom: none;
}

.row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.012);
}

.cell {
  font-family: 'Space Mono', monospace;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 8px;
  text-align: center;
  color: var(--cream);
}

.cell.rank {
  color: var(--ball);
}

.cell.team {
  text-align: left;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell.diff.pos {
  color: var(--up);
}

.cell.diff.neg {
  color: var(--down);
}

.col-label {
  padding: 0 5px 0 0;
}

.col-label.team {
  padding-left: 8px;
}

/* board states */
.board-msg {
  padding: 60px 20px;
  text-align: center;
  color: var(--cream-dim);
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.board-msg .big {
  display: block;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 20px;
  color: var(--cream);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.board-msg.error .big {
  color: var(--down);
}

/* teams list (card style, not the board/grid look) */
.teams-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.team-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 82px;
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--tile);
  overflow: hidden;
  isolation: isolate;
}

.team-card-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(120% 140% at 8% 50%, hsla(var(--hue, 190), 80%, 52%, 0.4), transparent 62%),
    linear-gradient(115deg, hsla(var(--hue, 190), 65%, 38%, 0.16), transparent 60%);
  pointer-events: none;
}

.team-logo {
  position: relative;
  z-index: 1;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 5px;
  background: var(--board);
  border: 1px solid rgba(238, 247, 243, 0.2);
  padding: 2px;
  object-fit: contain;
}

.team-name {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: clamp(18px, 3vw, 22px);
  letter-spacing: 0.035em;
  text-transform: uppercase;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.team-captain {
  display: none;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  font-family: 'Space Mono', monospace;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cream-dim);
  text-align: right;
}

/* roster names — stacked on the right of the card (desktop/tablet) */
.team-roster {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: flex-end;
  text-align: right;
  max-width: 40%;
}

.roster-name {
  font-family: 'Space Mono', monospace;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--cream-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.roster-name.captain {
  color: var(--captain);
  letter-spacing: 0.05em;
  text-decoration-color: color-mix(in srgb, var(--captain) 45%, transparent);
  text-underline-offset: 3px;
}

/* roster button — only shown on mobile, opens the popup instead */
.roster-btn {
  display: none;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(238, 247, 243, 0.06);
  color: var(--cream-dim);
}

.roster-btn:hover {
  border-color: var(--ball);
  color: var(--ball);
}

/* roster popup modal */
.roster-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.roster-modal.open {
  display: flex;
}

.roster-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 14, 18, 0.72);
}

.roster-modal-card {
  position: relative;
  z-index: 1;
  width: min(320px, calc(100vw - 48px));
  background: var(--tile);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px 20px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.roster-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--cream-dim);
  font-size: 20px;
  line-height: 1;
  padding: 0;
}

.roster-modal-close:hover {
  color: var(--ball);
  border-color: transparent;
}

.roster-modal-team {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 18px;
  color: var(--cream);
  margin-bottom: 14px;
  padding-right: 20px;
}

.roster-modal-names {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.roster-modal-name {
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--cream-dim);
}

.roster-modal-name.captain {
  color: var(--captain);
  letter-spacing: 0.05em;
  text-decoration-color: color-mix(in srgb, var(--captain) 45%, transparent);
  text-underline-offset: 3px;
}

@media (max-width: 640px) {
  .team-card {
    padding: 10px 12px;
    gap: 10px;
    min-height: 68px;
  }

  .team-logo {
    width: 36px;
    height: 36px;
    border-radius: 4px;
  }

  .team-captain {
    font-size: 11px;
  }

  .team-roster {
    display: none;
  }

  .roster-btn {
    display: flex;
  }
}

footer {
  max-width: 820px;
  margin: 0 auto 0;
  color: var(--cream-dim);
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width:640px) {
  body {
    padding: 20px 15px 20px;
  }

  .board-head,
  .row {
    grid-template-columns: 40px minmax(0, 1fr) 40px 61px 58px;
    padding-left: 0;
    padding-right: 0;
  }

  .board-head>div {
    padding: 0 2px;
  }

  .col-label.team {
    padding-left: 2px;
  }

  .cell {
    padding: 8px 2px;
  }

  .board-head .col-gp,
  .board-head .col-l,
  .row .col-gp,
  .row .col-l {
    display: none;
  }

  .board.teams .board-head,
  .board.teams .row {
    grid-template-columns: minmax(0, 1fr) 108px;
  }
}