* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", sans-serif;
  color: #eee;
  touch-action: none;
}

#pip {
  position: absolute;
  left: 40px; top: 40px;
  width: 480px; height: 480px;
  border: 1px solid #333;
  overflow: hidden;
  background: #000;
}
#pip-dragbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 18px;
  background: rgba(255, 255, 255, 0.06);
  cursor: move;
  z-index: 5;
}
#pip-content {
  position: absolute;
  inset: 0;
  transform-origin: center center;
}
#video-frame {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
#track-canvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
#pip-resize {
  position: absolute;
  right: 0; bottom: 0;
  width: 18px; height: 18px;
  cursor: nwse-resize;
  background: rgba(255, 255, 255, 0.15);
  z-index: 5;
}

#controls {
  position: absolute;
  right: 16px; bottom: 16px;
  display: flex; flex-direction: column; gap: 8px;
  background: rgba(20, 20, 20, 0.7);
  padding: 12px;
  border-radius: 10px;
  z-index: 20;
}
#controls button {
  background: #1c1c1c;
  color: #eee;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}
#controls button:active { background: #333; }
.slider-group {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px;
  color: #aaa;
}

body.ui-hidden #controls { display: none; }

.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-inner {
  background: #111;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 20px;
  max-width: 90vw;
}
#capture-canvas {
  max-width: 80vw;
  max-height: 60vh;
  border: 1px solid #444;
  cursor: crosshair;
  touch-action: none;
  display: block;
}
.modal-actions {
  margin-top: 12px;
  display: flex; gap: 8px; justify-content: flex-end;
}
.modal-actions button {
  background: #1c1c1c; color: #eee; border: 1px solid #444;
  border-radius: 6px; padding: 6px 14px; cursor: pointer;
}
.modal-inner .slider-group {
  margin-bottom: 14px;
  min-width: 240px;
}
.modal-inner input[type="range"] {
  width: 100%;
}
#target-file-input {
  color: #ccc;
  margin-bottom: 12px;
}
#target-preview-wrap {
  max-width: 320px;
  max-height: 240px;
  overflow: hidden;
  border: 1px solid #333;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-height: 60px;
}
#target-preview {
  max-width: 100%;
  max-height: 240px;
  display: none;
}

.named-entry-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.named-entry-form input[type="text"] {
  flex: 1;
  background: #1c1c1c;
  color: #eee;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 6px 10px;
}
.named-entry-form button {
  background: #1c1c1c; color: #eee; border: 1px solid #444;
  border-radius: 6px; padding: 6px 14px; cursor: pointer;
}
#named-entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  min-width: 280px;
}
.named-entry-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #222;
}
.named-entry-name {
  flex: 1;
  word-break: break-all;
}
.named-entry-row button {
  background: #1c1c1c;
  color: #eee;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}

.bg-help {
  font-size: 12px;
  color: #aaa;
  max-width: 520px;
  line-height: 1.5;
}
.bg-refs {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.bg-ref {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 240px;
}
.bg-ref-title {
  font-size: 13px;
}
.bg-ref-preview {
  height: 160px;
  border: 1px solid #333;
  border-radius: 6px;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.bg-ref-preview img {
  max-width: 100%;
  max-height: 100%;
  display: none;
}
.bg-ref-preview.has-image img { display: block; }
.bg-ref-preview.has-image .bg-empty { display: none; }
.bg-empty {
  color: #666;
  font-size: 12px;
}
.bg-ref button,
.bg-file-label {
  background: #1c1c1c;
  color: #eee;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
}
.bg-file-input { display: none; }
.bg-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 10px;
}
#bg-modal .modal-inner {
  max-height: 90vh;
  overflow-y: auto;
}

.target-hint {
  font-size: 12px;
  color: #aaa;
  max-width: 360px;
  line-height: 1.5;
}
.target-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  font-size: 13px;
}
.target-options select {
  margin-left: 8px;
  background: #1c1c1c;
  color: #eee;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 4px 6px;
}
.target-options .slider-group { margin-bottom: 0; }
.target-options button {
  background: #1c1c1c; color: #eee; border: 1px solid #444;
  border-radius: 6px; padding: 6px 14px; cursor: pointer;
  align-self: flex-start;
}
.target-score { color: #aaa; }
#target-modal .modal-inner {
  max-height: 90vh;
  overflow-y: auto;
}
#toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: rgba(30, 30, 30, 0.92);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  z-index: 200;
  pointer-events: none;
  transition: opacity 0.3s;
}
#toast.hidden { opacity: 0; }
#champion-picker.hidden { display: none; }
