* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 5px;
    background: #f5f5f5;
}

header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

h1 {
    color: #333;
    margin: 0;
    font-size: 1.2rem;
}

.server-time {
    font-size: 0.9rem;
    color: #666;
    font-family: monospace;
}

.viewer-stats {
    display: flex;
    gap: 10px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.85rem;
    color: #666;
    background: #e8e8e8;
    padding: 2px 8px;
    border-radius: 12px;
}

.stat-icon {
    width: 14px;
    height: 14px;
}

.viewer-stats-table {
    margin: 10px auto;
    font-size: 0.8rem;
    color: #666;
    border-collapse: collapse;
}

.viewer-stats-table td {
    padding: 2px 6px;
    vertical-align: middle;
}

.courts-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
    max-width: 1400px;
    margin: 0 auto;
}

.court {
    background: white;
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.court-header {
    font-size: 1rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.court-status {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 6px;
    border-radius: 4px;
    margin-bottom: 5px;
}

.timestamp {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.8;
    margin-top: 2px;
}

.court-buttons {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.status-btn {
    padding: 5px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: opacity 0.2s, transform 0.1s;
}

.status-btn:hover:not(:disabled) {
    opacity: 0.85;
    transform: scale(1.02);
}

.status-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Status colors */
.status-tom {
    background: #e0e0e0;
    color: #666;
}

.status-spiller {
    background: #4caf50;
    color: white;
}

.status-opvarmer {
    background: #ff9800;
    color: white;
}

.status-kaldt-ud {
    background: #2196f3;
    color: white;
}

.status-færdig {
    background: #f44336;
    color: white;
}

/* Location list */
.location-list {
    max-width: 400px;
    margin: 20px auto;
    text-align: center;
}

.location-list h2 {
    font-size: 1rem;
    color: #666;
    margin-bottom: 10px;
}

.location-link {
    display: block;
    padding: 12px;
    margin: 5px 0;
    background: white;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.location-link:hover {
    background: #f0f0f0;
}

.location-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 5px 0;
}

.location-item .location-link {
    flex: 1;
    margin: 0;
}

.btn-delete {
    padding: 8px 12px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-delete:hover {
    background: #d32f2f;
}

.admin-link, .back-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    color: #666;
    text-decoration: none;
    font-size: 0.9rem;
}

.admin-link:hover, .back-link:hover {
    color: #333;
}

/* Admin page */
.admin-container {
    max-width: 500px;
    margin: 0 auto;
}

.master-login {
    background: white;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.master-login h2 {
    font-size: 1rem;
    margin: 0 0 10px 0;
}

.btn-login {
    padding: 8px 15px;
    background: #9c27b0;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap;
}

.btn-login:hover {
    background: #7b1fa2;
}

.master-badge {
    background: #9c27b0;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    margin-bottom: 15px;
}

.master-badge-global {
    position: fixed;
    top: 5px;
    left: 5px;
    background: #9c27b0;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 1000;
}

.pin-display {
    display: block;
    font-size: 0.75rem;
    color: #9c27b0;
    font-weight: 600;
    margin-top: 2px;
}

.create-location {
    background: white;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.create-location h2 {
    font-size: 1rem;
    margin: 0 0 10px 0;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row .form-group {
    flex: 1;
}

.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 3px;
}

.form-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.btn-create {
    width: 100%;
    padding: 10px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.btn-create:hover {
    background: #43a047;
}

.error {
    color: #f44336;
    font-size: 0.85rem;
    margin: 5px 0;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 280px;
    text-align: center;
}

.modal h2 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
}

.modal p {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 15px;
}

.modal input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 8px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn-cancel, .btn-confirm {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.btn-cancel {
    background: #e0e0e0;
    color: #666;
}

.btn-confirm {
    background: #4caf50;
    color: white;
}

.btn-unlock {
    display: block;
    margin: 15px auto;
    padding: 10px 20px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.btn-unlock:hover {
    background: #1e88e5;
}

.auth-status.locked {
    font-size: 0.75rem;
    background: #f44336;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Responsive */
@media (max-width: 600px) {
    .courts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 400px) {
    .courts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
