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

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a1a;
    color: #e8e8e8;
    min-height: 100vh;
    padding: 8px;
    line-height: 1.4;
    margin: 0;
    position: relative;
}

.judge-display {
    position: absolute;
    top: -10px;
    right: 20px;
    background: #2a2a2a;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #404040;
    font-size: 14px;
    color: #e8e8e8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.judge-display span:first-child {
    color: #a8a8a8;
    font-weight: 500;
}

.judge-display span:last-child {
    color: #6b73ff;
    font-weight: 600;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background: #2a2a2a;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    margin-bottom: 20px;
    color: #c0c0c0;
    font-size: 0.9rem;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #404040;
    border-top: 2px solid #6b73ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

header h1 {
    text-align: center;
    color: #f0f0f0;
    margin-bottom: 12px;
    font-size: 1.3rem;
    font-weight: 500;
    letter-spacing: -0.02em;
}



.team-selection {
    margin-bottom: 16px;
}

.team-selection label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #c0c0c0;
    font-size: 0.85rem;
}

.search-dropdown input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #404040;
    border-radius: 12px;
    font-size: 16px;
    background: #333333;
    color: #e8e8e8;
    transition: all 0.2s ease;
}

.search-dropdown input:focus {
    outline: none;
    border-color: #6b73ff;
    box-shadow: 0 0 0 3px rgba(107, 115, 255, 0.1);
}

.search-dropdown {
    position: relative;
    width: 100%;
}

.clear-search-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    color: #888;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.clear-search-btn:hover {
    background: #404040;
    color: #e8e8e8;
}

.dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #333333;
    border: 1px solid #404040;
    border-top: none;
    border-radius: 0 0 12px 12px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #404040;
    transition: background-color 0.2s ease;
    color: #e8e8e8;
    font-size: 14px;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover, .dropdown-item.highlighted {
    background: #404040;
}

.dropdown-item.selected {
    background: #6b73ff;
    color: #ffffff;
}

.search-dropdown input.has-selection {
    border-radius: 12px 12px 0 0;
}


.rating-form {
    margin-top: 16px;
}

.rating-form h2 {
    color: #f0f0f0;
    margin-bottom: 28px;
    text-align: center;
    font-weight: 500;
    font-size: 1.3rem;
}

.criteria {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.criterion {
    background: #333333;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #404040;
    position: relative;
    transition: all 0.2s ease;
}

.criterion:hover {
    background: #363636;
    border-color: #505050;
}

.criterion:nth-child(1) {
    border-left: 3px solid #ff9f9f;
}

.criterion:nth-child(2) {
    border-left: 3px solid #9fff9f;
}

.criterion:nth-child(3) {
    border-left: 3px solid #9f9fff;
}

.criterion:nth-child(4) {
    border-left: 3px solid #ff9fff;
}

.criterion:nth-child(5) {
    border-left: 3px solid #ffff9f;
}

.criterion label {
    display: block;
    font-weight: 500;
    color: #e8e8e8;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.criterion-hint {
    color: #a8a8a8;
    font-size: 0.75rem;
    margin-bottom: 8px;
    line-height: 1.3;
    font-style: italic;
}

.rating-scale {
    display: flex;
    align-items: center;
    gap: 18px;
}

.rating-scale input[type="range"] {
    flex: 1;
    height: 4px;
    background: #505050;
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.rating-scale input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #6b73ff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rating-scale input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 8px rgba(107, 115, 255, 0.1);
}

.rating-scale input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #6b73ff;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.rating-value {
    font-size: 1.1rem;
    font-weight: 600;
    min-width: 32px;
    text-align: center;
    color: #6b73ff;
    background: rgba(107, 115, 255, 0.1);
    padding: 4px 8px;
    border-radius: 8px;
}

.actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 16px;
}

.actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

#saveRating {
    background: #4ade80;
    color: #1a1a1a;
}

#saveRating:hover:not(:disabled) {
    background: #22c55e;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
}

#saveRating:disabled {
    background: #2a5a3a;
    color: #a0a0a0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}


#nextTeam {
    background: #6b73ff;
    color: #ffffff;
}

#nextTeam:hover:not(:disabled) {
    background: #5b63ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(107, 115, 255, 0.3);
}

#nextTeam:disabled {
    background: #4a4a5a;
    color: #a0a0a0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.total-score {
    text-align: center;
    font-size: 1.1rem;
    color: #f0f0f0;
    background: #333333;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #404040;
    font-weight: 600;
    margin-bottom: 16px;
}

.status {
    margin-top: 20px;
    padding: 12px 16px;
    border-radius: 12px;
    text-align: center;
    font-weight: 500;
    font-size: 0.9rem;
}

.status.success {
    background: rgba(74, 222, 128, 0.1);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.status.error {
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.status.info {
    background: rgba(107, 115, 255, 0.1);
    color: #6b73ff;
    border: 1px solid rgba(107, 115, 255, 0.2);
}

/* Spreadsheet Link */
.spreadsheet-link {
    margin-top: 24px;
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #404040;
}

.spreadsheet-link a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #333333;
    color: #e8e8e8;
    text-decoration: none;
    border-radius: 12px;
    border: 1px solid #505050;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.spreadsheet-link a:hover {
    background: #404040;
    border-color: #606060;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.link-icon {
    font-size: 1rem;
    filter: grayscale(0.2);
}

.external-icon {
    font-size: 0.9rem;
    color: #e8e8e8;
    margin-left: 6px;
    opacity: 0.8;
}


/* Mobile Optimizations */
@media (max-width: 768px) {
    body {
        padding: 16px 12px;
    }
    
    .judge-display {
        top: -8px;
        right: 16px;
        font-size: 13px;
        padding: 6px 12px;
    }
    
    .container {
        padding: 24px 20px;
        border-radius: 16px;
    }
    
    header h1 {
        font-size: 1.5rem;
        margin-bottom: 28px;
    }
    
    .team-selection {
        margin-bottom: 24px;
    }
    
    .rating-form {
        margin-top: 28px;
    }
    
    .rating-form h2 {
        font-size: 1.2rem;
        margin-bottom: 24px;
    }
    
    .criteria {
        gap: 16px;
        margin-bottom: 28px;
    }
    
    .criterion {
        padding: 20px 16px;
    }
    
    .criterion-hint {
        margin-bottom: 14px;
    }
    
    .rating-scale {
        gap: 14px;
    }
    
    .rating-value {
        min-width: 28px;
        font-size: 1rem;
    }
    
    .total-score {
        padding: 20px;
        margin-bottom: 24px;
        font-size: 1.2rem;
    }
    
    .actions {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 24px;
    }
    
    .actions button {
        width: 100%;
        min-width: unset;
        padding: 16px 20px;
    }
    
    
    .spreadsheet-link {
        margin-top: 20px;
        padding-top: 16px;
    }
    
    .spreadsheet-link a {
        padding: 14px 20px;
        font-size: 0.9rem;
        width: 100%;
        max-width: 280px;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px 8px;
    }
    
    .judge-display {
        top: -6px;
        right: 12px;
        font-size: 12px;
        padding: 5px 10px;
    }
    
    .container {
        padding: 20px 16px;
        margin: 0;
    }
    
    header h1 {
        font-size: 1.3rem;
        margin-bottom: 24px;
    }
    
    .team-selection {
        margin-bottom: 20px;
    }
    
    .rating-form {
        margin-top: 24px;
    }
    
    .rating-form h2 {
        margin-bottom: 20px;
    }
    
    .criteria {
        gap: 14px;
        margin-bottom: 24px;
    }
    
    .criterion {
        padding: 16px 14px;
    }
    
    .criterion label {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }
    
    .criterion-hint {
        font-size: 0.8rem;
        margin-bottom: 12px;
    }
    
    .rating-scale {
        gap: 12px;
    }
    
    .search-dropdown input {
        padding: 12px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .dropdown-list {
        max-height: 160px;
    }
    
    .dropdown-item {
        padding: 14px;
        font-size: 14px;
        min-height: 44px; /* Touch-friendly minimum size */
        display: flex;
        align-items: center;
    }
    
    .dropdown-list {
        max-height: 180px;
    }
    
    .total-score {
        font-size: 1.1rem;
        padding: 18px 16px;
        margin-bottom: 20px;
    }
    
    .actions {
        gap: 10px;
        margin-bottom: 20px;
    }
    
    .actions button {
        padding: 14px 16px;
        font-size: 0.9rem;
    }
    
    
    .spreadsheet-link {
        margin-top: 16px;
        padding-top: 14px;
    }
    
    .spreadsheet-link a {
        padding: 12px 16px;
        font-size: 0.85rem;
        max-width: 100%;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .rating-scale input[type="range"]::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }
    
    .rating-scale input[type="range"]::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }
    
    .actions button {
        padding: 16px 32px;
        min-height: 48px;
    }
    
}