:root {
  --bg: #0e1217;
  --panel: rgba(16, 21, 28, 0.88);
  --line: #2a3441;
  --text: #ece7df;
  --muted: #93a0ae;
  --accent: #f0a15e;
  --ok: #6bd490;
  --warn: #f4c85d;
  --bad: #ea6f58;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  background: var(--bg);
  touch-action: none;
  cursor: grab;
  outline: none;
}

#stage.dragging { cursor: grabbing; }

#streamVideo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: var(--bg);
  pointer-events: none;
}

#ripple {
  position: fixed;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.4);
}

#ripple.active { animation: rippleOut 420ms ease-out forwards; }

@keyframes rippleOut {
  0% { opacity: 0.95; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(2.1); }
}

#overlayMsg {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}

#overlayMsg.hidden { display: none; }

#overlayMsg .card {
  max-width: 390px;
  margin: 16px;
  padding: 16px 20px;
  border-radius: 12px;
  background: rgba(16, 21, 28, 0.92);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  text-align: center;
  pointer-events: auto;
}

#overlayMsg .title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
#overlayMsg .desc { font-size: 12px; color: var(--muted); }

.primary-btn {
  margin-top: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #141920;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

#panel {
  position: fixed;
  top: 12px;
  left: 12px;
  width: 344px;
  max-height: calc(100dvh - 56px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  backdrop-filter: blur(10px);
  z-index: 20;
}

#panel.hidden { display: none; }

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.panel-header h1 { margin: 0; font-size: 14px; font-weight: 600; }
.sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.mobile-url-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin: 6px 0 2px;
  border-radius: 7px;
  background: rgba(240, 161, 94, 0.08);
  border: 1px solid rgba(240, 161, 94, 0.3);
  font-size: 11px;
}
.mobile-url-row[hidden] { display: none; }
.mobile-url-label { color: var(--accent); white-space: nowrap; }
.mobile-url-row code {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-family: ui-monospace, Consolas, monospace;
}

.badge {
  font: 11px/1 ui-monospace, Consolas, monospace;
  padding: 4px 7px;
  border-radius: 5px;
  background: #232c37;
  border: 1px solid var(--line);
  color: var(--accent);
  white-space: nowrap;
}
.badge.ok { color: var(--ok); border-color: rgba(107, 212, 144, 0.45); }
.badge.warn { color: var(--warn); border-color: rgba(244, 200, 93, 0.45); }
.badge.bad { color: var(--bad); border-color: rgba(234, 111, 88, 0.45); }

.section-title {
  margin-top: 10px;
  margin-bottom: 5px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0;
}

.row label { color: var(--muted); font-size: 12px; }

select, button {
  background: #222b36;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
}

select { max-width: 184px; }
button { cursor: pointer; }
button:hover { border-color: #46566a; }
button.active { border-color: var(--accent); color: var(--accent); }

.btn-group { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.range-wrap { display: flex; align-items: center; gap: 6px; }
input[type=range] { width: 122px; accent-color: var(--accent); }
.val { font: 11px ui-monospace, Consolas, monospace; min-width: 28px; text-align: right; }

.stats-grid { display: flex; flex-direction: column; gap: 4px; }
.stats-block pre {
  margin: 0;
  font: 11px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

#mobileBar {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
#mobileBar[hidden] { display: none; }
#showHudBtn { border-radius: 999px; padding: 5px 11px; font-weight: 500; }
.mini-stats { font: 11px/1 ui-monospace, Consolas, monospace; color: var(--muted); white-space: nowrap; }

#hint {
  position: fixed;
  bottom: 12px;
  left: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  z-index: 15;
  pointer-events: none;
}

@media (max-width: 640px) {
  #panel { width: calc(100vw - 24px); max-height: calc(100dvh - 32px); }
  #hint { display: none; }
}
