
    .team-header-section {
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 0;
  text-align: center;
  padding-bottom: 18px;
  width: 100px;
}
#teamHeader {
  text-align: center;
  margin-bottom: 18px;
  font-size: 2rem;
  color: var(--primary-dark);
  word-break: break-all;
}
.team-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;   /* Center the buttons horizontally */
  width: 100%;
  color: white;
}

.team-actions button {
  color: white !important;
  min-width: 140px;      /* Optional: makes buttons look more uniform */
  max-width: 100%;
  text-align: center;
}


@media (max-width: 600px) {
  .team-actions {
    flex-direction: column;
    gap: 10px;
  }
}

    :root {
      --primary: #0077cc;
      --primary-dark: #005fa3;
      --accent: #00aaff;
      --bg: #f7fafd;
      --section-bg: #fff;
      --border: grey;
      --shadow: 0 2px 12px rgba(0,0,0,0.07);
      --radius: 12px;
      --font: 'Segoe UI', Arial, sans-serif;
      --danger: #e74c3c;
      --success: #27ae60;
      --grey: #888;
    }

    html, body {
      height: auto;
      overflow-x: hidden;
      overflow-y: auto;                 /* Ensure vertical scrolling is enabled */
      -webkit-overflow-scrolling: touch;
      overscroll-behavior-y: contain; /* Smooth scrolling on iOS */
      scroll-behavior: smooth;
      margin: 0;
      padding: 0;
      font-family: var(--font);
      background: linear-gradient(35deg,rgb(109, 185, 255) 0%);
      min-height: 100vh;
      width: 100vw;
      overflow-x: hidden;
    }
    .section {
  min-height: 100px; /* or more */
}


    .container {
      width: 100%;
      max-width: 420px;
      margin: 40px 0 0 0;
      display: flex;
      flex-direction: column;
      gap: 32px;
      box-sizing: border-box;
    }

    .section {
      background: var(--section-bg);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 32px 28px 28px 28px;
      margin: 0 auto;
      width: 400px;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    h2, h3 {
      margin: 0 0 18px 0;
      font-weight: 600;
      color: var(--primary-dark);
      letter-spacing: 0.5px;
    }

    input, button, select {
      font-family: var(--font);
      font-size: 1rem;
      padding: 12px 14px;
      margin: 8px 0;
      width: 100%;
      max-width: 260px;
      border-radius: 6px;
      border: 1px solid var(--border);
      box-sizing: border-box;
      transition: border 0.2s, box-shadow 0.2s;
      outline: none;
    }

    input:focus, select:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 2px #e3f1ff;
    }

    button {
      background: var(--primary);
      color: #fff;
      border: none;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.2s, box-shadow 0.2s;
      margin-top: 10px;
      box-shadow: 0 1px 4px rgba(0,0,0,0.04);
      min-height: 44px;
      min-width: 44px;
      font-size: 1.05rem;
      letter-spacing: 0.02em;
    }

    button:active {
      background: var(--primary-dark);
    }


    .bike-rider-list {
  border: 1px solid #ddd;
  padding: 8px;
  border-radius: 6px;
  background: #f9f9f9;
}
/* --- Rider Order Modal Scroll & Visibility --- */
#bikeListsContainer {
  max-height: 55vh; /* Responsive, fits most screens */
  overflow-y: auto;
  padding-right: 8px;
  margin-bottom: 16px;
  background: #f7faff;
  border-radius: 10px;
  border: 1px solid #cce3f7;
  box-shadow: 0 2px 8px #0077cc11;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
#bikeListsContainer::-webkit-scrollbar {
  width: 10px;
}
#bikeListsContainer::-webkit-scrollbar-thumb {
  background: #b3d8f7;
  border-radius: 6px;
}
#bikeListsContainer::-webkit-scrollbar-track {
  background: #eaf4fb;
  border-radius: 6px;
}
#bikeListsContainer {
  scrollbar-width: thin;
  scrollbar-color: #b3d8f7 #eaf4fb;
}

/* Bike Section Header (sticky) */
.bike-rider-list h3,
#bikeListsContainer h3 {
  position: sticky;
  top: 0;
  background: #f7faff;
  z-index: 2;
  padding: 8px 0 4px 0;
  margin: 0 0 8px 0;
  border-bottom: 1px solid #b3d8f7;
  font-size: 1.1rem;
  color: #0077cc;
  font-weight: 700;
}

/* Rider Row Styles */
.rider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #f9f9f9;
  border: 1px solid #e0e0e0;
  transition: background 0.18s, box-shadow 0.18s;
  cursor: grab;
  user-select: none;
}
.rider-row:hover {
  background: #e3f2fd;
  box-shadow: 0 2px 8px #0077cc11;
}

/* Highlight the "in bike" rider */
.rider-row.in-bike {
  background: #d1f5d3 !important;
  color: #1b5e20 !important;
  font-weight: bold;
  border-left: 5px solid #43a047;
  box-shadow: 0 2px 8px #43a04722;
}

/* Responsive for mobile */
@media (max-width: 600px) {
  #bikeListsContainer {
    max-height: 45vh;
    padding-right: 2px;
  }
  .rider-row {
    font-size: 0.98rem;
    padding: 7px 4px;
  }
  .bike-rider-list h3,
  #bikeListsContainer h3 {
    font-size: 1rem;
    padding: 6px 0 2px 0;
  }
}

body.modal-open {
  overflow: hidden !important;
  position: relative;
  height: 100vh;
  width: 100vw;
  overscroll-behavior: contain;
  touch-action: none;
  /* Prevents scroll jump on iOS/Safari */
  top: 0;
  left: 0;
}


#overlayRetryBox,
.overlay-retry-box {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #23272f;
  color: #fff;
  padding: 16px 20px;
  border-radius: 12px;
  z-index: 99999;
  font-size: 1.05rem;
  box-shadow: 0 2px 16px rgba(0,0,0,0.18);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: 260px;
  max-width: 98vw;
  width: auto;
  word-break: break-word;
  text-align: center;
  overflow-x: visible;
  overflow-y: visible;
}

.overlay-retry-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  width: 100%;
  justify-content: center;
  flex-wrap: nowrap;
}

.overlay-retry-btn-row {
  display: flex;
  flex-direction: row;
  gap: 10px;
  justify-content: center;
  align-items: center;
  width: 100%;
  flex-wrap: wrap; /* Allow buttons to wrap if needed */
}

#overlayRetryBox button,
.overlay-retry-box button {
  flex-shrink: 1;
  min-width: 0;
  max-width: 100%;
  font-size: 0.98rem;
  border-radius: 6px;
  padding: 7px 18px;
  border: none;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  font-weight: 500;
  margin-left: 0;
  white-space: nowrap;
  box-sizing: border-box;
}

.overlay-retry-btn-row button + button {
  margin-left: 8px;
}

#overlayRetryBoxCancel,
.overlay-retry-cancel {
  background: #e74c3c;
  color: #fff;
}

#overlayRetryBoxEmergency,
.overlay-retry-emergency {
  background: #ff3333;
  color: #fff;
  font-weight: bold;
  box-shadow: 0 0 8px #ff3333cc;
  animation: emergencyPulse 1s infinite alternate;
}

@keyframes emergencyPulse {
  0% { box-shadow: 0 0 8px #ff3333cc; }
  100% { box-shadow: 0 0 24px #ff3333ee; }
}

#overlayRetryBoxPreview,
.overlay-retry-preview-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-right: 8px;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
  flex-shrink: 0;
  user-select: none;
  overflow: hidden;
  text-align: center;
  line-height: 1.1;
  color: #fff;
  border-radius: 50%;
  aspect-ratio: 1/1;
  min-width: 32px;
  min-height: 32px;
  font-size: 0.95rem;
  padding: 0 4px;
}

/* Responsive: on very small screens, allow wrapping and full-width buttons */
@media (max-width: 480px) {
  #overlayRetryBox,
  .overlay-retry-box {
    max-width: 98vw;
    min-width: 0;
    padding: 10px 2vw;
    font-size: 0.98rem;
    gap: 10px;
  }
  .overlay-retry-row {
    flex-direction: column;
    gap: 6px;
    width: 100%;
  }
  .overlay-retry-btn-row {
    flex-direction: row;
    gap: 8px;
    width: 100%;
    flex-wrap: wrap;
  }
  .overlay-retry-btn-row button {
    width: 100%;
    min-width: 0;
    font-size: 0.98rem;
    margin-left: 0 !important;
    margin-top: 6px;
  }
  .overlay-retry-btn-row button + button {
    margin-left: 0;
  }
  #overlayRetryBoxPreview,
  .overlay-retry-preview-circle {
    margin: 0 auto 6px auto;
  }
}





    .danger {
  background-color: #e74c3c;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}

    .danger:active {
      background: #c0392b;
    }

    #output {
      margin-top: 16px;
      font-weight: 500;
      color: var(--danger);
      min-height: 24px;
      text-align: center;
    }

    .success {
      color: var(--success);
    }

    .team-entry {
      display: flex;
      flex-direction: column; /* ✅ Vertical layout */
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      background: #f3f7fa;
      border-radius: 6px;
      padding: 10px 16px;
      margin: 6px 0;
      width: 100%;
      box-sizing: border-box;
      border: 1px solid var(--border);
    }

    .team-name {
      font-weight: 500;
      color: var(--primary-dark);
      font-size: 1.05rem;
      word-break: break-all;
      text-align: center; /* ✅ Centered text */
    }

    .join-button {
      width: auto;
      min-width: 250px;
      background: rgb(0, 203, 0); /* ✅ Green */
      color: #fff;
      border: none;
      border-radius: 6px;
      padding: 10px 18px;
      font-size: 1rem;
      font-weight: 500;
      transition: background 0.2s;
    }
    .join-button:active {
      background: #0088cc;
    }

    /* Team Page */
    #teamPage .section {
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      gap: 18px;
      width: 100%;
    }
    
    #teamPage {
  min-height: 100vh;
  width: 100%;
  box-sizing: border-box;
  position: relative;
z-index: 0;

}


    .team-buttons {
      display: flex;
      flex-wrap: wrap;
      justify-content: center; /* ✅ center on PC */
      align-items: center;
      gap: 14px;
      margin-top: 18px;
      max-width: 100%;
      width: 100%;
      padding-bottom: 60px; /* ✅ adds slight scroll buffer at bottom */
      box-sizing: border-box;
    }



    .circle-button {
      width: 68px;
      height: 68px;
      border-radius: 50%;
      border: 2px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1rem;
      font-weight: 500;
      text-align: center;
      padding: 8px;
      background: #f7fafd;
      color: var(--primary-dark);
      cursor: pointer;
      box-shadow: 0 1px 4px rgba(0,0,0,0.04);
      transition: box-shadow 0.2s, border 0.2s;
      user-select: none;
      min-width: 68px;
      min-height: 68px;
      word-break: break-word;
    }
    .circle-button:active {
      box-shadow: 0 2px 8px rgba(0,0,0,0.10);
      border-color: var(--primary);
    }

    .edit-controls {
      display: none;
      flex-direction: column;
      gap: 8px;
      margin-top: 10px;
      align-items: center;
      width: 100%;
    }
    .edit-mode-active .edit-controls {
      display: flex;
    }


  .red-dot {
  position: absolute;
  top: 8px;
  right: 14px;
  width: 12px;
  height: 12px;
  background: #e53935;
  border-radius: 50%;
  display: inline-block;
  pointer-events: none;
  z-index: 10;
}




.mobile-friendly-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
}

.mobile-friendly-form input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.switch-label {
  font-size: 1rem;
  margin: 0;
}

.mobile-friendly-form input[type="time"] {
  width: 120px;
  padding: 4px;
}

.button-row {
  display: flex;
  gap: 8px;
}

.button-row button {
  padding: 6px 10px;
  font-size: 0.95rem;
  min-width: 80px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #f5f5f5;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.button-row button:active {
  background: #e0e0e0;
}

/* Responsive styles for mobile */
@media (max-width: 600px) {
  .mobile-friendly-form {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .mobile-friendly-form input[type="time"] {
    width: 100%;
  }
  .button-row {
    flex-direction: row;
    justify-content: space-between;
    gap: 8px;
  }
  .button-row button {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 0;
    font-size: 0.95rem;
  }
}




    #mainPageMessageModal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.5);
  align-items: center; justify-content: center;
  z-index: 99999;
}
#mainPageMessageModal .modal-content {
  background: #fff;
  padding: 24px 20px;
  border-radius: 10px;
  max-width: 400px;
  width: 90vw;
  box-shadow: 0 2px 12px #0003;
  text-align: center;
}


    /* Modal */
    .modal {
      display: none;
      position: fixed;
      top: 0; left: 0;
      width: 100vw; height: 100vh;
      background: rgba(0,0,0,0.45);
      justify-content: center;
      align-items: center;
      z-index: 2000;
      touch-action: none;
  overscroll-behavior: contain;
    }
    .modal-content {
      background: #fff;
      padding: 28px 16px 20px 16px;
      border-radius: var(--radius);
      width: 95vw;
      max-width: 340px;
      text-align: center;
      box-shadow: var(--shadow);
      position: relative;
    }
    .modal-content h3 {
      margin-bottom: 18px;
      color: var(--primary-dark);
    }
    .modal-content input[type="color"] {
      width: 48px;
      height: 32px;
      border: none;
      background: none;
      margin: 0 0 0 8px;
      padding: 0;
      vertical-align: middle;
    }
    .modal-content button {
      margin: 12px 6px 0 6px;
      width: 100px;
    }


    /* Fullscreen Display */
    #fullscreenDisplay {
      position: fixed;
      top: 0; left: 0;
      width: 100vw; height: 100vh;
      background: rgba(0, 0, 0, 0.88);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 10000 !important;
      flex-direction: column;
      padding: 0 4vw;
      box-sizing: border-box;
    }
    #fullscreenDisplay .bigButton {
      width: 44vw;
      max-width: 170px;
      min-width: 120px;
      height: 44vw;
      max-height: 170px;
      min-height: 120px;
      border-radius: 50%;
      border: 4px solid #fff;
      background: var(--accent);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 2.2rem;
      color: #fff;
      text-align: center;
      padding: 16px;
      margin-bottom: 32px;
      font-weight: 600;
      box-shadow: 0 4px 24px rgba(0,0,0,0.18);
      word-break: break-word;
    }
    #fullscreenDisplay button {
      font-size: 1.1rem;
      padding: 12px 32px;
      border-radius: 8px;
      background: var(--success);
      color: #fff;
      border: none;
      font-weight: 600;
      margin-top: 18px;
      transition: background 0.2s;
      min-width: 120px;
    }
    #fullscreenDisplay button:active {
      background: #219150;
    }

    /* Mini Status Display */
    #miniStatusDisplay {
      position: fixed;
      bottom: 16px;
      right: 8px;
      background: #fff;
      border: 1.5px solid var(--border);
      border-radius: 12px;
      padding: 14px 10px;
      box-shadow: 0 2px 12px rgba(0,0,0,0.10);
      z-index: 2500;
      text-align: center;
      width: 90vw;
      max-width: 170px;
      font-size: 1rem;
    }
    #miniStatusDisplay .miniButton {
      width: 60px;
      height: 60px;
      margin: 0 auto 10px;
      border-radius: 50%;
      background: var(--accent);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1rem;
      border: 2px solid var(--border);
      color: #fff;
      font-weight: 500;
    }
    #seenStatusText {
      font-size: 1rem;
      margin-top: 8px;
      color: var(--grey);
    }

    /* Responsive */
    @media (max-width: 600px) {
      .container, .section, .modal-content {
        max-width: 98vw;
        padding: 18px 4vw;
      }
      .team-buttons {
        gap: 8px;
      }
      .circle-button {
        width: 22vw;
        min-width: 56px;
        max-width: 80px;
        height: 22vw;
        min-height: 56px;
        max-height: 80px;
        font-size: 0.95rem;
        padding: 4px;
      }
      #miniStatusDisplay {
        right: 4vw;
        bottom: 8px;
        width: 90vw;
        min-width: 0;
        padding: 12px 8px;
      }
      #fullscreenDisplay .bigButton {
        width: 60vw;
        min-width: 100px;
        max-width: 180px;
        height: 60vw;
        min-height: 100px;
        max-height: 180px;
        font-size: 1.3rem;
        padding: 8px;
      }
      #fullscreenDisplay button {
        min-width: 90px;
        font-size: 1rem;
        padding: 10px 18px;
      }
      #timerOverlay {
        padding: 18px 4vw;
        width: 92vw;
        max-width: 340px;
      }
    }

    .small-button {
  padding: 6px 10px;
  font-size: 0.8rem;
  margin-left: 5px;
}

.icon-button {
  width: 30px;
  height: 30px;
  font-size: 1rem;
  padding: 0;
  border-radius: 4px;
  text-align: center;
  line-height: 1;
  cursor: pointer;
}


.voice-button-container {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.voice-button {
  height: 100px;
  min-width: 200px;
  padding: 0 24px;
  font-size: 1.5rem;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  color: white;
  text-align: center;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.15);
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-button:active {
  transform: scale(0.98);
}

.green-button {
  background-color: #27ae60;
}
.green-button:active {
  background-color: #219150;
}

.red-button {
  background-color: #e74c3c;
}
.red-button:active {
  background-color: #c0392b;
}


@media (max-width: 600px) {
  .voice-button-container {
    flex-direction: column;
    align-items: center;
  }

  .voice-button {
    width: 100%;
    max-width: 300px;
  }
}
.tab {
  padding: 8px 14px;
  background-color: #007bff;      /* Blue background */
  color: white;                   /* White text */
  border: 2px solid black;        /* Black border */
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.tab:hover {
  background-color: #0069d9;
  transform: scale(1.02);
}

.tab.active {
  background-color: #0056b3;      /* Darker blue for active tab */
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}



#teamPage::after {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 1;
  transition: opacity 0.3s ease;
}


#startLapBtnDetail {
  background-color: #27ae60; /* Green */
  color: white;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: background-color 0.2s;
}
#startLapBtnDetail:active {
  background-color: #219150;
}

#pauseLapBtnDetail {
  background-color: #f1c40f; /* Yellow */
  color: #222;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: background-color 0.2s;
}
#pauseLapBtnDetail:active {
  background-color: #d4ac0d;
}

#stopLapBtnDetail {
  background-color: #e74c3c; /* Red */
  color: white;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: background-color 0.2s;
}
#stopLapBtnDetail:active {
  background-color: #c0392b;
}


.lap-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: 6px;
  background: #f9f9f9;
  user-select: none;
}

.lap-drag-handle {
  cursor: grab;
  font-size: 1.2rem;
  padding: 0 6px;
  user-select: none;
}

.lap-number {
  width: 24px;
  font-weight: bold;
}

.lap-time-input, .lap-notes-input {
  flex: 1;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
}

.lap-notes-input {
  max-width: 200px;
}

.lap-delete-btn {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.9rem;
}


.yellow-button {
  background-color: #f1c40f;
  color: #222;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 1rem;
  transition: background-color 0.2s;
}
.yellow-button:active {
  background-color: #d4ac0d;
}
.hide {
  display: none !important;
}


.timer-button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 12px;
  margin: 18px 0 8px 0;
  max-width: 340px;
}

.timer-button-grid button {
  width: 100%;
  min-width: 0;
  font-size: 1rem;
  padding: 12px 0;
  border-radius: 8px;
  box-sizing: border-box;
}


#mainActions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 16px 0;
}

#mainActions button {
  flex: 1 1 160px;
  min-width: 140px;
  max-width: 100%;
  padding: 14px 8px;
  font-size: 1.1rem;
  border-radius: 8px;
  border: none;
  background: #0077cc;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  margin: 0 0 8px 0;
  transition: background 0.2s;
}

#mainActions button:active {
  background: #005fa3;
}

@media (max-width: 600px) {
  #mainActions {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  #mainActions button {
    width: 100%;
    min-width: 0;
    font-size: 1rem;
    padding: 16px 0;
  }
}

#emergencyOverlayBanner {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  min-width: 100vw !important;
  z-index: 20001 !important;
  pointer-events: none !important;
  box-sizing: border-box !important;
}

