:root {
  --void: #0a0a0a;
  --paper: #e9e9e7;
  --dim: #6e6e6e;
  --line: #242424;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ptb: #fdd601;
  --sidebar-w: 240px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--void);
  color: var(--paper);
  font-family: 'Google Sans', sans-serif;
  font-variant-numeric: tabular-nums;
}

button,
a {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 20px 0px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  pointer-events: none;
  user-select: none;
}

.srp-logo {
  display: none;
  width: min(100%, 190px);
  height: auto;
}

.srp-logo--full {
  display: block;
}

.sidebar-subtitle {
  margin: 0;
  color: var(--paper);
  font-size: 13px;
  font-weight: 1000;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.header-leaderboards {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0;
  pointer-events: auto;
  user-select: none;
  gap: 8px;
}

.header-leaderboard-link {
  color: var(--paper);
  border-bottom: 1px solid transparent;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  transition:
    border-color 0.15s var(--ease),
    opacity 0.15s var(--ease);
}

.header-leaderboard-link:hover,
.header-leaderboard-link:focus-visible {
  color: var(--dim);
  border-bottom: 1px solid var(--dim);
  outline: none;
}

.sidebar-content {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px 20px;
  text-align: left;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.route-item {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.01em;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s var(--ease);
}

.route-item:hover,
.route-item:focus-visible {
  color: var(--paper);
  outline: none;
}

.route-item.active {
  color: var(--paper);
  font-weight: 700;
}

.route-item .name-wrap {
  position: relative;
  min-width: 0;
  width: max-content;
  max-width: none;
  flex: 0 1 auto;
  overflow: visible;
}

.route-item .item-name {
  display: block;
  overflow: visible;
  white-space: nowrap;
}

.route-item .tick {
  position: absolute;
  right: 0;
  bottom: -4px;
  left: 0;
  height: 2px;
  opacity: 0;
  transition: opacity 0.15s var(--ease);
}

.route-item.active .tick {
  opacity: 1;
}

.route-item .ptb-tag {
  flex: 0 0 auto;
  margin-left: auto;
  border-bottom: 1px dashed var(--ptb);
  color: var(--ptb);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.map-canvas {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.map-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  user-select: none;
}

#map-content {
  visibility: hidden;
}

#map-content.ready {
  visibility: visible;
}

.map-viewport.dragging {
  cursor: grabbing;
}

svg#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-reset {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgb(10 10 10 / 82%);
  color: var(--paper);
  font-size: 12px;
  cursor: pointer;
  opacity: 0.7;
  transition:
    opacity 0.15s var(--ease),
    border-color 0.15s var(--ease);
}

.map-reset:hover,
.map-reset:focus-visible {
  opacity: 1;
  outline: none;
}

.route-group .hitareas path {
  fill: transparent;
  stroke: transparent;
  stroke-width: 12;
  pointer-events: all;
  cursor: pointer;
}

.route-group .visible-layer {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s var(--ease);
}

.route-group.active .visible-layer {
  opacity: 1;
}

#Track > path {
  transition: opacity 0.35s var(--ease);
}

svg#map.dimmed #Track > path {
  opacity: 0.2;
}

.timeattack-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: var(--sidebar-w);
  z-index: 10;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background: var(--void);
  padding: 20px 25px;
  transform: translateY(100%);
  opacity: 0;
  transition:
    transform 0.35s var(--ease),
    opacity 0.35s var(--ease);
}

.timeattack-footer.active {
  transform: translateY(0);
  opacity: 1;
}

.route-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}

.route-heading .route-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
}

.route-heading .ptb-tag {
  flex: 0 0 auto;
  border-bottom: 1px dashed var(--ptb);
  color: var(--ptb);
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  user-select: none;
}

.data-grid {
  display: grid;
  grid-template-columns:
    7ch
    repeat(var(--n-cols), minmax(84px, max-content))
    minmax(84px, max-content);
  width: max-content;
  min-width: 100%;
  justify-content: start;
  column-gap: 20px;
  row-gap: 10px;
  align-items: start;
}

.data-grid .cell {
  min-width: 0;
}

.data-grid .row-label {
  display: flex;
  align-items: center;
  height: 100%;
  font-size: 12px;
  white-space: nowrap;
}

.timeattack-footer a {
  color: var(--dim);
  text-decoration: none;
  border-bottom: 0;
  transition: color 0.15s var(--ease);
}

.timeattack-footer a:hover,
.timeattack-footer a:focus-visible {
  color: var(--paper);
  outline: none;
}

.data-grid .row-label a.external-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.data-grid .row-label a.external-link svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.data-grid .col-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--c, var(--paper));
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}

.split-tick {
  flex: 0 0 auto;
  width: 20px;
  height: 4px;
  background: var(--c, var(--dim));
}

.overall-tick {
  flex: 0 0 auto;
  width: 20px;
  height: 4px;
  background: conic-gradient(#fff 25%, #000 0 50%, #fff 0 75%, #000 0) 0 / 4px 4px;
}

.data-grid .time {
  color: var(--c, var(--paper));
  font-size: 20px;
  font-weight: 700;
}

.data-grid .time.total {
  color: var(--paper);
}

.data-grid .time .car {
  display: block;
  width: var(--car-width);
  min-width: var(--car-width);
  margin-top: 2px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.data-grid .no-data,
.no-times {
  color: var(--dim);
}

.data-grid .no-data {
  font-size: 14px;
}

.no-times {
  font-size: 13px;
}

.footer-note {
  margin: 10px 0 -10px;
  color: var(--dim);
  font-size: 11px;
  pointer-events: none;
  user-select: none;
}

@media (max-width: 780px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    grid-template-rows: auto auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-header {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    padding: 16px 0px 8px;
  }

  .header-leaderboards {
    flex-basis: 100%;
    margin-top: 5px;
  }

  .srp-logo--full {
    display: none;
  }

  .srp-logo--compact {
    display: block;
    width: 120px;
  }

  .sidebar-subtitle {
    padding-left: 4px;
    margin-bottom: -2px;
  }

  .sidebar-content {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
    touch-action: pan-x;
  }

  .sidebar-content::-webkit-scrollbar {
    display: none;
  }

  .sidebar-content.dragging {
    cursor: grabbing;
    user-select: none;
  }

  .route-item {
    width: max-content;
    min-width: max-content;
    flex: 0 0 auto;
    padding: 4px 16px 4px 8px;
  }

  .route-item .name-wrap {
    width: max-content;
    max-width: none;
  }

  .route-item .ptb-tag {
    margin-left: 10px;
  }

  .map-canvas {
    padding: 10px;
  }

  .timeattack-footer {
    left: 0;
  }

  .timeattack-footer.dragging {
    cursor: grabbing;
    user-select: none;
  }

  .data-grid {
    width: max-content;
    min-width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    grid-template-columns:
      7ch
      repeat(var(--n-cols), max-content)
      max-content;
    padding-bottom: 4px;
    scrollbar-width: none;
    cursor: grab;
    touch-action: pan-y;
  }

  .data-grid.dragging {
    cursor: grabbing;
    user-select: none;
  }

  .footer-note {
    text-align: center;
  }
}
