* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #4caf50;
    --error-color: #f44336;
    --warning-color: #ff9800;
    --text-color: #333;
    --bg-color: #fff;
    --border-radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.page {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

.page.active {
    display: block;
}

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

.home-content {
    text-align: center;
    color: white;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: slideInDown 0.8s ease-out;
}

.subtitle {
    font-size: 1.2rem;
    margin-bottom: 3rem;
    opacity: 0.9;
    animation: slideInUp 0.8s ease-out 0.2s both;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.quiz-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.info-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: left;
    animation: slideInUp 0.8s ease-out 0.4s both;
}

.info-card h3 {
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.info-card ul {
    list-style: none;
    padding-left: 0;
}

.info-card li {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
}

.info-card li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: bold;
}

.home-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.history-content {
    text-align: center;
    color: white;
}

.history-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
}

.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    min-width: 150px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(45deg, var(--success-color), #45a049);
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(76, 175, 80, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border: 2px solid rgba(102, 126, 234, 0.3);
    font-weight: 600;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 1);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-danger {
    background: linear-gradient(45deg, var(--error-color), #d32f2f);
    color: white;
    box-shadow: var(--shadow);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(244, 67, 54, 0.4);
}

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    background: rgba(200, 200, 200, 0.8);
    color: #666;
    border-color: rgba(200, 200, 200, 0.5);
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.progress-container {
    flex: 1;
    margin-right: 2rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), #45a049);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

#question-counter {
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.progress-indicator {
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    opacity: 0.9;
}

.timer-container {
    text-align: center;
    color: white;
}

.timer {
    font-size: 2.5rem;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 0.25rem;
    animation: pulse 1s infinite;
}

.timer.warning {
    color: var(--warning-color);
    animation: shake 0.5s infinite;
}

.timer.danger {
    color: var(--error-color);
    animation: shake 0.3s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

.timer-label {
    font-size: 0.8rem;
    opacity: 0.8;
}

.quiz-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    animation: slideInUp 0.5s ease-out;
}

.question-container {
    margin-bottom: 2rem;
}

#question-text {
    font-size: 1.4rem;
    color: var(--text-color);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.answers-container {
    display: grid;
    gap: 1rem;
    margin-bottom: 2rem;
}

.answer-option {
    padding: 1rem 1.5rem;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    background: white;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.answer-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    transition: left 0.3s;
}

.answer-option:hover::before {
    left: 100%;
}

.answer-option:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.answer-option.selected {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
}

.answer-option.correct {
    border-color: var(--success-color);
    background: rgba(76, 175, 80, 0.1);
    animation: correctAnswer 0.6s ease-out;
}

.answer-option.incorrect {
    border-color: var(--error-color);
    background: rgba(244, 67, 54, 0.1);
    animation: incorrectAnswer 0.6s ease-out;
}

@keyframes correctAnswer {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes incorrectAnswer {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.quiz-controls {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.quiz-controls .btn {
    flex: 1;
    min-width: 150px;
}

.results-content {
    text-align: center;
    color: white;
}

.score-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.score-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 3px solid rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: scaleIn 0.8s ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.score-number {
    font-size: 3rem;
    font-weight: bold;
    line-height: 1;
}

.score-label {
    font-size: 1rem;
    opacity: 0.8;
    margin-top: 0.5rem;
}

.score-details h3 {
    font-size: 2rem;
    margin-bottom: 1rem;
    animation: slideInUp 0.8s ease-out 0.2s both;
}

.score-details p {
    font-size: 1.1rem;
    opacity: 0.9;
    animation: slideInUp 0.8s ease-out 0.4s both;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.stat-item {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    animation: slideInUp 0.8s ease-out 0.6s both;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.8;
}

.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    animation: slideInUp 0.8s ease-out 0.8s both;
}

.question-review-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: left;
    animation: slideInUp 0.8s ease-out 1s both;
}

.question-review-container h3 {
    color: white;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    text-align: center;
}

.review-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.review-item {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    border-left: 4px solid;
}

.review-item.correct {
    border-left-color: var(--success-color);
}

.review-item.incorrect {
    border-left-color: var(--error-color);
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.review-number {
    font-weight: 600;
    color: var(--text-color);
}

.review-status {
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

.review-item.correct .review-status {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
}

.review-item.incorrect .review-status {
    background: rgba(244, 67, 54, 0.1);
    color: var(--error-color);
}

.review-question {
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.1rem;
}

.review-answers {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.review-answer {
    padding: 0.75rem;
    border-radius: 8px;
    background: rgba(102, 126, 234, 0.05);
}

.review-answer.correct-answer {
    background: rgba(76, 175, 80, 0.1);
    border-left: 3px solid var(--success-color);
    padding-left: 1rem;
}

.review-explanation {
    padding: 1rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 8px;
    color: var(--text-color);
    line-height: 1.6;
}

.score-history-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: left;
    animation: slideInUp 0.8s ease-out 1.2s both;
}

.score-history-container h3 {
    color: white;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    text-align: center;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.history-list::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.history-item {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: var(--transition);
}

.history-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.history-rank {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    min-width: 40px;
    text-align: center;
}

.history-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.history-score {
    font-weight: 600;
    color: var(--text-color);
    font-size: 1.1rem;
}

.history-time {
    color: #666;
    font-size: 0.9rem;
}

.history-date {
    color: #999;
    font-size: 0.85rem;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideInUp 0.3s ease-out;
}

.modal-content h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.5rem;
}

.modal-content p {
    margin-bottom: 1.5rem;
    color: #666;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.modal-actions .btn {
    min-width: 120px;
}

.feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    pointer-events: none;
}

.feedback.hidden {
    display: none;
}

.feedback-content {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: feedbackPop 0.5s ease-out;
}

@keyframes feedbackPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.feedback-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feedback-message {
    font-size: 1.2rem;
    font-weight: 600;
}

.feedback.success .feedback-icon {
    color: var(--success-color);
}

.feedback.error .feedback-icon {
    color: var(--error-color);
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .quiz-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .progress-container {
        margin-right: 0;
        width: 100%;
    }
    
    .score-container {
        flex-direction: column;
        gap: 2rem;
    }
    
    .score-circle {
        width: 150px;
        height: 150px;
    }
    
    .score-number {
        font-size: 2rem;
    }
    
    .results-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .home-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 300px;
    }
    
    .quiz-controls {
        flex-direction: column;
    }
    
    .quiz-controls .btn {
        width: 100%;
    }
    
    .progress-info {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .question-review-container,
    .score-history-container {
        padding: 1rem;
    }
    
    .review-item {
        padding: 1rem;
    }
    
    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .history-rank {
        align-self: flex-start;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .quiz-content {
        padding: 1rem;
    }
    
    #question-text {
        font-size: 1.2rem;
    }
    
    .answer-option {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }
    
    .timer {
        font-size: 2rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.btn:focus-visible,
.answer-option:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

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

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =====================================================
   Styles pour les fonctionnalités PHP
   ===================================================== */

/* Input pseudo */
.pseudo-input {
    width: 100%;
    padding: 1rem;
    margin: 1rem 0;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    background: rgba(255, 255, 255, 0.9);
    transition: var(--transition);
}

.pseudo-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.pseudo-input.error {
    border-color: var(--error-color);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    color: white;
    font-size: 1.2rem;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

/* Player rank announcement */
.player-rank-container {
    margin: 1.5rem 0;
}

.rank-announcement {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #333;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    text-align: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* Leaderboard styles */
.leaderboard-container,
.global-leaderboard-section {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.leaderboard-container h3,
.global-leaderboard-section h3 {
    color: white;
    margin-bottom: 1rem;
    text-align: center;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 1rem;
    transition: var(--transition);
}

.leaderboard-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.leaderboard-item.current-player {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    border: 2px solid var(--success-color);
}

.leaderboard-rank {
    font-size: 1.5rem;
    font-weight: bold;
    min-width: 50px;
    text-align: center;
}

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

.leaderboard-pseudo {
    font-weight: 600;
    font-size: 1.1rem;
    color: #333;
}

.leaderboard-date {
    font-size: 0.85rem;
    color: #666;
}

.leaderboard-stats {
    text-align: right;
}

.leaderboard-score {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.leaderboard-time {
    font-size: 0.85rem;
    color: #666;
}

.no-scores {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    padding: 2rem;
    font-style: italic;
}

/* Responsive pour les nouveaux éléments */
@media (max-width: 600px) {
    .leaderboard-item {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .leaderboard-rank {
        min-width: 40px;
        font-size: 1.2rem;
    }
    
    .leaderboard-info {
        flex: 1;
        min-width: 120px;
    }
    
    .leaderboard-stats {
        width: 100%;
        display: flex;
        justify-content: space-between;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        margin-left: 50px;
    }
    
    .rank-announcement {
        font-size: 1rem;
        padding: 1rem;
    }
}
