/* ===== CSS COMMUN UNIFIÉ POUR TOUS LES JEUX GUESSER ===== */

/* Variables CSS communes */
:root {
    /* Couleurs principales */
    --primary-color: #3f51b5;
    --secondary-color: #f39c12;
    --success-color: #4caf50;
    --error-color: #f44336;
    --warning-color: #ff9800;
    
    /* Couleurs de base - MODE SOMBRE PAR DÉFAUT */
    --bg-color: #1e1e1e;
    --text-color: #ccc;
    --header-bg: #333;
    --header-text: #f5f5f5;
    --container-bg: #2d2d2d;
    --border-color: #444;
    --highlight-bg: #444;
    --button-bg: #007bff;
    --button-text: #fff;
    
    /* Couleurs de thème sombre */
    --dark-bg: #121212;
    --light-bg: #1e1e1e;
    --dark-text-color: #e0e0e0;
    --dark-border-color: #333;
    
    /* Couleurs spécifiques aux jeux */
    --skin-daily-primary: #3f51b5;
    --skin-unlimited-primary: #9c27b0;
    --item-daily-primary: #cd853f;
    --item-unlimited-primary: #cd853f;
    --itemdle-primary: #28a745;
}

/* Mode sombre renforcé (optionnel, car déjà par défaut) */
.dark-mode {
    --bg-color: #1e1e1e;
    --text-color: #ccc;
    --header-bg: #333;
    --header-text: #f5f5f5;
    --container-bg: #2d2d2d;
    --border-color: #444;
    --highlight-bg: #444;
    --button-bg: #007bff;
    --button-text: #fff;
    --dark-bg: #0f0f0f;
    --light-bg: #1a1a1a;
    --dark-text-color: #f0f0f0;
    --dark-border-color: #444;
}

/* Mode clair */
.light-mode {
    --bg-color: #f5f5f5;
    --text-color: #333;
    --header-bg: #fff;
    --header-text: #333;
    --container-bg: #fff;
    --border-color: #ccc;
    --highlight-bg: #eaeaea;
    --button-bg: #007bff;
    --button-text: #fff;
    --dark-bg: #f8f9fa;
    --light-bg: #ffffff;
    --dark-text-color: #212529;
    --dark-border-color: #dee2e6;
}

/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== HEADER ===== */

header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.3s, color 0.3s;
}

.title {
    font-size: 1.2rem;
    font-weight: bold;
}

.back-btn {
    margin-right: auto;
    margin-left: 20px;
    background: #6c757d;
    text-decoration: none;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
}

.theme-toggle-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--header-text);
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
}

.theme-toggle-btn:hover {
    background: var(--highlight-bg);
    background: rgba(0,0,0,0.9);
    transform: scale(1.1);
}

/* ===== LAYOUT PRINCIPAL ===== */

main {
    padding-top: 120px;
    min-height: 100vh;
    background: var(--bg-color);
}

.container, .game-container {
    max-width: 1000px;
    margin: 20px auto;
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: background 0.3s, border-color 0.3s;
}

.game-container {
    padding: 2rem 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

h1 {
    margin-bottom: 20px;
    text-align: center;
}

/* ===== HEADER DU JEU ===== */

.game-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
}

.game-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
}

.game-header .subtitle {
    color: #ccc;
    font-size: 1.1rem;
    position: relative;
    z-index: 1;
}

/* Headers spécifiques par jeu */
.skin-daily .game-header {
    background: linear-gradient(135deg, rgba(63,81,181,0.15), rgba(243,156,18,0.15));
}
.skin-daily .game-header h1 {
    color: var(--skin-daily-primary);
}

.skin-unlimited .game-header {
    background: linear-gradient(135deg, rgba(156,39,176,0.15), rgba(233,30,99,0.15));
}
.skin-unlimited .game-header h1 {
    color: var(--skin-unlimited-primary);
}

.item-daily .game-header,
.item-unlimited .game-header {
    background: linear-gradient(135deg, rgba(139,69,19,0.15), rgba(210,180,140,0.15));
}
.item-daily .game-header h1,
.item-unlimited .game-header h1 {
    color: var(--item-daily-primary);
}

.itemdle-daily .game-header,
.itemdle-unlimited .game-header {
    background: linear-gradient(135deg, rgba(40,167,69,0.15), rgba(25,135,84,0.15));
}
.itemdle-daily .game-header h1,
.itemdle-unlimited .game-header h1 {
    color: var(--itemdle-primary);
}

/* Badge unlimited */
.unlimited-badge {
    display: inline-block;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 10px;
    animation: pulse 2s infinite;
}

/* ===== GAME BOARD ===== */

.game-board {
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.dark-mode .game-board {
    background: var(--light-bg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.game-board::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 20%, rgba(63, 81, 181, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(243, 156, 18, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.game-board > * {
    position: relative;
    z-index: 1;
}

/* ===== CONTAINER D'IMAGE ===== */

.splash-container, #splashContainer {
    position: relative;
    width: 400px;
    height: 300px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    margin: 10px auto;
    border-radius: 12px;
    transition: width 0.5s, height 0.5s;
    box-shadow: 0 4px 16px rgba(63, 81, 181, 0.3);
}

.splash-container img, #splashImg {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    pointer-events: none;
    -webkit-touch-callout: none;
}

.splash-container.reveal {
    width: 100%;
    max-width: 800px;
    aspect-ratio: 1920 / 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin: 0 auto;
}

.splash-container.reveal img {
    position: static;
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
}

/* Reveal pour SkinGuesser seulement - ItemGuesser garde sa taille 64x64px */
.reveal:not(.item-guesser) {
    width: 600px !important;
    height: 400px !important;
}

/* Pour ItemGuesser, la classe reveal ne change pas la taille */
.reveal.item-guesser {
    /* Garde les dimensions CSS par défaut (64x64px) */
}

/* Styles spécifiques par jeu pour les containers */
.skin-unlimited .splash-container,
.skin-unlimited #splashContainer {
    border-color: var(--skin-unlimited-primary);
    box-shadow: 0 4px 16px rgba(156, 39, 176, 0.3);
}

.item-daily .splash-container,
.item-daily #splashContainer,
.item-unlimited .splash-container,
.item-unlimited #splashContainer {
    border-color: var(--item-daily-primary);
    box-shadow: 0 4px 16px rgba(205, 133, 63, 0.3);
}

.itemdle-daily .splash-container,
.itemdle-daily #splashContainer,
.itemdle-unlimited .splash-container,
.itemdle-unlimited #splashContainer {
    border-color: var(--itemdle-primary);
    box-shadow: 0 4px 16px rgba(40, 167, 69, 0.3);
}

/* ===== STATS DU JEU ===== */

.game-stats {
    display: flex;
    justify-content: space-around;
    margin: 2rem 0;
    padding: 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
}

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

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    color: #ccc;
    font-size: 0.9rem;
}

/* Stats pour unlimited */
.skin-unlimited .game-stats,
.item-unlimited .game-stats,
.itemdle-unlimited .game-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.skin-unlimited .stat-item,
.item-unlimited .stat-item,
.itemdle-unlimited .stat-item {
    padding: 0.5rem;
}

.skin-unlimited .stat-value {
    color: var(--skin-unlimited-primary);
}

.item-daily .stat-value,
.item-unlimited .stat-value {
    color: var(--item-daily-primary);
}

.itemdle-daily .stat-value,
.itemdle-unlimited .stat-value {
    color: var(--itemdle-primary);
}

/* High score styling */
.high-score {
    color: var(--secondary-color) !important;
    text-shadow: 0 0 10px rgba(243, 156, 18, 0.5);
}

/* ===== PROGRESS BAR ===== */

.attempt-progress {
    margin-bottom: 2rem;
    text-align: center;
}

.attempt-progress label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

#attemptProgress {
    width: 200px;
    height: 20px;
    border-radius: 10px;
    overflow: hidden;
}

/* ===== SECTIONS ===== */

.section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.3s ease;
}

.section.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(63, 81, 181, 0.3);
    transform: scale(1.02);
}

.section h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
}

.section h3 i {
    font-size: 1.5rem;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Styles spécifiques par jeu pour les sections */
.skin-unlimited .section h3 {
    color: var(--skin-unlimited-primary);
}

.item-daily .section h3,
.item-unlimited .section h3 {
    color: var(--item-daily-primary);
}

.itemdle-daily .section h3,
.itemdle-unlimited .section h3 {
    color: var(--itemdle-primary);
}

.section form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.section label {
    font-weight: bold;
}

/* ===== FORMULAIRES ===== */

.guess-form {
    display: flex;
    gap: 10px;
    align-items: end;
}

.guess-input-group {
    flex: 1;
    position: relative;
}

input[type="text"], .guess-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--container-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

input[type="text"]:focus, .guess-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.5);
    outline: none;
    background-color: var(--bg-color);
}

/* Focus spécifique par jeu */
.skin-unlimited input[type="text"]:focus,
.skin-unlimited .guess-input:focus {
    border-color: var(--skin-unlimited-primary);
    box-shadow: 0 0 0 3px rgba(156, 39, 176, 0.2);
}

.item-daily input[type="text"]:focus,
.item-daily .guess-input:focus,
.item-unlimited input[type="text"]:focus,
.item-unlimited .guess-input:focus {
    border-color: var(--item-daily-primary);
    box-shadow: 0 0 0 3px rgba(205, 133, 63, 0.2);
}

.itemdle-daily input[type="text"]:focus,
.itemdle-daily .guess-input:focus,
.itemdle-unlimited input[type="text"]:focus,
.itemdle-unlimited .guess-input:focus {
    border-color: var(--itemdle-primary);
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.2);
}

select {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-color);
    color: var(--text-color);
    transition: background 0.3s, color 0.3s, border-color 0.3s;
}

/* ===== SUGGESTIONS AUTOCOMPLETE ===== */

.autocomplete-wrapper {
    position: relative;
    width: 100%;
}

.autocomplete, .guess-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
    list-style: none;
    padding: 0;
    margin: 0;
    margin-top: 4px;
    z-index: 999;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.guess-suggestions.hidden {
    display: none;
}

.autocomplete li, .guess-suggestions li {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.autocomplete li:last-child, .guess-suggestions li:last-child {
    border-bottom: none;
}

.autocomplete li:hover, .guess-suggestions li:hover,
.autocomplete li.selected, .guess-suggestions li.selected {
    background: var(--highlight-bg);
}

/* Hover spécifique par jeu */
.skin-unlimited .autocomplete li:hover,
.skin-unlimited .autocomplete li.selected,
.skin-unlimited .guess-suggestions li:hover,
.skin-unlimited .guess-suggestions li.selected {
    background: rgba(156, 39, 176, 0.2);
}

.item-daily .autocomplete li:hover,
.item-daily .autocomplete li.selected,
.item-daily .guess-suggestions li:hover,
.item-daily .guess-suggestions li.selected,
.item-unlimited .autocomplete li:hover,
.item-unlimited .autocomplete li.selected,
.item-unlimited .guess-suggestions li:hover,
.item-unlimited .guess-suggestions li.selected {
    background: rgba(205, 133, 63, 0.2);
}

.itemdle-daily .autocomplete li:hover,
.itemdle-daily .autocomplete li.selected,
.itemdle-daily .guess-suggestions li:hover,
.itemdle-daily .guess-suggestions li.selected,
.itemdle-unlimited .autocomplete li:hover,
.itemdle-unlimited .autocomplete li.selected,
.itemdle-unlimited .guess-suggestions li:hover,
.itemdle-unlimited .guess-suggestions li.selected {
    background: rgba(40, 167, 69, 0.2);
}

/* ===== BOUTONS ===== */

.btn {
    background: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 1rem;
    transition: background 0.2s;
    margin: 5px 0;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    opacity: 0.9;
}

.btn-guess {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary-color), #4f61c7);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-guess:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(63, 81, 181, 0.4);
}

.btn-guess:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Boutons spécifiques par jeu */
.skin-unlimited .btn-guess {
    background: linear-gradient(135deg, var(--skin-unlimited-primary), #ba68c8);
}

.skin-unlimited .btn-guess:hover {
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.4);
}

.item-daily .btn-guess,
.item-unlimited .btn-guess {
    background: linear-gradient(135deg, var(--item-daily-primary), #b8860b);
}

.item-daily .btn-guess:hover,
.item-unlimited .btn-guess:hover {
    box-shadow: 0 4px 12px rgba(205, 133, 63, 0.4);
}

.itemdle-daily .btn-guess,
.itemdle-unlimited .btn-guess {
    background: linear-gradient(135deg, var(--itemdle-primary), #20c997);
}

.itemdle-daily .btn-guess:hover,
.itemdle-unlimited .btn-guess:hover {
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

/* ===== BOUTONS D'ACTION ===== */

.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.btn-action {
    padding: 12px 24px;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-primary-action {
    background: linear-gradient(135deg, var(--primary-color), #4f61c7);
    color: white;
}

.btn-secondary-action {
    background: linear-gradient(135deg, var(--secondary-color), #ff8c42);
    color: white;
}

.btn-danger-action {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
}

.btn-action:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    color: white;
    text-decoration: none;
}

/* Boutons spécifiques par jeu */
.item-daily .btn-primary-action,
.item-unlimited .btn-primary-action {
    background: linear-gradient(135deg, var(--item-daily-primary), #b8860b);
}

.itemdle-daily .btn-primary-action,
.itemdle-unlimited .btn-primary-action {
    background: linear-gradient(135deg, var(--itemdle-primary), #20c997);
}

.logout-btn {
    background-color: #dc3545;
    color: #fff;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 1rem;
    transition: opacity 0.2s ease-in-out;
}

.logout-btn:hover {
    opacity: 0.8;
}

/* ===== FEEDBACK ===== */

.feedback {
    margin-top: 1rem;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: red;
    font-size: 0.95rem;
}

.feedback-success {
    background: linear-gradient(135deg, var(--success-color), #66bb6a);
    color: white;
}

.feedback-error {
    background: linear-gradient(135deg, var(--error-color), #ef5350);
    color: white;
}

.feedback-warning {
    background: linear-gradient(135deg, var(--warning-color), #ffb74d);
    color: white;
}

.feedback-info {
    background: linear-gradient(135deg, #2196f3, #42a5f5);
    color: white;
}

/* ===== HISTORIQUE DES TENTATIVES ===== */

.guess-history {
    margin: 2rem 0;
    padding: 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
}

.guess-history h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

#guessHistoryList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#guessHistoryList li {
    padding: 0.5rem;
    margin: 0.25rem 0;
    border-radius: 4px;
    font-weight: 500;
}

#guessHistoryList li.correct {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
}

#guessHistoryList li.incorrect {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
}

/* ===== AUTHENTIFICATION ===== */

.auth-section {
    text-align: center;
    margin: 2rem 0;
}

#loginContainer button,
#logoutBtn {
    background: linear-gradient(135deg, var(--primary-color), #4f61c7);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#loginContainer button:hover,
#logoutBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(63, 81, 181, 0.4);
}

#logoutBtn {
    background: linear-gradient(135deg, #dc3545, #c82333);
}

/* ===== LEADERBOARD ===== */

.leaderboard-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 25px;
}

.leaderboard {
    width: 100%;
    max-width: 500px;
    padding: 20px;
    background: #2c3849;
    border-radius: 12px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
    transition: transform 0.3s ease;
}

.leaderboard:hover {
    transform: scale(1.02);
}

.leaderboard h2, .game-board h3 {
    margin-bottom: 18px;
    font-size: 1.7rem;
    color: #ffffff;
    text-shadow: none;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

#leaderboardList {
    list-style: none;
    counter-reset: leaderboard;
    padding: 0;
    margin: 0;
}

#leaderboardList li {
    position: relative;
    padding: 10px 15px 10px 50px;
    margin-bottom: 12px;
    font-size: 1.2rem;
    font-weight: 500;
    background: #243141;
    color: #ffffff;
    border-radius: 10px;
    box-shadow: none;
    transition: background-color 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid transparent;
}

#leaderboardList li:hover {
    background-color: #1e2938;
    background: rgba(255,255,255,0.1);
    transform: translateX(5px);
}

#leaderboardList li::before {
    counter-increment: leaderboard;
    content: counter(leaderboard);
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    background-color: #ffca28;
    color: #050608;
    width: 28px;
    height: 28px;
    line-height: 28px;
    border-radius: 50%;
    text-align: center;
    font-weight: bold;
}

/* Couleurs spéciales podium */
#leaderboardList li:nth-child(1)::before,
#leaderboardList li.top-1 {
    background-color: #ffca28;
    border-left-color: #ffd700;
    background: linear-gradient(135deg, rgba(255,215,0,0.1), rgba(255,215,0,0.05));
}

#leaderboardList li:nth-child(1)::before {
    background-color: #ffca28;
}

#leaderboardList li:nth-child(2)::before,
#leaderboardList li.top-2 {
    background-color: #aab2bd;
    border-left-color: #c0c0c0;
    background: linear-gradient(135deg, rgba(192,192,192,0.1), rgba(192,192,192,0.05));
}

#leaderboardList li:nth-child(2)::before {
    background-color: #aab2bd;
}

#leaderboardList li:nth-child(3)::before,
#leaderboardList li.top-3 {
    background-color: #cd7f32;
    border-left-color: #cd7f32;
    background: linear-gradient(135deg, rgba(205,127,50,0.1), rgba(205,127,50,0.05));
}

#leaderboardList li:nth-child(3)::before {
    background-color: #cd7f32;
}

.leaderboard-rank {
    font-weight: bold;
    color: var(--primary-color);
    min-width: 30px;
}

.leaderboard-entry {
    flex: 1;
    margin-left: 1rem;
}

/* Bouton connexion intégré au thème */
.leaderboard-container .btn {
    margin-bottom: 20px;
    text-decoration: none;
    font-size: 1rem;
    color: white;
    background-color: #1565c0;
    padding: 8px 16px;
    border-radius: 8px;
    transition: background-color 0.3s ease;
}

.leaderboard-container .btn:hover {
    background-color: #1255a3;
}

/* Adaptation parfaite pour le thème sombre existant */
.dark-mode .leaderboard {
    background: #2c3849;
}

.dark-mode .leaderboard h2,
.dark-mode #leaderboardList li {
    color: #ffffff;
}

/* ===== MODAL ===== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-content {
    background: var(--container-bg);
    padding: 2rem;
    border-radius: 16px;
    max-width: 90%;
    width: 600px;
    text-align: center;
}

.dark-mode .modal-content {
    background: var(--light-bg);
}

.game-suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.game-card {
    background: rgba(255,255,255,0.05);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.3s ease;
}

.game-card:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-2px);
}

.game-link {
    color: inherit;
    text-decoration: none;
}

.game-link:hover {
    color: inherit;
    text-decoration: none;
}

/* ===== ANIMATIONS ===== */

.flash-success {
    animation: flashSuccess 0.6s ease;
}

.flash-error {
    animation: flashError 0.6s ease;
}

.correct-effect {
    animation: correctFlash 1s ease-out;
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

@keyframes flashSuccess {
    0%, 100% { background: transparent; }
    50% { background: rgba(76, 175, 80, 0.3); }
}

@keyframes flashError {
    0%, 100% { background: transparent; }
    50% { background: rgba(244, 67, 54, 0.3); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes pulseSuccess {
    0% {
        background-color: #d4edda;
        transform: scale(1);
    }
    50% {
        background-color: #c3e6cb;
        transform: scale(1.05);
    }
    100% {
        background-color: #d4edda;
        transform: scale(1);
    }
}

@keyframes correctFlash {
    0% {
        background-color: transparent;
    }
    50% {
        background-color: #d4edda;
    }
    100% {
        background-color: transparent;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE DESIGN ===== */

@media (max-width: 768px) {
    main {
        padding-top: 100px;
    }
    
    .container, .game-container {
        padding: 1rem 0.5rem;
        margin: 10px;
    }
    
    .splash-container, #splashContainer {
        width: 250px;
        height: 167px;
    }
    
    .game-header h1 {
        font-size: 2rem;
    }
    
    .guess-form {
        flex-direction: column;
        gap: 15px;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
    }

    .game-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .theme-toggle-btn {
        bottom: 1rem;
        right: 1rem;
        padding: 8px;
        font-size: 1.2rem;
    }
}

/* ===== CLASSES UTILITAIRES ===== */

.hidden {
    display: none !important;
}

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

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.loading {
    opacity: 0.7;
    pointer-events: none;
}

.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ===== FOCUS ET ACCESSIBILITÉ ===== */

*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus,
.btn:focus {
    outline: 2px solid rgba(255,255,255,0.5);
}

/* Amélioration du contraste pour l'accessibilité */
@media (prefers-contrast: high) {
    :root {
        --text-color: #ffffff;
        --border-color: #666;
    }
    
    input[type="text"], .guess-input {
        border-width: 3px;
    }
}

/* Réduction des animations pour les utilisateurs sensibles */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== STYLES SPÉCIAUX ITEMDLE ===== */

/* Grille Itemdle */
.itemdle-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin: 1rem 0;
}

.itemdle-header {
    font-weight: bold;
    padding: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    text-align: center;
    font-size: 0.9rem;
}

.itemdle-cell {
    padding: 8px;
    border-radius: 4px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.itemdle-cell.correct {
    background: rgba(76, 175, 80, 0.3);
    color: #4caf50;
}

.itemdle-cell.close {
    background: rgba(255, 152, 0, 0.3);
    color: #ff9800;
}

.itemdle-cell.incorrect {
    background: rgba(244, 67, 54, 0.3);
    color: #f44336;
}

/* ===== FIN DU CSS UNIFIÉ ===== */

/* ===== Design tokens additionnels (unifie le style) ===== */
:root {
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;

  --dur-1: 150ms;
  --dur-2: 250ms;
  --ease-1: cubic-bezier(.2,.6,.2,1);
  --ease-2: cubic-bezier(.16,1,.3,1);

  /* Surfaces (remplace les hardcodes #2c3849 etc.) */
  --surface-1: var(--container-bg);
  --surface-2: color-mix(in srgb, var(--container-bg) 85%, #000 15%);
  --surface-3: color-mix(in srgb, var(--container-bg) 70%, #000 30%);

  /* Ombres unifiées */
  --shadow-1: 0 1px 2px rgba(0,0,0,.15);
  --shadow-2: 0 6px 16px rgba(0,0,0,.25);
  --shadow-3: 0 10px 28px rgba(0,0,0,.35);

  /* Anneau de focus */
  --ring: 0 0 0 3px color-mix(in srgb, var(--primary-color) 30%, transparent);
}

@supports not (color-mix: in srgb, black, white) {
  :root {
    /* Fallback simple si color-mix pas dispo */
    --surface-2: #2a2a2a;
    --surface-3: #242424;
  }
}

/* ===== Typo fluide & lissage ===== */
html { font-size: clamp(14px, 0.9vw + 10px, 18px); }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* ===== Header sticky + padding auto ===== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
}
:root { --header-h: 56px; }
header { min-height: var(--header-h); }
main { padding-top: calc(var(--header-h) + var(--space-3)); }

/* ===== Theme toggle (nettoyé, un seul style) ===== */
.theme-toggle-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 48px; height: 48px;
  border-radius: 50%;
  display: grid; place-items: center;
  border: none;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 1.25rem;
  box-shadow: var(--shadow-2);
  transition: transform var(--dur-1) var(--ease-2), background-color var(--dur-1), box-shadow var(--dur-1);
}
.theme-toggle-btn:hover { transform: scale(1.07); background: rgba(0,0,0,.8); box-shadow: var(--shadow-3); }

/* ===== Cartes & conteneurs unifiés ===== */
.container, .game-container, .game-board, .leaderboard, .modal-content, .section {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}
.game-container, .game-board { box-shadow: var(--shadow-2); }
.dark-mode .game-board { box-shadow: var(--shadow-3); }

/* ===== Buttons unifiés (rayon/anneau/transition) ===== */
:where(.btn, .btn-guess, .btn-action, button) {
  border-radius: var(--radius-sm);
  transition: transform var(--dur-1) var(--ease-2), box-shadow var(--dur-1), background-color var(--dur-1), opacity var(--dur-1);
  will-change: transform;
}
.btn:hover, .btn-guess:hover, .btn-action:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.btn:disabled, .btn-guess:disabled, .btn-action:disabled { opacity: .6; transform: none; box-shadow: none; }

/* ===== Inputs & groupe d’entrée ===== */
.guess-input-group:focus-within { filter: drop-shadow(0 0 0 rgba(0,0,0,0)) drop-shadow(0 0 0 rgba(0,0,0,0)); box-shadow: var(--ring); border-radius: var(--radius-sm); }
input[type="text"], .guess-input {
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-1), box-shadow var(--dur-1), background-color var(--dur-1);
}
input::placeholder, .guess-input::placeholder { color: color-mix(in srgb, var(--text-color) 55%, #999 45%); opacity: .8; }

/* ===== Suggestions (z-index & ombre) ===== */
.autocomplete, .guess-suggestions {
  z-index: 1200;
  box-shadow: var(--shadow-2);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* ===== Game stats en grid natif (sans !important) ===== */
.game-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
  background: var(--surface-2);
}

/* ===== Leaderboard sur surfaces tokens ===== */
.leaderboard { background: var(--surface-2); }
#leaderboardList li {
  background: var(--surface-3);
  border-left: 4px solid transparent;
  transition: transform var(--dur-1) var(--ease-2), background-color var(--dur-1);
}
#leaderboardList li:hover { transform: translateX(4px); background: color-mix(in srgb, var(--surface-3) 85%, #fff 15%); }

/* ===== Focus accessible & discret ===== */
*:focus { outline: none; }
:where(a, button, .btn, input, select, textarea):focus-visible { outline: 2px solid transparent; box-shadow: var(--ring); border-radius: var(--radius-sm); }

/* ===== Transitions ciblées (évite transition: all) ===== */
:where(.btn, .btn-guess, .btn-action, .game-card, .game-board, .leaderboard, .section) {
  transition: background-color var(--dur-1), color var(--dur-1), box-shadow var(--dur-1), transform var(--dur-1);
}

/* ===== Splash container (aspect ratio cohérent) ===== */
.splash-container, #splashContainer {
  aspect-ratio: 4 / 3;
  width: min(100%, 480px);
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
}
.splash-container.reveal {
  max-width: 900px;
  aspect-ratio: 16 / 9;
}
.splash-container img, #splashImg {
  -webkit-user-select: none;
  user-select: none;
}

/* ===== Sections (surface & hover subtil) ===== */
.section {
  background: var(--surface-2);
  border: 1px solid var(--dark-border-color);
}
.section.active {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 25%, transparent);
  transform: translateY(-2px);
}

/* ===== Media query: simplifications ===== */
@media (max-width: 768px) {
  .theme-toggle-btn { bottom: 1rem; right: 1rem; width: 44px; height: 44px; }
  .guess-form { gap: var(--space-3); }
  .splash-container, #splashContainer { width: 100%; }
}

/* ===== CONTRASTE — HOTFIX DARK THEME ===== */

/* Rehausse les variables de base en sombre */
:root,
.dark-mode {
  --text-color: #E9EDF3;        /* texte par défaut + clair */
  --header-text: #FFFFFF;        /* titres header bien lisibles */
  --container-bg: #262a31;       /* surface principale un poil plus sombre */
  --border-color: #5a6170;       /* bordure + visible */
  --highlight-bg: #333A46;       /* hover/focus list + marqué */
}

/* Titres & sous-titres de section plus contrastés */
h1, h2, h3,
.game-header .subtitle,
.section h3,
.leaderboard h2,
.game-board h3 {
  color: #F3F6FA;
}

/* Corps de texte dans les sections/boards */
.section,
.game-board,
.leaderboard {
  color: var(--text-color);
  background: #2a2f37;          /* légère séparation avec le fond global */
  border-color: var(--border-color);
}

/* Inputs : fond plus sombre, texte clair, bordure lisible */
input[type="text"],
.guess-input,
select {
  background-color: #1f232a;
  color: #F5F7FB;
  border-color: #5a6170;
}

/* Placeholders bien visibles (et non translucides) */
input::placeholder,
.guess-input::placeholder {
  color: #B8C1D1;
  opacity: 1;
}

/* Suggestions (autocomplete) : contraste renforcé */
.autocomplete, .guess-suggestions {
  background: #232833;
  border-color: #5a6170;
}
.autocomplete li, .guess-suggestions li { color: #E9EDF3; }
.autocomplete li:hover, .guess-suggestions li:hover,
.autocomplete li.selected, .guess-suggestions li.selected {
  background: #394152;
}

/* Bouton principal : texte blanc + ombre, meilleur focus */
.btn, .btn-guess, .btn-action, #loginContainer button, #logoutBtn {
  color: #FFFFFF;
  box-shadow: 0 6px 16px rgba(0,0,0,.3);
}
:where(.btn, .btn-guess, .btn-action, #loginContainer button, #logoutBtn):focus-visible {
  outline: 2px solid transparent;
  box-shadow: 0 0 0 3px rgba(63,81,181,.35), 0 6px 16px rgba(0,0,0,.35);
  border-radius: 10px;
}

/* Labels et micro-texte (stat-label…) un poil plus clairs */
.stat-label,
.section label {
  color: #D7DCE5;
}

/* Feedback par défaut : évite le rouge “texte pur” sur sombre */
.feedback { color: #F3F6FA; }
.feedback-error { background: linear-gradient(135deg, #f44336, #ef5350); color: #fff; }
.feedback-success { background: linear-gradient(135deg, #43a047, #66bb6a); color: #fff; }

/* Leaderboard : supprime les gris codés en dur au profit des surfaces */
.leaderboard { background: #2a2f37; }
#leaderboardList li { background: #242a34; }
#leaderboardList li:hover { background: #2c3340; }
