:root { --ink: #f3ead6; --dim: #c9bda2; --panel: rgba(28, 22, 16, 0.82); --line: rgba(243, 234, 214, 0.18); --gold: #e0b34a; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #15110d; color: var(--ink);
  font: 14px/1.4 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#gl.dragging { cursor: grabbing; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.panel { position: fixed; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  backdrop-filter: blur(6px); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35); }
button, select { font: inherit; color: var(--ink); background: rgba(243, 234, 214, 0.08); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 10px; cursor: pointer; }
button:hover, select:hover { background: rgba(243, 234, 214, 0.18); }
button:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
button.toggle.on { background: rgba(224, 179, 74, 0.28); border-color: var(--gold); }
select option { color: #111; }

#head { top: 12px; left: 12px; padding: 10px 14px 12px; max-width: min(420px, calc(100vw - 24px)); }
#brand { display: block; margin-bottom: 6px; font: 700 15px/1 Georgia, "Times New Roman", serif; letter-spacing: 0.04em;
  color: var(--gold); text-decoration: none; }
a#brand[href]:hover { text-decoration: underline; }
#back { display: block; margin-bottom: 6px; font-size: 12px; color: #e8c877; text-decoration: none; }
#back:hover { text-decoration: underline; }
#all { display: block; margin-bottom: 6px; font-size: 12px; color: #e8c877; text-decoration: none; }
#all:hover { text-decoration: underline; }
#back[hidden], #all[hidden], #picker[hidden] { display: none; }
body.ui-min #back, body.ui-min #all, body.headless #back, body.headless #all { display: none; }
#picker { font-size: 12px; padding: 2px 6px; margin-bottom: 6px; max-width: 100%; }
#head h1 { margin: 0; font: 700 22px/1.15 Georgia, "Times New Roman", serif; text-wrap: balance; }
#date { color: var(--dim); font: italic 14px Georgia, serif; margin-top: 2px; }
#clock { margin-top: 8px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
#clock-now { font: 700 26px/1 Georgia, serif; font-variant-numeric: tabular-nums; }
#approx { font-size: 11px; color: var(--dim); border: 1px solid var(--line); border-radius: 10px; padding: 1px 8px; }
#phase { color: var(--gold); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 4px; min-height: 17px; }

#sides { top: 12px; right: 12px; padding: 10px 12px; width: 270px; }
.side { margin-bottom: 8px; } .side:last-child { margin-bottom: 0; }
.side .row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.side .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side .name i { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 6px; border: 1px solid rgba(255, 255, 255, 0.5); }
.side .men { font-variant-numeric: tabular-nums; color: var(--dim); font-size: 12px; white-space: nowrap; }
.side .meter { height: 5px; background: rgba(255, 255, 255, 0.12); border-radius: 3px; margin-top: 3px; overflow: hidden; }
.side .meter b { display: block; height: 100%; border-radius: 3px; }

#unitcard { top: 170px; right: 12px; width: 270px; padding: 10px 12px; }
#unitcard h3 { margin: 0 0 2px; font: 700 16px Georgia, serif; }
#unitcard .sub { color: var(--dim); font-size: 12px; }
#unitcard dl { margin: 8px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; }
#unitcard dt { color: var(--dim); } #unitcard dd { margin: 0; font-variant-numeric: tabular-nums; }
#unitcard button { margin-top: 8px; font-size: 12px; padding: 3px 8px; }
#unitcard .src { margin-top: 6px; font-size: 11px; color: var(--dim); }

#caption { left: 50%; bottom: 76px; transform: translateX(-50%); width: min(640px, calc(100vw - 24px)); padding: 12px 16px;
  text-align: center; transition: opacity 0.3s; }
#caption h2 { margin: 0; font: 700 20px/1.2 Georgia, serif; text-wrap: balance; }
#caption p { margin: 4px 0 0; font-size: 15px; color: var(--ink); text-wrap: pretty; }
#caption small { display: block; margin-top: 4px; color: var(--dim); font-size: 11px; }
#caption small:empty { display: none; }

#minimap { position: fixed; left: 12px; bottom: 76px; border: 1px solid var(--line); border-radius: 6px; cursor: crosshair;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35); }

#bar { left: 12px; right: 12px; bottom: 12px; padding: 8px 10px; display: flex; align-items: center; gap: 6px; }
#bar button { min-width: 36px; }
#track { flex: 1; position: relative; height: 40px; min-width: 80px; }
#scrub { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; touch-action: none; }
#tip { position: absolute; bottom: 44px; transform: translateX(-50%); background: #000d; padding: 3px 8px; border-radius: 4px;
  font-size: 12px; white-space: nowrap; pointer-events: none; }

#help { left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 16px 20px; z-index: 5; }
#help h2 { margin: 0 0 8px; font: 700 18px Georgia, serif; }
#help td { padding: 2px 14px 2px 0; } #help td:first-child { color: var(--gold); white-space: nowrap; }
#error { left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 16px 20px; max-width: min(760px, 92vw); max-height: 80vh;
  overflow: auto; z-index: 6; white-space: pre-wrap; font: 13px/1.5 ui-monospace, Menlo, monospace; border-color: #c0392b; }
#loading { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--dim); font: italic 18px Georgia, serif; }

/* labels drawn over the 3D view */
.ulabel, .plabel, .mark { position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform; }
.ulabel { padding: 1px 7px 2px; border-radius: 4px; color: #fff; text-align: center;
  font-size: 12px; line-height: 1.25; border: 1px solid rgba(255, 255, 255, 0.55); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }
.ulabel b { display: block; font: 700 13px Georgia, serif; }
.ulabel span { opacity: 0.9; font-size: 11px; font-variant-numeric: tabular-nums; }
.ulabel.sel { outline: 2px solid #fff; outline-offset: 1px; }
.ulabel.fallen b { text-decoration: line-through; opacity: 0.8; }
.ulabel.light { color: #1b140c; border-color: rgba(0, 0, 0, 0.45); }
.plabel { font: italic 600 13px Georgia, serif; color: #2a2014;
  text-shadow: 0 0 3px #f6eeda, 0 0 3px #f6eeda, 0 0 5px #f6eeda, 0 0 2px #f6eeda; }
.plabel.big { font-size: 15px; font-style: normal; }
.plabel.feature { font-size: 12px; color: #3a4a5c; }
.mark { font: 700 12px Georgia, serif; color: #fff; background: rgba(20, 16, 12, 0.85); border-radius: 4px; padding: 1px 6px;
  border: 1px solid rgba(255, 255, 255, 0.4); }
body.nolabels #labels { display: none; }
body.ui-min #bar, body.ui-min #minimap, body.ui-min #picker, body.ui-none .panel, body.ui-none #minimap { display: none; }
body.ui-min #caption { bottom: 24px; }
body.headless #picker, body.headless #helpbtn, body.headless #loading { display: none; }

@media (max-width: 760px) {
  #sides, #minimap, #director, #stops, #labelsbtn { display: none; }
  #head { right: 12px; max-width: none; } #head h1 { font-size: 18px; } #clock-now { font-size: 20px; }
  #bar { flex-wrap: wrap; } #track { order: -1; flex-basis: 100%; }
  #caption { bottom: 122px; padding: 10px 12px; } #caption h2 { font-size: 17px; } #caption p { font-size: 14px; }
  #unitcard { top: auto; bottom: 122px; left: 12px; right: 12px; width: auto; z-index: 2; }
}
@media (prefers-reduced-motion: reduce) { #caption { transition: none; } }
#help .credit { margin: 10px 0 0; max-width: 340px; font-size: 11px; line-height: 1.4; opacity: 0.75; }
