:root {
  color-scheme: dark;
  --bg: #15171a;
  --panel: #20242a;
  --panel-2: #252a31;
  --line: #363d46;
  --text: #f3f4f1;
  --muted: #a7afb8;
  --teal: #22b8a0;
  --amber: #e2b84f;
  --red: #ef635f;
  --violet: #b78cff;
  --blue: #5aa9ff;
  --green: #8fcb6b;
  --shadow: rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

body.is-loading {
  overflow: hidden;
}

button,
select,
input {
  font: inherit;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--text);
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 160ms ease, visibility 160ms ease;
}

body.is-loading .loading-overlay {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.loading-lockup {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(243, 244, 241, 0.18);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: loading-spin 760ms linear infinite;
}

.loading-lockup p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-overlay {
    transition: none;
  }

  .loading-spinner {
    animation: none;
    border-color: rgba(243, 244, 241, 0.24);
    border-top-color: var(--teal);
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: #191c20;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.15;
}

h2 {
  font-size: 15px;
  line-height: 1.25;
}

.status {
  max-width: 42ch;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(420px, 1fr) 330px;
  gap: 14px;
  min-height: calc(100vh - 72px);
  padding: 14px;
}

.sidebar,
.rightbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 30px var(--shadow);
}

.panel h2 {
  margin-bottom: 12px;
}

label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
button {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #171a1f;
}

select {
  padding: 0 10px;
}

button {
  cursor: pointer;
  color: #061613;
  font-weight: 800;
  background: var(--teal);
  border-color: transparent;
}

button:hover {
  filter: brightness(1.08);
}

.playback-row {
  display: grid;
  grid-template-columns: 1fr 72px 64px;
  gap: 8px;
  align-items: center;
}

.playback-row output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  margin-top: 14px;
  accent-color: var(--teal);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  margin: 5px 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.map-workspace {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111315;
  box-shadow: 0 14px 30px var(--shadow);
  overflow: hidden;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 66px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.workspace-header h2 {
  font-size: 18px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-line,
.legend-dot {
  display: inline-block;
  flex: 0 0 auto;
}

.legend-line {
  width: 24px;
  height: 2px;
  border-radius: 999px;
}

.legend-line.human {
  background: var(--teal);
}

.legend-line.bot {
  border-top: 2px dashed var(--amber);
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.legend-dot.kill {
  background: var(--red);
}

.legend-dot.death {
  background: #ffffff;
}

.legend-dot.loot {
  background: var(--blue);
}

.legend-dot.storm {
  background: var(--violet);
}

.map-stage {
  position: relative;
  width: min(100%, calc(100vh - 168px));
  aspect-ratio: 1;
  margin: 14px auto;
  overflow: hidden;
  background: #0b0d0f;
}

.map-stage img,
.map-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-stage img {
  object-fit: contain;
}

.map-stage canvas {
  pointer-events: none;
}

.tooltip {
  position: absolute;
  z-index: 5;
  max-width: 260px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: rgba(20, 23, 26, 0.96);
  box-shadow: 0 10px 20px var(--shadow);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #171a1f;
}

.metric strong {
  display: block;
  font-size: 20px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.match-panel {
  flex: 1;
  min-height: 0;
}

.match-table-wrap {
  max-height: calc(100vh - 242px);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--panel);
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.active {
  background: rgba(34, 184, 160, 0.13);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 260px minmax(380px, 1fr);
  }

  .rightbar {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 300px 1fr;
  }

  .match-table-wrap {
    max-height: 320px;
  }
}

@media (max-width: 780px) {
  .topbar,
  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .status {
    text-align: left;
  }

  .app-shell,
  .rightbar {
    grid-template-columns: 1fr;
  }

  .map-stage {
    width: 100%;
    margin: 0;
  }
}
