:root {
  --bg: #0b1020;
  --panel: rgba(11, 16, 32, 0.86);
  --panel-solid: #0e1428;
  --line: rgba(255, 255, 255, 0.12);
  --line2: rgba(255, 255, 255, 0.2);
  --text: #eef2f8;
  --muted: #a3aec3;
  --accent: #43a047;
  --accent-2: #66bb6a;
  --gold: #ffcf5c;
  --radius: 16px;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); overflow: hidden; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button, select, input { font: inherit; color: inherit; }
a { color: #8fc4ff; }

.loading {
  position: fixed; inset: 0; z-index: 30; display: flex; gap: 14px; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #16213f, #070a14 70%); font: 700 22px var(--cond); letter-spacing: 0.3px;
  transition: opacity 0.5s ease;
}
body.ready .loading { opacity: 0; pointer-events: none; }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.2); border-top-color: var(--accent-2); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sim-badge {
  position: fixed; left: 14px; bottom: 12px; margin: 0; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(8, 12, 24, 0.75); color: var(--text); font-size: 12px; pointer-events: none; z-index: 5;
}
.compass {
  position: fixed; right: 16px; top: 16px; width: 56px; height: 56px; border-radius: 50%;
  background: rgba(8, 12, 24, 0.75); border: 1px solid var(--line2); z-index: 5; display: grid; place-items: center;
}
.compass .needle { position: absolute; inset: 4px; display: flex; justify-content: center; font: 800 14px var(--cond); color: #ff7043; transform: rotate(var(--rot, 0deg)); transition: transform 0.08s linear; }
.compass .deg { font: 700 13px var(--cond); color: var(--muted); margin-top: 14px; }

#panel {
  position: fixed; left: 16px; top: 16px; width: 372px; max-height: calc(100% - 64px); overflow: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--line2); border-radius: var(--radius); z-index: 6;
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.panel-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 16px 16px 8px; position: sticky; top: 0; background: linear-gradient(var(--panel-solid), rgba(14,20,40,0.92)); z-index: 1; }
.panel-head h1 { margin: 0; font: 800 26px/1 var(--cond); letter-spacing: 0.2px; }
.panel-head .sub { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.head-btns { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.ghost { background: rgba(255,255,255,0.04); border: 1px solid var(--line2); border-radius: 10px; padding: 6px 11px; cursor: pointer; font-size: 13px; }
.ghost:hover { background: rgba(255, 255, 255, 0.1); }
.ghost.sq { width: 40px; padding: 7px 0; font-size: 19px; line-height: 1; }
.primary { display: block; width: 100%; margin-top: 10px; background: linear-gradient(180deg, #4caf50, #2e7d32); border: 0; border-radius: 12px; padding: 11px 14px; color: #fff; font: 800 19px var(--cond); letter-spacing: 0.3px; cursor: pointer; box-shadow: 0 6px 18px rgba(46,125,50,0.35); }
.primary:hover { filter: brightness(1.08); }
.card { margin: 8px 12px 12px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255, 255, 255, 0.035); }
.card h2 { margin: 0 0 9px; font: 800 20px var(--cond); }
.card h3 { margin: 12px 0 6px; font: 700 16px var(--cond); }
.card h3 small { font: 400 12px var(--font); color: var(--muted); }
.card.small { font-size: 12.5px; color: var(--muted); }
.card.small p { margin: 0 0 6px; }
.row { display: flex; align-items: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.lbl { width: 74px; color: var(--muted); font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 11px; overflow: hidden; background: rgba(0,0,0,0.15); }
.seg.wide { display: flex; width: 100%; margin: 8px 0; }
.seg.wide button { flex: 1; }
.seg button { background: transparent; border: 0; border-right: 1px solid var(--line); padding: 8px 12px; cursor: pointer; font-size: 13.5px; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 700; }
.bay-pick { display: flex; gap: 6px; margin: 8px 0; }
.bay-pick select { flex: 1; min-width: 0; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line2); border-radius: 10px; padding: 8px; font: 700 18px var(--cond); }
.bay-pick select option { background: #121a2e; font: 15px var(--font); }
.chks { gap: 14px; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.chk { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; cursor: pointer; }

.mini-map { display: block; width: 100%; height: 210px; margin: 4px 0 2px; border-radius: 10px; background: radial-gradient(ellipse at 50% 30%, rgba(67,160,71,0.06), rgba(0,0,0,0.25)); }
.mini-map .mm-of { fill: #1f4d24; stroke: #3d7a3f; stroke-width: 1; }
.mini-map .mm-t { stroke: rgba(0,0,0,0.5); stroke-width: 0.8; }
.mini-map .mm-b { fill: #5b6b86; stroke: #0e1428; stroke-width: 0.8; cursor: pointer; transition: fill 0.15s; }
.mini-map .mm-b:hover { fill: #8fa3c4; }
.mini-map .mm-prime { fill: #b8913a; }
.mini-map .mm-chairman { fill: #8e4fb8; }
.mini-map .mm-event { fill: #2a8f8a; }
.mini-map .mm-b.on { fill: #ff6d00; stroke: #fff; stroke-width: 1.2; }
.mini-map .mm-l { fill: var(--muted); font: 700 9px var(--cond); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin: 2px 0 2px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.lg-regular { background: #5b6b86; } .lg-prime { background: #b8913a; } .lg-chairman { background: #8e4fb8; } .lg-event { background: #2a8f8a; }

.info .zone { margin: -4px 0 8px; color: var(--gold); font-size: 13.5px; }
.info dl { display: grid; grid-template-columns: 96px 1fr; gap: 3px 10px; margin: 0; font-size: 13.5px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; }
.tgt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 13.5px; }
.tgt-list li { display: grid; grid-template-columns: 16px 1fr auto 50px; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.tgt-list li:last-child { border-bottom: 0; }
.tgt-list .dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.6); }
.tgt-list small { color: var(--muted); }
.tgt-list .td { font-weight: 700; }
.tgt-list .ty { color: var(--muted); text-align: right; }
.tgt-list .hid { font-style: normal; font-size: 11.5px; color: #ffb74d; margin-left: 4px; }
.credit { font-size: 11.5px; }

.hud {
  position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%); width: min(640px, calc(100% - 420px)); min-width: 420px; z-index: 7;
  background: var(--panel); border: 1px solid var(--line2); border-radius: var(--radius); padding: 12px 14px; display: none;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 18px 50px rgba(0,0,0,0.45);
}
body.is-pov .hud { display: block; }
.hud-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.hud h2 { margin: 0; font: 800 22px/1.05 var(--cond); }
.hud-sub { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.hud-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.zoom-l { font-size: 13px; color: var(--muted); white-space: nowrap; }
.zoom-l b { color: var(--text); }
.hud input[type=range] { flex: 1; min-width: 140px; accent-color: var(--accent); }
.hit { display: inline-block; width: auto; margin: 0 0 0 auto; padding: 8px 14px; font-size: 17px; }
.shot-out { margin: 8px 0 0; padding: 7px 10px; border-radius: 10px; background: rgba(67,160,71,0.16); border: 1px solid rgba(102,187,106,0.35); font-size: 13.5px; }
.hud-note { margin: 8px 0 0; font-size: 11.5px; color: var(--muted); }

.note {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100% - 28px)); z-index: 20;
  background: rgba(12, 17, 32, 0.97); border: 1px solid var(--line2); border-radius: 18px; padding: 20px 22px; box-shadow: 0 30px 80px rgba(0,0,0,0.6);
}
.note h2 { margin: 0 0 10px; font: 800 26px/1.05 var(--cond); }
.note ul { margin: 0 0 6px; padding-left: 18px; font-size: 14px; }
.note li { margin: 6px 0; }
.note[hidden] { display: none; }
.show-ui {
  position: fixed; left: 14px; top: 14px; z-index: 9; background: rgba(8, 12, 24, 0.82); border: 1px solid var(--line2);
  border-radius: 999px; padding: 8px 15px; cursor: pointer; display: none;
}
body.ui-hidden .show-ui { display: block; }
body.ui-hidden #panel, body.ui-hidden .compass, body.ui-hidden .note, body.ui-hidden .hud { display: none !important; }
body.panel-closed #panelBody { display: none; }

@media (max-width: 1100px) { .hud { width: calc(100% - 420px); min-width: 0; } }
@media (max-width: 760px) {
  #panel { left: 0; right: 0; top: auto; bottom: 0; width: 100%; max-height: 58%; border-radius: 18px 18px 0 0; border-left: 0; border-right: 0; border-bottom: 0; }
  body.is-pov #panel { display: none; }
  .panel-head { padding: 12px 14px 6px; }
  .panel-head h1 { font-size: 22px; }
  .head-btns { flex-direction: row; }
  .card { margin: 6px 10px 10px; padding: 11px; }
  .sim-badge { top: 12px; bottom: auto; left: 12px; font-size: 11px; }
  .compass { top: 44px; right: 12px; width: 48px; height: 48px; }
  .hud { left: 8px; right: 8px; bottom: 8px; transform: none; width: auto; min-width: 0; padding: 10px 12px; }
  .hud h2 { font-size: 19px; }
  .hud-note { display: none; }
  body.ui-hidden .sim-badge { top: auto; bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) { .compass .needle { transition: none; } .spin { animation: none; } }
