/* Quiz Frontend Styles */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap');
.quiz-body {
    margin: 0;
    padding: 0;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #800020 0%, #800020 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: #333;
}

.quiz-body[style*="background-image"] {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.quiz-body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: -1;
}

#quiz-app {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.quiz-screen {
    display: none;
    width: 100%;
    max-width: 800px;
    animation: fadeIn 0.5s ease-in-out;
}

.quiz-screen.active {
    display: block;
}

.quiz-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.quiz-header {
    text-align: center;
    margin-bottom: 40px;
}

.quiz-header h1 {
    font-size: 2.5rem;
    margin: 0 0 15px 0;
    background: linear-gradient(135deg, #800020, #800020);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.quiz-description {
    font-size: 1.2rem;
    color: #666;
    margin: 0;
}

/* Registration Form */
.registration-form {
    text-align: center;
    margin-bottom: 40px;
}

.registration-form h2 {
    font-size: 1.5rem;
    margin-bottom: 30px;
    color: #444;
}

.registration-form input {
    width: 100%;
    max-width: 300px;
    padding: 15px 20px;
    font-size: 1.1rem;
    border: 2px solid #e1e5e9;
    border-radius: 50px;
    outline: none;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.registration-form input:focus {
    border-color: #800020;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.registration-form input,
.mcq-option label {
    box-sizing: border-box;
}

/* Buttons */
.btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    min-width: 150px;
}

.btn-primary {
    background: linear-gradient(135deg, #800020, #800020);
    color: white;
    margin-top: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #e9ecef;
}

.btn-secondary:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

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

/* Quiz Info */
.quiz-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.info-item {
    display: flex;
    align-items: center;
    padding: 15px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 15px;
    font-weight: 500;
}

.info-icon {
    font-size: 1.5rem;
    margin-right: 10px;
}

/* Game Header */
.game-header {
    margin-bottom: 30px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 1.1rem;
    width: 100%;
}

.progress-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    width: 0%;
    transition: width 0.3s ease;
}

/* Time Progress Bar */
.time-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
    width: 100%;
}

#time-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #fd7e14, #ffc107);
    width: 100%;
    transition: width 1s linear;
}

/* Multiple-Choice (QCM) Options */
.mcq-option {
    margin-bottom: 15px;
}

.mcq-option input[type="radio"] {
    display: none;
}

.mcq-option label {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 15px;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.mcq-option label:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.mcq-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #e9ecef;
    font-weight: 600;
    margin-right: 18px;
    color: #495057;
    transition: background 0.3s ease, color 0.3s ease;
}

.mcq-text {
    flex: 1;
}

.mcq-option input[type="radio"]:checked + label {
    border-color: #800020;
    background: linear-gradient(135deg, #800020 0%, #800020 100%);
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.25);
}

.mcq-option input[type="radio"]:checked + label .mcq-letter {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* Top navigation bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    position: relative;
    color: #495057;
    padding: 5px;
}

.icon-btn:hover {
    transform: scale(1.1);
}

/* Time wrapper */
.time-wrapper {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 10px;
    width: 100%;
}

.time-label {
    font-weight: 600;
    margin-right: 10px;
}

.time-wrapper #timer {
    margin-left: 10px;
    font-weight: 600;
}

.time-wrapper .time-bar {
    flex: 1;
    min-width: 0;
}

/* Score badge */
#current-score {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: #ffffff;
    padding: 6px 16px;
    border-radius: 25px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    font-weight: 600;
}

#current-score::before {
    content: '🏆';
    display: inline-block;
    font-size: 1rem;
}

/* Hint Modal */
.hint-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.hint-modal-content {
    background: #ffffff;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.hint-modal-content p {
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: #495057;
}

#hint-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #dc3545;
    color: #ffffff;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.7rem;
    line-height: 1;
}

/* Question Container */
#question-container {
    margin-bottom: 20px;
}

.question-content {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.question-content h2 {
    margin: 0 0 15px 0;
    color: #495057;
}

.question-video {
    width: 100%;
    max-width: 600px;
    height: 300px;
    border-radius: 15px;
    margin: 20px 0;
}

/* Answer Forms */
.answer-form {
    margin-bottom: 20px;
}

.text-answer input {
    width: 100%;
    padding: 15px 20px;
    font-size: 1.1rem;
    border: 2px solid #e1e5e9;
    border-radius: 15px;
    outline: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.text-answer input:focus {
    border-color: #800020;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Sortable Images */
.sortable-container {
    min-height: 200px;
    padding: 20px;
    border: 2px dashed #e1e5e9;
    border-radius: 15px;
    background: #f8f9fa;
}

.sortable-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    min-height: 150px;
}

.sortable-item {
    background: white;
    border-radius: 15px;
    padding: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    cursor: move;
    transition: all 0.3s ease;
    position: relative;
}

.sortable-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.sortable-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 10px;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}

.sortable-item .item-number {
    position: absolute;
    top: -5px;
    left: -5px;
    background: #800020;
    color: white;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}

.ui-sortable-helper {
    transform: rotate(5deg) scale(1.05);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3) !important;
}

.ui-sortable-placeholder {
    background: rgba(102, 126, 234, 0.2);
    border: 2px dashed #800020;
    visibility: visible !important;
    height: 150px !important;
    margin: 15px;
    border-radius: 15px;
}

/* Hints */
#hints-container {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

#hints-container h3 {
    margin: 0 0 15px 0;
    color: #856404;
}

.hint-item {
    background: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 10px;
    border-left: 4px solid #ffc107;
}

.hint-item:last-child {
    margin-bottom: 0;
}

.hint-character{
    text-align:center;
    margin-bottom:10px;
}
.hint-character img{
    max-width:600px;
    height:auto;
}

/* Feedback */
.feedback {
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    font-weight: 600;
    animation: slideIn 0.3s ease;
}

.feedback.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.feedback.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Finish Screen */
.finish-header {
    text-align: center;
    margin-bottom: 40px;
}

.final-score {
    font-size: 3rem;
    font-weight: bold;
    background: linear-gradient(135deg, #28a745, #20c997);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 20px 0;
}

/* Leaderboard */
#leaderboard-container {
    margin-bottom: 40px;
}

#leaderboard-container h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #495057;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 15px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.leaderboard-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.leaderboard-item.current-player {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border: 2px solid #800020;
}

.player-rank {
    font-weight: bold;
    font-size: 1.2rem;
    color: #800020;
    min-width: 30px;
}

.player-name {
    flex: 1;
    margin-left: 15px;
    font-weight: 600;
}

.player-score {
    font-weight: bold;
    color: #28a745;
}

.player-time {
    color: #6c757d;
    font-size: 0.9rem;
    margin-left: 15px;
}

/* Finish Actions */
.finish-actions {
    text-align: center;
}

.finish-actions .btn {
    margin: 0 10px 10px 10px;
}

/* Music Toggle */
.music-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 1000;
}

.music-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.music-toggle.muted {
    opacity: 0.5;
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

.pulse {
    animation: pulse 2s infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
    .quiz-container {
        padding: 20px;
        margin: 10px;
    }
    
    .quiz-header h1 {
        font-size: 2rem;
    }
    
    .game-info {
        font-size: 1rem;
    }
    
    .game-info span {
        margin-bottom: 10px;
    }
    
    .quiz-info {
        grid-template-columns: 1fr;
    }
    
    .sortable-images {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
    
    .sortable-item {
        padding: 8px;
    }
    
    .sortable-item img {
        height: 80px;
    }
    
    .btn {
        padding: 12px 24px;
        font-size: 1rem;
        min-width: 120px;
    }
    
    .final-score {
        font-size: 2rem;
    }
    
    .finish-actions .btn {
        display: block;
        width: 100%;
        margin: 10px 0;
    }
}

@media (max-width: 480px) {
    .registration-form input {
        width: 100%;
        max-width: 100%;
    }
    .quiz-container{padding:20px}
    .question-content{padding:15px}
    .question-video{height:180px}
    .sortable-item img{height:80px}
    .game-info{flex-direction:column;gap:10px;text-align:center}
    .btn{padding:12px 20px;font-size:1rem;min-width:120px}
    
    /* Amélioration pour les champs de saisie mobile */
    .text-answer {
        margin: 20px 0;
        position: relative;
    }
    
    #text-answer-input {
        font-size: 16px !important; /* Évite le zoom automatique sur iOS */
        padding: 15px 12px;
        width: 100%;
        border: 2px solid #ddd;
        border-radius: 8px;
        box-sizing: border-box;
        background: #fff;
        line-height: 1.5;
    }
    
    #text-answer-input:focus {
        border-color: #007cba;
        outline: none;
        box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
    }
    
    /* Espacement pour éviter que le clavier cache le contenu */
    .answer-form {
        padding-bottom: 100px;
    }
    
    /* S'assurer que le conteneur de réponse a assez d'espace */
    #answer-container {
        min-height: 200px;
        margin-bottom: 50px;
    }
    
    .game-info {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .leaderboard-item {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }
    
    .player-time {
        margin-left: 0;
        margin-top: 5px;
    }
}

/* Masquer l’avancement des questions pour ne pas révéler la progression au joueur */
#question-number,
#question-pagination {
    display: none !important;
}

.regular-text {
    width: 50% !important;
}

.hint-modal{align-items:flex-end;justify-content:flex-end;}
.hint-modal-content{position:fixed!important;top:50%!important;left:50%!important;transform:translate(-50%,-50%)!important;width:90%;max-width:500px;}
.hint-modal-content::after{border-top-color:#ffffff;}
.hint-modal-content::before{content:'';position:absolute;bottom:-22px;right:82px;border-left:22px solid transparent;border-right:22px solid transparent;border-top:22px solid #ffffff;}
.hint-character{position:fixed;bottom:0px;right:0px;text-align:center;pointer-events:none;z-index:2100;}
.hint-character img{max-width:180px;height:auto;}
.progress-bar{display:none!important}
#quiz-logo{position:fixed;bottom:20px;left:20px;width:80px;height:auto;pointer-events:none;z-index:500}
#quiz-logo{right:20px;left:auto}

/* ------------------ UI Fix : Centrage boîte de dialogue & image indice ------------------ */
.hint-modal {
    align-items: center !important;
    justify-content: center !important;
}

/* Image de personnage toujours en bas à droite, taille adaptée sur mobile */
@media (max-width: 480px) {
    .hint-character img {
        max-width: 240px !important; /* toujours grande mais adaptée aux petits écrans */
    }
}

/* Ajustement taille dynamique personnage indice */
.hint-character img {
    width: auto;
    height: auto;
    max-width: 320px !important;   /* largeur maxi */
    max-height: 40vh !important;   /* hauteur maxi, 40% de la hauteur viewport */
}

@media (max-width: 480px) {
    .hint-character img {
        max-width: 240px !important;
        max-height: 30vh !important;
    }
}

/* Question Image */
.question-image {
    width: 100%;
    max-width: 600px;
    height: auto;
    border-radius: 15px;
    margin: 20px 0;
    display: block;
    object-fit: contain;
}