* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface-2: #232340;
  --border: #2a2a4a;
  --text: #e8e8f0;
  --text-dim: #8888aa;
  --primary: #6366F1;
  --primary-glow: rgba(99, 102, 241, 0.3);
  --success: #22c55e;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
  -webkit-user-select: none;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
}

#connect-screen {
  align-items: center;
  justify-content: center;
}

.connect-container {
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.logo {
  margin-bottom: 16px;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-dim);
  font-size: 15px;
  margin: 6px 0 24px;
}

.servers-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.server-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.server-item:hover {
  background: var(--border);
}

.server-info {
  text-align: left;
}

.server-name {
  font-weight: 500;
  font-size: 14px;
}

.server-ip {
  font-size: 12px;
  color: var(--text-dim);
  font-family: 'SF Mono', 'Consolas', monospace;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hint {
  color: var(--text-dim);
  font-size: 13px;
}

.manual-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.manual-form input {
  flex: 1;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.manual-form input:focus {
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #8B5CF6);
  color: white;
  white-space: nowrap;
}

.btn-primary:hover {
  opacity: 0.9;
}

.recent {
  text-align: left;
  margin-bottom: 16px;
}

.recent h3 {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 13px;
}

.recent-item:hover {
  border-color: var(--primary);
}

.footer-hint {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 24px;
}

#stream-screen {
  flex-direction: column;
  background: #000;
}

#videoCanvas {
  flex: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.stream-controls {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 10;
  background: var(--surface);
  padding: 8px 16px;
  border-radius: 24px;
  border: 1px solid var(--border);
  opacity: 0;
  transition: opacity 0.3s;
}

.stream-controls.visible {
  opacity: 1;
}

.ctrl-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.ctrl-btn:hover {
  background: var(--border);
}

.vr-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
}

.btn-vr {
  padding: 14px 32px;
  font-size: 16px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
}

#settings-screen {
  align-items: center;
  justify-content: center;
}

.settings-container {
  max-width: 350px;
  width: 90%;
}

.settings-container h2 {
  margin-bottom: 20px;
  text-align: center;
}

.setting-group {
  margin-bottom: 16px;
}

.setting-group label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.setting-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

.setting-group select:focus {
  border-color: var(--primary);
}

#connectingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 50;
}

#connectingOverlay.hidden {
  display: none;
}

/* ---- Options overlay ---------------------------------------------------- */

.options-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s, transform 0.2s;
}

.options-toggle:hover,
.options-toggle.active {
  opacity: 1;
  transform: scale(1.06);
}

.options-panel {
  position: fixed;
  right: 16px;
  bottom: 72px;
  z-index: 20;
  width: 320px;
  max-height: 72vh;
  overflow-y: auto;
  padding: 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  display: none;
}

.options-panel.open {
  display: block;
}

.options-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.options-header h3 {
  font-size: 15px;
  margin: 0;
}

.options-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;
}

.options-group {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.options-group h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 10px;
  font-weight: 600;
}

.opt-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
}

.opt-row span {
  color: var(--text-dim);
}

.opt-row select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  min-width: 150px;
}

.opt-row input[type='range'] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--primary);
}

.opt-row output {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: 12px;
}

.opt-hint {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 6px 0 0;
}

.options-group .btn {
  width: 100%;
  margin-top: 4px;
}

.btn-diag {
  margin-top: 10px;
  width: 100%;
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-size: 12px;
}

.diag-output {
  display: none;
  margin-top: 10px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10px;
  line-height: 1.5;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-all;
  text-align: left;
  max-height: 190px;
  overflow-y: auto;
}
