:root {
  /* Backgrounds */
  --page-bg: #030507;
  --panel-bg: #151c2a;
  --card-bg: #1a2232;
  --row-a-bg: #1f2939;
  --row-b-bg: #18202e;
  --th-bg: #243049;
  --bar-bg: #0c111b;
  --card-foot-bg: #121926;
  --icon-bg: #0b0f17;
  --section-bg: #2a3650;
  --error-bg: #2a1418;

  /* Borders and bevels */
  --black: #000;
  --bevel-hi: #3d4d6b;
  --bevel-lo: #06090f;
  --inset: #4a5872;
  --divider: #33405a;

  /* Gradients */
  --masthead-top: #2c4a7e;
  --masthead-mid: #13213a;
  --masthead-bottom: #0c1526;
  --title-top: #3b5d96;
  --title-bottom: #1b2e52;
  --win-badge: #23893f;
  --loss-badge: #b3303c;

  /* Text */
  --text: #e8edf5;
  --label: #9fb3d1;
  --muted: #7d8aa3;
  --link: #7fb2ff;
  --accent: #ff4655;
  --gold: #ffd24a;
  --good: #6fe08f;
  --bad: #ff7d86;
  --attack: #ff5f6b;
  --defend: #4fe0a0;
  --error-text: #ffb3b9;
  --rr-fill: #3fd46a;
  --active: #3fd46a;
  --idle: #5a6478;
}

html {
  min-height: 100%;
}

body {
  max-width: 800px;
  margin: 12px auto;
  font:
    11px Verdana,
    Tahoma,
    Geneva,
    sans-serif;
  color: var(--text);
  background: var(--panel-bg);
  box-shadow:
    0 0 0 1px var(--bevel-hi),
    0 0 24px var(--black);
}

a {
  color: var(--link);
}

/* Header */
.masthead {
  padding: 18px 16px 14px;
  background: linear-gradient(
    var(--masthead-top),
    var(--masthead-mid) 60%,
    var(--masthead-bottom)
  );
  border-bottom: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.masthead .team-logo {
  height: 40px;
  margin: -6px 0;
  filter: drop-shadow(2px 2px 0 var(--black));
}
.masthead h1 {
  margin: 0;
  font:
    bold 26px "Trebuchet MS",
    Verdana,
    sans-serif;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 var(--black);
}
.masthead h1 span {
  color: var(--accent);
}
.tagline {
  margin-top: 4px;
  color: var(--label);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* Page links */
.nav {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--black);
  font-weight: bold;
}
.nav a {
  padding: 2px 10px;
  color: var(--label);
  text-decoration: none;
  background: linear-gradient(var(--section-bg), var(--row-b-bg));
  border: 1px solid var(--divider);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 4%);
}
.nav a:hover {
  color: var(--text);
  background: linear-gradient(var(--bevel-hi), var(--row-a-bg));
  border-color: var(--bevel-hi);
}
.nav a.current {
  color: var(--text);
  background: linear-gradient(var(--title-top), var(--title-bottom));
  border-color: var(--bevel-hi);
}

.statusbar {
  padding: 4px 8px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--black);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
  color: var(--label);
}
.statusbar b {
  color: var(--text);
}
.stale {
  color: var(--gold);
  font-weight: bold;
}

main {
  padding: 12px;
}

.section-title {
  margin: 0 0 10px;
  padding: 3px 6px;
  font:
    bold 11px Verdana,
    sans-serif;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text);
  background: linear-gradient(90deg, var(--section-bg), transparent);
  border-left: 4px solid var(--accent);
}

/* Cards */
.roster {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--black);
  box-shadow: inset 1px 1px 0 var(--bevel-hi);
}

.card-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  background: linear-gradient(var(--title-top), var(--title-bottom));
  border-bottom: 1px solid var(--black);
  font-weight: bold;
  text-shadow: 1px 1px 0 var(--black);
}
.card-title .player {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.card-title .square {
  width: 7px;
  height: 7px;
  background: var(--idle);
}
.card-title .square.active {
  background: var(--active);
}
.card-title .crown {
  width: 14px;
  height: 14px;
}
.card-title .role {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--label);
  font-size: 10px;
  font-weight: normal;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.card-title .role img {
  width: 14px;
  height: 14px;
}
.card-title .tag {
  color: var(--label);
  font-weight: normal;
}
/* Player tag (roster cards, scoreboards): a small see-through box after the name. */
.tag-box {
  padding: 0 4px;
  color: var(--label);
  font-size: 10px;
  font-weight: normal;
  line-height: 14px;
  background: rgb(255 255 255 / 8%);
  border: 1px solid rgb(255 255 255 / 15%);
}
.card-title .team {
  color: var(--gold);
  font-size: 10px;
  letter-spacing: 1px;
}

.card-body {
  padding: 8px;
}

fieldset {
  margin: 0 0 8px;
  padding: 6px 8px 8px;
  border: 1px solid var(--black);
  box-shadow: inset 1px 1px 0 var(--bevel-hi);
}
legend {
  padding: 0 4px;
  /* Covers the fieldset's inset highlight, which (unlike its border) isn't notched for the legend. */
  background: var(--card-bg);
  color: var(--label);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.icon-frame {
  display: inline-block;
  background: var(--icon-bg);
  border: 2px inset var(--inset);
  line-height: 0;
}

/* Rank */
.rank-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.rank-row img {
  width: 56px;
  height: 56px;
  padding: 2px;
}
.rank-name {
  font:
    bold 16px "Trebuchet MS",
    Verdana,
    sans-serif;
  text-shadow: 1px 1px 0 var(--black);
}
.rr-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}
.rr-bar {
  width: 150px;
  height: 10px;
  margin-top: 2px;
  padding: 1px;
  background: var(--icon-bg);
  border: 1px inset var(--inset);
}
.rr-fill {
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    var(--rr-fill) 0 6px,
    transparent 6px 8px
  );
}

.peak {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--divider);
  color: var(--label);
}
.peak img {
  width: 20px;
  height: 20px;
}
.peak b {
  color: var(--text);
}

/* Stats */
.stats {
  width: 100%;
  margin-bottom: 8px;
  border-collapse: collapse;
}
.stats th,
.stats td {
  padding: 3px 6px;
  border: 1px solid var(--black);
}
.stats th {
  width: 45%;
  text-align: left;
  font-weight: normal;
  color: var(--label);
  background: var(--th-bg);
}
.stats td {
  text-align: right;
  font-weight: bold;
  background: var(--row-a-bg);
}
/* Header row across a stats table, styled like a card title bar. */
.stats .stats-title {
  width: auto;
  font-weight: bold;
  color: var(--text);
  text-shadow: 1px 1px 0 var(--black);
  background: linear-gradient(var(--title-top), var(--title-bottom));
}
.stats tr:nth-child(even) td {
  background: var(--row-b-bg);
}
.good {
  color: var(--good);
}
.bad {
  color: var(--bad);
}

/* Team card */
.team-card {
  grid-column: 1 / -1;
}
.roster + .section-title {
  margin-top: 12px;
}
.standing {
  --standing-icon: 26px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 6px;
}
/*
 * Each item: icon on the left, as tall as the label + value beside it. An item
 * whose icon is missing is just the two lines, so labels and values stay level
 * across the row.
 */
.standing > div {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.standing-text {
  display: flex;
  flex-direction: column;
}
.standing small {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.standing img {
  width: var(--standing-icon);
  height: var(--standing-icon);
  object-fit: contain;
}
.standing b {
  font:
    bold 16px "Trebuchet MS",
    Verdana,
    sans-serif;
  text-shadow: 1px 1px 0 var(--black);
}

/* Agents */
.agents {
  display: flex;
  gap: 6px;
}
.agent {
  flex: 1;
  text-align: center;
}
.agent img {
  width: 44px;
  height: 44px;
}
.agent b {
  display: block;
  margin-top: 3px;
}
.agent small {
  color: var(--muted);
  font-size: 10px;
}

.card-foot {
  padding: 3px 6px;
  border-top: 1px solid var(--black);
  background: var(--card-foot-bg);
  color: var(--muted);
  font-size: 10px;
}

.error {
  padding: 10px;
  border: 1px solid var(--black);
  background: var(--error-bg);
  color: var(--error-text);
}

/* Match history */
.match-list {
  display: grid;
  gap: 12px;
}
.card-title .result {
  padding: 0 4px;
  border: 1px solid var(--black);
  color: var(--text);
  font-size: 10px;
}
.result.win {
  background: var(--win-badge);
}
.result.loss {
  background: var(--loss-badge);
}
.result.draw {
  background: var(--muted);
}
.card-title .team-icon {
  width: 16px;
  height: 16px;
}
.card-title .date {
  color: var(--text);
  font-size: 10px;
  font-weight: normal;
}
/* VOD link: a small bevelled button, like the nav links. */
.card-title .vod {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
  padding: 0 6px;
  color: var(--label);
  font-weight: bold;
  line-height: 14px;
  letter-spacing: 1px;
  text-decoration: none;
  text-shadow: none;
  background: linear-gradient(var(--section-bg), var(--row-b-bg));
  border: 1px solid var(--divider);
  border-top-color: var(--bevel-hi);
  border-bottom-color: var(--bevel-lo);
}
/* Icon from icons/vod-*.svg, masked like .round-icon so it takes the text colour. */
.card-title .vod::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  background: currentColor;
  -webkit-mask: url(icons/vod-play.svg) center / contain no-repeat;
  mask: url(icons/vod-play.svg) center / contain no-repeat;
}
/* No VOD yet: the same button, flat and faded, with no hover or press. */
.card-title .vod.none {
  color: var(--muted);
  background: var(--row-b-bg);
  border-color: var(--divider);
  opacity: 0.6;
  cursor: default;
}
.card-title .vod.none::before {
  -webkit-mask-image: url(icons/vod-none.svg);
  mask-image: url(icons/vod-none.svg);
}
.card-title a.vod:hover {
  color: var(--text);
  background: linear-gradient(var(--bevel-hi), var(--row-a-bg));
  border-color: var(--bevel-hi);
}
.card-title a.vod:active {
  background: linear-gradient(var(--row-b-bg), var(--section-bg));
  border-top-color: var(--bevel-lo);
  border-bottom-color: var(--bevel-hi);
}
.match-summary {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}
.icon-frame.map {
  position: relative;
  width: 228px;
  height: 52px;
  overflow: hidden;
}
.icon-frame.map img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.map-name {
  position: absolute;
  left: 6px;
  bottom: 5px;
  font:
    bold 13px "Trebuchet MS",
    Verdana,
    sans-serif;
  line-height: 1;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 1px 1px 0 var(--black);
}
.match-score {
  font:
    bold 22px "Trebuchet MS",
    Verdana,
    sans-serif;
  text-shadow: 1px 1px 0 var(--black);
}
.points,
.duration {
  margin-top: 2px;
  color: var(--muted);
}
/* Round timeline: one column per round, our row on top, theirs below. */
/* Stretches to the card width: team tags on the left, the round grid fills the rest. */
/* Sits in a one-cell table under the scoreboards, with the same header bar. */
.timeline-table {
  margin-top: 8px;
}
.timeline-table td {
  text-align: left;
  font-weight: normal;
}
.timeline {
  display: flex;
  gap: 6px;
  align-items: start;
}
/* Team tags down the left, lined up with the two icon rows. */
.timeline-tags {
  display: grid;
  grid-template-rows: 20px 12px 20px;
  color: var(--label);
  font-size: 10px;
}
.timeline-tags > span {
  display: flex;
  align-items: center;
}
.timeline-tags > span:last-child {
  grid-row: 3;
}
/* 12 | spacer | 12 [| spacer | overtime]. Each spacer holds a swap-sides
   icon; every round column is the same 1fr. */
.timeline-rounds {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(12, 1fr) 18px repeat(12, 1fr);
  gap: 6px 2px;
  min-width: 0;
}
.timeline-rounds.has-ot {
  grid-template-columns:
    repeat(12, 1fr) 18px repeat(12, 1fr)
    18px repeat(var(--ot), 1fr);
}
.timeline-gap {
  display: grid;
  place-items: center;
  color: var(--muted);
}
.timeline-gap .round-icon {
  width: 18px;
  height: 12px;
}
.round {
  display: grid;
  grid-template-rows: 20px auto 20px;
  min-width: 0;
  text-align: center;
}
/* No boxes: the winner's row gets a coloured icon, the loser's a faded diamond. */
.round-cell {
  display: grid;
  place-items: center;
}
.round-cell.us.win {
  color: var(--good);
}
.round-cell.them.win {
  color: var(--bad);
}
/* Colour by the side the round was won on (overrides the us/them fallback). */
.round-cell.win.attack {
  color: var(--attack);
}
.round-cell.win.defense {
  color: var(--defend);
}
/* Each icon file is a mask over a currentColor box, so one file serves both teams. */
.round-icon {
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.round-icon.elimination {
  --icon: url(icons/round-elimination.svg);
}
.round-icon.detonate {
  --icon: url(icons/round-detonate.svg);
}
.round-icon.defuse {
  --icon: url(icons/round-defuse.svg);
}
.round-icon.time {
  --icon: url(icons/round-time.svg);
}
.round-icon.surrender {
  --icon: url(icons/round-surrender.svg);
}
.round-icon.unplayed {
  --icon: url(icons/round-unplayed.svg);
}
.round-icon.swap {
  --icon: url(icons/round-swap.svg);
}
/* Loser's row and unplayed rounds: a small faded diamond. */
.round-cell.empty .round-icon {
  width: 6px;
  height: 6px;
  color: var(--muted);
  opacity: 0.5;
}
.round.unplayed .round-num {
  opacity: 0.5;
}
.round-num {
  color: var(--muted);
  font-size: 9px;
  line-height: 12px;
}
.scoreboard {
  margin-bottom: 0;
  /* Keep the outer edges; the cells below drop their column dividers. */
  border-inline: 1px solid var(--black);
}
/* Us and them side by side; stacked on phones (see media query). */
.scoreboards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}
/* A match with only our side keeps the full width. */
.scoreboards > :only-child {
  grid-column: 1 / -1;
}
.team-head {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.team-head img {
  width: 16px;
  height: 16px;
}
/* Tags keep their own case inside the uppercase heading row. */
.team-head .tag-box {
  letter-spacing: 0;
  text-transform: none;
}
.scoreboard th,
.scoreboard td {
  border-inline: 0;
}
.scoreboard tr:first-child th {
  color: var(--text);
  background: linear-gradient(var(--title-top), var(--title-bottom));
  font-weight: bold;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.scoreboard tr:first-child th:not(:first-child) {
  text-align: right;
}
.scoreboard th {
  width: auto;
}
.scoreboard .player-cell {
  text-align: left;
  font-weight: normal;
}
.agent-cell {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.agent-cell img {
  width: 18px;
  height: 18px;
}

/* Footer */
footer {
  padding: 8px;
  background: var(--bar-bg);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
  color: var(--muted);
  text-align: center;
  font-size: 10px;
}

/* Tablets: full-bleed page, still two columns. */
@media (max-width: 820px) {
  body {
    margin: 0;
  }
}
/* Phones: one column. */
@media (max-width: 640px) {
  .roster,
  .scoreboards {
    grid-template-columns: 1fr;
  }
  .standing {
    grid-template-columns: repeat(2, 1fr);
  }
  /* Halves stack: 12 columns per row, overtime wraps onto a third row and
     lines up with the halves above it. */
  .timeline-rounds,
  .timeline-rounds.has-ot {
    grid-template-columns: repeat(12, 1fr);
  }
  .timeline-gap {
    display: none;
  }
}
