/* ═════════════════════════════════════════════════════════════════
   Stats V2 — Minimalist, high-contrast statistics overlay
   ═════════════════════════════════════════════════════════════════ */

/* ── Overlay backdrop ───────────────────────────────────────────── */
.stats-v2-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.70);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}
.stats-v2-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ── Card container ─────────────────────────────────────────────── */
.stats-v2-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.25);
    max-width: 900px;
    width: 92vw;
    max-height: 88vh;
    overflow-y: auto;
    padding: 36px 40px 32px;
    position: relative;
    animation: statsV2SlideUp 0.3s ease;
}
@keyframes statsV2SlideUp {
    from { transform: translateY(32px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ── Close button ───────────────────────────────────────────────── */
.stats-v2-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s;
}
.stats-v2-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* ── Title ──────────────────────────────────────────────────────── */
.stats-v2-title {
    font-size: 20px;
    font-weight: 700;
    color: #111;
    margin: 0 0 4px;
    letter-spacing: -0.3px;
}
.stats-v2-subtitle {
    font-size: 14px;
    color: #888;
    margin: 0 0 24px;
    font-weight: 400;
}

/* ═════════════════════════════════════════════════════════════════
   PARETO CHART — horizontal bars + cumulative line
   ═════════════════════════════════════════════════════════════════ */
.pareto-chart {
    margin: 8px 0 0;
}
.pareto-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.pareto-label {
    flex: 0 0 140px;
    font-size: 13px;
    color: #444;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pareto-bar-container {
    flex: 1;
    height: 32px;
    background: #f5f5f5;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}
.pareto-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-width: 2px;
}
/* Default: slate blue */
.pareto-bar-fill {
    background: #6C7A89;
}
/* Correct answer: green */
.pareto-bar-fill.correct {
    background: #22C55E;
}
/* Wrong answers: muted red */
.pareto-bar-fill.wrong {
    background: #E2E2E2;
}

.pareto-bar-pct {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    font-weight: 600;
    color: #555;
}
.pareto-bar-count {
    flex: 0 0 36px;
    font-size: 14px;
    font-weight: 600;
    color: #222;
    text-align: center;
}

/* Cumulative % line — rendered as SVG overlay */
.pareto-cumline {
    margin-top: 10px;
    width: 100%;
    height: 48px;
}
.pareto-cumline line {
    stroke: #CBD5E1;
    stroke-width: 1;
}
.pareto-cumline polyline {
    fill: none;
    stroke: #F97316;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.pareto-cumline circle {
    fill: #F97316;
}
.pareto-cumline text {
    font-size: 10px;
    fill: #888;
    font-family: inherit;
}

/* Legend below the chart */
.pareto-legend {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    flex-wrap: wrap;
}
.pareto-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #666;
}
.pareto-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* ── Totals pill ────────────────────────────────────────────────── */
.stats-v2-pill {
    display: inline-block;
    background: #F1F5F9;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 100px;
    margin-left: 8px;
    vertical-align: middle;
}

/* ═════════════════════════════════════════════════════════════════
   PLAYER STATS CARDS
   ═════════════════════════════════════════════════════════════════ */
.player-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
    margin-top: 8px;
}
.player-stat-card {
    background: #FAFAFA;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 20px 24px 16px;
    position: relative;
}
.player-stat-card.rank-1 {
    border-color: #FFD700;
    background: #FFFDF5;
}
.player-stat-card.rank-2 {
    border-color: #C0C0C0;
    background: #FCFCFC;
}
.player-stat-card.rank-3 {
    border-color: #CD7F32;
    background: #FFFCF8;
}

/* Player header row */
.psc-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}
.psc-rank-badge {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
    color: #fff;
    background: #94A3B8;
    flex-shrink: 0;
}
.rank-1 .psc-rank-badge { background: #F59E0B; }
.rank-2 .psc-rank-badge { background: #9CA3AF; }
.rank-3 .psc-rank-badge { background: #B45309; }

.psc-name {
    font-size: 16px;
    font-weight: 700;
    color: #111;
}
.psc-score {
    margin-left: auto;
    font-size: 22px;
    font-weight: 800;
    color: #111;
    letter-spacing: -0.5px;
}
.psc-score-label {
    font-size: 11px;
    color: #aaa;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Accuracy ring (SVG) */
.psc-accuracy-ring {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}
.psc-ring-bg {
    fill: none;
    stroke: #E5E7EB;
    stroke-width: 6;
}
.psc-ring-fg {
    fill: none;
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.7s ease;
}
.psc-ring-text {
    font-size: 14px;
    font-weight: 700;
    fill: #111;
    text-anchor: middle;
    dominant-baseline: central;
}

/* Stat grid inside card */
.psc-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    margin-top: 12px;
}
.psc-stat {
    display: flex;
    flex-direction: column;
}
.psc-stat-label {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 500;
    margin-bottom: 2px;
}
.psc-stat-value {
    font-size: 15px;
    font-weight: 600;
    color: #222;
}
.psc-stat-value.good {
    color: #16A34A;
}
.psc-stat-value.bad {
    color: #DC2626;
}

/* ── Category badges ────────────────────────────────────────────── */
.psc-cat-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.psc-cat-badge {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 100px;
    font-weight: 600;
}
.psc-cat-badge.best {
    background: #DCFCE7;
    color: #15803D;
}
.psc-cat-badge.worst {
    background: #FEE2E2;
    color: #B91C1C;
}

/* ── Per-type mini bars ─────────────────────────────────────────── */
.psc-types {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}
.psc-type-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.psc-type-label {
    flex: 0 0 110px;
    font-size: 11px;
    color: #666;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.psc-type-bar-bg {
    flex: 1;
    height: 8px;
    background: #E5E7EB;
    border-radius: 4px;
    overflow: hidden;
}
.psc-type-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: #6366F1;
    transition: width 0.5s ease;
}
.psc-type-pct {
    flex: 0 0 38px;
    font-size: 12px;
    font-weight: 600;
    color: #444;
    text-align: right;
}

/* ═════════════════════════════════════════════════════════════════
   HARDEST / EASIEST QUESTIONS
   ═════════════════════════════════════════════════════════════════ */
.stats-v2-section-title {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    margin: 24px 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.q-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.q-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #F9FAFB;
    border-radius: 8px;
}
.q-list-acc {
    flex: 0 0 50px;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    border-radius: 6px;
    padding: 2px 0;
}
.q-list-acc.hard {
    color: #DC2626;
    background: #FEE2E2;
}
.q-list-acc.easy {
    color: #16A34A;
    background: #DCFCE7;
}
.q-list-text {
    flex: 1;
    font-size: 13px;
    color: #444;
}
.q-list-type {
    font-size: 11px;
    color: #999;
    flex: 0 0 auto;
}

/* ── Responsive tweaks ──────────────────────────────────────────── */
@media (max-width: 640px) {
    .stats-v2-card {
        padding: 24px 20px 20px;
        border-radius: 12px;
    }
    .pareto-label {
        flex: 0 0 80px;
        font-size: 12px;
    }
    .player-stats-grid {
        grid-template-columns: 1fr;
    }
    .psc-stats {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── Scrollbar polish ───────────────────────────────────────────── */
.stats-v2-card::-webkit-scrollbar {
    width: 6px;
}
.stats-v2-card::-webkit-scrollbar-track {
    background: transparent;
}
.stats-v2-card::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}
