:root {
  --green: #2e9b46;
  --green-dark: #1f7a34;
  --ink: #1c2733;
  --muted: #6b7785;
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #e3e8ec;
  --orange: #ef6c00;
  --blue: #1565c0;
  --grey-street: #b0b6bb;
  --shadow: 0 1px 3px rgba(20,40,60,.08), 0 1px 2px rgba(20,40,60,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

#app { display: flex; height: 100vh; overflow: hidden; }

#panel {
  width: 370px;
  flex: 0 0 370px;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 16px 28px;
  background: var(--bg);
  border-right: 1px solid #e3e8ec;
}
#map { flex: 1; height: 100vh; background: #dfe6ea; }

.brand h1 { margin: 0; font-size: 22px; letter-spacing: -.3px; }
.brand .sub { margin: 2px 0 16px; color: var(--muted); font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid #e7ecef;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 10px; font-size: 14px; font-weight: 650; color: var(--ink); }

/* progress ring */
.progress { display: flex; align-items: center; gap: 16px; }
.ring-wrap { position: relative; width: 120px; height: 120px; flex: 0 0 120px; }
.ring { transform: rotate(-90deg); width: 120px; height: 120px; }
.ring-bg { fill: none; stroke: #edf1f3; stroke-width: 12; }
.ring-fg { fill: none; stroke: var(--green); stroke-width: 12; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .8s ease; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; }
.ring-pct { font-size: 26px; font-weight: 750; line-height: 1; }
.ring-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.level { flex: 1; }
.level-name { font-weight: 650; font-size: 15px; margin-bottom: 8px; }
.level-bar { height: 8px; background: #edf1f3; border-radius: 6px; overflow: hidden; }
.level-bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), #74c98a);
  border-radius: 6px; transition: width .8s ease; }
.level-next { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* score */
.score-card { display: flex; align-items: baseline; gap: 8px; }
.score { font-size: 34px; font-weight: 800; color: var(--green-dark); letter-spacing: -1px; }
.score-label { color: var(--muted); font-size: 13px; }

/* stat grid */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--card); border: 1px solid #e7ecef; border-radius: 12px;
  padding: 12px 12px; box-shadow: var(--shadow);
}
.stat .v { font-size: 20px; font-weight: 750; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .l { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.stat.warn .v { color: var(--orange); }

/* badges */
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.badge {
  text-align: center; border-radius: 12px; padding: 10px 6px; border: 1px solid #e7ecef;
  background: #fafbfc;
}
.badge.earned { background: #eafaef; border-color: #bfe9cb; }
.badge .e { font-size: 22px; filter: grayscale(1); opacity: .45; }
.badge.earned .e { filter: none; opacity: 1; }
.badge .n { font-size: 10.5px; color: var(--muted); margin-top: 3px; line-height: 1.2; }
.badge.earned .n { color: var(--ink); font-weight: 600; }

/* routes */
.routes { list-style: none; margin: 0; padding: 0; }
.routes li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px; border-bottom: 1px solid #eef2f4; font-size: 13px;
  cursor: pointer; border-left: 3px solid transparent; transition: background .12s;
}
.routes li:last-child { border-bottom: none; }
.routes li:hover { background: #f2f7f3; }
.routes li.pinned { background: #eef6f0; border-left-color: var(--green); padding-left: 7px; }
.routes li.done .name b { color: var(--green-dark); }
.routes .done-check { color: var(--green); font-weight: 800; margin-right: 2px; }
.routes .name { overflow: hidden; text-overflow: ellipsis; }
.routes .rkm { color: var(--muted); }
.routes a.dl {
  text-decoration: none; color: var(--green-dark); font-weight: 600; font-size: 12px;
  border: 1px solid #bfe9cb; background: #eafaef; padding: 3px 9px; border-radius: 999px;
}
.routes a.dl:hover { background: #d8f3e0; }

.muted { color: var(--muted); }
.small { font-size: 11.5px; }
h2 .muted { font-weight: 500; }

/* legend on the map */
.legend {
  position: fixed; right: 12px; bottom: 12px; z-index: 1000;
  background: rgba(255,255,255,.95); border: 1px solid #e7ecef; border-radius: 10px;
  padding: 8px 11px; font-size: 12px; box-shadow: var(--shadow); line-height: 1.7;
}
.legend .row { display: flex; align-items: center; gap: 7px; }
.legend .sw { width: 16px; height: 4px; border-radius: 2px; display: inline-block; }

/* responsive */
@media (max-width: 760px) {
  #app { flex-direction: column; height: auto; }
  #panel { width: 100%; flex: none; height: auto; border-right: none; border-bottom: 1px solid #e3e8ec; }
  #map { height: 64vh; }
  .legend { bottom: 8px; right: 8px; }
}
