html {
  font-size: 16px; /* Establish a base for rem units */
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background-color: black;
  overflow: hidden; /* Hide scrollbars */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

video {
  width: 100%;  /* Make the video element's box fill the parent width */
  height: 100%; /* Make the video element's box fill the parent height */
  object-fit: contain; /* Fit video content within this box, maintain aspect ratio */
  display: block; /* Remove extra space below video if any */
}

.player-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent black */
  display: flex;
  flex-direction: column; /* Stack items vertically */
  justify-content: center;
  align-items: center;
  z-index: 10;
  visibility: hidden; /* Hidden by default */
  opacity: 0;
  transition: opacity 0.2s ease-in-out, visibility 0s 0.2s;
}
.player-overlay.visible {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.2s ease-in-out;
}

/* Basic CSS Spinner */
.spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 4px solid #fff;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.overlay-message {
    color: #bbb; /* Lighter gray, adjust as needed */
    margin-top: 10px; /* Adjust spacing below spinner */
    font-family: inherit;
    font-size: 0.9em; /* Slightly smaller */
}

/* Custom Player Controls */
.player-container {
  position: relative;
  width: 100%; /* Use 100% width */
  height: 100%; /* Use 100% height */
  display: flex; /* Use flexbox for centering */
  justify-content: center;
  align-items: center;
  background-color: black; /* Ensure background is black */
}

.custom-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0; /* Ensure controls span full width */
  background: linear-gradient(to top, rgba(0,0,0,0.7), rgba(0,0,0,0));
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Use padding for spacing and safe area, use rem for base padding */
  padding: 0.625rem 1.25rem calc(1rem + env(safe-area-inset-bottom)) 1.25rem; /* 10px 20px calc(10px + safe) 20px */
  box-sizing: border-box;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 5;
  pointer-events: none;
}

.custom-controls.active {
  opacity: 1;
  pointer-events: auto;
}

.control-button {
  background: none;
  border: none;
  width: 2.25rem; /* 36px / 16px */
  height: 2.25rem; /* 36px / 16px */
  margin-right: 0.3125rem; /* 5px / 16px */
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-button svg {
  width: 1.5rem; /* 24px / 16px */
  height: 1.5rem; /* 24px / 16px */
  fill: white;
  transition: transform 0.2s ease;
}

.control-button:hover svg {
  transform: scale(1.1);
}

.volume-container {
  display: flex;
  align-items: center;
  /* width: 120px; */ /* Let content define width */
  margin-right: 1.25rem; /* 20px / 16px */
}

.volume-slider {
  width: 5rem; /* 80px / 16px */
  margin-left: 0.625rem; /* 10px / 16px */
  -webkit-appearance: none;
  appearance: none;
  height: 0.25rem; /* 4px / 16px */
  border-radius: 0.125rem; /* 2px / 16px */
  background: rgba(255, 255, 255, 0.3);
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none; /* Standard property */
  width: 1rem; /* 16px / 16px - Increased size */
  height: 1rem; /* 16px / 16px - Increased size */
  border-radius: 50%;
  background: white;
  cursor: pointer;
  margin-top: 0rem; /* (thumb height - track height) / 2 = (1rem - 0.25rem) / 2 = 0.375rem to vertically center */
}

.volume-slider::-moz-range-thumb {
  width: 1rem; /* 16px / 16px - Increased size */
  height: 1rem; /* 16px / 16px - Increased size */
  border-radius: 50%;
  background: white;
  cursor: pointer;
  border: none;
}

/* Hide volume slider on iOS devices */
.ios-device .volume-slider {
  display: none !important; /* Use !important to ensure it overrides other display properties if necessary */
}

.controls-right {
  display: flex;
  align-items: center;
}

.spacer {
  flex-grow: 1;
} 

.stream-form-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 1000;
}

.stream-form {
  background-color: #222;
  padding: 2rem;
  border-radius: 8px;
  width: 80%;
  max-width: 400px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.stream-form h2 {
  color: #fff;
  margin-top: 0;
  margin-bottom: 1.5rem;
  text-align: center;
  font-family: inherit;
  font-weight: 500;
  font-size: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  color: #ddd;
  margin-bottom: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #444;
  background-color: #333;
  color: #fff;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  box-sizing: border-box;
}

.submit-btn {
  width: 100%;
  padding: 0.75rem;
  background-color: #0078d4;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  margin-top: 1rem;
  transition: background-color 0.2s;
}

.submit-btn:hover {
  background-color: #0066b3;
}

.form-error {
  color: #ff6b6b;
  font-size: 0.9rem;
  font-family: inherit;
  margin-top: 1rem;
  text-align: center;
  min-height: 1.2rem;
}

/* Connection Status Overlay */
.connection-status-overlay {
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.875rem;
  color: #ccc;
  width: 180px;
}

.status-item {
  display: flex;
  align-items: center;
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  flex-shrink: 0;
}

.status-detail {
  margin-left: auto;
  color: #aaa;
  font-family: monospace;
  font-size: 0.8125rem;
}

/* Status Indicator Colors */
.status-indicator.gray  { background-color: #6b7280; }
.status-indicator.green { background-color: #22c55e; }
.status-indicator.amber { background-color: #f59e0b; }
.status-indicator.red   { background-color: #ef4444; }

/* Stats Popup */
.stats-popup {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 8px;
  padding: 0.75rem;
  min-width: 220px;
  max-width: 280px;
  color: #fff;
  font-size: 0.875rem;
  z-index: 15;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.stats-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-weight: 600;
  cursor: move;
  user-select: none;
}

.stats-close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.stats-close-btn:hover {
  color: #ccc;
}

.stats-section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stats-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0.5rem 0;
}

.metric-item {
  display: flex;
  justify-content: space-between;
  font-family: monospace;
}

.metric-label {
  color: #aaa;
}

.metric-value {
  color: #fff;
  font-weight: 600;
}

.metric-value.green {
  color: #22c55e;
}

.metric-value.amber {
  color: #f59e0b;
}

.metric-value.red {
  color: #ef4444;
}

.stats-build-id {
  margin-top: 0.75rem;
  font-size: 0.6875rem;
  color: #666;
  text-align: right;
  font-family: monospace;
}

.stream-title {
  position: absolute;
  top: 1.25rem;
  left: 1.5rem;
  display: none;
  align-items: center;
  gap: 0.25rem;
  color: #fff;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 6;
}

.stream-title.populated { display: flex; }

.custom-controls.active ~ .stream-title { opacity: 1; }

.title-chevron {
  width: 1.1em;
  height: 1.1em;
  fill: rgba(255, 255, 255, 0.55);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

.settings-modal {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  z-index: 20;
}

.settings-window {
  background: rgba(0, 0, 0, 0.92);
  border-radius: 8px;
  padding: 1rem;
  width: min(20rem, 90%);
  max-height: 85%;
  overflow-y: auto;
  color: #fff;
  font-size: 0.875rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.settings-close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.settings-section { margin-bottom: 0.75rem; }
.settings-section-title {
  color: #aaa;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
}
.setting-label small { color: #888; }

.setting-options { display: flex; gap: 0.25rem; }
.setting-options button, .overlay-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 4px;
  color: #ccc;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  font-size: 0.8125rem;
}
.setting-options button.on, .overlay-toggle.on {
  background: #22c55e;
  color: #000;
  font-weight: 600;
}

.settings-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding-bottom: 0.5rem;
}
.settings-tab {
  background: none;
  border: none;
  border-radius: 4px;
  color: #aaa;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  font-size: 0.8125rem;
}
.settings-tab.on { background: rgba(255, 255, 255, 0.15); color: #fff; font-weight: 600; }

.setting-select {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 4px;
  color: #fff;
  padding: 0.25rem 0.4rem;
  font-size: 0.8125rem;
  max-width: 11rem;
}
.setting-select option { background: #111; }

.setting-note { color: #888; font-size: 0.75rem; margin-top: 0.5rem; }

.overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

#guides-svg { position: absolute; display: none; }

.clock-overlay {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  display: none;
  color: #fff;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-family: monospace;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.vu-meter {
  position: absolute;
  top: 50%;
  right: 0.75rem;
  transform: translateY(-50%);
  width: 4rem;
  height: 60%;
  display: none;
}
