body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 20px;
  background-color: #f9f9f9;
}
.container {
  max-width: 800px;
  margin: 0 auto;
}
header {
  background-color: #4285f4;
  color: white;
  padding: 15px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
h1 {
  margin: 0;
  font-size: 24px;
}
.preview-container {
  position: relative;
  background-color: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  margin-bottom: 20px;
  aspect-ratio: 16 / 9;
}
video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #aaa;
  font-style: italic;
  text-align: center;
  padding: 20px;
}
.controls {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
}
button {
  padding: 10px 15px;
  border: none;
  border-radius: 4px;
  background-color: #4285f4;
  color: white;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
  min-width: 100px;
  min-height: 44px; /* Better for mobile touch targets */
}
button:hover {
  background-color: #3367d6;
}
button.danger {
  background-color: #ea4335;
}
button.danger:hover {
  background-color: #d33426;
}
button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}
.status {
  padding: 15px;
  border-radius: 8px;
  margin-top: 20px;
  background-color: #f1f3f4;
}
.status.connected {
  background-color: #e6f4ea;
  border-left: 4px solid #34a853;
  color: #137333;
}
.status.disconnected {
  background-color: #f8d7da;
  border-left: 4px solid #ea4335;
  color: #721c24;
}
.status.streaming {
  background-color: #fef7e0;
  border-left: 4px solid #fbbc04;
  color: #b06000;
}
.streaming-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: rgba(234, 67, 53, 0.8);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-weight: bold;
  display: none;
}
.streaming-indicator.active {
  display: block;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.6; }
  100% { opacity: 1; }
}
.header-links a {
  color: white;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 4px;
  background-color: rgba(255,255,255,0.1);
  transition: background-color 0.2s;
}
.header-links a:hover {
  background-color: rgba(255,255,255,0.2);
}
/* Archery scoreboard styles */
.score-manager {
  background-color: white;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.score-manager h3 {
  margin-top: 0;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.archery-score-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
}

.archer-input {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.archer-input label {
  font-size: 14px;
  color: #5f6368;
}

.archer-input input {
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.score-stats {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 10px;
  background-color: #f1f3f4;
  padding: 10px;
  border-radius: 4px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 12px;
  color: #5f6368;
}

.stat-value {
  font-size: 18px;
  font-weight: bold;
}

.arrow-input {
  display: flex;
  align-items: center;
  gap: 10px;
}

.arrow-input input {
  width: 60px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
  text-align: center;
}

.add-arrow-btn {
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  background-color: #4285f4;
  color: white;
  cursor: pointer;
}

.arrow-history {
  margin-top: 15px;
  border: 1px solid #eee;
  border-radius: 4px;
  padding: 10px;
  max-height: 100px;
  overflow-y: auto;
}

.arrow-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.arrow-item {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  background-color: #f1f3f4;
}

/* Arrow score colors */
.arrow-item[data-score="10"], .arrow-item[data-score="9"] {
  background-color: #ffd700; /* gold */
  color: black;
}

.arrow-item[data-score="8"], .arrow-item[data-score="7"] {
  background-color: #ff0000; /* red */
  color: white;
}

.arrow-item[data-score="6"], .arrow-item[data-score="5"] {
  background-color: #0000ff; /* blue */
  color: white;
}

.arrow-item[data-score="4"], .arrow-item[data-score="3"] {
  background-color: #000000; /* black */
  color: white;
}

.arrow-item[data-score="2"], .arrow-item[data-score="1"] {
  background-color: #ffffff; /* white */
  color: black;
  border: 1px solid #ddd;
}

.arrow-item[data-score="0"], .arrow-item[data-score="M"] {
  background-color: #cccccc; /* miss */
  color: black;
}

.score-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 15px;
}

.toggle-scoreboard {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Switch toggle for scoreboard visibility */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #4285f4;
}

input:checked + .slider:before {
  transform: translateX(26px);
}

/* Remove scoreboard display styles - no longer needed in client view */
/*
.scoreboard-display {
  background-color: white;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.scoreboard-display h3 {
  margin-top: 0;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
  color: #4285f4;
}

.scoreboard-status {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scoreboard-status p {
  margin: 0;
  font-size: 14px;
  color: #666;
}

#scoreboardStatus {
  font-weight: bold;
  padding: 8px 12px;
  background-color: #f1f3f4;
  border-radius: 4px;
  color: #5f6368;
}

#scoreboardStatus:not(:empty) {
  border-left: 3px solid #4285f4;
}

.match-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 15px;
  padding: 10px 15px;
  background-color: #f1f3f4;
  border-radius: 8px;
}

.player-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 10px;
}

.player-display .player-name {
  font-weight: bold;
  margin-bottom: 5px;
  color: #4285f4;
}

.player-display .player-score {
  font-size: 24px;
  font-weight: bold;
}

.vs-display {
  font-weight: bold;
  color: #5f6368;
  padding: 0 15px;
}
*/

/* Permission alert styling */
.permission-alert {
  padding: 10px;
  border-radius: 4px;
  margin: 10px 0;
  font-weight: bold;
}

.permission-alert.prompt {
  background-color: #fef7e0;
  border-left: 4px solid #fbbc04;
  color: #b06000;
}

.permission-alert.denied {
  background-color: #f8d7da;
  border-left: 4px solid #ea4335;
  color: #721c24;
}

.permission-alert.granted {
  background-color: #e6f4ea;
  border-left: 4px solid #34a853;
  color: #137333;
}

.permission-alert.error {
  background-color: #f8d7da;
  border-left: 4px solid #ea4335;
  color: #721c24;
}

/* Direct camera access button */
.direct-camera-btn {
  background-color: #4caf50;
  color: white;
  width: 100%;
  margin-bottom: 10px;
  display: none; /* Hidden by default */
}

/* Minimal camera test button styling */
#testCamera {
  background-color: #9c27b0;
  color: white;
  width: 100%;
  margin-bottom: 10px;
  font-weight: bold;
  display: none; /* Hidden by default */
}

/* Permission button styling */
#requestPermission {
  display: none; /* Hidden by default, shown on mobile */
  background-color: #fbbc04;
  font-weight: bold;
  width: 100%;
  max-width: 300px;
  margin: 0 auto 15px;
  height: 50px;
  font-size: 16px;
  border: none;
  border-radius: 25px;
  padding: 10px 20px;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  animation: pulse-button 2s infinite;
  z-index: 10; /* Make sure it's on top and clickable */
  text-transform: uppercase; /* Make it more prominent */
}

/* Mobile-responsive styles */
@media (max-width: 768px) {
  .container {
    padding: 0;
    width: 100%;
  }

  header {
    flex-direction: column;
    gap: 10px;
  }

  .header-links {
    width: 100%;
    display: flex;
    justify-content: space-around;
  }

  button {
    flex-grow: 1;
    padding: 12px 8px; /* Taller buttons for mobile */
  }

  .controls {
    gap: 8px;
    margin-bottom: 15px;
  }

  /* Ensure the video preview is always visible */
  .preview-container {
    margin-bottom: 10px;
    height: 40vh;  /* Use viewport height for better mobile viewing */
    aspect-ratio: auto;  /* Override the desktop aspect ratio */
  }

  /* Make sure the status section is easy to read */
  .status {
    font-size: 14px;
    padding: 10px;
    margin-top: 10px;
  }

  /* Improve touch targets */
  .header-links a {
    padding: 10px 15px;
  }

  .permission-alert {
    font-size: 14px;
    padding: 12px;
    margin: 12px 0;
  }

  /* Make sure buttons are easier to tap on mobile */
  #startCamera {
    font-size: 16px;
    padding: 12px 16px;
    margin-bottom: 10px;
  }

  /* Status messages should be very clear */
  #deviceInfo,
  #connectionStatus,
  #streamStats,
  #permissionInfo {
    line-height: 1.4;
  }

  /* Make permission request button very prominent on mobile */
  #requestPermission {
    position: relative; /* Ensure proper stacking */
    display: block;
    font-size: 18px;
    padding: 15px 20px;
    margin-bottom: 20px;
    background-color: #ff5722; /* More attention-grabbing color */
    color: white;
    transform: translateZ(0); /* Force hardware acceleration */
    -webkit-appearance: none; /* Fix iOS button styling */
  }

  /* Stronger pulse animation */
  @keyframes pulse-button {
    0% { transform: scale(1); box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
    50% { transform: scale(1.05); box-shadow: 0 5px 15px rgba(255,87,34,0.4); }
    100% { transform: scale(1); box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
  }

  /* Show direct camera button on mobile */
  .direct-camera-btn {
    display: block;
  }

  /* Show test button on mobile */
  #testCamera {
    display: block;
  }

  /* Make permission request button extra noticeable */
  #requestPermission {
    position: relative;
    display: block;
    font-size: 18px;
    padding: 15px 20px;
    margin: 0 auto 20px;
    background-color: #ff5722; /* Attention-grabbing color */
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transform: translateZ(0);
    -webkit-appearance: none; /* Fix iOS button styling */
    animation: pulse-button 1.5s infinite;
    letter-spacing: 0.5px;
  }

  /* Larger touch target for start camera button */
  #startCamera {
    height: 56px;
    margin-bottom: 12px;
    font-size: 16px;
    background-color: #4285f4;
    border-radius: 8px;
  }
}
