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

:root {
    --primary: #d94f3d;
    --primary-dark: #c43e2d;
    --secondary: #fca5a5;
    --background: #1a3b42;
    --background-alt: #2d5a64;
    --surface: #f9ead4;
    --surface-light: #fef5e7;
    --text: #1a1a1a;
    --text-muted: #5a5a5a;
    --success: #d94f3d;
    --hint-color: #C76855;
    --hint-color-dark: #b55845;
    --answer-color: #6F8FAF;
    --answer-color-dark: #5f7f9f;
    --button-color: #4D7F7A;
    --button-color-dark: #3d6f6a;
    --border-radius: 20px;
    --shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1a3b42;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(45, 90, 100, 0.6) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(45, 90, 100, 0.5) 0%, transparent 60%),
        radial-gradient(circle at 40% 80%, rgba(45, 90, 100, 0.4) 0%, transparent 50%);
    color: var(--text);
    min-height: 100vh;
    padding: 0.5rem;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3vh;
    animation: fadeInDown 0.6s ease;
}

header h1 {
    font-size: 1.5rem;
    color: white;
    font-weight: 900;
    letter-spacing: 1px;
    line-height: 1.1;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 0.5rem;
}

header .subtitle {
    font-size: 0.75rem;
    color: white;
    font-weight: 400;
    opacity: 0.9;
    line-height: 1.4;
    max-width: 500px;
    margin: 0 auto;
}

/* Game Card */
.game-card {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    animation: fadeInUp 0.6s ease;
    border: 3px solid rgba(45, 90, 100, 0.4);
}

/* Question Section */
.question-section {
    margin-bottom: 4vh;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid rgba(45, 90, 100, 0.3);
}

.question-section h2 {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text);
    font-weight: 700;
    text-align: center;
}

/* Hints Section */
.hints-section {
    margin-bottom: 4vh;
}

.hints-section h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

#hints-list {
    list-style: none;
}

#hints-list li {
    position: relative;
    background: var(--surface-light);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.4rem;
    border-radius: 8px;
    color: var(--text);
    font-size: 0.8rem;
    border-left: 3px solid var(--hint-color);
    animation: slideInLeft 0.4s ease;
    animation-fill-mode: both;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, height 0.3s ease;
    height: 2.25rem;
    display: flex;
    align-items: center;
}

#hints-list li:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(199, 104, 85, 0.3);
}

#hints-list li:nth-child(1) { animation-delay: 0.1s; }
#hints-list li:nth-child(2) { animation-delay: 0.2s; }
#hints-list li:nth-child(3) { animation-delay: 0.3s; }
#hints-list li:nth-child(4) { animation-delay: 0.4s; }
#hints-list li:nth-child(5) { animation-delay: 0.5s; }

.hint-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--hint-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.hint-overlay span {
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.hint-content {
    position: relative;
    z-index: 1;
}

#hints-list li.hint-revealed .hint-overlay {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#hints-list li.hint-revealed {
    animation: revealHint 0.4s ease;
    animation-fill-mode: forwards;
    height: auto;
}

#hints-list li.hint-revealed:hover {
    transform: none;
}

/* Answer Section */
.answer-section {
    margin-bottom: 4vh;
}

#answer-container {
    position: relative;
    background: var(--surface-light);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#answer-container.answer-animate {
    animation: slideInLeft 0.4s ease;
    animation-delay: 0.4s;
    animation-fill-mode: both;
}

#answer-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(111, 143, 175, 0.4);
}

.answer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--answer-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.answer-overlay span {
    font-size: 1rem;
    font-weight: 600;
    color: white;
    text-align: center;
    padding: 0 1rem;
}

.answer-content {
    padding: 1rem;
    position: relative;
    z-index: 1;
}

.answer-content h3 {
    display: none;
}

.answer-content p {
    font-size: 0.95rem;
    color: var(--text);
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
}

#answer-container.answer-revealed .answer-overlay {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
}

.btn-primary {
    background: var(--button-color);
    color: white;
    border: none;
    padding: 0.9rem 2rem;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: 0 6px 12px rgba(77, 127, 122, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary:hover {
    transform: translateY(-3px);
    background: var(--button-color-dark);
    box-shadow: 0 8px 16px rgba(77, 127, 122, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}


/* Footer */
.navigation-footer {
    margin-top: 3vh;
    background: rgba(249, 234, 212, 0.95);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    animation: fadeInUp 0.6s ease 0.2s both;
    border: 2px solid rgba(45, 90, 100, 0.3);
}

.footer-info {
    text-align: center;
    margin-bottom: 1rem;
}

.footer-info span {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
}

.footer-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.nav-btn {
    background: white;
    color: var(--text);
    border: 2px solid var(--text-muted);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 1.1rem;
    font-weight: 700;
}

.nav-btn:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.1);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.question-input-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.question-input-group span {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
}

#question-id-input {
    width: 2.5rem;
    padding: 0.25rem 0.35rem;
    background: white;
    border: 1px solid var(--text-muted);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.75rem;
    text-align: center;
    font-weight: 600;
}

#question-id-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* Supprimer les flèches du input number sur Chrome, Safari, Edge */
#question-id-input::-webkit-outer-spin-button,
#question-id-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Supprimer les flèches du input number sur Firefox */
#question-id-input {
    appearance: textfield;
}

.btn-go {
    background: var(--button-color);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-go:hover {
    background: var(--button-color-dark);
    transform: scale(1.05);
}

.footer-hint p {
    color: var(--text-muted);
    font-size: 0.65rem;
    margin: 0;
}

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

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

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@keyframes revealHint {
    0% {
        transform: scale(0.98);
    }
    50% {
        transform: scale(1.01);
    }
    100% {
        transform: scale(1);
    }
}

/* Responsive - Tablet et plus */
@media (min-width: 768px) {
    body {
        padding: 2rem;
    }

    header h1 {
        font-size: 2.5rem;
    }

    header .subtitle {
        font-size: 1rem;
    }

    .game-card {
        padding: 2.5rem;
    }

    .question-section h2 {
        font-size: 1.2rem;
    }

    #hints-list li {
        font-size: 1rem;
        padding: 1rem 1.25rem;
        height: 3rem;
    }

    .answer-content p {
        font-size: 1.25rem;
    }

    .btn-primary {
        padding: 1.125rem 2.5rem;
        font-size: 1.05rem;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .game-card:hover {
        box-shadow: 0 25px 30px -5px rgba(0, 0, 0, 0.4), 0 15px 15px -5px rgba(0, 0, 0, 0.3);
    }
}

/* Modale pour agrandir l'image */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.image-modal.active {
    display: flex;
}

.image-modal img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* Image Mode Toggle */
.image-mode-container {
    margin-top: 2vh;
    background: rgba(249, 234, 212, 0.95);
    border-radius: 12px;
    padding: 0.6rem 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(45, 90, 100, 0.3);
    animation: fadeInUp 0.6s ease 0.1s both;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-mode-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.image-mode-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 22px;
    background: rgba(90, 90, 90, 0.3);
    border-radius: 50px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
    border: 1.5px solid rgba(90, 90, 90, 0.2);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 1.5px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border-radius: 50%;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* État actif du toggle */
.image-mode-toggle input[type="checkbox"]:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--button-color) 0%, var(--button-color-dark) 100%);
    border-color: var(--button-color-dark);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 10px rgba(77, 127, 122, 0.4);
}

.image-mode-toggle input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translate(22px, -50%);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Animation au hover */
.image-mode-toggle:hover .toggle-slider {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 6px rgba(77, 127, 122, 0.3);
}

.image-mode-toggle:hover .toggle-slider::before {
    transform: translateY(-50%) scale(1.08);
}

.image-mode-toggle input[type="checkbox"]:checked:hover + .toggle-slider::before {
    transform: translate(22px, -50%) scale(1.08);
}

/* Label du toggle */
.toggle-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
}

.image-mode-toggle input[type="checkbox"]:checked ~ .toggle-label {
    color: var(--button-color);
}

/* Animation du container au focus */
.image-mode-toggle input[type="checkbox"]:focus + .toggle-slider {
    outline: 2px solid var(--button-color);
    outline-offset: 2px;
}

/* Responsive */
@media (min-width: 768px) {
    .image-mode-container {
        padding: 0.75rem 1.25rem;
    }

    .toggle-slider {
        width: 52px;
        height: 26px;
    }

    .toggle-slider::before {
        width: 22px;
        height: 22px;
        left: 1.5px;
    }

    .image-mode-toggle input[type="checkbox"]:checked + .toggle-slider::before {
        transform: translate(26px, -50%);
    }

    .image-mode-toggle input[type="checkbox"]:checked:hover + .toggle-slider::before {
        transform: translate(26px, -50%) scale(1.08);
    }

    .toggle-label {
        font-size: 0.8rem;
    }
}


/* =====================================================================
   Mise en page : tout tient dans la fenêtre, sans défilement
   - .screen  : titre + affiche + fiche de jeu
   - .bottom-bar : mode image + navigation
   Classes posées par le script sur .container :
   .has-poster (une affiche est affichée), .image-mode, .no-image
   ===================================================================== */
[hidden] { display: none !important; }

body { padding: 0; }
.container { max-width: none; padding: 0.6rem 0.75rem 1rem; }

header { margin-bottom: 0.75rem; }
.stage { display: flex; flex-direction: column; gap: 0.75rem; min-height: 0; }

.game-card { padding: 1rem; }
.question-section { margin-bottom: 0.9rem; padding-bottom: 0.9rem; }
.hints-section, .answer-section { margin-bottom: 0.9rem; }
.image-mode .question-section { display: none; }

/* Affiche */
.poster {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    animation: fadeIn 0.3s ease;
}
.poster img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: var(--shadow);
    cursor: zoom-in;
}

/* Barre du bas */
.bottom-bar { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.75rem; }
.image-mode-container, .navigation-footer { margin-top: 0; animation: none; }
.navigation-footer { padding: 0.6rem 1rem; border-radius: 12px; }
.footer-info { margin-bottom: 0.4rem; }
.footer-controls { margin-bottom: 0; }
.no-image .image-mode-container { display: none; }

/* ---------- Téléphone et tablette ---------- */
@media (max-width: 899px) {
    .container { max-width: 640px; margin: 0 auto; }
    header h1 { font-size: 1.15rem; margin-bottom: 0.25rem; }
    header .subtitle { font-size: 0.72rem; }

    /* Avec une affiche : affiche, indices, réponse et bouton tiennent dans l'écran */
    .has-poster .screen {
        /* svh = hauteur de l'écran barre d'adresse visible : elle ne change pas quand on fait
           défiler (avec dvh, l'affiche changeait de taille quand la barre se repliait) */
        height: calc(100vh - 0.6rem);
        height: calc(100svh - 0.6rem);
        display: flex;
        flex-direction: column;
    }
    .has-poster header { margin-bottom: 0.5rem; }
    .has-poster header .subtitle { display: none; }
    .has-poster .stage { flex: 1; }
    .has-poster .poster { flex: 1 1 0; min-height: 150px; }
    .has-poster .game-card { flex: none; padding: 0.75rem; }
    .has-poster .question-section { margin-bottom: 0.6rem; padding-bottom: 0.6rem; }
    .has-poster .hints-section, .has-poster .answer-section { margin-bottom: 0.6rem; }
    .has-poster .answer-content { padding: 0.7rem; }
    .has-poster .btn-primary { padding: 0.7rem 1.6rem; }
}
@media (min-width: 768px) and (max-width: 899px) {
    #hints-list li { height: 2.6rem; padding: 0.6rem 1rem; }
}

/* ---------- Ordinateur : tout dans la hauteur de la fenêtre ---------- */
@media (min-width: 900px) {
    body { padding: 0; }
    .container {
        height: 100vh;
        height: 100dvh;
        max-width: 1180px;
        margin: 0 auto;
        padding: 1rem 1.5rem 1rem;
        display: flex;
        flex-direction: column;
    }
    .screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }

    header { margin-bottom: 1rem; flex: none; }
    header h1 { font-size: 1.7rem; margin-bottom: 0.3rem; }
    header .subtitle { font-size: 0.85rem; max-width: none; }

    .stage {
        flex: 1;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 1.75rem;
    }
    .poster { height: 100%; flex: 0 1 auto; max-width: 48%; }
    .poster img { max-height: 100%; }

    .game-card {
        flex: 0 1 560px;
        max-height: 100%;
        overflow-y: auto;
        padding: 1.5rem 1.75rem;
    }
    .question-section { margin-bottom: 1.1rem; padding-bottom: 1.1rem; }
    .question-section h2 { font-size: 1.1rem; }
    .hints-section, .answer-section { margin-bottom: 1.1rem; }
    #hints-list li { height: 2.75rem; padding: 0.7rem 1.1rem; font-size: 0.95rem; }
    .answer-content p { font-size: 1.15rem; }
    .btn-primary { padding: 0.9rem 2.2rem; font-size: 0.95rem; }

    /* Barre du bas : une seule ligne */
    .bottom-bar {
        flex: none;
        flex-direction: row;
        align-items: stretch;
        justify-content: center;
        gap: 0.75rem;
        margin-top: 1rem;
    }
    .image-mode-container { padding: 0.5rem 1.1rem; }
    .navigation-footer {
        display: flex;
        align-items: center;
        gap: 1.25rem;
        padding: 0.5rem 1.1rem;
    }
    .footer-info { margin-bottom: 0; }
    .footer-info span { font-size: 0.8rem; }
    .nav-btn { width: 2.2rem; height: 2.2rem; }
}
