:root {
    --background-color: #121218;
    --surface-color: #1c1c24;
    --border-color: #33333f;
    --primary-color: #9146ff;
    --primary-hover-color: #a970ff;
    --text-color: #f0f0f5;
    --text-muted-color: #a0a0b0;
    --live-color: #2ecc71;
    --offline-color: #e74c3c;

    --font-primary: 'Poppins', sans-serif;
    --font-secondary: 'Inter', sans-serif;

    --border-radius: 12px;
    --spacing: 14px;
}

@keyframes fadeInSlideDown {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.new-game-animation {
    animation: fadeInSlideDown 0.5s ease-out forwards;
}


*, *::before, *::after {
    box-sizing: border-box;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: var(--font-secondary);
    margin: 0;
    padding: var(--spacing);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 900px;
}

#twitch-status-header {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 18px var(--spacing);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 20px;
    margin-bottom: calc(var(--spacing) * 1.5);
}

.status-light-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

#twitch-light {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
.light-on {
    background-color: var(--live-color);
    box-shadow: 0 0 8px var(--live-color);
}
.light-off {
    background-color: var(--offline-color);
}

#status-text {
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-muted-color);
}

#stream-info {
    min-width: 0;
}
#stream-info p {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
    color: var(--text-color);
}

#twitch-button {
    background-color: var(--primary-color);
    color: white;
    font-family: var(--font-primary);
    font-weight: 600;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}
#twitch-button:hover {
    background-color: var(--primary-hover-color);
}


/* Styles pour les onglets */
.tab-navigation {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: calc(var(--spacing) * 1.5);
}

.tab-button {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-muted-color);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-family: var(--font-primary);
    font-weight: 600;
    transition: all 0.2s ease;
}

.tab-button:hover {
    background-color: rgba(var(--primary-color), 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.tab-button.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.tab-content {
    display: none;
    animation: fadeInSlideDown 0.5s ease-out forwards;
}

.tab-content.active {
    display: block;
}


.stat-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px;
    transition: transform 0.2s ease, border-color 0.2s ease;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
}

.stat-card h2, .stat-card h3 {
    font-family: var(--font-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    margin: 0 0 12px 0;
    color: var(--text-muted-color);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: center;
}

.stat-card p {
    font-family: var(--font-primary);
    font-weight: 700;
    margin: 0;
    line-height: 1;
}

.main-stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing);
    margin-bottom: var(--spacing);
}

.bilan-stats-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
}

.bilan-stat {
    text-align: center;
}

.bilan-label {
    font-family: var(--font-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-muted-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
}
.bilan-value {
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 3rem;
    color: var(--primary-color);
    margin: 0;
    line-height: 1.2;
}


.secondary-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing);
    margin-bottom: calc(var(--spacing) * 1.5);
}
.secondary-stats-grid p {
    font-size: 2.5rem;
}

.highlight-value {
    color: var(--primary-color);
}

.stat-date {
    font-size: 0.8rem;
    font-style: italic;
    color: var(--text-muted-color);
    margin-top: 5px;
    text-align: center;
}


.value-with-button {
    display: flex;
    align-items: center;
    gap: 15px;
}

.history-title-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: var(--spacing);
    flex-wrap: wrap;
}

.history-container h2, .clips-container h2 {
    font-family: var(--font-primary);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-color);
    text-align: center;
    margin: 0;
}

#show-full-history-btn, #reset-sort-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted-color);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

#show-full-history-btn:hover, #reset-sort-btn:hover {
    background-color: var(--surface-color);
    color: var(--text-color);
    border-color: var(--primary-color);
}

.history-table {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, black 90%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 90%, transparent 100%);
}

.history-header, .history-row {
    display: grid;
    grid-template-columns: 1fr 0.7fr 0.7fr 0.5fr 0.5fr 0.5fr;
    padding: 16px var(--spacing);
    align-items: center;
    text-align: center;
}

.history-header {
    background-color: rgba(0, 0, 0, 0.2);
    font-family: var(--font-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-muted-color);
    text-transform: uppercase;
}

.history-header .sortable {
    cursor: pointer;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.history-header .sortable:hover {
    color: var(--primary-color);
}
.history-header .sortable.active {
    color: var(--primary-hover-color);
    text-decoration: none;
}

.sort-indicator {
    display: flex;
    flex-direction: column;
    height: 12px;
    justify-content: center;
    align-items: center;
    gap: 1px;
}

.sort-indicator svg {
    display: block;
    height: 6px;
    width: 6px;
    color: var(--text-muted-color); /* Couleur par défaut */
    transition: color 0.2s ease;
}

.sortable.active .sort-indicator svg {
    color: var(--text-muted-color); /* On garde la couleur par défaut pour les non-actifs */
}

/* On cache la flèche inactive */
.history-header .sortable[data-sort].active.asc .arrow-down,
.history-header .sortable[data-sort].active.desc .arrow-up {
    opacity: 0.4;
}

/* On change la couleur de la flèche active */
.history-header .sortable[data-sort].active.asc .arrow-up,
.history-header .sortable[data-sort].active.desc .arrow-down {
    color: var(--primary-color);
}

#game-history-body {
    max-height: 300px;
    overflow-y: auto;
}
.history-row {
    border-top: 1px solid var(--border-color);
    font-size: 1rem;
    font-weight: 500;
}
.history-row:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.history-row span:first-child {
    font-size: 0.9rem;
    color: var(--text-muted-color);
}

.duo-separator {
    background-color: rgba(52, 152, 219, 0.1); /* Fond bleu avec 10% d'opacité */
    color: #3498db; /* Couleur du texte en bleu */
    text-align: center;
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 10px var(--spacing);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    letter-spacing: 1px;
}

.history-row.in-duo-session {
    background-color: rgba(52, 152, 219, 0.05); /* Surlignage bleu avec 5% d'opacité */
}

#game-history-body::-webkit-scrollbar { width: 8px; }
#game-history-body::-webkit-scrollbar-track { background: transparent; }
#game-history-body::-webkit-scrollbar-thumb { background-color: var(--border-color); border-radius: 10px; }

.scroll-indicator {
    text-align: center;
    margin-top: 10px;
    margin-bottom: calc(var(--spacing) * 2);
}
.scroll-indicator p {
    margin: 0;
    font-size: 0.8rem;
    font-style: italic;
    color: var(--text-muted-color);
}


footer {
    text-align: center;
    margin-top: calc(var(--spacing) * 2);
    padding-top: var(--spacing);
    border-top: 1px solid var(--border-color);
    width: 100%;
}
footer p { margin: 0; font-size: 0.9rem; color: var(--text-muted-color); }
footer a { color: var(--primary-color); text-decoration: none; font-weight: 600; transition: color 0.2s ease; }
footer a:hover { color: var(--primary-hover-color); text-decoration: underline; }

.share-button-container { display: flex; justify-content: center; margin: calc(var(--spacing) * 0.5) 0; }
#screenshot-btn { background-color: var(--primary-color); color: white; font-family: var(--font-primary); font-weight: 600; font-size: 1rem; border: none; padding: 12px 24px; border-radius: 8px; cursor: pointer; transition: background-color 0.2s ease, transform 0.2s ease; }
#screenshot-btn:hover { background-color: var(--primary-hover-color); transform: scale(1.05); }

#stats-capture-card {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 600px;
    background-color: var(--surface-color);
    border: 3px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 24px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.capture-header { text-align: center; }
.capture-header h3 { font-size: 1.2rem; font-weight: 500; color: var(--text-muted-color); margin: 0; text-transform: uppercase; letter-spacing: 2px; }
.capture-header h1 { font-size: 3rem; font-family: var(--font-primary); font-weight: 700; color: var(--primary-color); margin: 5px 0 0 0; }
.capture-main-stats { display: flex; justify-content: space-around; text-align: center; border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); padding: 20px 0; }
.capture-stat .label { font-size: 1rem; color: var(--text-muted-color); text-transform: uppercase; letter-spacing: 1px;}
.capture-stat .value { font-size: 3.5rem; font-family: var(--font-primary); font-weight: 700; color: var(--text-color); display: block; line-height: 1.1; }
.capture-secondary-stats { display: flex; justify-content: space-around; text-align: center; }
.capture-stat-secondary .label { font-size: 1rem; color: var(--text-muted-color); }
.capture-stat-secondary .value { font-size: 1.5rem; font-family: var(--font-primary); font-weight: 600; color: var(--text-color); display: block; }
.capture-footer { text-align: center; font-size: 1rem; color: var(--primary-color); font-weight: 600; padding-top: 10px; }
.capture-timestamp {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted-color);
    margin-top: -10px;
    font-family: var(--font-secondary);
}

.hidden {
    display: none !important;
}

.clip-button {
    background: none;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: var(--font-secondary);
    font-weight: 500;
    margin-top: 0; 
    transition: all 0.2s ease;
}

.clip-button:hover {
    background-color: var(--primary-color);
    color: white;
}

#image-modal, #clip-modal, #history-modal, #info-modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

#clip-modal {
    z-index: 1001;
}

.modal-hidden {
    display: none !important;
}

.modal-content {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing);
    text-align: center;
    max-width: 90%;
    max-height: 90%;
    animation: fadeInSlideDown 0.3s ease-out;
}

#image-modal .modal-content {
    max-width: 90%;
}

#clip-modal .modal-content {
    width: 90%;
    max-width: 960px;
}

#history-modal .modal-content {
    width: 90%;
    max-width: 800px;
}

#info-modal .modal-content {
    max-width: 700px;
}

#info-modal-text {
    font-size: 1rem;
    color: var(--text-muted-color);
    line-height: 1.6;
    margin-top: 10px;
    margin-bottom: 20px;
    white-space: pre-wrap;
}

#info-tweet-link:hover {
    background-color: #1a91da !important;
}

#info-clip-embed-container:empty {
    display: none;
}

.modal-content h2 { margin-top: 0; color: var(--text-color); }
.modal-content img { max-width: 100%; max-height: 60vh; border-radius: 8px; border: 1px solid var(--border-color); }
.modal-close { position: absolute; top: 15px; right: 35px; color: #aaa; font-size: 28px; font-weight: bold; cursor: pointer; }
.modal-close:hover { color: white; }
.modal-actions { display: flex; gap: 15px; justify-content: center; margin-top: 20px; }
.modal-actions button { background-color: var(--primary-color); color: white; font-family: var(--font-primary); font-weight: 600; font-size: 1rem; border: none; padding: 12px 24px; border-radius: 8px; cursor: pointer; transition: background-color 0.2s ease; }
.modal-actions button:hover { background-color: var(--primary-hover-color); }

#clip-embed-container, #info-clip-embed-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
}

#clip-embed-container iframe, #info-clip-embed-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

#full-history-container {
    max-height: 65vh;
    overflow-y: auto;
    margin-top: var(--spacing);
}

#full-history-container .history-header {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: var(--surface-color); 
}

#full-history-container::-webkit-scrollbar { width: 8px; }
#full-history-container::-webkit-scrollbar-track { background: transparent; }
#full-history-container::-webkit-scrollbar-thumb { background-color: var(--border-color); border-radius: 10px; }
#full-history-container::-webkit-scrollbar-thumb:hover { background-color: #555; }

.clips-container {
    margin-top: calc(var(--spacing) * 0);
}

.clips-sort-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: var(--spacing);
    flex-wrap: wrap;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px;
}

.clips-sort-controls span {
    align-self: center;
    color: var(--text-muted-color);
    font-size: 0.9rem;
    font-weight: 500;
}

.sort-select {
    background-color: #2a2a33;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    font-family: var(--font-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sort-select:hover {
    border-color: var(--primary-color);
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 5px var(--primary-color);
}


.clips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--spacing);
    margin-top: var(--spacing);
}

.clip-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.clip-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
}

.clip-thumbnail {
    position: relative;
}

.clip-thumbnail img {
    width: 100%;
    display: block;
    aspect-ratio: 16 / 9;
    background-color: #000;
}

.clip-views {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.clip-info {
    padding: 12px;
}

.clip-info h4 {
    margin: 0 0 4px 0;
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-color);
}

.clip-info .clip-creator {
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.clip-info p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted-color);
}

.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: calc(var(--spacing) * 1.5);
    flex-wrap: wrap;
}

.pagination-button {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-muted-color);
    font-family: var(--font-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-button:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pagination-button.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.pagination-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    color: var(--text-muted-color);
    font-size: 0.9rem;
    margin: 0 10px;
}

.last-updated-info {
    text-align: center;
    width: 100%;
    margin-top: calc(var(--spacing) * 1.2);
    font-size: 0.85rem;
    color: var(--text-muted-color);
    font-style: italic;
}

.history-clip-btn {
    background: none;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 5px 0;
    width: 40px;
    margin: 0 auto;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: var(--font-secondary);
    font-weight: 500;
    transition: all 0.2s ease;
}

.history-clip-btn:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: white;
}

.history-clip-btn:disabled {
    border-color: var(--border-color);
    color: var(--text-muted-color);
    opacity: 0.4;
    cursor: not-allowed;
}

.clip-thumbnail--no-image, .clip-thumbnail--error {
    background-color: #2a2a33;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23a0a0b0'%3E%3Cpath d='M21.01 3H2.99C1.89 3 1 3.9 1 5v14c0 1.1.89 2 1.99 2H21.01c1.1 0 1.99-.9 1.99-2V5c0-1.1-.89-2-1.99-2zM21 19.01H3V4.99h18v14.02zM8.5 11.5l2.5 3.01L14.5 11l4.5 6H5l3.5-4.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 50px;
    aspect-ratio: 16 / 9;
}

.info-icon {
    display: inline-block;
    color: var(--offline-color);
    font-weight: 700;
    margin-left: 5px;
    cursor: pointer;
    transition: transform 0.2s ease, text-shadow 0.2s ease;
    user-select: none; /* Empêche la sélection du texte */
}

.info-icon:hover {
    transform: scale(1.2);
    text-shadow: 0 0 5px var(--offline-color);
}

@media (max-width: 768px) {
    #twitch-status-header { grid-template-columns: 1fr; text-align: center; gap: 15px; }
    #twitch-button { width: 100%; justify-self: center; }
    .secondary-stats-grid { grid-template-columns: 1fr; }
    .modal-content { width: 95%; }
    .tab-navigation { flex-wrap: wrap; }
    .clips-sort-controls { flex-wrap: wrap; justify-content: flex-start; }
}

#leaderboard-container {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 12px;
    margin-bottom: var(--spacing);
}

#leaderboard-container h2 {
    font-family: var(--font-primary);
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    color: var(--primary-color);
    margin: 0 0 12px 0;
}

.bilan-stat-wrapper {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-top: 15px;
}

#leaderboard-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.leaderboard-item {
    display: grid;
    grid-template-columns: 25px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background-color: var(--background-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.leaderboard-item.leaderboard-item--top1 {
    grid-column: 1 / -1; 
    justify-self: center;
    width: 60%; 
    border-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(145, 70, 255, 0.4);
}


.leaderboard-item .rank {
    font-weight: 700;
    font-family: var(--font-primary);
    color: var(--text-muted-color);
    font-size: 0.9rem;
}

.leaderboard-item .name {
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-item .count {
    font-weight: 600;
    font-family: var(--font-primary);
    background-color: #3e3e4a;
    color: var(--text-color);
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.8rem;
}

.leaderboard-item--top1 .count {
    background-color: var(--primary-color);
    color: white;
}

@media (max-width: 768px) {
    #leaderboard-list {
        grid-template-columns: 1fr 1fr;
    }
    .leaderboard-item.leaderboard-item--top1 {
       width: 90%;
    }
}