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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.controls {
    padding: 40px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.controls h2 {
    font-size: 1.3em;
    margin-bottom: 15px;
    color: #495057;
}

.club-selection {
    margin-bottom: 30px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid #e9ecef;
    font-size: 1em;
}

.checkbox-group label:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #667eea;
}

.date-selection {
    margin-bottom: 30px;
}

.date-selection input[type="date"] {
    width: 100%;
    max-width: 300px;
    padding: 12px 16px;
    font-size: 1em;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.date-selection input[type="date"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.duration-selection {
    margin-bottom: 30px;
}

.duration-select {
    width: 100%;
    max-width: 300px;
    padding: 12px 16px;
    font-size: 1em;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
}

.duration-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.time-range-selection {
    margin-bottom: 30px;
}

.time-range-selection .optional-label {
    font-weight: normal;
    color: #6c757d;
    font-size: 0.9em;
}

.time-range-inputs {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.time-range-inputs label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.time-range-inputs .time-select {
    min-width: 5rem;
    padding: 10px 12px;
    font-size: 1em;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: white;
    cursor: pointer;
}

.time-range-inputs .time-select:focus {
    outline: none;
    border-color: #667eea;
}

.search-btn {
    width: 100%;
    max-width: 300px;
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.search-btn:active {
    transform: translateY(0);
}

.loading {
    padding: 60px;
    text-align: center;
}

.loading.hidden {
    display: none;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.results {
    padding: 40px;
    color: #333;
}

.club-results {
    margin-bottom: 40px;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 30px;
    border: 1px solid #e9ecef;
}

.club-results h2 {
    color: #495057;
    margin-bottom: 20px;
    font-size: 1.5em;
    display: flex;
    align-items: center;
    gap: 10px;
}

a.club-results-link {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

a.club-results-link:hover .club-results {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.no-availability {
    color: #6c757d;
    font-style: italic;
    padding: 20px;
    text-align: center;
}

.availability-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.slot-card {
    background: white;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: all 0.3s;
}

.slot-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.slot-time {
    font-size: 1.1em;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 6px;
}

.slot-court {
    color: #495057;
    font-size: 0.9em;
    font-weight: 500;
    margin-bottom: 4px;
    padding: 2px 6px;
    background: #e9ecef;
    border-radius: 4px;
    display: inline-block;
}

.slot-duration {
    color: #6c757d;
    font-size: 0.85em;
    margin-bottom: 4px;
}

.slot-price {
    color: #28a745;
    font-weight: 600;
    font-size: 1em;
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border: 1px solid #f5c6cb;
}

@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
        color: #e9ecef;
    }

    .container {
        background: #1e1e1e;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    }

    .controls {
        background: #2d2d2d;
        border-bottom: 1px solid #404040;
    }

    .controls h2 {
        color: #e9ecef;
    }

    .checkbox-group label {
        background: #2d2d2d;
        border-color: #404040;
        color: #e9ecef;
    }

    .checkbox-group label:hover {
        border-color: #667eea;
        background: #353535;
    }

    .date-selection input[type="date"],
    .duration-select {
        background: #2d2d2d;
        border-color: #404040;
        color: #e9ecef;
    }

    .date-selection input[type="date"]:focus,
    .duration-select:focus {
        border-color: #667eea;
        background: #353535;
    }

    .club-results {
        background: #2d2d2d;
        border-color: #404040;
    }

    .club-results h2 {
        color: #e9ecef;
    }

    a.club-results-link:hover .club-results {
        border-color: #667eea;
        box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25);
    }

    .no-availability {
        color: #adb5bd;
    }

    .slot-card {
        background: #2d2d2d;
        border-color: #404040;
        color: #e9ecef;
    }

    .slot-card:hover {
        border-color: #667eea;
        background: #353535;
    }

    .slot-court {
        color: #e9ecef;
        background: #404040;
    }

    .slot-duration {
        color: #adb5bd;
    }

    .error {
        background: #3d1f1f;
        color: #ff6b6b;
        border-color: #5a2a2a;
    }

    .results {
        color: #e9ecef;
    }

    .results h2 {
        color: #e9ecef;
    }

    .spinner {
        border-color: #2d2d2d;
        border-top-color: #667eea;
    }

    .time-range-selection .optional-label {
        color: #adb5bd;
    }

    .time-range-inputs .time-select {
        background: #2d2d2d;
        border-color: #404040;
        color: #e9ecef;
    }

    .time-range-inputs .time-select:focus {
        border-color: #667eea;
        background: #353535;
    }

    .time-range-inputs label {
        color: #e9ecef;
    }

    .loading {
        color: #e9ecef;
    }
}

/* Tablet and small desktop: slightly smaller cells */
@media (max-width: 900px) {
    .availability-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }

    .slot-card {
        padding: 10px;
    }

    .slot-time {
        font-size: 1em;
        margin-bottom: 4px;
    }

    .slot-court,
    .slot-duration,
    .slot-price {
        font-size: 0.8em;
    }
}

/* Mobile: compact layout, multiple cells per row */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        padding: 20px 16px;
    }

    header h1 {
        font-size: 1.5em;
        margin-bottom: 4px;
    }

    header p {
        font-size: 0.95em;
    }

    .controls {
        padding: 16px;
    }

    .controls h2 {
        font-size: 1.1em;
        margin-bottom: 10px;
    }

    .club-selection,
    .date-selection,
    .duration-selection,
    .time-range-selection {
        margin-bottom: 16px;
    }

    .checkbox-group {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }

    .checkbox-group label {
        padding: 8px 12px;
        font-size: 0.9em;
    }

    .checkbox-group input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }

    .date-selection input[type="date"] {
        padding: 10px 12px;
        font-size: 0.95em;
    }

    .time-range-inputs .time-select {
        min-width: 4rem;
        padding: 8px 10px;
        font-size: 0.9em;
    }

    .search-btn {
        padding: 12px 20px;
        font-size: 1em;
    }

    .results {
        padding: 16px;
    }

    .club-results {
        margin-bottom: 20px;
        padding: 16px;
        border-radius: 8px;
    }

    .club-results h2 {
        margin-bottom: 12px;
        font-size: 1.2em;
    }

    .availability-grid {
        grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
        gap: 8px;
        margin-top: 12px;
    }

    .slot-card {
        padding: 8px;
        border-radius: 6px;
        border-width: 1px;
    }

    .slot-time {
        font-size: 0.95em;
        margin-bottom: 2px;
    }

    .slot-court {
        font-size: 0.75em;
        padding: 2px 4px;
        margin-bottom: 2px;
    }

    .slot-duration {
        font-size: 0.75em;
        margin-bottom: 2px;
    }

    .slot-price {
        font-size: 0.85em;
    }

    .no-availability {
        padding: 12px;
        font-size: 0.9em;
    }

    .error {
        padding: 12px;
        font-size: 0.9em;
    }

    .loading {
        padding: 30px;
    }

    .spinner {
        width: 36px;
        height: 36px;
        border-width: 3px;
        margin-bottom: 12px;
    }
}

/* Very small phones: max cells per row */
@media (max-width: 400px) {
    body {
        padding: 6px;
    }

    header {
        padding: 12px 10px;
    }

    header h1 {
        font-size: 1.25em;
    }

    header p {
        font-size: 0.85em;
    }

    .controls {
        padding: 12px;
    }

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

    .slot-card {
        padding: 6px;
    }

    .slot-time {
        font-size: 0.9em;
    }

    .slot-court,
    .slot-duration {
        font-size: 0.7em;
    }

    .slot-price {
        font-size: 0.8em;
    }
}
