/* Modern CSS Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables for theming */
:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --accent-color: #06d6a0;
    --warning-color: #fbbf24;
    --danger-color: #ef4444;
    --success-color: #10b981;
    
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-hover: #1e2749;
    
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    --border-color: #27272a;
    --border-hover: #3f3f46;
    
    --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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Base Styles */
body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

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

.logo {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    object-fit: cover;
    box-shadow: var(--shadow-md);
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.stat-item {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    text-align: center;
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.section-title {
    font-size: 1.875rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    text-align: center;
}

/* Positions Section */
.positions-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

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

.position-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    text-align: center;
    position: relative;
    transition: all 0.3s ease;
    overflow: hidden;
}

.position-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.position-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.first-place {
    border-color: #ffd700;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(255, 215, 0, 0.1) 100%);
}

.first-place::before {
    background: linear-gradient(90deg, #ffd700, #ffed4e);
}

.second-place {
    border-color: #c0c0c0;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(192, 192, 192, 0.1) 100%);
}

.second-place::before {
    background: linear-gradient(90deg, #c0c0c0, #e5e5e5);
}

.position-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 0.875rem;
}

.crown, .medal {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.player-name {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.player-status {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.position-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.online {
    color: var(--success-color);
}

.offline {
    color: var(--text-muted);
}

/* Scoreboard Section */
.scoreboard-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    flex: 1;
}

.scoreboard-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.toggle-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.toggle-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.toggle-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.scoreboard-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.scoreboard-header {
    display: grid;
    grid-template-columns: 80px 1fr 120px 100px;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.scoreboard-body {
    max-height: 500px;
    overflow-y: auto;
}

.player-row {
    display: grid;
    grid-template-columns: 80px 1fr 120px 100px;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    transition: all 0.2s ease;
}

.player-row:hover {
    background: var(--bg-hover);
}

.player-row:last-child {
    border-bottom: none;
}

.rank {
    font-weight: 700;
    font-size: 1.125rem;
}

.rank-1 { color: #ffd700; }
.rank-2 { color: #c0c0c0; }
.rank-3 { color: #cd7f32; }

.player-name-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.points {
    font-weight: 600;
    color: var(--accent-color);
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 500;
}

.status-online {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success-color);
}

.status-offline {
    background: rgba(113, 113, 122, 0.2);
    color: var(--text-muted);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.loading-spinner {
    padding: 3rem;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Footer */
.footer {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.last-updated {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.refresh-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.refresh-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

/* Connection Status */
.connection-status {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: all 0.3s ease;
}

.connection-status.connected .status-dot {
    background: var(--success-color);
    animation: pulse 2s infinite;
}

.connection-status.disconnected {
    border-color: var(--danger-color);
}

.connection-status.disconnected .status-dot {
    background: var(--danger-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }
    
    .header {
        padding: 1rem;
    }
    
    .title {
        font-size: 2rem;
    }
    
    .logo {
        width: 48px;
        height: 48px;
    }
    
    .stats-bar {
        grid-template-columns: 1fr;
    }
    
    .positions-grid {
        grid-template-columns: 1fr;
    }
    
    .scoreboard-header,
    .player-row {
        grid-template-columns: 60px 1fr 80px 80px;
        gap: 0.5rem;
        padding: 0.75rem;
        font-size: 0.875rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .footer {
        flex-direction: column;
        text-align: center;
    }
    
    .connection-status {
        position: relative;
        top: auto;
        right: auto;
        margin-bottom: 1rem;
        align-self: flex-end;
    }
}

@media (max-width: 480px) {
    .scoreboard-header,
    .player-row {
        grid-template-columns: 50px 1fr 70px;
        gap: 0.25rem;
    }
    
    .status-col {
        display: none;
    }
    
    .player-row .status-indicator {
        display: none;
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    :root {
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
        --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-md);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}
