:root {
    --primary-color: #1a4d72;
    --secondary-color: #2d5aa0;
    --accent-color: #e74c3c;
    --accent-color-hover: #c0392b;
    --danger-color: #dc3545;
    --danger-color-hover: #c82333;
}

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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: #333;
    min-height: 100vh;
}

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: white;
    padding: 5px;
}

.title {
    font-size: 1.8rem;
    font-weight: bold;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

.auth-section {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-color-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    color: white;
    border: 2px solid white;
}

.btn-secondary:hover {
    background: white;
    color: var(--primary-color);
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}
.btn-danger:hover {
    background: var(--danger-color-hover);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.card {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-left: 4px solid var(--accent-color);
}

.tabs {
    display: flex;
    background: white;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.tab {
    flex: 1;
    padding: 1rem;
    background: #f8f9fa;
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    border-right: 1px solid #ddd;
}

.tab:last-child {
    border-right: none;
}

.tab.active {
    background: var(--primary-color);
    color: white;
}

.tab:hover:not(.active) {
    background: #e9ecef;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.group-section {
    margin-bottom: 2rem;
}

.group-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary-color); 
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
}

.players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.player-card {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid #ddd;
    transition: all 0.3s ease;
    min-height: 120px; 
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.player-card.unavailable {
    opacity: 0.4;
    background: #e9ecef;
}


.player-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.player-name {
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.player-stats {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem; 
}

.player-card-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.challenges-remaining {
    background: var(--accent-color);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    flex-shrink: 0; 
}

.player-card-admin-buttons-container .btn-secondary {
    background: #6c757d; 
    color: white; 
    border: none; 
}

.player-card-admin-buttons-container .btn-secondary:hover {
    background: #5a6268;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.activity-result {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border-left: 4px solid #28a745; 
}

.activity-result.race { border-left-color: #28a745; }
.activity-result.sprint { border-left-color: #ffc107; }
.activity-result.agility-drill { border-left-color: #007bff; }
.activity-result.power { border-left-color: #9c27b0; }

.activity-date {
    font-size: 0.8rem;
    color: #666;
    float: right;
}

.admin-only, .player-only, .interactive-only {
    display: none;
}

.admin-mode .interactive-only,
.player-mode .interactive-only {
    display: block;
}

.admin-mode .admin-only {
    display: block;
}
.player-mode .player-only {
    display: block;
}
.player-mode .admin-only {
    display: none;
}
.admin-mode .player-only {
    display: none;
}
.player-mode #challenger-form-group {
    display: none;
}
#player-challenge-name {
    margin-bottom: 1rem;
    padding: 10px;
    background-color: #f0f0f0;
    border-radius: 5px;
    border: 2px solid #ddd;
}

.hidden {
    display: none !important;
}

#logged-out-buttons {
    display: flex;
    gap: 1rem;
}
.admin-mode #logged-out-buttons,
.player-mode #logged-out-buttons {
    display: none;
}

.statistics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.upcoming-races { 
    max-height: 400px;
    overflow-y: auto;
}

.race-item { 
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    flex-wrap: wrap; 
}

.race-players { 
    font-weight: bold;
    color: var(--primary-color);
    flex-basis: 60%; 
    min-width: 150px; 
}

.race-type { 
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    background: var(--accent-color);
    color: white;
    flex-shrink: 0; 
    margin-left: auto; 
}

.race-type.race { background: #28a745; }
.race-type.sprint { background: #ffc107; color: #333; }
.race-type.agility-drill { background: #007bff; }
.race-type.power { background: #9c27b0; }

.collapsible-group-section,
.collapsible-activity-section {
    background: white;
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.group-summary,
.activity-summary {
    display: block; 
    padding: 1rem 1.5rem;
    background: var(--primary-color); 
    color: white;
    font-weight: bold;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
    user-select: none; 
}

.activity-summary {
    background: var(--secondary-color); 
    padding-left: 2.5rem; 
}

.group-summary::-webkit-details-marker,
.activity-summary::-webkit-details-marker {
    display: none;
}

.group-summary::before,
.activity-summary::before {
    content: '▶'; 
    position: absolute;
    left: 1rem;
    font-size: 0.8em;
    transition: transform 0.2s;
}

.collapsible-activity-section .activity-summary::before {
    left: 1.5rem; 
}

details[open] > .group-summary::before,
details[open] > .activity-summary::before {
    transform: rotate(90deg);
}

.group-content,
.activity-content {
    padding: 1rem;
    background: #fefefe; 
    border-top: 1px solid #eee;
}

.collapsible-activity-section .activity-content {
    padding-left: 2rem; 
}

.leaderboard-item {
    display: flex;
    align-items: center;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.leaderboard-position {
    font-size: 1.5rem;
    font-weight: bold;
    width: 40px;
    text-align: center;
    margin-right: 1rem;
    color: var(--primary-color);
}

.leaderboard-info { flex-grow: 1; }

.leaderboard-name {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.leaderboard-group { font-size: 0.9rem; color: #666; }
.leaderboard-stats { font-size: 0.8rem; color: #777; margin-top: 0.2rem; }

.leaderboard-score {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent-color);
}

.group-champion-card {
    background: linear-gradient(135deg, #FFD700 0%, #FFA000 100%);
    color: #333;
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 1rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.champion-name { font-size: 1.5rem; font-weight: bold; margin-bottom: 0.5rem; }
.champion-group { font-size: 1rem; color: #555; margin-bottom: 0.5rem; }
.champion-stats { font-size: 0.9rem; color: #777; }

.list-management { list-style: none; padding: 0; }
.list-management li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 0.7rem 1rem;
    border-radius: 5px;
    margin-bottom: 0.5rem;
    border: 1px solid #ddd;
}
.list-management li span { font-weight: bold; color: var(--primary-color); }

.player-detail-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    text-align: center;
}
.player-detail-summary div { font-size: 1.2rem; font-weight: bold; color: var(--primary-color); }
.player-detail-summary span { font-size: 0.8rem; color: #666; display: block; text-transform: uppercase; }

.details-section-header {
    color: var(--primary-color);
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.details-list { max-height: 200px; overflow-y: auto; padding-right: 10px; }
.details-list-item { background: #f8f9fa; padding: 0.75rem; border-radius: 5px; margin-bottom: 0.5rem; font-size: 0.9rem; }
.details-list-item.win { border-left: 4px solid #28a745; }
.details-list-item.loss { border-left: 4px solid var(--danger-color); }
.details-list-item.pending { border-left: 4px solid #ffc107; }

.clickable-name { cursor: pointer; text-decoration: underline; color: var(--primary-color); font-weight: bold; }

.info-icon {
    display: inline-block;
    margin-left: 12px;
    font-size: 1.2rem;
    color: #fff;
    background-color: var(--secondary-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease-in-out;
    user-select: none;
    vertical-align: middle;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.info-icon:hover {
    background-color: var(--accent-color);
    transform: scale(1.15) rotate(10deg);
}

.formula-breakdown { list-style: none; padding: 0; margin-top: 1rem; }
.formula-breakdown li { background-color: #f8f9fa; border-left: 4px solid var(--primary-color); padding: 10px; margin-bottom: 0.75rem; line-height: 1.5; border-radius: 4px; }

.color-picker-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border: 1px solid #eee;
    padding: 10px;
    border-radius: 5px;
}
.color-picker-group input[type="color"] {
    width: 50px;
    height: 30px;
    border: none;
    padding: 0;
    cursor: pointer;
    background: none;
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.card-header-flex h2 {
    margin-bottom: 0;
}

#challenger-token-display {
    background-color: #f0f0f0;
    border-radius: 8px;
    padding: 8px 12px;
    text-align: center;
    border: 2px solid #ddd;
    flex-shrink: 0;
}
.token-count-label {
    font-size: 0.9rem;
    color: #666;
    margin-right: 8px;
}
.token-count-number {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.randomizer-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.spinner-container {
    height: 100px;
    overflow: hidden;
    position: relative;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: linear-gradient(to bottom, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 20%, rgba(255,255,255,0) 80%, rgba(255,255,255,1) 100%);
}

#activity-spinner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    animation: spin 3s ease-out forwards;
}

#activity-spinner div {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.selected-activity {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    margin-top: 0.5rem;
}

#selected-activity-players {
    font-size: 1.5rem;
    color: var(--primary-color);
    display: block;
    margin-top: 0.5rem;
}

#activity-result-display p {
    text-align: center;
    font-size: 1rem;
    color: #666;
    font-weight: bold;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.availability-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.availability-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.availability-card {
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease-in-out;
}

.availability-card.is-active {
    background-color: #e8f5e9; /* Light green */
    border-color: #4caf50;
}

.availability-card-name {
    font-weight: bold;
    color: #333;
}


/* Toggle Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

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

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

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

input:checked + .slider {
  background-color: #28a745;
}

input:focus + .slider {
  box-shadow: 0 0 1px #28a745;
}

input:checked + .slider:before {
  -webkit-transform: translateX(22px);
  -ms-transform: translateX(22px);
  transform: translateX(22px);
}


@keyframes spin {
    0% {
        transform: translateY(-100%);
    }
    100% {
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .header-content { flex-direction: column; gap: 1rem; }
    .tabs { flex-direction: column; }
    .tab { border-right: none; border-bottom: 1px solid #ddd; }
    .tab:last-child { border-bottom: none; }
    .players-grid { grid-template-columns: 1fr; }
    .player-card-bottom-row { flex-direction: column; align-items: flex-start; }
    .admin-mode .player-card-admin-buttons-container { width: 100%; justify-content: flex-start; }
    .race-item .admin-only, .race-item .player-only { width: 100%; margin-top: 0.5rem; }
}
