/* Colours and type from the Clanware brand system draft (brand-system/project). */
:root {
  --field: #0b111b;
  --raised: #131b28;
  --raised-2: #1c2636;
  --line: #2a3648;
  --line-strong: #5f7088;
  --ink: #f4f7fb;
  --muted: #9aa8bc;
  --blue: #429bfb;
  --att: #ff7a59;
  --def: #429bfb;
  --live: #e5484d;
  --panel: rgba(11, 17, 27, 0.82);
  --panel-solid: rgba(11, 17, 27, 0.95);
  --controls-h: 128px;
  --dock-h: 0px;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--field);
  color: var(--ink);
  font-size: 14px;
}

button,
select,
input,
.button {
  font: inherit;
  color: var(--ink);
  border-radius: 6px;
}

button,
.button {
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: var(--raised-2);
  padding: 6px 12px;
  text-decoration: none;
  display: inline-block;
}

button:hover,
.button:hover {
  background: #263347;
}

button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #06101d;
  font-weight: 700;
}

button.primary:hover {
  background: #66aefc;
}

button.ghost {
  background: transparent;
  border-color: var(--line);
}

button.ghost:hover {
  background: var(--raised-2);
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Entry and message pages */
.landing,
.message {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 16px;
  gap: 8px;
}

.landing-mark {
  width: 72px;
  margin-bottom: 8px;
}

.landing h1,
.message h1 {
  font-size: 30px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.01em;
}

.landing p,
.message p {
  color: var(--muted);
  max-width: 460px;
  margin: 4px 0 16px;
  line-height: 1.5;
}

.code-form {
  width: min(440px, 100%);
  text-align: left;
}

.code-form label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

.code-row {
  display: flex;
  gap: 8px;
}

.code-row input {
  flex: 1;
  min-width: 0;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  padding: 10px 12px;
  font-size: 16px;
}

.form-error {
  color: #ff8b8b !important;
  min-height: 20px;
  margin: 8px 0 0 !important;
}

.sign-in {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.consent a,
.footer-links a {
  color: var(--blue);
}

.footer-links,
.account {
  font-size: 13px;
  margin: 4px 0 0 !important;
}

.dev-links {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
}

.dev-links a {
  color: var(--blue);
}

/* Watching */
.watch {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.stage {
  position: absolute;
  inset: 0;
}

.stage canvas {
  display: block;
}

.labels {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.label {
  position: absolute;
  left: 0;
  top: 0;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  will-change: transform;
}

.label-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  text-shadow: 0 1px 3px #000, 0 0 2px #000;
}

.label-health {
  width: 44px;
  height: 4px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 2px;
  overflow: hidden;
}

.label-health i {
  display: block;
  height: 100%;
  background: #6ee7a0;
}

.label.side-att .label-name {
  color: #ffb19b;
}

.label.side-def .label-name {
  color: #a3cdfd;
}

.label.far .label-name {
  display: none;
}

.label.selected .label-name {
  color: #fff;
  background: var(--blue);
  padding: 0 5px;
  border-radius: 3px;
  text-shadow: none;
}

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(to bottom, rgba(11, 17, 27, 0.92), rgba(11, 17, 27, 0));
}

.brand img {
  height: 30px;
  display: block;
}

.title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.title strong {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.code-chip {
  padding: 2px 8px;
  font-size: 12px;
  background: var(--panel);
  border-color: var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.pill {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--raised-2);
  color: var(--muted);
  white-space: nowrap;
}

.pill.live {
  background: var(--live);
  color: #fff;
}

.note {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.spacer {
  flex: 1;
}

.teams {
  position: absolute;
  left: 16px;
  top: 64px;
  width: 236px;
  max-height: calc(100% - 64px - var(--controls-h) - 8px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.team {
  flex: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.team h2 {
  display: flex;
  justify-content: space-between;
  margin: 0;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}

.team.side-att h2 {
  color: var(--att);
}

.team.side-def h2 {
  color: var(--def);
}

.team button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: none;
  border: none;
  border-radius: 0;
  padding: 3px 10px;
  text-align: left;
}

.team button:hover {
  background: var(--raised-2);
}

.team button.selected {
  background: rgba(66, 155, 251, 0.28);
}

.team button.down {
  color: var(--line-strong);
}

.team .who {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team .kd {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.feed {
  position: absolute;
  right: 16px;
  top: 64px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  pointer-events: none;
}

.feed div {
  background: var(--panel);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 13px;
}

.feed .att {
  color: #ffb19b;
  font-weight: 600;
}

.feed .def {
  color: #a3cdfd;
  font-weight: 600;
}

.feed .verb {
  color: var(--muted);
  margin: 0 6px;
}

/* Everything that sits above the controls on the right, so nothing overlaps. */
.dock {
  position: absolute;
  right: 16px;
  bottom: calc(var(--controls-h) + 8px);
  width: 268px;
  max-height: calc(100% - 64px - var(--controls-h) - 16px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.dock > * {
  pointer-events: auto;
  flex: none;
}

.in-room .dock {
  bottom: calc(var(--controls-h) + 52px);
}

.pov-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.pov-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.loading {
  position: absolute;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  background: var(--panel);
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--muted);
}

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 24px 16px 12px;
  background: linear-gradient(to top, rgba(11, 17, 27, 0.95) 55%, rgba(11, 17, 27, 0));
}

.timeline {
  display: block;
  width: 100%;
  height: 48px;
  cursor: pointer;
  touch-action: none;
}

.tip {
  position: absolute;
  top: 22px;
  transform: translate(-50%, -100%);
  background: var(--raised-2);
  border: 1px solid var(--line-strong);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.icon {
  width: 40px;
  padding: 6px 0;
  text-align: center;
}

.time {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  margin: 0 4px;
  white-space: nowrap;
}

.speed {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.speed select {
  background: var(--raised-2);
  border: 1px solid var(--line);
  padding: 5px;
}

.cameras {
  display: flex;
}

.cameras button {
  border-radius: 0;
  border-right-width: 0;
  background: var(--raised);
  border-color: var(--line-strong);
}

.cameras button:first-child {
  border-radius: 6px 0 0 6px;
}

.cameras button:last-child {
  border-radius: 0 6px 6px 0;
  border-right-width: 1px;
}

.cameras button.active {
  background: var(--blue);
  color: #06101d;
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--controls-h) + 8px);
  transform: translateX(-50%);
  background: var(--raised-2);
  border: 1px solid var(--line-strong);
  padding: 8px 14px;
  border-radius: 6px;
  z-index: 10;
}

button:disabled,
select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.small {
  padding: 2px 8px;
  font-size: 12px;
}

.room-panel {
  position: absolute;
  right: 16px;
  top: 64px;
  width: 268px;
  max-height: calc(100% - 64px - var(--controls-h) - var(--dock-h) - 60px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.in-room .feed {
  display: none;
}

.room-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.room-members,
.room-marks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.room-members li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.room-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.room-who {
  flex: 1;
  min-width: 90px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-tag {
  font-size: 11px;
  color: var(--muted);
}

.room-marks button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 2px 0;
  text-align: left;
  font-size: 12px;
}

.mark-tools {
  position: absolute;
  left: 50%;
  bottom: calc(var(--controls-h) + 8px);
  transform: translateX(-50%);
  display: flex;
}

.mark-tools button {
  border-radius: 0;
  border-right-width: 0;
  background: var(--raised);
  white-space: nowrap;
}

.mark-tools button:first-child {
  border-radius: 6px 0 0 6px;
}

.mark-tools button:last-child {
  border-radius: 0 6px 6px 0;
  border-right-width: 1px;
}

.mark-tools button.active {
  background: var(--blue);
  color: #06101d;
  font-weight: 700;
}

.stage.drawing canvas {
  cursor: crosshair;
}

#teams-toggle {
  display: none;
}

/* Analysis */
.tools {
  display: flex;
  gap: 6px;
}

.tools button {
  white-space: nowrap;
}

.tools button.active,
.segmented button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #06101d;
  font-weight: 700;
}

.phone-only {
  display: none;
}

.record-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--live);
  margin-right: 6px;
  flex: none;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.panel-head :focus-visible {
  outline-offset: 4px;
}

.panel-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.scan {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.scan-text {
  flex: 1 1 100%;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.scan-bar,
.record-progress {
  flex: 1 1 80px;
  min-width: 60px;
  height: 6px;
  appearance: none;
  border: none;
  border-radius: 3px;
  overflow: hidden;
  background: var(--line);
}

.scan-bar::-webkit-progress-bar,
.record-progress::-webkit-progress-bar {
  background: var(--line);
}

.scan-bar::-webkit-progress-value {
  background: var(--blue);
}

.scan-bar::-moz-progress-bar {
  background: var(--blue);
}

.record-progress::-webkit-progress-value {
  background: var(--live);
}

.record-progress::-moz-progress-bar {
  background: var(--live);
}

/* The stats table */
.stats-panel {
  position: absolute;
  top: 64px;
  right: 16px;
  bottom: calc(var(--controls-h) + 8px);
  width: min(800px, calc(100% - 284px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats-open .dock,
.stats-open .feed {
  display: none;
}

.in-room .stats-panel {
  right: 300px;
  width: min(760px, calc(100% - 584px));
  bottom: calc(var(--controls-h) + 52px);
}

.recording .stats-panel {
  top: 112px;
}

.stats-busy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: 12px;
}

.stats-busy ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.stats-busy button {
  font-variant-numeric: tabular-nums;
}

.stats-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.stats-table {
  width: 100%;
  min-width: 700px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.stats-table th,
.stats-table td {
  padding: 3px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-weight: 400;
}

.stats-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--raised);
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  padding: 0 2px;
}

.stats-table thead th:first-child {
  text-align: left;
  left: 0;
  z-index: 3;
}

.stats-table thead th:last-child {
  padding: 0 8px;
  text-align: left;
}

.stats-table tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  background: var(--raised);
  padding: 0;
}

.sort {
  width: 100%;
  background: none;
  border: none;
  border-radius: 0;
  color: inherit;
  padding: 6px;
  text-align: inherit;
  white-space: nowrap;
}

.sort-arrow {
  display: inline-block;
  width: 12px;
  font-size: 9px;
  color: var(--ink);
  text-align: center;
}

th[aria-sort] .sort {
  color: var(--ink);
  font-weight: 700;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stat-name {
  display: block;
  width: 100%;
  max-width: 180px;
  background: none;
  border: none;
  border-radius: 0;
  padding: 3px 8px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-row:hover td,
.player-row:hover th {
  background: var(--raised-2);
}

.player-row.selected td,
.player-row.selected th {
  background: #1a3350;
}

.player-row.selected .stat-name {
  font-weight: 700;
}

.team-total th,
.team-total td {
  background: var(--raised-2);
  font-weight: 700;
}

.stats-table .team-total th {
  background: var(--raised-2);
  padding: 5px 8px;
  font-weight: 700;
}

.stats-table .team-total td {
  font-weight: 700;
}

.team-dot,
.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--muted);
}

.team-dot.side-att {
  background: var(--att);
}

.team-dot.side-def {
  background: var(--def);
}

.spark {
  display: block;
  width: 80px;
  height: 16px;
  fill: var(--muted);
}

.spark.side-att {
  fill: var(--att);
}

.spark.side-def {
  fill: var(--def);
}

.spark-none {
  color: var(--line-strong);
  font-size: 12px;
}

/* The heatmap's controls */
.heat-panel {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.segmented {
  display: flex;
}

.segmented button {
  flex: 1;
  border-radius: 0;
  border-right-width: 0;
  background: var(--raised);
  padding: 4px 8px;
  font-size: 12px;
}

.segmented button:first-child {
  border-radius: 6px 0 0 6px;
}

.segmented button:last-child {
  border-radius: 0 6px 6px 0;
  border-right-width: 1px;
}

.heat-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.heat-filter select {
  flex: 1;
  min-width: 0;
  background: var(--raised-2);
  border: 1px solid var(--line);
  padding: 4px;
  font-size: 13px;
}

.heat-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.heat-legend.deaths {
  flex-wrap: wrap;
  gap: 2px 10px;
}

.heat-ramp {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background-color: var(--raised);
}

.legend-item {
  display: inline-flex;
  align-items: center;
}

.legend-dot.hollow {
  background: none;
  border: 2px solid var(--muted);
}

/* Recording */
.record-bar {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 6px 12px;
  background: var(--panel-solid);
  border: 1px solid var(--live);
  border-radius: 8px;
}

.record-bar .record-dot {
  margin: 0;
  animation: record-pulse 1.4s ease-in-out infinite;
}

.record-bar.paused {
  border-color: var(--line-strong);
}

.record-bar.paused .record-dot {
  animation: none;
  background: var(--line-strong);
}

@keyframes record-pulse {
  50% {
    opacity: 0.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  .record-bar .record-dot {
    animation: none;
  }
}

.record-time {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.record-progress {
  flex: 0 1 80px;
}

.recording .loading {
  top: 116px;
}

.recording .teams {
  top: 112px;
}

@media (max-width: 1180px) {
  .in-room .stats-open .room-panel {
    display: none;
  }

  .in-room .stats-panel {
    right: 16px;
    width: min(800px, calc(100% - 284px));
  }
}

@media (max-width: 980px) {
  .stats-open .teams,
  .stats-open .teams.open {
    display: none;
  }

  .stats-panel,
  .in-room .stats-panel {
    left: 16px;
    right: 16px;
    width: auto;
  }
}

@media (max-width: 820px) {
  .note,
  .feed {
    display: none;
  }

  #teams-toggle {
    display: inline-block;
  }

  .topbar {
    gap: 8px;
    padding: 10px 16px;
  }

  .speed {
    font-size: 0;
    gap: 0;
  }

  .speed select {
    font-size: 14px;
  }

  .code-chip {
    display: none;
  }

  #share {
    padding: 4px 8px;
    font-size: 12px;
  }

  .teams {
    display: none;
  }

  .teams.open {
    display: flex;
    width: calc(100% - 32px);
    max-height: calc(100% - 64px - var(--controls-h) - var(--dock-h) - 16px);
  }

  .dock {
    left: 16px;
    right: 16px;
    width: auto;
  }

  .room-panel {
    left: 16px;
    right: 16px;
    width: auto;
    max-height: min(30%, calc(100% - 64px - var(--controls-h) - var(--dock-h) - 60px));
  }

  .mark-tools {
    max-width: calc(100% - 32px);
  }

  .mark-tools button {
    padding: 6px 8px;
    font-size: 12px;
  }

  #review {
    padding: 4px 8px;
    font-size: 12px;
  }

  .title strong {
    max-width: 34vw;
  }

  .control-row .spacer {
    display: none;
  }

  .cameras button,
  .tools button {
    padding: 4px 8px;
    font-size: 12px;
  }

  .wide-only {
    display: none;
  }

  .phone-only {
    display: inline;
  }

  .stat-name {
    min-height: 36px;
    max-width: 112px;
  }
}
