:root {
  --bg: #0b1020;
  --panel: #111734;
  --card: #141c3d;
  --fg: #e6ecff;
  --muted: #a7b6ff;
  --accent: #7aa2ff;
  --accent2: #ffd56b;
  --good: #6bff95;
  --bad: #ff8e8e;
  --line: #91a6ff;
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 12px;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

.app {
  display: flex;
  height: 100%;
  min-height: 100dvh;
}

#map {
  flex: 1 1 64%;
  min-width: 50vw;
}

.panel {
  flex: 0 0 36%;
  max-width: 36%;
  min-width: 360px;
  background: var(--panel);
  padding: var(--space-3);
  overflow-y: auto;
}

.panel-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  background: linear-gradient(var(--panel), color-mix(in oklab, var(--panel) 85%, transparent));
  border-bottom: 1px solid #1e2753;
}

h1 {
  margin: 0;
  font-size: 18px;
}

.badge {
  background: #0c1230;
  border: 1px solid #253065;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid #1e2753;
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

form.card {
  display: grid;
  gap: 12px;
}

.intro {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.row {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: 1fr;
}

label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: 13px;
  color: var(--muted);
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

textarea,
input,
select,
button {
  font-size: 16px;
}

textarea,
input,
select {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #2a3359;
  background: #0f1530;
  color: var(--fg);
}

button {
  margin-top: 2px;
  padding: 12px 16px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #0a0a0a;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

button:active {
  transform: translateY(1px);
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 0;
  display: block;
}

.hint.error {
  color: var(--bad);
}

.hint.ok {
  color: var(--good);
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-bottom: 10px;
  border-bottom: 1px solid #1f2750;
  margin-bottom: 10px;
}

.results-tools {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

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

.sort-control select {
  width: auto;
  min-width: 0;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
}

.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.muted {
  color: var(--muted);
}

.summary {
  font-size: 13px;
  line-height: 1.45;
}

.checkout-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
}

.results-more {
  margin-top: 12px;
  width: 100%;
  background: #0f1530;
  color: var(--fg);
  border: 1px solid #2a3359;
}

.results-more:hover {
  border-color: var(--line);
}

.checkout-item {
  border: 1px solid #1f2750;
  border-radius: 10px;
  padding: 12px;
  background: #101943;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.checkout-item[data-highlight-labels]:hover,
.throw-list--group[data-highlight-labels]:hover {
  border-color: #5b6fbe;
  box-shadow: inset 0 0 0 1px rgba(145, 166, 255, 0.2);
}

.checkout-item--exact {
  border-color: rgba(107, 255, 149, 0.35);
  background: linear-gradient(180deg, rgba(26, 61, 48, 0.92), rgba(16, 25, 67, 0.96));
}

.checkout-item--setup {
  border-color: rgba(122, 162, 255, 0.28);
}

.checkout-item--group {
  border-color: rgba(255, 213, 107, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255, 213, 107, 0.18);
}

.simulation-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.sim-plot-wrap {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #1f2750;
}

.sim-plot-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--fg);
  font-weight: 700;
}

.sim-plot-caption {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-align: right;
}

.sim-plot {
  display: block;
  width: 100%;
  height: 300px;
  overflow: visible;
}

.checkout-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
}

.route-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.route-sep {
  color: var(--muted);
  font-size: 11px;
}

.group-leave {
  color: var(--fg);
  font-size: 14px;
}

.group-leave-value {
  color: var(--accent2);
  font-size: 18px;
  font-weight: 900;
}

.group-leave-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.throw-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.throw-list--group {
  padding: 10px;
  border-radius: 10px;
  background: rgba(12, 18, 48, 0.55);
  border: 1px solid #1f2750;
}

.throw-list--extra {
  margin-top: 8px;
}

.throw-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid #1f2750;
}

.throw-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.throw-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  background: #0c1230;
  border: 1px solid #253065;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.throw-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content 68px 170px;
  align-items: center;
  column-gap: 14px;
  min-width: 0;
  font-size: 13px;
}

.throw-source {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.throw-source > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.csv-badge {
  display: inline-block;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border: 1.5px solid #0b1020;
  box-shadow: 0 0 0 1px rgba(145, 166, 255, 0.18);
}

.csv-badge--0 {
  background: #7aa2ff;
  border-radius: 999px;
}

.csv-badge--1 {
  background: #ffd56b;
  border-radius: 2px;
}

.csv-badge--2 {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 12px solid #ff8e8e;
  border-top: 0;
  border-radius: 0;
  box-shadow: none;
}

.throw-detail-row {
  display: contents;
}

.throw-detail-row .score-chip {
  justify-self: start;
}

.throw-score {
  color: var(--accent2);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
  justify-self: start;
}

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

.throw-coords {
  display: inline-flex;
  align-items: center;
  justify-self: end;
}

.route-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
}

.route-total {
  color: var(--accent2);
  font-size: 12px;
  font-weight: 700;
}

.toggle-options {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
  padding: 8px 12px;
  width: auto;
  background: #0f1530;
  color: var(--muted);
  border: 1px solid #2a3359;
  border-radius: 9px;
  cursor: pointer;
  list-style: none;
}

.toggle-options:hover {
  color: var(--fg);
  border-color: var(--line);
}

.toggle-options::-webkit-details-marker {
  display: none;
}

.setup-extras {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.setup-details {
  margin-top: 10px;
}

.checkout-meta {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.pill {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #09101f;
  background: var(--accent2);
}

.pill--good {
  background: var(--good);
}

.pill--accent {
  background: var(--accent2);
}

.score-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}

.score-chip--single {
  color: #0f1020;
  background: #dbe3ff;
  border-color: rgba(145, 166, 255, 0.4);
}

.score-chip--double {
  color: #07150d;
  background: #6bff95;
  border-color: rgba(107, 255, 149, 0.35);
}

.score-chip--triple {
  color: #2a1400;
  background: #ffd56b;
  border-color: rgba(255, 213, 107, 0.35);
}

.score-chip--bull {
  color: #240a0a;
  background: #ff8e8e;
  border-color: rgba(255, 142, 142, 0.35);
}

.score-chip--miss {
  color: var(--muted);
  background: #0c1230;
  border-color: #253065;
}

.coord-copy {
  appearance: none;
  border: 1px solid #2a3359;
  background: #0f1530;
  color: var(--muted);
  border-radius: 8px;
  padding: 4px 8px;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.coord-copy:hover {
  border-color: var(--line);
  color: var(--fg);
}

.coord-copy--copied {
  border-color: var(--good);
  color: var(--good);
}

.coord-copy--static {
  cursor: default;
}

.tag {
  font-size: 11px;
  color: #0a0a0a;
  background: var(--accent2);
  padding: 2px 6px;
  border-radius: 6px;
}

.maplibregl-ctrl-top-right,
.maplibregl-ctrl-bottom-right {
  z-index: 2;
}

@media (max-width: 900px) {
  .app {
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
  }

  #map {
    order: 1;
    width: 100%;
    min-width: 0;
    min-height: 48dvh;
    height: 48dvh;
  }

  .panel {
    order: 2;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 14px clamp(12px, 3vw, 18px);
  }

  .two-up,
  .three-up {
    grid-template-columns: 1fr;
  }

  .throw-body {
    grid-template-columns: minmax(0, 1fr) max-content max-content max-content;
    column-gap: 8px;
  }

  .throw-coords {
    justify-self: end;
  }

  .throw-index {
    min-height: 22px;
    font-size: 10px;
    padding: 0 8px;
  }

  .throw-body {
    font-size: 12px;
  }

  .throw-source {
    font-size: 12px;
  }

  .throw-score {
    font-size: 11px;
  }

  .coord-copy {
    padding: 3px 7px;
    font-size: 11px;
  }
}
