:root {
  color-scheme: dark;
  --bg: #111827;
  --panel: #182235;
  --panel-strong: #22304a;
  --text: #f8fafc;
  --muted: #a7b3c7;
  --accent: #22c55e;
  --accent-strong: #86efac;
  --warning: #f59e0b;
  --danger: #fb7185;
  --line: rgba(255, 255, 255, 0.12);
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(34, 197, 94, 0.14), transparent 34rem),
    linear-gradient(135deg, #0f172a 0%, var(--bg) 46%, #1f2937 100%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: 0;
}

button {
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: #f8fafc;
  color: #111827;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

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

.app-shell {
  width: min(980px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
  display: grid;
  gap: 14px;
}

.next-panel,
.status-panel,
.stops-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 34, 53, 0.94);
  box-shadow: var(--shadow);
}

.next-panel {
  min-height: 235px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.panel-topline,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
}

#direction-label {
  text-align: right;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  overflow-wrap: anywhere;
  font-size: clamp(2.1rem, 9vw, 5rem);
  line-height: 0.95;
}

.next-distance {
  color: var(--accent-strong);
  font-size: clamp(3rem, 16vw, 8rem);
  font-weight: 900;
  line-height: 0.9;
}

.progress-track {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
  transition: width 220ms ease;
}

.status-panel {
  padding: 16px;
}

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

.status-grid div {
  min-width: 0;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.status-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.05rem;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.notice {
  min-height: 1.5em;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 650;
}

.stops-panel {
  overflow: hidden;
}

.section-header {
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.04);
}

h2 {
  font-size: 1.1rem;
}

.stop-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stop-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 72px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.stop-item.next {
  background: rgba(34, 197, 94, 0.14);
}

.stop-item.passed {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
}

.stop-name {
  overflow-wrap: anywhere;
  font-size: clamp(1.15rem, 5vw, 1.75rem);
  font-weight: 850;
}

.stop-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.stop-distance {
  min-width: 6.5ch;
  text-align: right;
  color: var(--accent-strong);
  font-size: clamp(1.4rem, 7vw, 2.4rem);
  font-weight: 900;
}

.stop-item.passed .stop-distance {
  color: var(--danger);
}

@media (min-width: 760px) {
  .app-shell {
    padding-top: 24px;
    grid-template-columns: 1fr 360px;
    align-items: start;
  }

  .next-panel,
  .stops-panel {
    grid-column: 1;
  }

  .status-panel {
    position: sticky;
    top: 24px;
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }
}
