:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #111514;
  --panel: rgba(20, 24, 23, 0.94);
  --panel-solid: #171c1a;
  --line: #3a423f;
  --text: #f3f5f1;
  --muted: #9da6a1;
  --teal: #42d6b0;
  --orange: #ff9b52;
  --red: #ff645f;
  --yellow: #e5d45d;
  --fydneg: #a98bff;
  --panel-width: 280px;
  --detail-width: 320px;
  --top-height: 56px;
  --bottom-height: 98px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; letter-spacing: 0; }
button, select, input {
  border: 1px solid var(--line);
  background: #202624;
  color: var(--text);
  border-radius: 4px;
}
button { min-height: 34px; padding: 0 12px; cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.62; }
button:hover, button.active { border-color: var(--teal); color: var(--teal); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
input, select { height: 34px; padding: 0 10px; min-width: 0; }

.app-shell { position: relative; width: 100%; height: 100%; background: #101311; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; background: #101311; }
.player-tooltip {
  position: fixed; z-index: 9; left: 0; top: 0; width: min(310px, calc(100vw - 20px));
  padding: 9px 11px; border: 1px solid var(--teal); border-radius: 4px;
  background: rgba(15, 19, 18, 0.96); pointer-events: none; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.34);
}
.player-tooltip strong, .player-tooltip span, .player-tooltip small { display: block; overflow-wrap: anywhere; }
.player-tooltip strong { font-size: 13px; }.player-tooltip span { margin-top: 2px; color: var(--orange); font-size: 11px; }
.player-tooltip small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.player-tooltip dl { margin: 7px 0 0; padding-top: 5px; border-top: 1px solid var(--line); }
.player-tooltip dl div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 7px; padding: 2px 0; }
.player-tooltip dt { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.player-tooltip dd { min-width: 0; margin: 0; font-size: 10px; overflow-wrap: anywhere; }
.speech-layer { position: fixed; inset: 0; z-index: 8; pointer-events: none; }
.speech-bubble {
  position: absolute; left: 0; top: 0; max-width: 260px;
  padding: 6px 9px; border: 1px solid var(--teal); border-radius: 8px;
  background: rgba(15, 19, 18, 0.92); color: var(--text);
  font-size: 12px; line-height: 1.35; text-align: center; overflow-wrap: anywhere;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.42); transition: opacity 120ms linear;
}
.speech-bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; width: 8px; height: 8px;
  transform: translateX(-50%) rotate(45deg);
  background: rgba(15, 19, 18, 0.92); border-right: 1px solid var(--teal); border-bottom: 1px solid var(--teal);
}
.speech-who { display: block; margin-bottom: 2px; color: var(--teal); font-size: 9px; text-transform: uppercase; letter-spacing: 0.03em; }

.topbar {
  position: absolute; inset: 0 0 auto 0; height: var(--top-height); z-index: 5;
  display: grid; grid-template-columns: var(--panel-width) minmax(260px, 1fr) var(--detail-width);
  align-items: center; border-bottom: 1px solid var(--line); background: rgba(17, 21, 20, 0.96);
}
.brand { height: 100%; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-right: 1px solid var(--line); }
.brand strong { color: var(--teal); font-size: 18px; }
.brand span { color: var(--muted); font-size: 12px; }
.connection { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 16px; }
.auth-user {
  min-width: 0; overflow: hidden; color: var(--muted); font-size: 11px;
  text-overflow: ellipsis; white-space: nowrap;
}
.connection button { min-width: 150px; }
.scene-tools { height: 100%; display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 0 12px; border-left: 1px solid var(--line); }
.scene-tools button { width: 48px; padding: 0; font-size: 11px; font-weight: 700; }

.side-panel {
  position: absolute; z-index: 4; top: var(--top-height); bottom: var(--bottom-height);
  background: var(--panel); overflow: hidden;
}
.rounds-panel { left: 0; width: var(--panel-width); border-right: 1px solid var(--line); }
.detail-panel { right: 0; width: var(--detail-width); border-left: 1px solid var(--line); }
.panel-heading { height: 68px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-heading h1 { margin: 2px 0 0; font-size: 18px; line-height: 1; }
.eyebrow { color: var(--orange); font-size: 10px; font-weight: 700; }
.count { min-width: 28px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.filters { display: grid; grid-template-columns: 1fr 92px; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); }
.filters select { font-size: 12px; }
.round-list { height: calc(100% - 123px); overflow-y: auto; }
.round-row { width: 100%; min-height: 78px; padding: 11px 14px; display: grid; gap: 6px; border: 0; border-bottom: 1px solid #2b312f; border-radius: 0; background: transparent; text-align: left; }
.round-row:hover, .round-row.active { background: #222925; color: var(--text); box-shadow: inset 3px 0 var(--teal); }
.round-row .primary { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 650; }
.round-row .secondary { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.round-row .hash { color: #748079; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; overflow: hidden; text-overflow: ellipsis; }

.tabs { height: 46px; display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-radius: 0; background: transparent; border-bottom: 2px solid transparent; }
.tabs button.active { border-bottom-color: var(--teal); }
.detail-view { height: calc(100% - 46px); overflow-y: auto; }
.hidden { display: none !important; }
.event-row { width: 100%; display: grid; grid-template-columns: 58px 1fr; gap: 9px; padding: 10px 12px; border: 0; border-bottom: 1px solid #2b312f; border-radius: 0; background: transparent; text-align: left; }
.event-row:hover { background: #222925; color: var(--text); }
.event-time { color: var(--teal); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.event-copy { min-width: 0; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.event-copy strong { display: block; color: var(--orange); font-size: 10px; text-transform: uppercase; }
.event-toolbar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; background: var(--panel-solid); border-bottom: 1px solid var(--line); }
.event-count { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.fydneg-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.fydneg-toggle span { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; }
.fydneg-toggle input { width: 14px; height: 14px; min-width: 14px; accent-color: var(--fydneg); }
.fydneg-toggle input:checked + span { color: var(--fydneg); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.fydneg { background: var(--fydneg); }
.event-row.fydneg { background: rgba(150, 128, 255, 0.05); box-shadow: inset 3px 0 var(--fydneg); }
.event-row.fydneg:hover { background: rgba(150, 128, 255, 0.11); }
.event-row.fydneg .event-time { color: var(--fydneg); }
.event-copy .tag { display: inline-block; margin-right: 6px; padding: 0 5px; border-radius: 3px; background: var(--fydneg); color: #17131f; font-style: normal; font-size: 9px; font-weight: 700; letter-spacing: 0.03em; vertical-align: 1px; }
.event-copy .dry { display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 3px; border: 1px solid var(--muted); color: var(--muted); font-style: normal; font-size: 9px; vertical-align: 1px; }
.event-row.fydneg.sev-medium { box-shadow: inset 3px 0 var(--yellow); }
.event-row.fydneg.sev-medium .event-time { color: var(--yellow); }
.event-row.fydneg.sev-high { box-shadow: inset 3px 0 var(--orange); }
.event-row.fydneg.sev-high .event-time { color: var(--orange); }
.event-row.fydneg.sev-critical { box-shadow: inset 3px 0 var(--red); }
.event-row.fydneg.sev-critical .event-time { color: var(--red); }
.empty-state { padding: 20px 14px; color: var(--muted); font-size: 13px; }
.player-info { padding: 14px; }
.player-name { margin: 0 0 4px; font-size: 18px; }
.player-role { color: var(--orange); font-size: 12px; }
.dossier { margin: 18px 0 0; border-top: 1px solid var(--line); }
.dossier div { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 8px; padding: 8px 0; border-bottom: 1px solid #2b312f; }
.dossier dt { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.dossier dd { min-width: 0; margin: 0; font-size: 11px; overflow-wrap: anywhere; }
.stat-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.stat { min-height: 58px; padding: 9px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.stat strong { display: block; margin-top: 5px; font-size: 14px; overflow-wrap: anywhere; }
.inventory { margin-top: 18px; }
.inventory h2 { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.inventory ul { margin: 0; padding: 0; list-style: none; }
.inventory li { padding: 7px 0; border-bottom: 1px solid #2b312f; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }

.playback {
  position: absolute; z-index: 6; inset: auto 0 0 0; min-height: var(--bottom-height);
  background: rgba(17, 21, 20, 0.97); border-top: 1px solid var(--line); padding: 10px 14px 8px;
}
.transport { display: grid; grid-template-columns: 36px 78px minmax(120px, 1fr) 78px 74px 36px; gap: 9px; align-items: center; }
.icon-button { width: 36px; min-height: 34px; padding: 0; font-size: 15px; }
.time { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
input[type="range"] { width: 100%; height: 24px; padding: 0; accent-color: var(--teal); border: 0; background: transparent; }
.legend { height: 34px; display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.audio-toggle { width: 58px; min-height: 26px; padding: 0 7px; font-size: 9px; color: var(--muted); }
.audio-toggle.active { color: var(--teal); border-color: var(--teal); }
.volume { max-width: 92px; }
.legend strong { margin-left: auto; color: var(--text); font-weight: 500; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone { width: 8px; height: 8px; display: inline-block; }
.zone.lcz { background: #51c6dc; }.zone.hcz { background: #e5d45d; }.zone.ez { background: #8bd56e; }.zone.surface { background: #ff806f; }
.mobile-only { display: none; }

.fly-pad { position: absolute; z-index: 7; left: calc(var(--panel-width) + 16px); bottom: calc(var(--bottom-height) + 16px);
  display: flex; align-items: flex-end; gap: 10px; }
.fly-move { display: grid; grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(2, 42px); gap: 4px; }
.fly-move .fly-w { grid-column: 2; grid-row: 1; } .fly-move .fly-a { grid-column: 1; grid-row: 2; }
.fly-move .fly-s { grid-column: 2; grid-row: 2; } .fly-move .fly-d { grid-column: 3; grid-row: 2; }
.fly-lift { display: grid; grid-template-rows: 42px 42px; gap: 4px; }
.fly-pad button { width: 42px; height: 42px; min-height: 0; padding: 0; font-size: 16px; line-height: 1;
  background: rgba(20, 24, 23, 0.82); border-color: var(--line); color: var(--text); touch-action: none; user-select: none; }
.fly-pad button:hover { border-color: var(--teal); color: var(--teal); }
.fly-pad button.down { background: var(--teal); border-color: var(--teal); color: #10201b; }

@media (max-width: 900px) {
  :root { --panel-width: min(84vw, 300px); --detail-width: min(88vw, 340px); --bottom-height: 112px; }
  .topbar { grid-template-columns: 84px minmax(110px, 1fr) 170px; }
  .brand { padding: 0 10px; }.brand span { display: none; }
  .connection { display: grid; grid-template-columns: minmax(0, 1fr) 38px; padding: 0 6px; }
  .auth-user { width: 100%; }
  .connection button { display: block; width: 38px; padding: 0; overflow: hidden; font-size: 0; }
  .connection button::before { content: "→"; font-size: 16px; }
  .scene-tools { padding: 0 5px; gap: 4px; }.scene-tools button { width: 30px; }
  .fly-pad { left: 12px; bottom: calc(var(--bottom-height) + 12px); }
  .mobile-only { display: block; }
  .side-panel { transition: transform 180ms ease; }
  .rounds-panel { transform: translateX(-101%); }.rounds-panel.open { transform: translateX(0); }
  .detail-panel { transform: translateX(101%); }.detail-panel.open { transform: translateX(0); }
  .transport { grid-template-columns: 34px 66px minmax(80px, 1fr) 66px 62px 34px; gap: 5px; }
  .legend span, .volume { display: none; }.legend strong { margin-left: 0; max-width: 100%; }
}
