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

:root {
    /* Blue and white professional theme */
    --primary-blue: #2563eb;
    --primary-blue-dark: #1e40af;
    --primary-blue-light: #3b82f6;
    --success-green: #10b981;
    --danger-red: #ef4444;
    --warning-yellow: #f59e0b;
    
    /* Background colors */
    --bg-main: #f8fafc;
    --bg-white: #ffffff;
    --bg-header: #1e293b;
    
    /* Text colors */
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --text-white: #ffffff;
    
    /* Borders and dividers */
    --border-color: #e2e8f0;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Header */
.top-header {
    background: var(--bg-header);
    color: var(--text-white);
    padding: 8px 12px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 16px;
}

.logo-icon {
    font-size: 20px;
}

.logo-text {
    letter-spacing: -0.3px;
}

/* Top Navigation */
.top-nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    flex: 1;
    justify-content: flex-end;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
    white-space: nowrap;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
}

.nav-item.active {
    background: var(--primary-blue);
    color: var(--text-white);
}

.nav-icon {
    font-size: 14px;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page {
    display: none;
    animation: fadeIn 0.2s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cards */
.card {
    background: var(--bg-white);
    border-radius: 8px;
    padding: 16px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    max-width: 100%;
    margin: 0 auto;
}

.card h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.card-header h2 {
    margin-bottom: 0;
}

.filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filters select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filters select:hover,
.filters select:focus {
    border-color: var(--primary-blue);
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Form Elements */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 12px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.form-group input::placeholder {
    color: var(--text-light);
}

/* Buttons */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    box-shadow: var(--shadow-sm);
    margin-top: 4px;
}

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

.btn-primary:hover {
    background: var(--primary-blue-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success-green);
    color: var(--text-white);
}

.btn-success:hover {
    background: #059669;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Scores List */
.scores-list {
    max-height: 500px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Tabular header for top scores */
.table-view {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.2fr 0.9fr 1fr 1fr;
    gap: 8px;
    padding: 10px 8px;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 4px 4px 0 0;
    margin-bottom: 0;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.score-item {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    gap: 12px;
}

.score-item:hover {
    border-color: var(--primary-blue);
    box-shadow: var(--shadow-sm);
}

/* Tabular layout for top scores */
.score-item-tabular {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.2fr 0.9fr 1fr 1fr;
    gap: 8px;
    padding: 10px 8px;
    margin-bottom: 0;
    border-top: none;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-white);
    align-items: center;
    font-size: 13px;
    transition: all 0.2s ease;
}

.score-item-tabular:last-child {
    border-radius: 0 0 4px 4px;
}

.score-item-tabular:hover {
    background: #f8fafc;
    border-color: var(--primary-blue);
}

.tabular-song {
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tabular-artist {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tabular-player {
    color: var(--text-primary);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tabular-difficulty {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

.tabular-score {
    font-weight: 700;
    color: var(--primary-blue);
    font-size: 14px;
    text-align: right;
    white-space: nowrap;
}

.tabular-date {
    color: var(--text-secondary);
    font-size: 11px;
    white-space: nowrap;
}

.score-item-compact {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
}

.score-song-artist {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.score-details {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.score-player {
    font-weight: 500;
}

.score-separator {
    color: var(--text-light);
}

.score-difficulty,
.score-date {
    color: var(--text-secondary);
}

.score-info {
    flex: 1;
    min-width: 0;
}

.score-info h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score-info p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary-blue);
    flex-shrink: 0;
}

.score-value.top-score {
    color: var(--warning-yellow);
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-style: italic;
    font-size: 13px;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-weight: 800;
    margin-right: 8px;
    font-size: 12px;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.rank-badge.gold {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #000;
}

.rank-badge.silver {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    color: #000;
}

.rank-badge.bronze {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #fff;
}

.rank-badge.other {
    background: var(--primary-blue);
    color: #fff;
}

/* Scrollbar */
.scores-list::-webkit-scrollbar,
.players-list::-webkit-scrollbar {
    width: 6px;
}

.scores-list::-webkit-scrollbar-track,
.players-list::-webkit-scrollbar-track {
    background: transparent;
}

.scores-list::-webkit-scrollbar-thumb,
.players-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.scores-list::-webkit-scrollbar-thumb:hover,
.players-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 16px;
    right: 16px;
    background: var(--success-green);
    color: white;
    padding: 10px 16px;
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideIn 0.3s ease;
    font-weight: 600;
    font-size: 13px;
    max-width: calc(100% - 32px);
}

.toast.error {
    background: var(--danger-red);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading State */
.loading {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Players List */
.players-list {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 16px;
}

.player-item {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    gap: 12px;
}

.player-item:hover {
    border-color: var(--primary-blue);
    box-shadow: var(--shadow-sm);
}

.player-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-delete {
    padding: 5px 12px;
    font-size: 11px;
    background: var(--danger-red);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    flex-shrink: 0;
}

.btn-delete:hover {
    background: #dc2626;
    box-shadow: var(--shadow-sm);
}

/* Responsive Design */
@media (max-width: 768px) {
    .top-header {
        padding: 6px 8px;
    }
    
    .header-content {
        gap: 8px;
    }
    
    .logo {
        font-size: 14px;
    }
    
    .logo-icon {
        font-size: 18px;
    }
    
    .top-nav {
        gap: 2px;
        width: 100%;
        order: 3;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .top-nav::-webkit-scrollbar {
        display: none;
    }
    
    .nav-item {
        padding: 6px 10px;
        font-size: 12px;
        gap: 4px;
    }
    
    .nav-icon {
        font-size: 12px;
    }
    
    .main-content {
        padding: 8px;
    }
    
    .card {
        padding: 12px;
        border-radius: 6px;
    }
    
    .card h2 {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .form-group {
        margin-bottom: 10px;
    }
    
    .form-group label {
        font-size: 11px;
        margin-bottom: 4px;
    }
    
    .form-group input,
    .form-group select {
        padding: 7px 9px;
        font-size: 13px;
    }
    
    .btn {
        padding: 9px 14px;
        font-size: 13px;
    }
    
    .score-item {
        padding: 10px 12px;
    }
    
    .table-view,
    .score-item-tabular {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        font-size: 12px;
        padding: 8px 6px;
    }
    
    .table-view > div:nth-child(n+3),
    .score-item-tabular > div:nth-child(n+3) {
        grid-column: span 2;
        font-size: 11px;
    }
    
    .tabular-score {
        text-align: left !important;
        grid-column: 1;
    }
    
    .tabular-date {
        grid-column: 2;
        text-align: right;
    }
    
    .score-item-compact {
        grid-template-columns: auto 1fr;
        gap: 8px;
    }
    
    .score-item-compact .score-value {
        grid-column: 1 / -1;
        justify-self: end;
        margin-top: -8px;
    }
    
    .score-song-artist {
        font-size: 13px;
    }
    
    .score-details {
        font-size: 11px;
        grid-column: 1 / -1;
    }
    
    .score-info h3 {
        font-size: 13px;
    }
    
    .score-info p {
        font-size: 11px;
    }
    
    .score-value {
        font-size: 16px;
    }
    
    .rank-badge {
        width: 22px;
        height: 22px;
        font-size: 11px;
        margin-right: 6px;
    }
    
    .scores-list {
        max-height: 400px;
    }
    
    .toast {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* Import Page Styles */
.format-info {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
}

.format-info h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.format-section p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.5;
}

.format-section ul {
    margin-left: 20px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.format-section li {
    margin-bottom: 4px;
}

.format-section pre {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    font-size: 12px;
    overflow-x: auto;
    margin-top: 8px;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
}

.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'Courier New', monospace;
    transition: all 0.2s ease;
    resize: vertical;
    line-height: 1.5;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.import-results {
    margin-top: 20px;
    padding: 16px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #f8fafc;
}

.import-results h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.import-success {
    color: var(--success-green);
    font-size: 13px;
    margin-bottom: 12px;
    font-weight: 600;
}

.import-errors {
    color: var(--danger-red);
    font-size: 13px;
}

.import-errors ul {
    margin-left: 20px;
    margin-top: 8px;
}

.import-errors li {
    margin-bottom: 4px;
}

@media (max-width: 480px) {
    .logo-text {
        display: none;
    }
    
    .nav-item span:not(.nav-icon) {
        display: none;
    }
    
    .nav-item {
        padding: 8px;
        min-width: 40px;
        justify-content: center;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filters {
        width: 100%;
    }
    
    .filters select {
        flex: 1;
        min-width: 0;
    }
}