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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: #0a0a1a;
    color: #fff;
    min-height: 100vh;
}

/* Container Three.js */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ===========================================
   ÉCRAN D'ACCUEIL
   =========================================== */
#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    background: linear-gradient(135deg, rgba(10, 10, 30, 0.97), rgba(30, 10, 50, 0.97));
}

#start-screen h1 {
    font-size: clamp(2.5rem, 8vw, 5rem);
    margin-bottom: 0.5rem;
    background: linear-gradient(90deg, #00f0ff, #8b5cf6, #ff6b9d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: glow 2s ease-in-out infinite alternate;
    text-align: center;
    padding: 0 20px;
}

#start-screen .subtitle {
    font-size: clamp(1rem, 3vw, 1.4rem);
    color: #888;
    margin-bottom: 0.5rem;
}

#start-screen .rules {
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    color: #666;
    margin-bottom: 2rem;
    text-align: center;
    padding: 0 20px;
    line-height: 1.6;
}

#start-screen .rules span {
    display: inline-block;
    margin: 0 10px;
    color: #8b5cf6;
}

#start-btn {
    padding: clamp(0.8rem, 2vw, 1.2rem) clamp(2rem, 5vw, 4rem);
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    font-weight: 600;
    background: linear-gradient(135deg, #8b5cf6, #00f0ff);
    border: none;
    border-radius: 50px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.4);
}

#start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 50px rgba(139, 92, 246, 0.7);
}

#start-btn:active {
    transform: scale(0.98);
}

/* ===========================================
   UI DU JEU
   =========================================== */
.game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: none;
    flex-direction: column;
    pointer-events: none;
}

.game-container.show {
    display: flex;
}

/* Header UI */
#header-ui {
    display: flex;
    justify-content: center;
    gap: clamp(15px, 4vw, 50px);
    align-items: center;
    padding: 15px 20px;
    flex-wrap: wrap;
}

.timer-container {
    position: relative;
    width: clamp(50px, 12vw, 80px);
    height: clamp(50px, 12vw, 80px);
}

.timer-circle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(20, 20, 40, 0.9);
    border: 3px solid #333;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    backdrop-filter: blur(10px);
}

.timer-circle svg {
    position: absolute;
    top: -3px;
    left: -3px;
    width: calc(100% + 6px);
    height: calc(100% + 6px);
    transform: rotate(-90deg);
}

.timer-circle circle {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
}

.timer-bg {
    stroke: #333;
}

.timer-progress {
    stroke: #00f0ff;
    transition: stroke-dashoffset 0.1s linear;
    filter: drop-shadow(0 0 5px rgba(0, 240, 255, 0.5));
}

.timer-text {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    font-weight: bold;
    color: #00f0ff;
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.stat-box {
    background: rgba(20, 20, 40, 0.9);
    padding: clamp(8px, 2vw, 15px) clamp(15px, 3vw, 30px);
    border-radius: 30px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(139, 92, 246, 0.3);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.15);
}

.stat-box.score {
    border-color: rgba(139, 92, 246, 0.5);
}

.stat-box.progress {
    border-color: rgba(0, 240, 255, 0.3);
}

.stat-box .label {
    font-size: clamp(0.7rem, 2vw, 0.85rem);
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-box .value {
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    font-weight: bold;
    color: #fff;
}

.stat-box.score .value {
    color: #8b5cf6;
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

/* ===========================================
   QUESTION & RÉPONSES
   =========================================== */
#question-display {
    background: rgba(15, 15, 35, 0.95);
    margin: clamp(10px, 2vw, 20px) auto;
    padding: clamp(15px, 3vw, 25px) clamp(20px, 4vw, 40px);
    border-radius: 20px;
    max-width: 90%;
    width: 800px;
    text-align: center;
    backdrop-filter: blur(15px);
    border: 2px solid rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.15);
    pointer-events: auto;
}

#question-number {
    font-size: clamp(0.7rem, 2vw, 0.9rem);
    color: #8b5cf6;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

#question-text {
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    line-height: 1.5;
    color: #fff;
}

/* Réponses */
#answers-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: clamp(10px, 2vw, 20px);
    padding: clamp(10px, 2vw, 20px);
    max-width: 95%;
    width: 1000px;
    margin: auto auto 20px;
    pointer-events: auto;
}

.answer-btn {
    background: rgba(20, 20, 40, 0.9);
    border: 3px solid;
    border-radius: 15px;
    padding: clamp(15px, 3vw, 25px);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 15px;
    backdrop-filter: blur(10px);
    pointer-events: auto;
}

.answer-btn:hover:not(:disabled) {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.answer-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.answer-btn .answer-letter {
    width: clamp(35px, 8vw, 50px);
    height: clamp(35px, 8vw, 50px);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: bold;
    flex-shrink: 0;
}

.answer-btn .answer-text {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: #fff;
    text-align: left;
    line-height: 1.4;
}

/* Couleurs des réponses */
.answer-btn.cyan {
    border-color: #00f0ff;
}
.answer-btn.cyan .answer-letter {
    background: rgba(0, 240, 255, 0.2);
    color: #00f0ff;
}
.answer-btn.cyan:hover:not(:disabled) {
    background: rgba(0, 240, 255, 0.15);
    box-shadow: 0 10px 30px rgba(0, 240, 255, 0.3);
}

.answer-btn.violet {
    border-color: #8b5cf6;
}
.answer-btn.violet .answer-letter {
    background: rgba(139, 92, 246, 0.2);
    color: #8b5cf6;
}
.answer-btn.violet:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.15);
    box-shadow: 0 10px 30px rgba(139, 92, 246, 0.3);
}

.answer-btn.red {
    border-color: #ff6b6b;
}
.answer-btn.red .answer-letter {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
}
.answer-btn.red:hover:not(:disabled) {
    background: rgba(255, 107, 107, 0.15);
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.3);
}

.answer-btn.green {
    border-color: #00ff88;
}
.answer-btn.green .answer-letter {
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
}
.answer-btn.green:hover:not(:disabled) {
    background: rgba(0, 255, 136, 0.15);
    box-shadow: 0 10px 30px rgba(0, 255, 136, 0.3);
}

/* États correct/incorrect */
.answer-btn.correct {
    background: rgba(0, 255, 136, 0.3) !important;
    border-color: #00ff88 !important;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.5) !important;
    animation: pulse-correct 0.5s ease-out;
}

.answer-btn.incorrect {
    background: rgba(255, 68, 102, 0.3) !important;
    border-color: #ff4466 !important;
    box-shadow: 0 0 30px rgba(255, 68, 102, 0.5) !important;
    animation: shake 0.5s ease-out;
}

.answer-btn.reveal-correct {
    background: rgba(0, 255, 136, 0.2) !important;
    border-color: #00ff88 !important;
}

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

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

/* ===========================================
   FEEDBACK
   =========================================== */
#feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#feedback-overlay.show {
    opacity: 1;
}

.feedback-text {
    font-size: clamp(2rem, 8vw, 5rem);
    font-weight: bold;
    text-transform: uppercase;
    animation: feedbackPop 0.5s ease-out;
    letter-spacing: 5px;
}

.feedback-text.correct {
    color: #00ff88;
    text-shadow: 0 0 50px #00ff88, 0 0 100px rgba(0, 255, 136, 0.5);
}

.feedback-text.incorrect {
    color: #ff4466;
    text-shadow: 0 0 50px #ff4466, 0 0 100px rgba(255, 68, 102, 0.5);
}

@keyframes feedbackPop {
    0% { transform: scale(0) rotate(-10deg); opacity: 0; }
    60% { transform: scale(1.15) rotate(2deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* Points gagnés */
#points-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% + 50px));
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    opacity: 0;
    pointer-events: none;
    z-index: 51;
}

#points-popup.show {
    animation: pointsFloat 1.5s ease-out forwards;
}

@keyframes pointsFloat {
    0% { opacity: 0; transform: translate(-50%, 0); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -50px); }
}

/* ===========================================
   ÉCRAN DE FIN
   =========================================== */
#end-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    background: linear-gradient(135deg, rgba(10, 10, 30, 0.98), rgba(30, 10, 50, 0.98));
}

#end-screen.show {
    display: flex;
}

#end-screen h2 {
    font-size: clamp(1.8rem, 5vw, 3rem);
    margin-bottom: 1rem;
    color: #8b5cf6;
}

#final-score-container {
    text-align: center;
    margin-bottom: 1.5rem;
}

#final-score {
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: bold;
    background: linear-gradient(90deg, #00f0ff, #8b5cf6, #ff6b9d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

#score-label {
    font-size: clamp(1rem, 3vw, 1.3rem);
    color: #666;
    text-transform: uppercase;
    letter-spacing: 3px;
}

#score-message {
    font-size: clamp(1rem, 3vw, 1.4rem);
    color: #888;
    margin-bottom: 2rem;
    text-align: center;
    padding: 0 20px;
}

#score-breakdown {
    display: flex;
    gap: clamp(15px, 4vw, 40px);
    margin-bottom: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.breakdown-item {
    text-align: center;
    background: rgba(20, 20, 40, 0.8);
    padding: 15px 25px;
    border-radius: 15px;
    border: 2px solid rgba(139, 92, 246, 0.3);
}

.breakdown-item .number {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: bold;
    color: #00f0ff;
}

.breakdown-item .text {
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    color: #888;
    text-transform: uppercase;
}

#replay-btn {
    padding: clamp(1rem, 2.5vw, 1.2rem) clamp(2.5rem, 6vw, 4rem);
    font-size: clamp(1.1rem, 3vw, 1.4rem);
    font-weight: 600;
    background: linear-gradient(135deg, #8b5cf6, #00f0ff);
    border: none;
    border-radius: 50px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.4);
}

#replay-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 50px rgba(139, 92, 246, 0.7);
}

/* ===========================================
   ANIMATIONS
   =========================================== */
@keyframes glow {
    from {
        filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.5));
    }
    to {
        filter: drop-shadow(0 0 40px rgba(139, 92, 246, 0.8)) drop-shadow(0 0 60px rgba(0, 240, 255, 0.4));
    }
}

/* ===========================================
   RESPONSIVE
   =========================================== */
@media (max-width: 600px) {
    #header-ui {
        gap: 10px;
        padding: 10px;
    }

    .stat-box {
        padding: 8px 15px;
    }

    #answers-container {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 10px;
    }

    .answer-btn {
        padding: 15px;
    }

    #question-display {
        margin: 10px;
        padding: 15px;
    }

    #score-breakdown {
        gap: 10px;
    }

    .breakdown-item {
        padding: 12px 20px;
    }
}

@media (max-width: 400px) {
    #header-ui {
        flex-direction: column;
        gap: 8px;
    }

    .timer-container {
        order: -1;
    }
}

/* Mode paysage sur mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #question-display {
        padding: 10px 20px;
        margin: 5px auto;
    }

    #question-text {
        font-size: 1rem;
    }

    #answers-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 5px;
        margin-bottom: 5px;
    }

    .answer-btn {
        padding: 10px;
    }

    .answer-btn .answer-letter {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }

    .answer-btn .answer-text {
        font-size: 0.9rem;
    }

    #header-ui {
        padding: 5px 10px;
    }
}
