:root {
    --primary-color: #0d9488;
    --primary-hover: #0f766e;
    --primary-light: #ccfbf1;
    --dark-bg: #0f172a;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --gold-color: #f59e0b;
    --silver-color: #94a3b8;
    --bronze-color: #d97706;
}

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

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

/* Hero Header */
.hero {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0d9488 100%);
    color: white;
    padding: 3.5rem 1rem 3rem;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.logo-icon {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    display: inline-block;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}

.hero p {
    font-size: 1.15rem;
    color: #94a3b8;
    font-weight: 500;
}

/* Main Container */
.container {
    max-width: 1200px;
    width: 92%;
    margin: -1.5rem auto 3rem;
    flex: 1;
}

/* Status Banner */
.status-banner {
    padding: 0.85rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.status-info { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.status-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.status-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
}

.stat-icon {
    font-size: 2.25rem;
    background: #f1f5f9;
    padding: 0.5rem;
    border-radius: 10px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
}

/* Cards Base */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

/* Config Card */
.config-card {
    background: #ffffff;
    border-left: 4px solid var(--primary-color);
}

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.config-header h3 {
    font-size: 1.1rem;
    color: var(--text-main);
}

.connect-form {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.input-url {
    flex: 1;
    min-width: 280px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-url:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.btn {
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text-main);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-text:hover {
    text-decoration: underline;
}

.instructions-panel {
    display: none;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.instructions-panel.open {
    display: block;
}

.instructions-panel ol {
    margin: 0.5rem 0 1rem 1.25rem;
}

.instructions-panel li {
    margin-bottom: 0.35rem;
}

/* Content Grid Layout */
.content-grid {
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* Leaderboard Table */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
}

.table-controls {
    display: flex;
    gap: 0.75rem;
}

.input-search, .select-sort {
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
}

.input-search:focus, .select-sort:focus {
    border-color: var(--primary-color);
}

.table-wrapper {
    overflow-x: auto;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.leaderboard-table th {
    padding: 0.85rem 1rem;
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
}

.leaderboard-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
    vertical-align: middle;
}

.leaderboard-table tr:hover {
    background-color: #f1f5f9;
}

.rank-badge {
    font-weight: 700;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    display: inline-block;
}

.rank-gold { background: #fef3c7; color: var(--gold-color); }
.rank-silver { background: #f1f5f9; color: #475569; }
.rank-bronze { background: #ffedd5; color: var(--bronze-color); }
.rank-normal { color: var(--text-muted); }

.player-name {
    font-weight: 600;
}

.elo-score {
    color: var(--primary-color);
    font-size: 1.05rem;
}

.winrate-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.winrate-text {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 35px;
}

.winrate-bar {
    width: 80px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.winrate-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 3px;
}

.form-list {
    display: flex;
    gap: 4px;
}

.form-pill {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
}

.form-pill.win { background: var(--success-color); }
.form-pill.loss { background: var(--danger-color); }
.form-pill.neutral { background: var(--text-muted); }

.upset-tag {
    font-size: 0.7rem;
    font-weight: 700;
    background: #fee2e2;
    color: #ef4444;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.4rem;
}

/* Match History Feed */
.match-feed-card h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.match-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.match-card {
    padding: 0.85rem;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.match-details {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.match-winner {
    color: var(--primary-color);
}

.match-vs {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 400;
}

.match-loser {
    color: var(--text-main);
}

.match-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.match-score {
    font-weight: 700;
    color: var(--text-main);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 1rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}
