* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #1f2937;
    --light: #f9fafb;
    --gray: #6b7280;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    max-width: 800px;
    width: 100%;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Screens */
.screen {
    display: none;
    padding: 40px;
    min-height: 500px;
}

.screen.active {
    display: block;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Home Screen */
.game-info {
    background: var(--light);
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    border-left: 5px solid var(--primary);
}

.game-info h2 {
    color: var(--dark);
    margin-bottom: 15px;
}

.game-info p {
    color: var(--gray);
    line-height: 1.6;
    margin-bottom: 10px;
}

.btn {
    padding: 15px 40px;
    font-size: 1.1rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.btn-secondary {
    background: var(--gray);
    color: white;
    margin-top: 15px;
}

.btn-secondary:hover {
    background: var(--dark);
    transform: translateY(-2px);
}

#startBtn {
    width: 100%;
    margin-bottom: 30px;
}

/* Leaderboard */
.leaderboard {
    background: var(--light);
    padding: 25px;
    border-radius: 15px;
}

.leaderboard h3 {
    color: var(--dark);
    margin-bottom: 20px;
    text-align: center;
}

/* Onglets de classement */
.leaderboard-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    background: white;
    border-radius: 10px;
    padding: 5px;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--gray);
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: fit-content;
}

.tab-btn:hover {
    background: var(--light);
    color: var(--dark);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.leaderboard-content {
    min-height: 200px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: white;
    margin-bottom: 10px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.score-item:hover {
    transform: translateX(5px);
}

.score-rank {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.2rem;
    min-width: 40px;
}

.score-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.score-name {
    font-weight: 600;
    color: var(--dark);
    font-size: 1rem;
}

.score-info small {
    color: var(--gray);
    font-size: 0.8rem;
    font-weight: 500;
}

.score-mode {
    font-size: 0.9rem;
}

.score-points {
    font-weight: 700;
    color: var(--secondary);
    font-size: 1.1rem;
}

.loading {
    text-align: center;
    color: var(--gray);
    padding: 20px;
}

/* Game Screen - Version compacte */
.game-header {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    gap: 10px;
}

.stat {
    flex: 1;
    background: var(--light);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}

.stat .label {
    display: block;
    color: var(--gray);
    font-size: 0.8rem;
    margin-bottom: 3px;
}

.stat .value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

.game-area {
    text-align: center;
}

.question {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--dark);
    font-weight: 600;
}

#targetColor {
    font-size: 1.7rem;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 8px;
    display: inline-block;
    animation: pulse 0.5s ease-in;
    word-break: keep-all;
    white-space: nowrap;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    max-width: 400px;
    margin: 0 auto;
}

/* Grilles adaptatives selon le nombre de couleurs */
.color-grid.grid-3 {
    grid-template-columns: repeat(3, 1fr);
    max-width: 450px;
}

.color-grid.grid-5 {
    grid-template-columns: repeat(3, 1fr);
    max-width: 500px;
}

.color-grid.grid-6 {
    grid-template-columns: repeat(3, 1fr);
    max-width: 500px;
}

.color-grid.grid-7 {
    grid-template-columns: repeat(4, 1fr);
    max-width: 650px;
}

.color-grid.grid-8 {
    grid-template-columns: repeat(4, 1fr);
    max-width: 700px;
}

.color-btn {
    padding: 45px 15px;
    font-size: 1.3rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ajustements pour différents nombres de couleurs */
.color-grid.grid-5 .color-btn:nth-child(4),
.color-grid.grid-5 .color-btn:nth-child(5) {
    grid-column: span 1;
}

.color-grid.grid-5 .color-btn:nth-child(4) {
    grid-column: 1 / 2;
    grid-row: 2;
}

.color-grid.grid-5 .color-btn:nth-child(5) {
    grid-column: 3 / 4;
    grid-row: 2;
}

.color-grid.grid-7 .color-btn:nth-child(5),
.color-grid.grid-7 .color-btn:nth-child(6),
.color-grid.grid-7 .color-btn:nth-child(7) {
    grid-column: span 1;
}

.color-grid.grid-7 .color-btn:nth-child(5) {
    grid-column: 1 / 2;
    grid-row: 2;
}

.color-grid.grid-7 .color-btn:nth-child(6) {
    grid-column: 2 / 3;
    grid-row: 2;
}

.color-grid.grid-7 .color-btn:nth-child(7) {
    grid-column: 4 / 5;
    grid-row: 2;
}

/* Ajustement pour les modes avec plus de couleurs */
.color-grid.grid-7 .color-btn,
.color-grid.grid-8 .color-btn {
    padding: 40px 15px;
    font-size: 1.2rem;
}

.color-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.color-btn:active {
    transform: translateY(0);
}

.color-btn.correct {
    animation: correctAnim 0.5s ease;
}

.color-btn.wrong {
    animation: wrongAnim 0.5s ease;
}

@keyframes correctAnim {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.1) rotate(5deg);
    }
    75% {
        transform: scale(1.1) rotate(-5deg);
    }
}

@keyframes wrongAnim {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

/* End Screen */
.result {
    text-align: center;
}

.result h2 {
    color: var(--dark);
    margin-bottom: 30px;
    font-size: 2rem;
}

.final-score {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
}

.final-score .label {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 10px;
    opacity: 0.9;
}

.final-score .value {
    font-size: 4rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.stats-summary {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
}

.stat-item {
    flex: 1;
    background: var(--light);
    padding: 25px;
    border-radius: 15px;
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
}

.stat-label {
    display: block;
    color: var(--gray);
    font-size: 0.9rem;
}

.save-form {
    margin-bottom: 20px;
}

.save-form input {
    padding: 15px;
    font-size: 1.1rem;
    border: 2px solid var(--light);
    border-radius: 10px;
    width: 100%;
    max-width: 300px;
    margin-bottom: 15px;
    text-align: center;
    transition: border-color 0.3s;
}

.save-form input:focus {
    outline: none;
    border-color: var(--primary);
}

#playAgainBtn {
    width: 100%;
    max-width: 300px;
}

/* Game Modes */
.game-modes {
    background: var(--light);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
}

.game-modes h3 {
    color: var(--dark);
    margin-bottom: 20px;
    text-align: center;
}

.modes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.mode-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
}

.mode-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.mode-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary)10, var(--secondary)10);
}

.mode-name {
    font-weight: 700;
    color: var(--dark);
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.mode-description {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.mode-stats {
    display: flex;
    justify-content: space-around;
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 600;
}


/* Power-ups */
.active-powerups {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    min-height: 40px;
}

.active-powerup {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    animation: powerupPulse 2s infinite;
}

@keyframes powerupPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.powerups-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.powerup {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    pointer-events: all;
    animation: powerupSpawn 0.5s ease-out, powerupFloat 3s ease-in-out infinite;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 3px solid white;
}

@keyframes powerupSpawn {
    from {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes powerupFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

/* Particles */
.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
}

/* Notifications */
.notifications {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1000;
    max-width: 280px;
}

.notification {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    animation: notificationSlide 0.5s ease-out;
    max-width: 280px;
    font-size: 0.9rem;
}

@keyframes notificationSlide {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Configuration personnalisée */
.custom-config {
    background: var(--light);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 25px;
}

.custom-config h3 {
    color: var(--dark);
    margin-bottom: 15px;
    text-align: center;
}

.config-row {
    margin-bottom: 15px;
}

.config-row label {
    display: block;
    color: var(--dark);
    font-weight: 600;
    margin-bottom: 8px;
}

.config-row input[type="range"] {
    width: 100%;
    margin-top: 5px;
}

.config-row span {
    color: var(--primary);
    font-weight: 700;
}

.blitz-info {
    background: white;
    padding: 15px;
    border-radius: 10px;
    margin-top: 15px;
}

.blitz-info p {
    margin: 5px 0;
    color: var(--dark);
    font-size: 0.9rem;
}

.blitz-info strong {
    color: var(--primary);
}

/* Analytics */
.analytics-section {
    background: var(--light);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
}

.analytics-section h3 {
    color: var(--dark);
    margin-bottom: 20px;
    text-align: center;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.analytics-item {
    background: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.analytics-number {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.analytics-label {
    display: block;
    color: var(--gray);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Classement de fin */
.end-leaderboard {
    background: var(--light);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
}

.end-leaderboard h3 {
    color: var(--dark);
    margin-bottom: 20px;
    text-align: center;
}

.end-leaderboard .leaderboard-content {
    max-height: 300px;
    overflow-y: auto;
}

.end-leaderboard .score-item {
    background: white;
    margin-bottom: 8px;
    padding: 15px;
    border-radius: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.end-leaderboard .score-item:hover {
    background: #f8fafc;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Achievements */
.new-achievements {
    margin-bottom: 25px;
}

.achievement {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    animation: achievementUnlock 0.8s ease-out;
}

@keyframes achievementUnlock {
    0% {
        transform: scale(0.8) rotate(-5deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(2deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.achievement-icon {
    font-size: 2rem;
}

.achievement-info h4 {
    margin: 0 0 5px 0;
    font-size: 1.1rem;
}

.achievement-info p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.9rem;
}

/* Themes */
body.dark-theme {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
}

body.dark-theme .container {
    background: #374151;
    color: white;
}

body.dark-theme .game-info,
body.dark-theme .leaderboard,
body.dark-theme .game-modes {
    background: #4b5563;
}

body.dark-theme .score-item,
body.dark-theme .mode-card {
    background: #6b7280;
}

body.colorful-theme {
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4, #feca57, #ff9ff3);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Level indicator discret */
.level-indicator {
    text-align: center;
    margin-bottom: 10px;
    font-size: 0.8rem;
    color: var(--gray);
    font-weight: 500;
    opacity: 0.7;
}

.level-indicator span {
    color: var(--primary);
    font-weight: 700;
    font-size: 1rem;
}

.level-indicator span.level-up {
    animation: levelUpGlow 1s ease-out;
}

@keyframes levelUpGlow {
    0%, 100% {
        color: var(--primary);
        text-shadow: none;
    }
    50% {
        color: #fbbf24;
        text-shadow: 0 0 15px #fbbf24;
        transform: scale(1.1);
    }
}

/* Responsive */
@media (max-width: 600px) {
    header h1 {
        font-size: 2rem;
    }
    
    .screen {
        padding: 20px;
    }
    
    .game-header {
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 15px;
    }
    
    .stat {
        flex: 1;
        min-width: calc(50% - 4px);
        padding: 8px;
    }
    
    .stat .value {
        font-size: 1.2rem;
    }
    
    .color-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        max-width: 320px;
    }
    
    .color-grid.grid-5,
    .color-grid.grid-6,
    .color-grid.grid-7,
    .color-grid.grid-8 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Réinitialiser les positionnements spéciaux sur mobile */
    .color-grid.grid-5 .color-btn:nth-child(4),
    .color-grid.grid-5 .color-btn:nth-child(5),
    .color-grid.grid-7 .color-btn:nth-child(5),
    .color-grid.grid-7 .color-btn:nth-child(6),
    .color-grid.grid-7 .color-btn:nth-child(7) {
        grid-column: auto;
        grid-row: auto;
    }
    
    .color-grid.grid-5 .color-btn,
    .color-grid.grid-6 .color-btn,
    .color-grid.grid-7 .color-btn,
    .color-btn {
        padding: 35px 12px;
        font-size: 1.1rem;
    }
    
    .color-grid.grid-8 .color-btn {
        padding: 30px 10px;
        font-size: 1rem;
    }
    
    .stats-summary {
        flex-direction: column;
    }
    
    .final-score .value {
        font-size: 3rem;
    }
    
    /* Réduire la taille du mot cible sur mobile */
    #targetColor {
        font-size: 1.5rem;
        padding: 8px 15px;
    }
    
    .question {
        font-size: 1.2rem;
    }
    
    
    .notifications {
        right: 10px;
        left: 10px;
        top: 10px;
    }
    
    .notification {
        max-width: none;
        padding: 8px 12px;
        font-size: 0.8rem;
        margin-bottom: 5px;
    }
    
    .analytics-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .analytics-item {
        padding: 15px;
    }
    
    .analytics-number {
        font-size: 1.5rem;
    }
}

