:root {
    --stats-heading: #f5d9ff;
    --stats-accent: #e3a4ff;
    --stats-accent-soft: rgba(227, 164, 255, 0.2);
    --stats-accent-2: #ffb3e6;
    --stats-success: #5ee08f;
    --stats-card-bg: rgba(255, 255, 255, 0.08);
    --stats-card-border: rgba(255, 255, 255, 0.2);
    --stats-table-head-bg: rgba(255, 255, 255, 0.12);
    --stats-row-border: rgba(255, 255, 255, 0.12);
    --stats-bar-track: rgba(255, 255, 255, 0.18);
    --stats-heat-rgb: 227, 164, 255;
    --stats-heat-empty: rgba(255, 255, 255, 0.06);
    --stats-heat-border: rgba(0, 0, 0, 0.25);
    --stats-chart-text: #ead6f5;
    --stats-chart-grid: rgba(255, 255, 255, 0.12);
}

html {
    height: auto;
    overflow: auto;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    height: auto;
    min-height: 100%;
    overflow-y: auto;
    display: block;
    background-color: var(--background-color);
    color: var(--text-color);
}

#app {
    display: block;
    width: auto;
    max-width: 1000px;
    margin: 0 auto;
    background-color: var(--modal-content-background-color);
    padding: 24px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.25);
    box-sizing: border-box;
}

#stats-title {
    text-align: center;
    color: var(--stats-heading);
    margin-top: 0;
}

#stats-title .fa-chart-column {
    color: var(--stats-accent);
    margin-right: 6px;
}

#stats-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-bottom: 2px solid var(--stats-card-border);
    margin-bottom: 18px;
}

.stats-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 10px 14px;
    font-size: 1em;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.75;
}

.stats-tab.active {
    border-bottom-color: var(--stats-accent);
    font-weight: bold;
    opacity: 1;
}

.stats-tab:hover {
    opacity: 1;
}

.stats-section {
    display: none;
}

.stats-section.active {
    display: block;
}

.stats-section h2 {
    font-size: 1.1em;
    margin: 24px 0 10px;
    color: var(--stats-heading);
}

.stats-section h3 {
    font-size: 1em;
    margin: 18px 0 8px;
}

.stats-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

/* Choix du mois, sous le titre de la page. */
.stats-month-bar {
    justify-content: center;
}

.stats-toolbar select {
    padding: 6px 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
    font-size: 0.95em;
}

.stats-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stats-card {
    background-color: var(--stats-card-bg);
    border: 1px solid var(--stats-card-border);
    border-radius: 10px;
    padding: 12px 14px;
    text-align: center;
}

.stats-card-value {
    font-size: 1.6em;
    font-weight: bold;
    color: var(--stats-accent);
}

.stats-card-label {
    font-size: 0.85em;
    opacity: 0.8;
    margin-top: 2px;
}

/* Comparaison avec la moyenne des joueurs (« Ma Belote », « Ma Coinche »). */
.stats-card-average {
    font-size: 0.75em;
    font-style: italic;
    opacity: 0.7;
    margin-top: 4px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.stats-table th,
.stats-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--stats-row-border);
    text-align: left;
}

.stats-table th {
    background-color: var(--stats-table-head-bg);
}

.stats-table td.num,
.stats-table th.num {
    text-align: right;
}

.stats-rate {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 150px;
}

.stats-rate > span {
    white-space: nowrap;
}

.stats-rate-bar {
    flex: 1;
    min-width: 40px;
    height: 8px;
    border-radius: 4px;
    background-color: var(--stats-bar-track);
    overflow: hidden;
}

.stats-rate-fill {
    height: 100%;
    background-color: var(--stats-success);
}

.stats-chart {
    position: relative;
    height: 240px;
}

.stats-hint,
.stats-empty {
    font-size: 0.9em;
    opacity: 0.75;
    margin: 4px 0 8px;
}

#heatmap-wrapper {
    overflow-x: auto;
}

#heatmap {
    border-collapse: collapse;
    font-size: 0.75em;
}

#heatmap th {
    padding: 2px 4px;
    font-weight: normal;
    opacity: 0.8;
}

#heatmap td {
    min-width: 18px;
    width: 22px;
    height: 20px;
    text-align: center;
    border: 1px solid var(--stats-heat-border);
    border-radius: 3px;
}

.stats-records {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.stats-record {
    display: flex;
    gap: 12px;
    align-items: center;
    background-color: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 190, 0, 0.35);
    border-radius: 10px;
    padding: 12px 14px;
}

.stats-record i {
    font-size: 1.6em;
    color: #d4a100;
    width: 32px;
    text-align: center;
}

/* Titre de groupe (Parties, UNO, Rami...) sur toute la largeur de la grille. */
.stats-records-group {
    grid-column: 1 / -1;
    margin: 10px 0 0;
}

.stats-records-group:first-child {
    margin-top: 0;
}

.stats-record-smiley img {
    max-height: 32px;
}

.stats-record-title {
    font-size: 0.85em;
    opacity: 0.8;
}

.stats-record-value {
    font-weight: bold;
    font-size: 1.05em;
}

.stats-record-detail {
    font-size: 0.85em;
    opacity: 0.75;
}

#stats-message {
    text-align: center;
    margin: 10px 0;
}

#stats-message:empty {
    display: none;
}

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

.stats-cards + .stats-table-wrapper {
    margin-top: 12px;
}

.stats-footer {
    margin-top: 24px;
    font-size: 0.8em;
    opacity: 0.7;
    text-align: center;
}

.stats-smileys {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.stats-smiley {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 64px;
    padding: 8px;
    border-radius: 8px;
    background-color: var(--stats-card-bg);
    font-size: 0.85em;
}

.stats-smiley img {
    max-width: 40px;
    max-height: 40px;
}

.stats-card-value img {
    max-height: 32px;
    vertical-align: middle;
}

.stats-record-list {
    margin: 4px 0 0;
    padding-left: 20px;
    font-size: 0.9em;
}

.stats-record-list li {
    margin: 2px 0;
}

.stats-record-list .stats-record-detail {
    display: inline;
    margin-left: 4px;
}

@media (max-width: 600px) {
    body {
        padding: 8px;
    }

    #app {
        padding: 14px;
    }

    .stats-tab {
        padding: 8px 8px;
        font-size: 0.9em;
    }

    .stats-rate {
        min-width: 110px;
    }
}

/* Deux rangées de cartes à la suite (« Ma Coinche ») : même écart qu'entre
   les cartes. */
.stats-cards + .stats-cards {
    margin-top: 12px;
}
