/*
 * style.css  —  Челси Mini App
 * Primary: #034694 (Chelsea blue)
 * Secondary: #DBA111 (gold)
 * Accent: white
 */

:root {
    --blue: #034694;
    --blue-light: #0563c1;
    --blue-dark: #022d5c;
    --gold: #DBA111;
    --gold-light: #f0c040;
    --bg: #0a1628;
    --bg-card: #0f1f38;
    --bg-card-hover: #14284a;
    --text: #e8e8e8;
    --text-dim: #8899b0;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

[data-theme="light"] {
    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --bg-card-hover: #e8edf2;
    --text: #1a1a2e;
    --text-dim: #667788;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: 20px;
}

/* ── Demo banner ── */
#demo-banner {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9999;
    background: linear-gradient(90deg, #ff6b35, #f7c948);
    color: #000;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
body.demo-mode header { margin-top: 32px; }

/* ── pattern overlay (subtle Chelsea lions) ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" opacity="0.03" viewBox="0 0 60 60"><text x="50%" y="50%" font-size="40" text-anchor="middle" dominant-baseline="middle">🦁</text></svg>');
    pointer-events: none;
    z-index: 0;
}

/* ── Header ── */
header {
    background: linear-gradient(135deg, var(--blue-dark), var(--blue));
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
#logo { width: 40px; height: 40px; object-fit: contain; }
header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

/* ── Tabs ── */
#tabs {
    display: flex;
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 99;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.tab-btn {
    flex: 1;
    padding: 12px 6px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.7rem;
    transition: all 0.2s;
}
.tab-icon { font-size: 1.3rem; }
.tab-btn.active {
    color: var(--gold);
    border-bottom: 3px solid var(--gold);
}
.tab-btn:hover { background: var(--bg-card-hover); }

/* ── Main ── */
.tab-content {
    display: none;
    padding: 16px;
    max-width: 640px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}
.tab-content.active { display: block; }

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    transition: transform 0.15s;
}
.card:hover { transform: translateY(-2px); }
.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 8px;
}

/* ── Player card ── */
.player-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.player-photo {
    width: 48px; height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gold);
    flex-shrink: 0;
}
.player-photo-placeholder {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    flex-shrink: 0;
}
.player-info { flex: 1; }
.player-name { font-weight: 600; font-size: 0.95rem; }
.player-meta { font-size: 0.78rem; color: var(--text-dim); }
.player-rating-select { width: 60px; }
.player-rating-select input, .player-rating-select select {
    width: 100%;
    padding: 6px;
    border-radius: 8px;
    border: 2px solid var(--blue);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    text-align: center;
}
.rating-used { border-color: var(--danger) !important; opacity: 0.5; }

/* ── Rating chips ── */
.rating-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.rating-chip {
    padding: 4px 10px;
    border-radius: 20px;
    border: 2px solid var(--blue);
    background: transparent;
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}
.rating-chip.used {
    border-color: var(--danger);
    color: var(--danger);
    opacity: 0.4;
    cursor: not-allowed;
}
.rating-chip.selected {
    background: var(--gold);
    border-color: var(--gold);
    color: #000;
    font-weight: 700;
}

/* ── Buttons ── */
.btn-primary {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: #000;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 16px;
    box-shadow: 0 4px 15px rgba(219,161,17,0.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(219,161,17,0.5); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-secondary {
    padding: 10px 18px;
    border: 2px solid var(--blue);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.btn-secondary:hover { background: var(--blue); }

.btn-danger {
    padding: 10px 18px;
    border: 2px solid var(--danger);
    border-radius: 8px;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.85rem;
}

/* ── Progress bar ── */
#progress-bar {
    background: var(--bg-card);
    border-radius: 20px;
    height: 28px;
    overflow: hidden;
    position: relative;
    margin-bottom: 16px;
    border: 2px solid var(--blue);
}
#progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--gold));
    border-radius: 20px;
    transition: width 0.4s;
    width: 0%;
}
#progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* ── Messages ── */
.msg {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin: 12px 0;
    font-size: 0.9rem;
}
.msg.success { background: rgba(40,167,69,0.15); border: 1px solid var(--success); color: var(--success); }
.msg.error   { background: rgba(220,53,69,0.15); border: 1px solid var(--danger); color: var(--danger); }
.msg.info    { background: rgba(3,70,148,0.15); border: 1px solid var(--blue); color: var(--gold); }

/* ── Loading ── */
.loading {
    text-align: center;
    color: var(--text-dim);
    padding: 40px;
    font-size: 1rem;
}
.loading::after {
    content: '';
    display: inline-block;
    width: 24px; height: 24px;
    border: 3px solid var(--blue);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--blue);
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    z-index: 999;
    font-size: 0.9rem;
    font-weight: 500;
    transition: opacity 0.3s;
}

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 2px solid var(--blue);
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
}

/* ── Result row ── */
.result-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border-radius: 8px;
    margin-bottom: 6px;
}
.result-rank {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
}
.result-rank.gold { background: #DBA111; color: #000; }
.result-rank.silver { background: #c0c0c0; color: #000; }
.result-rank.bronze { background: #cd7f32; color: #000; }

/* ── Log entry ── */
.log-entry {
    font-size: 0.8rem;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: var(--text-dim);
}
.log-entry .log-action { color: var(--gold); font-weight: 600; }
.log-entry .log-time { float: right; font-size: 0.72rem; }

/* ── Admin section ── */
.admin-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    border-left: 4px solid var(--gold);
}
.admin-section h3 {
    color: var(--gold);
    margin-bottom: 12px;
    font-size: 1rem;
}

/* ── background preview ── */
.bg-preview {
    width: 100%;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    margin: 8px 0;
    border: 2px solid var(--blue);
}

/* ── Badge ── */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    margin: 2px;
}
.badge-blue { background: var(--blue); color: #fff; }
.badge-gold { background: var(--gold); color: #000; }
.badge-success { background: var(--success); color: #fff; }
.badge-danger { background: var(--danger); color: #fff; }

/* ── Grid helpers ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.text-center { text-align: center; }
.text-dim { color: var(--text-dim); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }

/* ── Countdown timer ── */
.countdown-timer {
    text-align: center;
    padding: 12px;
    margin-bottom: 12px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 2px solid var(--gold);
}
.countdown-timer .countdown-label {
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.countdown-timer .countdown-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
}
.countdown-timer.expired .countdown-value {
    color: var(--danger);
}
.countdown-timer.expired {
    border-color: var(--danger);
}

/* ── Bar chart for results ── */
.bar-chart-container { margin: 8px 0; }
.bar-chart-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-chart-label { width: 120px; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-chart-bar { height: 24px; border-radius: 4px; transition: width 0.6s ease; min-width: 2px; }
.bar-chart-value { font-size: 0.8rem; font-weight: 600; min-width: 35px; }

/* ── Medals ── */
.medal { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.75rem; }
.medal-gold { background: #DBA111; color: #000; }
.medal-silver { background: #c0c0c0; color: #000; }
.medal-bronze { background: #cd7f32; color: #fff; }

/* ── Form dots (sparkline) ── */
.form-dots { display: flex; gap: 3px; align-items: center; }
.form-dot { width: 8px; height: 8px; border-radius: 50%; }
.form-dot.good { background: var(--success); }
.form-dot.bad { background: var(--danger); }
.form-dot.neutral { background: var(--text-dim); }

/* ── Leaderboard ── */
.leaderboard-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--bg-card); border-radius: 8px; margin-bottom: 6px; }
.leaderboard-rank { width: 28px; height: 28px; border-radius: 50%; background: var(--blue); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.leaderboard-info { flex: 1; }
.leaderboard-name { font-weight: 600; font-size: 0.9rem; }
.leaderboard-stats { font-size: 0.75rem; color: var(--text-dim); }
.consistency-bar { width: 60px; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.consistency-fill { height: 100%; border-radius: 3px; background: var(--success); }

/* ── History cards ── */
.history-card { cursor: pointer; transition: all 0.2s; }
.history-card.expanded { border-left: 3px solid var(--gold); }
.history-card .results-detail { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.1); }
.history-card.expanded .results-detail { display: block; }

/* ── Top 3 podium ── */
.podium { display: flex; justify-content: center; gap: 16px; margin: 16px 0; }
.podium-item { text-align: center; }
.podium-name { font-size: 0.8rem; margin-top: 4px; }
.podium-rating { font-size: 0.75rem; color: var(--gold); }

/* ── Stat card ── */
.stat-card { text-align: center; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }

/* ── Prediction card ── */
.prediction-card { border: 2px solid var(--gold); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; background: rgba(219,161,17,0.05); }
.prediction-card h4 { color: var(--gold); margin-bottom: 8px; }
.prediction-select { width: 100%; padding: 10px; border-radius: 8px; border: 2px solid var(--blue); background: var(--bg); color: var(--text); font-size: 0.9rem; margin-bottom: 10px; }

/* ── Mini games ── */
.mini-game-card { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; border-left: 3px solid var(--blue-light); }
.mini-game-card h4 { color: var(--blue-light); margin-bottom: 10px; }
.score-inputs { display: flex; align-items: center; gap: 10px; justify-content: center; margin: 12px 0; }
.score-input { width: 60px; height: 50px; text-align: center; font-size: 1.5rem; font-weight: 700; border-radius: 8px; border: 2px solid var(--blue); background: var(--bg); color: var(--text); }
.score-vs { font-weight: 700; color: var(--text-dim); }
.lineup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 300px; overflow-y: auto; margin: 10px 0; }
.lineup-option { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 6px; background: var(--bg); cursor: pointer; font-size: 0.82rem; }
.lineup-option.selected { background: rgba(3,70,148,0.3); border: 1px solid var(--blue); }
.lineup-option input[type="checkbox"] { accent-color: var(--blue); }
.lineup-counter { text-align: center; font-size: 0.85rem; color: var(--gold); margin: 8px 0; }

/* ── Re-vote button ── */
.revote-btn { display: block; width: 100%; padding: 12px; border: 2px solid var(--warning); border-radius: var(--radius); background: rgba(255,193,7,0.1); color: var(--warning); font-size: 0.9rem; font-weight: 600; cursor: pointer; margin-top: 10px; transition: all 0.2s; }
.revote-btn:hover { background: rgba(255,193,7,0.2); }
.revote-info { text-align: center; font-size: 0.8rem; color: var(--text-dim); margin-top: 6px; }

/* ── Social ── */
.share-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 20px; border: 2px solid var(--blue-light); background: transparent; color: var(--blue-light); cursor: pointer; font-size: 0.8rem; transition: all 0.2s; }
.share-btn:hover { background: var(--blue-light); color: #fff; }
.compare-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.compare-result { text-align: center; margin-top: 16px; }
.similarity-score { font-size: 2.5rem; font-weight: 700; color: var(--gold); }
.similarity-label { font-size: 0.8rem; color: var(--text-dim); }
.referral-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.referral-code { background: var(--bg); padding: 10px 16px; border-radius: 8px; font-family: monospace; text-align: center; margin: 10px 0; font-size: 1.1rem; color: var(--gold); }
.copy-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; border: none; background: var(--blue); color: #fff; cursor: pointer; font-size: 0.85rem; }

/* ── Confetti ── */
#confetti-container { position: fixed; inset: 0; pointer-events: none; z-index: 9999; overflow: hidden; }
.confetti-particle { position: absolute; width: 10px; height: 10px; top: -10px; animation: confetti-fall 3s ease-out forwards; }
@keyframes confetti-fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ── Avatar selector ── */
.avatar-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 16px 0; }
.avatar-option { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; cursor: pointer; border: 3px solid transparent; transition: all 0.2s; margin: 0 auto; }
.avatar-option.selected { border-color: var(--gold); box-shadow: 0 0 12px rgba(219,161,17,0.5); }
.avatar-option:hover { transform: scale(1.1); }
.avatar-large { width: 80px; height: 80px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; margin: 0 auto 16px; border: 3px solid var(--gold); }

/* ── Sound/notification toggle rows ── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.toggle-label { font-size: 0.9rem; }

/* -- XP Progress Bar -- */
.xp-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.xp-level-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; background: linear-gradient(135deg, var(--gold), var(--gold-light)); color: #000; font-size: 0.8rem; font-weight: 700; margin-bottom: 8px; }
.xp-progress-container { background: var(--bg); border-radius: 10px; height: 20px; overflow: hidden; position: relative; border: 1px solid var(--blue); margin: 8px 0; }
.xp-progress-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--gold)); border-radius: 10px; transition: width 0.6s ease; }
.xp-progress-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.xp-stats { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text-dim); margin-top: 4px; }

/* -- Streak Display -- */
.streak-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 16px; }
.streak-fire { font-size: 2rem; animation: fire-pulse 1s ease-in-out infinite alternate; }
@keyframes fire-pulse { from { transform: scale(1); } to { transform: scale(1.15); } }
.streak-info { flex: 1; }
.streak-current { font-size: 1.2rem; font-weight: 700; color: var(--gold); }
.streak-record { font-size: 0.8rem; color: var(--text-dim); }

/* -- Locked Avatar -- */
.avatar-locked { opacity: 0.35; position: relative; cursor: not-allowed !important; }
.avatar-locked::after { content: '\1F512'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 1rem; }

/* -- Event badges on player cards -- */
.event-badge { display: inline-block; padding: 2px 6px; border-radius: 10px; font-size: 0.65rem; font-weight: 600; margin-left: 4px; background: rgba(255,255,255,0.1); }
.event-badge.goal { background: rgba(40,167,69,0.2); color: var(--success); }
.event-badge.card { background: rgba(255,193,7,0.2); color: var(--warning); }
.event-badge.card-red { background: rgba(220,53,69,0.2); color: var(--danger); }
.event-badge.sub { background: rgba(5,99,193,0.2); color: var(--blue-light); }

/* -- Match Timeline -- */
.timeline-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.timeline-toggle { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.timeline-toggle h4 { color: var(--gold); margin: 0; font-size: 0.9rem; }
.timeline-toggle-btn { font-size: 0.8rem; color: var(--text-dim); border: 1px solid var(--text-dim); border-radius: 4px; padding: 2px 8px; background: none; cursor: pointer; }
.timeline-bar-container { margin-top: 12px; position: relative; display: none; }
.timeline-bar-container.visible { display: block; }
.timeline-bar { height: 6px; background: var(--bg); border-radius: 3px; position: relative; margin: 20px 0 30px; }
.timeline-dot { position: absolute; width: 12px; height: 12px; border-radius: 50%; top: -3px; transform: translateX(-50%); cursor: pointer; transition: transform 0.15s; }
.timeline-dot:hover { transform: translateX(-50%) scale(1.4); }
.timeline-dot.goal { background: var(--success); }
.timeline-dot.card-yellow { background: var(--warning); }
.timeline-dot.card-red { background: var(--danger); }
.timeline-dot.sub { background: var(--blue-light); }
.timeline-labels { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--text-dim); margin-top: -20px; }
.timeline-tooltip { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--bg-card); border: 1px solid var(--blue); border-radius: 6px; padding: 4px 8px; font-size: 0.7rem; white-space: nowrap; display: none; z-index: 10; }
.timeline-dot:hover .timeline-tooltip { display: block; }

/* -- AI Rating Comparison -- */
.comparison-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.comparison-section h4 { color: var(--gold); margin-bottom: 12px; }
.comparison-table { width: 100%; font-size: 0.8rem; }
.comparison-table th { color: var(--text-dim); font-weight: 600; padding: 6px 4px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.1); }
.comparison-table td { padding: 6px 4px; text-align: center; }
.comparison-table td:first-child { text-align: left; }
.comparison-highlight { color: var(--gold); font-weight: 700; }
.comparison-diff-high { color: var(--success); }
.comparison-diff-low { color: var(--danger); }

/* -- Vote Heatmap -- */
.heatmap-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.heatmap-section h3 { color: var(--gold); margin-bottom: 12px; font-size: 0.95rem; }
.heatmap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; margin: 12px 0; }
.heatmap-cell { padding: 8px 6px; border-radius: 8px; text-align: center; font-size: 0.72rem; position: relative; }
.heatmap-cell-name { font-weight: 600; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.heatmap-cell-value { font-size: 0.68rem; opacity: 0.8; }
.heatmap-high { background: rgba(40,167,69,0.25); color: var(--success); border: 1px solid rgba(40,167,69,0.4); }
.heatmap-low { background: rgba(220,53,69,0.25); color: var(--danger); border: 1px solid rgba(220,53,69,0.4); }
.heatmap-neutral { background: rgba(136,153,176,0.15); color: var(--text-dim); border: 1px solid rgba(136,153,176,0.3); }
.insight-card { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg); border-radius: 8px; margin-bottom: 6px; font-size: 0.82rem; }
.insight-icon { font-size: 1.1rem; flex-shrink: 0; }

/* -- Controversial Badge -- */
.controversial-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-top: 12px; border: 1px solid rgba(220,53,69,0.3); }
.controversial-section h4 { color: var(--danger); margin-bottom: 10px; font-size: 0.9rem; }
.controversial-badge { display: inline-block; padding: 4px 10px; border-radius: 12px; background: rgba(220,53,69,0.2); color: var(--danger); font-size: 0.72rem; font-weight: 700; animation: pulse-badge 2s ease-in-out infinite; }
@keyframes pulse-badge { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.controversial-player { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--bg); border-radius: 8px; margin-bottom: 6px; }
.controversial-rank { font-size: 0.8rem; font-weight: 700; color: var(--text-dim); min-width: 20px; }
.controversial-name { flex: 1; font-size: 0.85rem; font-weight: 600; }
.controversial-stats { text-align: right; font-size: 0.75rem; color: var(--text-dim); }

/* -- Overrated / Underrated Section -- */
.overrated-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-top: 12px; border: 1px solid rgba(59,130,246,0.3); }
.overrated-section h4 { color: var(--blue); margin-bottom: 10px; font-size: 0.9rem; }
.overrated-item { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--bg); border-radius: 8px; margin-bottom: 6px; }
.overrated-arrow-up { color: #22c55e; font-size: 1.1rem; font-weight: 700; min-width: 20px; text-align: center; }
.overrated-arrow-down { color: #ef4444; font-size: 1.1rem; font-weight: 700; min-width: 20px; text-align: center; }
.overrated-name { flex: 1; font-size: 0.85rem; font-weight: 600; }
.overrated-diff { font-weight: 700; font-size: 0.85rem; min-width: 40px; text-align: right; }
.overrated-diff-up { color: #22c55e; }
.overrated-diff-down { color: #ef4444; }
.overrated-label { font-size: 0.72rem; color: var(--text-dim); min-width: 90px; text-align: right; }

/* -- Share Result Card -- */
.share-card-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 20px; border: 2px solid var(--gold); background: rgba(219,161,17,0.1); color: var(--gold); cursor: pointer; font-size: 0.8rem; font-weight: 600; transition: all 0.2s; margin-left: 8px; }
.share-card-btn:hover { background: var(--gold); color: #000; }

/* -- Live Indicator -- */
.live-container { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg-card); border-radius: 20px; margin-bottom: 12px; font-size: 0.82rem; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: live-blink 1.5s ease-in-out infinite; }
@keyframes live-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.live-count { font-weight: 600; color: var(--gold); }
.live-label { color: var(--text-dim); }

/* -- SSE Toast -- */
.sse-toast { position: fixed; top: 80px; right: 16px; background: var(--bg-card); border: 1px solid var(--blue); border-radius: 8px; padding: 8px 14px; font-size: 0.8rem; color: var(--text); box-shadow: var(--shadow); z-index: 200; animation: sse-slide-in 0.3s ease; }
@keyframes sse-slide-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* -- Challenge Cards -- */
.challenge-card { background: var(--bg-card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; border-left: 4px solid var(--blue); }
.challenge-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.challenge-type-badge { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; padding: 2px 8px; border-radius: 10px; background: rgba(5,99,193,0.15); color: var(--blue-light); }
.challenge-badge-complete { font-size: 0.7rem; font-weight: 600; color: var(--success); }
.challenge-time { font-size: 0.7rem; color: var(--text-dim); }
.challenge-title { font-size: 0.9rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.challenge-desc { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 8px; }
.challenge-progress-bar { height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.challenge-progress-fill { height: 100%; background: var(--blue); border-radius: 3px; transition: width 0.3s ease; }
.challenge-progress-fill.complete { background: var(--success); }
.challenge-footer { display: flex; align-items: center; justify-content: space-between; }
.challenge-progress-text { font-size: 0.75rem; color: var(--text-dim); }
.challenge-reward { font-size: 0.75rem; font-weight: 600; color: var(--gold); }

/* -- Awards Section -- */
.awards-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.awards-section h3 { color: var(--gold); margin-bottom: 12px; font-size: 0.95rem; }
.award-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg); border-radius: 8px; margin-bottom: 6px; }
.award-badge { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #f6d365 0%, #fda085 100%); font-size: 1.1rem; flex-shrink: 0; }
.award-text { flex: 1; font-size: 0.85rem; font-weight: 600; color: var(--text); }
.award-month { font-size: 0.72rem; color: var(--text-dim); }

/* -- FPL Badge & Correlation -- */
.fpl-badge { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 0.65rem; font-weight: 600; background: linear-gradient(135deg, #37003c, #00ff87); color: #fff; margin-left: 6px; white-space: nowrap; }
.fpl-badge-small { display: inline-block; padding: 1px 5px; border-radius: 8px; font-size: 0.6rem; font-weight: 600; background: rgba(0,255,135,0.15); color: #00ff87; border: 1px solid rgba(0,255,135,0.3); margin-left: 4px; }
.fpl-correlation { background: var(--bg-card); border-radius: var(--radius); padding: 12px 16px; margin-top: 12px; border: 1px solid rgba(0,255,135,0.3); display: flex; align-items: center; gap: 12px; }
.fpl-correlation-value { font-size: 1.3rem; font-weight: 700; color: #00ff87; min-width: 50px; text-align: center; }
.fpl-correlation-label { font-size: 0.8rem; color: var(--text-dim); }
.fpl-correlation-desc { font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }
.fpl-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-top: 12px; border: 1px solid rgba(0,255,135,0.2); }
.fpl-section h4 { color: #00ff87; margin-bottom: 10px; font-size: 0.9rem; }

/* -- Pre-match Analytics -- */
.analytics-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; border: 1px solid rgba(5,99,193,0.3); }
.analytics-toggle { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.analytics-toggle h4 { color: var(--gold); margin: 0; font-size: 0.9rem; }
.analytics-toggle-btn { font-size: 0.8rem; color: var(--text-dim); border: 1px solid var(--text-dim); border-radius: 4px; padding: 2px 8px; background: none; cursor: pointer; }
.analytics-content { margin-top: 12px; display: none; }
.analytics-content.visible { display: block; }
.analytics-opponent { margin-bottom: 10px; font-size: 0.85rem; }
.analytics-form-row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.analytics-form-indicator { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; font-size: 0.72rem; font-weight: 700; }
.analytics-form-indicator.form-win { background: rgba(40,167,69,0.25); color: #28a745; border: 1px solid rgba(40,167,69,0.5); }
.analytics-form-indicator.form-draw { background: rgba(255,193,7,0.25); color: #ffc107; border: 1px solid rgba(255,193,7,0.5); }
.analytics-form-indicator.form-loss { background: rgba(220,53,69,0.25); color: #dc3545; border: 1px solid rgba(220,53,69,0.5); }
.analytics-h2h { margin-bottom: 10px; font-size: 0.85rem; }
.analytics-h2h-stat { display: flex; gap: 12px; margin-top: 6px; font-size: 0.82rem; }
.analytics-h2h-stat .h2h-wins { color: #28a745; font-weight: 600; }
.analytics-h2h-stat .h2h-draws { color: #ffc107; font-weight: 600; }
.analytics-h2h-stat .h2h-losses { color: #dc3545; font-weight: 600; }
.analytics-meetings { margin-top: 8px; }
.analytics-meetings-title { font-size: 0.78rem; color: var(--text-dim); margin-bottom: 4px; }
.analytics-meeting-row { font-size: 0.78rem; padding: 4px 0; display: flex; align-items: center; gap: 6px; }
.analytics-prediction { margin-top: 10px; font-size: 0.85rem; padding: 8px 12px; background: var(--bg); border-radius: 8px; border-left: 3px solid var(--gold); }
.analytics-no-data { font-size: 0.8rem; color: var(--text-dim); }

/* -- Match Report Section -- */
.report-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-top: 12px; border: 1px solid transparent; background-clip: padding-box; position: relative; }
.report-section::before { content: ''; position: absolute; inset: 0; border-radius: var(--radius); padding: 1px; background: linear-gradient(135deg, var(--gold), var(--blue), var(--gold)); -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.report-section h4 { color: var(--gold); margin-bottom: 12px; font-size: 0.9rem; }
.report-mvp { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: linear-gradient(135deg, rgba(219,161,17,0.15), rgba(219,161,17,0.05)); border-radius: 8px; margin-bottom: 10px; border: 1px solid rgba(219,161,17,0.3); }
.report-mvp-medal { font-size: 1.2rem; }
.report-mvp-name { flex: 1; font-size: 0.85rem; font-weight: 600; color: var(--gold); }
.report-mvp-rating { font-size: 1rem; font-weight: 700; color: var(--gold); }
.report-top3-label { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 4px; font-weight: 600; }
.report-stat-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; background: var(--bg); border-radius: 6px; margin-bottom: 4px; font-size: 0.82rem; }
.report-stat-row.report-controversial { border-left: 3px solid #ef4444; }
.report-comparison { margin-top: 10px; }
.report-comparison-title { font-size: 0.8rem; font-weight: 600; color: var(--blue-light); margin-bottom: 6px; }
.report-timestamp { font-size: 0.7rem; color: var(--text-dim); text-align: right; margin-top: 8px; }


/* ════════════════════════════════════════════════════════════════════
   ANIMATIONS & MICRO-INTERACTIONS  (PR #12)
   ════════════════════════════════════════════════════════════════════ */

/* ── 0. Universal: respect motion-sickness toggle ──────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── 10. Theme transition (smooth color crossfade) ────────────────── */
body, .card, .tab-content, .player-card, .countdown-timer, .admin-section,
.btn-primary, .btn-secondary, .rating-chip, header, #tabs, .leaderboard-row,
.streak-section, .xp-section, .prediction-card, .controversial-section,
.overrated-section, .heatmap-section, .awards-section, .challenge-card,
.history-card, #toast {
    transition: background-color 0.4s ease, color 0.35s ease, border-color 0.35s ease;
}

/* ── 1. Tab cross-fade ────────────────────────────────────────────── */
.tab-content.active {
    animation: tab-fade-in 0.32s cubic-bezier(.22, .9, .28, 1.05);
}
@keyframes tab-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.tab-btn {
    position: relative;
}
.tab-btn::after {
    content: '';
    position: absolute;
    left: 50%; right: 50%;
    bottom: 0;
    height: 3px;
    background: var(--gold);
    border-radius: 2px;
    transition: left 0.25s ease, right 0.25s ease;
}
.tab-btn.active::after { left: 12%; right: 12%; }
.tab-btn.active { border-bottom: none; }   /* the ::after replaces the original border */
.tab-btn:active .tab-icon { transform: scale(0.88); transition: transform 0.1s; }

/* ── 2. Player card stagger entrance ──────────────────────────────── */
.player-card {
    animation: card-enter 0.42s cubic-bezier(.18, .89, .32, 1.05) both;
    animation-delay: var(--enter-delay, 0ms);
    will-change: transform, opacity;
}
@keyframes card-enter {
    from { opacity: 0; transform: translateY(14px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Card hover lift (replaces basic hover) */
.player-card { transition: transform 0.18s ease, box-shadow 0.18s ease; }
.player-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(3, 70, 148, 0.25);
}

/* ── 3. Rating tap feedback + landing pulse ───────────────────────── */
.rating-chip {
    transition: transform 0.12s, background-color 0.2s, border-color 0.2s, color 0.2s;
}
.rating-chip:not(.used):not(:disabled):active {
    transform: scale(0.92);
}
.rating-chip:not(.used):not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(3, 70, 148, 0.3);
}
.rating-chip.selected {
    box-shadow: 0 0 0 3px rgba(219, 161, 17, 0.18);
    animation: chip-pop 0.25s ease;
}
@keyframes chip-pop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.18); }
    100% { transform: scale(1); }
}
.player-card.just-rated {
    animation: gold-pulse 0.65s ease;
}
@keyframes gold-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(219,161,17, 0.55); }
    100% { box-shadow: 0 0 0 14px rgba(219,161,17, 0); }
}

/* ── 4. Submit button states (idle/submitting/success) ────────────── */
.btn-primary {
    position: relative;
    overflow: hidden;
}
.btn-primary.submitting {
    color: transparent;        /* hide label, show spinner */
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(219,161,17,0.25);
}
.btn-primary.submitting::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 22px; height: 22px;
    margin: -11px 0 0 -11px;
    border: 3px solid rgba(0, 0, 0, 0.25);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.btn-primary.success {
    background: linear-gradient(135deg, var(--success), #2ecc71) !important;
    color: #fff;
    animation: btn-success-flash 0.5s ease;
}
@keyframes btn-success-flash {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.04); box-shadow: 0 0 0 8px rgba(40, 167, 69, 0.18); }
    100% { transform: scale(1);   box-shadow: 0 4px 15px rgba(40, 167, 69, 0.5); }
}

/* Subtle ripple on tap (any .btn-primary click) */
.btn-primary:not(:disabled):active { transform: scale(0.98); }

/* ── 5. Live voter count pulse on increment ───────────────────────── */
.live-count {
    display: inline-block;
    transition: color 0.2s;
}
.live-count.bumping {
    animation: count-bump 0.45s cubic-bezier(.36, 1.45, .53, 1);
}
@keyframes count-bump {
    0%   { transform: scale(1);   color: var(--gold); }
    50%  { transform: scale(1.35); color: #fff; text-shadow: 0 0 8px rgba(219,161,17,0.8); }
    100% { transform: scale(1);   color: var(--gold); text-shadow: none; }
}

/* ── 6. Better toast: slide-up + bounce + backdrop blur ──────────── */
#toast {
    /* override the original opacity-fade */
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.35s cubic-bezier(.18, 1.18, .35, 1.06);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(3, 70, 148, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
#toast.toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── 7. Skeleton loaders (replace plain "Загрузка...") ────────────── */
.skeleton {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.04) 0%,
        rgba(255,255,255,0.10) 50%,
        rgba(255,255,255,0.04) 100%);
    background-size: 200% 100%;
    border-radius: 8px;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 8px;
    display: flex;
    gap: 12px;
    align-items: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.skeleton-avatar { width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; }
.skeleton-lines { flex: 1; }
.skeleton-line { height: 12px; border-radius: 6px; margin-bottom: 8px; }
.skeleton-line.short { width: 50%; }
.skeleton-line.long  { width: 90%; }
.skeleton-chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.skeleton-chip { width: 28px; height: 24px; border-radius: 14px; }

/* ── 8. XP bar smooth fill (extends existing transition) ──────────── */
.xp-progress-fill {
    transition: width 1s cubic-bezier(.22, .9, .28, 1);
    background-size: 200% 100%;
    background-image: linear-gradient(90deg, var(--blue), var(--gold), var(--blue));
}
.xp-progress-fill.gained {
    animation: xp-glow 1.2s ease;
}
@keyframes xp-glow {
    0%   { box-shadow: inset 0 0 0 0 rgba(255,255,255, 0); background-position: 0 0; }
    50%  { box-shadow: inset 0 0 18px 0 rgba(255,255,255, 0.55); }
    100% { box-shadow: inset 0 0 0 0 rgba(255,255,255, 0); background-position: 100% 0; }
}

/* Same treatment for challenge progress bars */
.challenge-progress-fill {
    transition: width 0.7s cubic-bezier(.22, .9, .28, 1);
}

/* ── 9. Empty states polish ───────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-dim);
}
.empty-state-icon {
    font-size: 3.4rem;
    margin-bottom: 10px;
    display: inline-block;
    animation: empty-bob 3.2s ease-in-out infinite;
}
@keyframes empty-bob {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50%      { transform: translateY(-7px) rotate(3deg); }
}
.empty-state-title { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-state-text  { font-size: 0.85rem; color: var(--text-dim); }

/* When .msg.info has only text and is being used as empty-state, give it
   a friendlier appearance via the new class (script.js sets it). */
.msg.info.empty-flavor {
    text-align: center;
    background: transparent;
    border: 2px dashed rgba(3, 70, 148, 0.4);
    padding: 24px 20px;
}

/* ── 11. Animated countdown digits ────────────────────────────────── */
.countdown-value {
    transition: transform 0.18s ease;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}
.countdown-value.ticking {
    animation: countdown-tick 0.18s ease;
}
@keyframes countdown-tick {
    0%   { transform: scale(1);    opacity: 1; }
    35%  { transform: scale(0.93); opacity: 0.55; }
    100% { transform: scale(1);    opacity: 1; }
}
.countdown-timer:not(.expired) {
    animation: countdown-breath 4s ease-in-out infinite;
}
@keyframes countdown-breath {
    0%, 100% { box-shadow: 0 0 0 0 rgba(219,161,17, 0); }
    50%      { box-shadow: 0 0 0 4px rgba(219,161,17, 0.06); }
}

/* ── 12. Confetti 2.0: varied shapes ──────────────────────────────── */
.confetti-particle.shape-circle { border-radius: 50%; }
.confetti-particle.shape-rect   { border-radius: 0; }
.confetti-particle.shape-strip  { width: 4px !important; height: 14px !important; border-radius: 2px; }
.confetti-particle.shape-square { width: 8px !important; height: 8px !important; }
@keyframes confetti-fall-v2 {
    0%   { transform: translate3d(0, 0, 0) rotate(0deg);             opacity: 1; }
    100% { transform: translate3d(var(--drift,0), 100vh, 0) rotate(var(--spin, 720deg)); opacity: 0; }
}
.confetti-particle {
    will-change: transform, opacity;
    animation: confetti-fall-v2 var(--fall-dur, 3s) cubic-bezier(.2, .55, .35, 1) forwards;
}

/* ── 13. Page micro-parallax (header on scroll) ───────────────────── */
header {
    transition: transform 0.22s cubic-bezier(.22, .9, .28, 1);
    will-change: transform;
}
header.scrolled {
    transform: translateY(-4px);
    box-shadow: 0 6px 26px rgba(0, 0, 0, 0.45);
}
header.scrolled #logo { transform: scale(0.92); transition: transform 0.22s; }
#logo { transition: transform 0.22s; }

/* Subtle page content lift on scroll for cards near top */
.tab-content.active { transition: transform 0.4s ease; }



/* When .loading hosts skeleton-card children (used in vote/other/profile
   tabs), the original centered text + spinner ::after look cluttered.
   Switch to a left-aligned skeleton list instead. */
.loading:has(.skeleton-card) {
    text-align: left;
    padding: 16px 0;
}
.loading:has(.skeleton-card)::after {
    display: none;
}



/* ════════════════════════════════════════════════════════════════════
   ANIMATIONS PART 2 — DEEPER POLISH (PR #13)
   Layered on top of PR #12. All GPU-accelerated, all reduced-motion aware.
   ════════════════════════════════════════════════════════════════════ */

/* ── 14. Bar chart fill from 0 with stagger (animation, not transition) — */
.bar-chart-bar {
    width: 0 !important;        /* override any inline width=X% */
    animation: bar-grow 0.85s cubic-bezier(.18, .89, .32, 1) forwards;
    animation-delay: var(--bar-delay, 0ms);
}
@keyframes bar-grow {
    to { width: var(--bar-target, 0%); }
}

/* ── 15. Player photo fade-in (paired with onload="this.classList.add('loaded')") */
.player-photo {
    opacity: 0;
    transform: scale(1.06);
    transition: opacity 0.45s ease, transform 0.5s cubic-bezier(.18, .89, .32, 1);
}
.player-photo.loaded {
    opacity: 1;
    transform: scale(1);
}
.player-photo-placeholder {
    animation: card-enter 0.4s ease both;
}

/* ── 16. Submit "ready" pulse — when all players are rated */
.btn-primary.ready {
    animation: ready-pulse 1.6s ease-in-out infinite;
}
@keyframes ready-pulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(219, 161, 17, 0.45);
        transform: translateY(0);
    }
    50% {
        box-shadow: 0 6px 28px rgba(219, 161, 17, 0.85), 0 0 0 4px rgba(219, 161, 17, 0.18);
        transform: translateY(-1px);
    }
}

/* ── 17. Top-3 podium reveal in bar charts: golden glow + scale-in stagger — */
.bar-chart-row.podium-1,
.bar-chart-row.podium-2,
.bar-chart-row.podium-3 {
    animation: podium-rise 0.7s cubic-bezier(.18, 1.18, .35, 1.06) both;
    border-radius: 8px;
    padding: 4px 6px;
    margin: 2px 0;
}
.bar-chart-row.podium-1 {
    animation-delay: 0.55s;
    background: linear-gradient(90deg, rgba(219,161,17,0.18), transparent 70%);
    box-shadow: inset 0 0 0 1px rgba(219, 161, 17, 0.3);
}
.bar-chart-row.podium-2 {
    animation-delay: 0.4s;
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.13), transparent 70%);
}
.bar-chart-row.podium-3 {
    animation-delay: 0.25s;
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.13), transparent 70%);
}
@keyframes podium-rise {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── 18. Medal emoji shine — continuous subtle sparkle */
.medal {
    display: inline-block;
    position: relative;
    background: linear-gradient(120deg,
        currentColor 0%, currentColor 40%,
        rgba(255,255,255,0.95) 50%,
        currentColor 60%, currentColor 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    /* fallback keeps emojis legible if -webkit-text-fill-color isn't honoured */
    filter: drop-shadow(0 0 6px rgba(255,215,90,0.4));
    animation: medal-shine 3s linear infinite;
}
@keyframes medal-shine {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
/* Drop the gradient text-clip on emojis (it kills emoji rendering on some
   platforms). Keep only the drop-shadow + a subtle bobbing. */
.medal-emoji {
    display: inline-block;
    filter: drop-shadow(0 0 6px rgba(255,215,90,0.55));
    animation: medal-bob 2.4s ease-in-out infinite;
}
@keyframes medal-bob {
    0%, 100% { transform: translateY(0)   rotate(0deg); }
    50%      { transform: translateY(-2px) rotate(-3deg); }
}

/* ── 19. Streak ember particles — only when streak >= 5 (.streak-fire on parent) */
.streak-fire-wrap {
    position: relative;
    display: inline-block;
    width: 2.4em;
    height: 2.4em;
    line-height: 1;
}
.streak-fire-wrap .ember {
    position: absolute;
    bottom: 8%;
    left: 50%;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: radial-gradient(circle, #ffd84a 0%, #ff7a18 70%, transparent 100%);
    opacity: 0;
    pointer-events: none;
    animation: ember-rise 2.2s ease-out infinite;
}
.streak-fire-wrap .ember:nth-child(1) { animation-delay: 0s;   --ember-x:  -10px; }
.streak-fire-wrap .ember:nth-child(2) { animation-delay: 0.4s; --ember-x:   12px; }
.streak-fire-wrap .ember:nth-child(3) { animation-delay: 0.9s; --ember-x:   -3px; }
.streak-fire-wrap .ember:nth-child(4) { animation-delay: 1.4s; --ember-x:    8px; }
.streak-fire-wrap .ember:nth-child(5) { animation-delay: 1.8s; --ember-x:  -16px; }
@keyframes ember-rise {
    0%   { transform: translate3d(-50%, 0, 0) scale(0.6); opacity: 0; }
    15%  { opacity: 0.95; }
    100% { transform: translate3d(calc(-50% + var(--ember-x, 0px)), -36px, 0) scale(0.4);
           opacity: 0; }
}

/* ── 20. First-paint entry sequence — runs once on app boot */
body.app-booting #header        { animation: boot-fade-in 0.55s 0.05s cubic-bezier(.22, .9, .28, 1) both; }
body.app-booting #tabs          { animation: boot-fade-in 0.55s 0.20s cubic-bezier(.22, .9, .28, 1) both; }
body.app-booting #main          { animation: boot-fade-in 0.55s 0.35s cubic-bezier(.22, .9, .28, 1) both; }
@keyframes boot-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── 21. Heading shimmer when its tab activates (not on every keystroke) — */
.tab-content.active > h2 {
    background: linear-gradient(120deg,
        var(--text) 0%, var(--text) 40%,
        var(--gold) 50%,
        var(--text) 60%, var(--text) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: heading-shimmer 2.2s ease-out 1;
}
@keyframes heading-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── 22. Tab icon bounce on becoming active */
.tab-btn.active .tab-icon {
    animation: tab-icon-bounce 0.6s cubic-bezier(.18, 1.18, .35, 1.06) 1;
}
@keyframes tab-icon-bounce {
    0%   { transform: translateY(0)   scale(1); }
    35%  { transform: translateY(-4px) scale(1.18); }
    65%  { transform: translateY(1px) scale(0.96); }
    100% { transform: translateY(0)   scale(1); }
}

/* ── 23. Counter (used by animateNumber JS helper) tabular-nums looks tighter */
.counter, [data-counter] {
    font-variant-numeric: tabular-nums;
}



/* ── Telegram avatar (real profile photo) styles ────────────────────── */
.tg-avatar {
    background: var(--bg-card);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.tg-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(3, 70, 148, 0.35);
}
/* Wrapper for the big profile-tab avatar so the centring stays consistent
   regardless of which tier (photo / emoji / initials) is rendered. */
.avatar-large-wrap {
    display: inline-block;
    margin: 0 auto 8px;
}



/* ─────────────────────────────────────────────────────────────────
   New themes
   Each theme overrides the same CSS variables defined in :root, so
   nothing else in the stylesheet has to know they exist.
   ───────────────────────────────────────────────────────────────── */

/* Stamford Bridge — saturated chelsea blue + heavy gold accents.
   Slightly darker base than the default `dark`, more vivid blue cards. */
[data-theme="stamford-bridge"] {
    --bg: #061429;
    --bg-card: #0c2454;
    --bg-card-hover: #143273;
    --text: #ffffff;
    --text-dim: #9ab3d6;
    --blue: #0563c1;
    --blue-light: #2b88e8;
    --blue-dark: #022d5c;
    --gold: #f0c040;
    --gold-light: #ffd866;
    --shadow: 0 4px 24px rgba(5,99,193,0.35);
}

/* Vintage Chelsea — warm cream + retro gold + dark navy.
   Matchday-program feel; high contrast for readability. */
[data-theme="vintage"] {
    --bg: #f4ead2;
    --bg-card: #fff8e6;
    --bg-card-hover: #efe2bf;
    --text: #1a2438;
    --text-dim: #6b6048;
    --blue: #1d3464;
    --blue-light: #2c4a8a;
    --blue-dark: #0f1f3d;
    --gold: #b88813;
    --gold-light: #d6a837;
    --shadow: 0 4px 18px rgba(184,136,19,0.18);
}

/* Stadium Lights — near-black + neon blue + electric yellow.
   "Floodlights at Stamford Bridge" vibe, high contrast. */
[data-theme="stadium"] {
    --bg: #050810;
    --bg-card: #0c1424;
    --bg-card-hover: #14223d;
    --text: #f5f8ff;
    --text-dim: #7a8aa6;
    --blue: #00a3ff;
    --blue-light: #3ec4ff;
    --blue-dark: #003e6e;
    --gold: #fff200;
    --gold-light: #fff766;
    --shadow: 0 0 32px rgba(0,163,255,0.25);
}

/* Auto — follow the OS color scheme. We don't change variables here
   directly; instead we switch between the dark defaults and the light
   override based on prefers-color-scheme. The :root block already sets
   the dark variables, so we only need to invert when the user is on
   light mode AND has chosen Auto. */
@media (prefers-color-scheme: light) {
    [data-theme="auto"] {
        --bg: #f0f4f8;
        --bg-card: #ffffff;
        --bg-card-hover: #e8edf2;
        --text: #1a1a2e;
        --text-dim: #667788;
    }
}

/* ─────────────────────────────────────────────────────────────────
   Theme picker cards (in Settings → Theme).
   Replaces the old grid-3 of two btn-secondary buttons. Each card is
   a colored swatch + label, with a gold selected ring.
   ───────────────────────────────────────────────────────────────── */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
@media (max-width: 380px) {
    .theme-grid { grid-template-columns: 1fr 1fr; }
}
.theme-card {
    background: var(--bg);
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 10px 8px 8px;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.78rem;
}
.theme-card:hover { transform: translateY(-2px); border-color: rgba(219,161,17,0.4); }
.theme-card:active { transform: scale(0.97); }
.theme-card.selected {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold), 0 4px 14px rgba(219,161,17,0.3);
}
.theme-card-swatch {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.08);
}
.theme-card-label {
    font-weight: 600;
    text-align: center;
    line-height: 1.1;
}

/* Per-theme swatch previews — give the user a visual cue what each
   theme looks like before they commit. */
.theme-swatch-dark      { background: linear-gradient(135deg, #0a1628 0%, #0f1f38 60%, #DBA111 100%); }
.theme-swatch-light     { background: linear-gradient(135deg, #f0f4f8 0%, #ffffff 60%, #DBA111 100%); }
.theme-swatch-stamford  { background: linear-gradient(135deg, #061429 0%, #0c2454 60%, #f0c040 100%); }
.theme-swatch-vintage   { background: linear-gradient(135deg, #f4ead2 0%, #fff8e6 60%, #b88813 100%); }
.theme-swatch-stadium   { background: linear-gradient(135deg, #050810 0%, #00a3ff 50%, #fff200 100%); }
.theme-swatch-auto      { background: linear-gradient(135deg, #0a1628 0%, #f0f4f8 50%, #DBA111 100%); }

/* ─────────────────────────────────────────────────────────────────
   iOS-style toggle switch
   Replaces the default OS checkbox in settings. Visual contract:
   - Off: muted grey track, thumb on the left
   - On:  blue→gold gradient track, thumb slid to the right with a
          subtle gold halo
   The underlying <input type="checkbox"> stays present (just visually
   hidden) so existing JS reading `.checked` keeps working unchanged.
   ───────────────────────────────────────────────────────────────── */
.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}
.switch input[type="checkbox"] {
    /* Visually hide but keep accessible to assistive tech and JS */
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
    z-index: 1;
}
.switch-track {
    display: inline-block;
    width: 46px;
    height: 26px;
    background: rgba(255,255,255,0.15);
    border-radius: 999px;
    position: relative;
    transition: background 0.2s ease;
    flex-shrink: 0;
}
[data-theme="light"] .switch-track,
[data-theme="vintage"] .switch-track {
    background: rgba(0,0,0,0.18);
}
.switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.switch input[type="checkbox"]:checked ~ .switch-track {
    background: linear-gradient(135deg, var(--blue) 0%, var(--gold) 100%);
}
.switch input[type="checkbox"]:checked ~ .switch-track .switch-thumb {
    transform: translateX(20px);
    box-shadow: 0 0 0 2px rgba(219,161,17,0.25), 0 1px 4px rgba(0,0,0,0.3);
}
.switch input[type="checkbox"]:focus-visible ~ .switch-track {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}
.switch input[type="checkbox"]:disabled ~ .switch-track {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─────────────────────────────────────────────────────────────────
   Profile Hero (avatar + name + ID badge).
   Replaces the old plain-text identity card AND the chelsea-themed
   avatar grid. Single source of truth for "who am I" visual.
   ───────────────────────────────────────────────────────────────── */
.profile-hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    isolation: isolate;
}
.profile-hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(120% 80% at 0% 0%, rgba(219,161,17,0.18) 0%, rgba(219,161,17,0) 55%),
        radial-gradient(120% 80% at 100% 100%, rgba(5,99,193,0.32) 0%, rgba(5,99,193,0) 60%),
        linear-gradient(135deg, var(--blue-dark) 0%, var(--bg-card) 60%);
}
.profile-hero-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, rgba(255,255,255,0) 35%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0) 65%);
    pointer-events: none;
}
.profile-hero-content {
    position: relative;
    z-index: 1;
    padding: 22px 18px 18px;
    text-align: center;
}
.profile-hero-avatar {
    width: 96px;
    height: 96px;
    margin: 0 auto 12px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(219,161,17,0.6);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 0 4px rgba(5,99,193,0.18);
}
.profile-hero-avatar img,
.profile-hero-avatar > div {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
}
.profile-hero-name {
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.15;
    color: #fff;
    letter-spacing: -0.01em;
    margin: 0 0 8px;
}
[data-theme="light"] .profile-hero-name,
[data-theme="vintage"] .profile-hero-name {
    /* On light backgrounds the gradient is still dark-blue dominant,
       so white still works — explicitly forced to avoid theme overrides
       further down the cascade. */
    color: #fff;
}
[data-theme="light"] .profile-id-row,
[data-theme="vintage"] .profile-id-row {
    /* Slightly darker pill backdrop on light themes so the white
       border + ID text don't blow out against the bright gradient. */
    background: rgba(0,0,0,0.18);
}
.profile-username-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--gold-light);
    background: rgba(219,161,17,0.12);
    border: 1px solid rgba(219,161,17,0.35);
    border-radius: 999px;
    padding: 3px 10px;
    text-decoration: none;
    transition: background 0.15s, transform 0.15s;
}
.profile-username-pill:hover { background: rgba(219,161,17,0.22); transform: translateY(-1px); }

.profile-id-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    padding: 4px 4px 4px 12px;
    background: rgba(0,0,0,0.28);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 999px;
}
.profile-id-label {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.profile-id-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    border-radius: 999px;
    padding: 5px 10px 5px 12px;
    font: 600 0.85rem/1 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.profile-id-badge:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
}
.profile-id-badge:active { transform: scale(0.97); }
.profile-id-badge.is-custom {
    background: linear-gradient(135deg, rgba(219,161,17,0.25), rgba(219,161,17,0.1));
    border-color: rgba(219,161,17,0.55);
    color: var(--gold-light);
}
.profile-id-badge.copied {
    background: rgba(40,167,69,0.25);
    border-color: rgba(40,167,69,0.6);
    color: #b8f0c4;
}
.profile-id-copy {
    display: inline-flex;
    align-items: center;
    opacity: 0.7;
}
.profile-id-badge:hover .profile-id-copy { opacity: 1; }

.profile-hero-badges {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}
