:root {
  --bg: #111316;
  --panel: rgba(22, 25, 30, 0.82);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e7e9ec;
  --muted: #9aa1ab;
  --accent: #d9b77a;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#title { position: absolute; left: 20px; top: 16px; pointer-events: none; }
#title h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: 0.02em; }
#title p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

#panel {
  position: absolute; right: 16px; top: 16px; width: 236px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 4px 14px 10px; backdrop-filter: blur(8px); font-size: 13px;
}
#panel section { padding: 8px 0; border-bottom: 1px solid var(--line); }
#panel section:last-child { border-bottom: 0; }
#panel h2 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 600; }
.readout { font-variant-numeric: tabular-nums; font-size: 15px; }
.small { font-size: 11.5px; color: var(--muted); }
.hint { margin: 6px 0 0; line-height: 1.35; }
.row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.row.buttons button { flex: 1; }
select, button {
  font: inherit; color: var(--text); background: rgba(255,255,255,0.06);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px;
}
select { flex: 1; }
button { cursor: pointer; margin-top: 6px; }
button:hover { background: rgba(255,255,255,0.12); }
button[aria-pressed="true"] { background: rgba(217,183,122,0.22); border-color: var(--accent); }
.seg { display: flex; gap: 4px; }
.seg button { flex: 1; font-size: 11.5px; padding: 5px 2px; margin-top: 0; }
.meter { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.08); overflow: hidden; }
#ro-reserve-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #c0563f, var(--accent)); }

#explode-bar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  width: min(980px, calc(100% - 32px)); display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px;
  font-size: 12px; color: var(--muted); backdrop-filter: blur(8px);
}
#explode-bar .bar-group { display: flex; align-items: center; gap: 10px; flex: 3 1 300px; }
#explode-bar .speed-group { flex: 2 1 220px; border-left: 1px solid var(--line); padding-left: 18px; }
#explode, #speed { flex: 1; min-width: 80px; accent-color: var(--accent); }
#reset-view { margin: 0; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; white-space: nowrap; }
#speed-val { min-width: 9.5em; color: var(--text, #e8eaee); font-variant-numeric: tabular-nums; }

#panel-toggle { display: none; }
@media (max-width: 720px), (max-height: 520px) {
  #panel { top: auto; bottom: 76px; right: 8px; left: 8px; width: auto; max-height: 46vh; overflow: auto; display: none; }
  #panel.open { display: block; }
  #panel-toggle { display: block; position: absolute; right: 12px; top: 12px; margin: 0; }
  #title { left: 16px; top: 10px; }
  #explode-bar { bottom: 10px; width: calc(100% - 32px); gap: 6px; border-radius: 14px; padding: 8px 14px; }
  #explode-bar .speed-group { border-left: none; padding-left: 0; }
}
body.render #panel, body.render #explode-bar, body.render #title, body.render #help, body.render #detail { display: none; }

#filters { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; pointer-events: auto; }
#filters button { margin: 0; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; }
#detail {
  position: absolute; right: 16px; bottom: 84px; width: 264px;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 14px;
  backdrop-filter: blur(8px); pointer-events: none;
}
#detail h3 { margin: 0 0 4px; font-size: 14px; color: var(--accent); }
#detail p { margin: 0 0 6px; font-size: 13px; line-height: 1.4; }
#detail small { color: var(--muted); font-size: 11px; }
#help { position: absolute; left: 50%; bottom: 62px; transform: translateX(-50%); margin: 0; pointer-events: none; white-space: nowrap; }
@media (max-width: 720px), (max-height: 520px) {
  #detail { left: 8px; right: 8px; width: auto; top: 96px; bottom: auto; }
  #help { display: none; }
  #filters button { font-size: 10.5px; padding: 3px 7px; }
}

/* short screens (a phone on its side): the panel and the card keep inside the screen */
@media (max-height: 520px) {
  #panel { max-height: calc(100vh - 150px); bottom: 70px; }
}
/* a phone held sideways: the panel is a column at the right, leaving the watch beside it */
@media (max-height: 520px) and (min-width: 600px) {
  #panel { top: 52px; bottom: 70px; left: auto; right: 8px; width: 250px; max-height: none; }
  #explode-bar .speed-group { border-left: 1px solid var(--line); padding-left: 12px; }   /* keep "Exploded" and "Time" apart */
}
@media (max-height: 520px) {
  #detail { top: 48px; max-height: calc(100vh - 140px); overflow: auto; }
  #title h1, #title .sub { font-size: 12px; }
}
