:root {
  --bg: #0f1012;
  --panel: #16171a;
  --fg: #e7e6e2;
  --muted: #8d8b86;
  --line: #2a2b30;
  --falls: #ff5a4a;
  --shove: #5a9bff;
  --style: #d873ff;
  --platform: #f29a33;
  --goal: #ffcc33;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overflow: hidden; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; }

#app {
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-rows: 63fr 37fr;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
@media (orientation: landscape) and (min-aspect-ratio: 4/3) {
  #app { grid-template-rows: none; grid-template-columns: 60fr 40fr; }
}

#view { position: relative; min-height: 0; min-width: 0; overflow: hidden; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; }
#hud {
  position: absolute; left: 12px; top: 10px; right: 90px;
  font-size: 12px; color: var(--muted); pointer-events: none;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#hud b { color: var(--falls); font-weight: 600; }
#msg {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 24px;
  text-align: center; color: var(--muted);
}
#details-btn {
  position: absolute; right: 10px; top: 6px;
  background: rgba(22, 23, 26, .7); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; font-size: 12px; color: var(--muted); cursor: pointer;
}
#details-btn[aria-expanded="true"] { color: var(--fg); }
#details {
  position: absolute; right: 10px; top: 40px; width: min(280px, calc(100% - 20px));
  background: rgba(22, 23, 26, .92); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-size: 13px; backdrop-filter: blur(6px);
}
#details .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
#details button {
  background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  min-height: 34px; cursor: pointer;
}
.seg { display: inline-flex; }
.seg button { border-radius: 0 !important; margin-left: -1px; }
.seg button:first-child { border-radius: 8px 0 0 8px !important; margin-left: 0; }
.seg button:last-child { border-radius: 0 8px 8px 0 !important; }
.seg button.on { background: #2b2d33; color: #fff; }
#facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; color: var(--muted); font-size: 12px; }
#facts dt { color: var(--muted); }
#facts dd { margin: 0; color: var(--fg); overflow-wrap: anywhere; }

#progress {
  min-height: 0; min-width: 0; display: flex; flex-direction: column;
  background: var(--panel); border-top: 1px solid var(--line); padding: 8px 12px 6px;
}
@media (orientation: landscape) and (min-aspect-ratio: 4/3) {
  #progress { border-top: 0; border-left: 1px solid var(--line); }
}
#headline { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
#headline strong { color: var(--fg); font-weight: 600; }
#headline .ok { color: #6ee08a; }
#chart-wrap { position: relative; flex: 1; min-height: 80px; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }
#legend { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 12px; color: var(--muted); }
#legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 5px; }
#legend i.dash { border-top-style: dashed; }
