/* Bouton retour accueil et message d'erreur sur la page de connexion */
.btn-retour {
    background: #34495e;
    color: #fff;
    padding: 0.7em 2em;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 500;
    display: inline-block;
    margin: 0 auto;
    transition: background 0.2s;
}
.btn-retour:hover {
    background: #22313a;
}
.retour-accueil {
    margin-top: 2em;
    text-align: center;
}
.erreur-photo {
    color: #c00;
    font-weight: bold;
    margin: 0.5em 0 0.5em 0;
    text-align: center;
}
/* Photo équipe sur la page finale */
.team-photo {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 18px auto 18px auto;
    border-radius: 10px;
    box-shadow: 0 2px 12px #0003;
}

/* Message d'information sous la photo */
.info-photo {
    color: #888;
    font-size: 0.95em;
    margin: 0.5em 0 0.5em 0;
    text-align: center;
}

/* Message d'erreur pour l'upload photo */
.erreur-photo {
    color: #c00;
    font-weight: bold;
    margin: 0.5em 0 0.5em 0;
    text-align: center;
}

/* Loader d'upload photo */
.photo-loader {
    display: none;
    margin-top: 1em;
    text-align: center;
}
.photo-loader.active {
    display: block;
}
.loader {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 4px solid #ccc;
    border-top: 4px solid #2c3e50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* Simplified responsive CSS for mobile harmony */
body {
    /* Dégradé Granit Rose pour Trébeurden */
    background: linear-gradient(135deg, #fdfbf7 0%, #e6c9c9 40%, #d48f8f 100%);
    color: #234020;
    font-family: 'Reenie Beanie', cursive, sans-serif;
    font-size: 28px;
    margin: 0;
    padding: 10px;
    overflow-x: hidden;
}


h1, h2, h3 {
    color: #fff;
    font-family: 'Reenie Beanie', cursive, sans-serif;
    text-shadow: 1px 2px 8px rgba(44,64,44,0.32);
    margin: 0.5em 0;
}
h1 { font-size: 2em; }
h2 { font-size: 1.4em; text-align: center; text-transform: uppercase; }
h3 { font-size: 1.1em; color: #e0f2e9; }

p, label, input, button, nav button {
    font-size: 1em;
    font-family: 'Reenie Beanie', cursive, sans-serif;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 10px;
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

input[type="text"] {
    width: 100%;
    height: 44px;
    border-radius: 6px;
    border: 1.5px solid #EAC4A3;
    background: #3E4E5E;
    color: #EAC4A3;
    font-weight: bold;
    margin-bottom: 10px;
    box-sizing: border-box;
    padding: 8px;
}

button, input[type="submit"], nav button {
    background: #6B7B8C;
    color: #EAC4A3;
    border: 1.5px solid #EAC4A3;
    border-radius: 6px;
    padding: 12px 0;
    font-size: 1.1em;
    font-weight: bold;
    width: 100%;
    margin: 8px 0;
    cursor: pointer;
    transition: background 0.2s;
}
button:hover, nav button:hover {
    background: #5B6C7D;
}

nav {
    padding: 8px 0;
    text-align: center;
}

#menu-toggle {
    display: block;
    font-size: 1.5em;
    background: none;
    border: none;
    color: #EAC4A3;
    margin: 0 auto 10px auto;
}

#menu-items {
    display: none;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    width: 100%;
}
#menu-items.show {
    display: flex;
}

#menu-items form {
    width: 100%;
    margin: 0;
}
#menu-items button {
    width: 100%;
    box-sizing: border-box;
}

.responsive-media {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px auto;
    border-radius: 8px;
}

audio {
    width: 100%;
    max-width: 100%;
    min-height: 54px; /* Hauteur standard pour les contrôles audio */
    background: #556070; /* Couleur de fond pour s'assurer que l'élément est visible */
    display: block;
    margin: 10px auto;
}

.page-memo {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.memo-intro,
.memo-scoreboard,
.memo-grid-wrapper,
.memo-tips {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.2em;
    margin: 1em auto;
    max-width: 960px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.memo-intro p {
    margin-bottom: 0.8em;
}

.memo-reset {
    width: auto;
    padding: 0.7em 2em;
    border-radius: 30px;
    background: rgba(50, 80, 120, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.25);
    color: #fdfdfd;
    font-weight: 600;
}

.memo-scoreboard {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.2em;
}

.memo-score {
    background: rgba(255, 255, 255, 0.18);
    padding: 1em;
    border-radius: 14px;
    text-align: center;
    box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.08);
}

.memo-score h3 {
    margin-bottom: 0.4em;
    color: #ffefd5;
}

.memo-score-value {
    font-size: 1.2em;
    margin: 0;
    color: #23313f;
    font-weight: 700;
}

.memo-status {
    max-width: 720px;
    margin: 1em auto;
    padding: 0.8em 1.4em;
    border-radius: 12px;
    text-align: center;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.memo-status-win {
    background: rgba(76, 175, 80, 0.8);
    color: #f5fff5;
}

.memo-status-lose {
    background: rgba(198, 40, 40, 0.85);
    color: #ffeeee;
}

.memo-status-draw {
    background: rgba(33, 150, 243, 0.8);
    color: #e7f4ff;
}

.memo-grid {
    display: grid;
    gap: 12px;
    justify-content: center;
    grid-template-columns: repeat(4, minmax(86px, 1fr));
}

.memo-card {
    position: relative;
    padding: 0;
    width: 100%;
    aspect-ratio: 3 / 4;
    background: transparent;
    border: none;
    cursor: pointer;
    perspective: 900px;
}

.memo-card:focus {
    outline: 3px solid rgba(255, 255, 255, 0.4);
}

.memo-card.revealed,
.memo-card.flipped {
    cursor: default;
}

.memo-card-inner {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: rgba(33, 50, 68, 0.8);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: clamp(1.9rem, 5vw, 3rem);
    font-weight: 700;
    /* box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); */
    transition: transform 0.45s ease;
    transform-style: preserve-3d;
    overflow: hidden;
}

.memo-card.flipped .memo-card-inner,
.memo-card.matched .memo-card-inner {
    transform: rotateY(180deg);
}

.memo-card-front,
.memo-card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 16px;
    display: grid;
    place-items: center;
}

.memo-card-front {
    background: linear-gradient(150deg, rgba(59, 89, 152, 0.9), rgba(72, 120, 168, 0.9));
}

.memo-card-back {
    background: linear-gradient(150deg, rgba(255, 183, 77, 0.92), rgba(255, 138, 101, 0.92));
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
}

.memo-card-icon {
    font-size: clamp(2rem, 6vw, 3rem);
    line-height: 1;
}

/* Image d'animal dans les cartes matchées */
.memo-card-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    padding: 5px;
}

.memo-card.matched .memo-card-inner {
    transform: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5);
    filter: saturate(1.2);
}

.memo-card.matched .memo-card-front,
.memo-card.matched .memo-card-back {
    transform: none;
    background: linear-gradient(150deg, rgba(129, 199, 132, 0.95), rgba(76, 175, 80, 0.95));
}

.memo-card-label {
    font-size: 0.95em;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.2s ease-in;
}

.memo-card.matched .memo-card-label {
    opacity: 1;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.pilotage-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    background: rgba(16, 32, 48, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 1.5rem;
    position: relative;
}

.pilotage-visual {
    position: relative;
    flex: 1 1 280px;
    min-width: 260px;
}

.pilotage-placeholder {
    min-height: 240px;
    border: 2px dashed rgba(255, 255, 255, 0.25);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.95rem;
    text-align: center;
    padding: 1rem;
}

.pilotage-diodes {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pilotage-diode {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(30, 46, 64, 0.9);
    border: 2px solid rgba(120, 150, 190, 0.45);
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.pilotage-diode.on {
    background: #8bc34a;
    box-shadow: 0 0 12px rgba(139, 195, 74, 0.8);
}

.pilotage-controls {
    flex: 1 1 320px;
    min-width: 300px;
    display: grid;
    gap: 1rem;
}

.pilotage-control {
    background: rgba(8, 18, 32, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 1rem 1.2rem;
}

.pilotage-control h3 {
    margin: 0 0 0.35rem;
    font-size: 1.1rem;
    letter-spacing: 0.02em;
}

.pilotage-control-hint {
    margin: 0 0 0.75rem;
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.65);
}

.engine-selector {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.engine-option {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    padding: 0.55rem 0.9rem;
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.engine-option:hover,
.engine-option:focus-visible {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
    outline: none;
}

.engine-option.is-active {
    background: #ffb300;
    border-color: #ffe082;
    color: #1b1b1b;
    transform: translateY(-1px);
}

.heading-control {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, auto));
    gap: 0.75rem;
    align-items: center;
}

.heading-input {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1rem;
}

.heading-input input {
    width: 90px;
    padding: 0.4rem 0.5rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(10, 20, 32, 0.85);
    color: #fff;
    font-size: 1rem;
}

.heading-control button {
    justify-self: start;
}

.heading-readout {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.72);
}

.winch-control {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

.winch-progress {
    font-size: 0.95rem;
}

.pilotage-status {
    margin-top: 1.4rem;
    font-size: 1rem;
    font-weight: 600;
    color: #ffe082;
}

@media (max-width: 720px) {
    .pilotage-wrapper {
        flex-direction: column;
    }

    .pilotage-controls {
        min-width: 0;
    }
}

.memo-tips ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.memo-tips li {
    padding-left: 1.4em;
    position: relative;
    margin-bottom: 0.8em;
}

.memo-tips li::before {
    content: '•';
    position: absolute;
    left: 0.4em;
    color: #ffd54f;
    font-size: 1.4em;
    line-height: 1;
}

@media (max-width: 640px) {
    .memo-grid {
        grid-template-columns: repeat(4, minmax(56px, 1fr));
    }
    .memo-card-inner {
        font-size: clamp(1.6rem, 10vw, 2.4rem);
    }
}

.star { color: gold; font-size: 1.2em; }
.star-empty { color: lightgray; }

/* Header niveau indicateur */
#niveau-indicateur {
    cursor: pointer;
    font-weight: bold;
    background: #fff3;
    border-radius: 8px;
    padding: 8px 16px;
    box-shadow: 0 2px 8px #0002;
    min-width: 110px;
    text-align: center;
}

.progress-bar-header {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.progress-bar-container {
    flex: 1;
    width: 100%;
    background: #3E4E5E;
    border-radius: 6px;
    overflow: hidden;
    height: 18px;
}
.progress-bar {
    height: 100%;
    background: #FFAB91;
    color: #fff;
    font-weight: bold;
    text-align: center;
    line-height: 18px;
    transition: width 0.4s cubic-bezier(.4,2,.6,1);
}

/* Table: responsive, hide extra columns on mobile */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}
th, td {
    padding: 6px;
    text-align: center;
    word-break: break-word;
}
@media (max-width: 600px) {
    body { font-size: 24px; padding: 12px; }
    h1, h2 { font-size: 1.4em; }
    .container { padding: 10px; }
    th:nth-child(4), td:nth-child(4), th:nth-child(5), td:nth-child(5) {
        display: none;
    }
    button, input[type="submit"], nav button {
        font-size: 1.1em;
        padding: 14px 0;
    }
    input[type="text"] {
        height: 44px;
        font-size: 1.1em;
    }
}

/* --- MODALE CHANGEMENT DE NIVEAU --- */
#modal-niveau {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: #0007;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
#modal-niveau .modal-niveau-content {
    background: #232b36;
    color: #EAC4A3;
    padding: 2em 2em 1em 2em;
    border-radius: 12px;
    min-width: 260px;
    max-width: 90vw;
    box-shadow: 0 4px 24px #0005;
    position: relative !important;
    display: block;
}
#close-modal-niveau {
    position: absolute !important;
    top: 0.7em !important;
    right: 1.2em !important;
    left: auto !important;
    margin: 0 !important;
    font-size: 1.7em;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    z-index: 10;
    color: #FFD6B0;
    padding: 0;
    display: block;
    width: auto;
    height: auto;
    text-align: right;
}
#close-modal-niveau:hover {
    color: #c00;
    background: #eee;
    border-radius: 50%;
}
#modal-niveau h3 {
    margin-top: 0;
    margin-bottom: 1.2em;
    color: #FFD6B0;
    font-weight: 700;
    font-size: 1.25em;
    letter-spacing: 0.01em;
}

/* Modale de félicitations (style similaire à la modale de niveau, palette harmonisée) */
#congrats-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(44, 62, 80, 0.7); /* bleu foncé semi-transparent */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
#congrats-modal .modal-niveau-content {
    background: #232b36; /* fond sombre comme la modale niveau */
    color: #FFD6B0;
    padding: 2em 2em 1em 2em;
    border-radius: 16px;
    box-shadow: 0 4px 24px #0005;
    text-align: center;
    max-width: 95vw;
    min-width: 320px;
}
#congrats-modal h2 {
    color: #FFD6B0;
    font-family: 'Reenie Beanie', cursive;
    font-size: 2.2em;
    margin-bottom: 0.5em;
    text-shadow: 1px 1px 8px #2e3847;
}
#congrats-modal p {
    font-size: 1.2em;
    margin-bottom: 1.5em;
    color: #EAC4A3;
}
#congrats-modal .btn-niveau {
    margin-top: 1em;
    padding: 0.7em 2em;
    font-size: 1.1em;
    background: linear-gradient(90deg, #FFAB91 0%, #FFD6B0 100%);
    color: #232b36;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px #0002;
    font-weight: bold;
    transition: background 0.2s;
}
#congrats-modal .btn-niveau:hover {
    background: linear-gradient(90deg, #FFD6B0 0%, #FFAB91 100%);
    color: #2e3847;
}

/* --- Liens de test des énigmes (carte) --- */
.test-links {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    padding: 1em 1.2em 1.2em 1.2em;
    border-radius: 14px;
    box-shadow: 0 2px 10px #0002, inset 0 0 12px #ffffff12;
}
.test-links h2 {
    margin-top: 0;
    margin-bottom: 0.8em;
    font-size: 1.05em;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #f5fff5;
    text-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.test-links ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.7em;
}
.test-links a.btn, .test-links a.btn-secondary {
    display: inline-block;
    background: linear-gradient(135deg, #2f6d3a, #349e4d);
    border: 1px solid #58c678;
    color: #fff !important;
    padding: 0.45em 0.9em;
    border-radius: 30px;
    font-size: 0.9em;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.2;
    box-shadow: 0 2px 6px #0003, 0 0 0 2px #ffffff10 inset;
    transition: transform 0.15s ease, background 0.25s, box-shadow 0.25s;
}
.test-links a.btn:hover, .test-links a.btn-secondary:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #349e4d, #42b55b);
    box-shadow: 0 4px 12px #0004, 0 0 0 2px #ffffff18 inset;
}
.test-links a.btn:active, .test-links a.btn-secondary:active {
    transform: translateY(0);
    background: linear-gradient(135deg, #2d6a39, #318f45);
}
@media (max-width: 640px) {
    .test-links ul { gap: 0.5em; }
    .test-links a.btn, .test-links a.btn-secondary { font-size: 0.85em; padding: 0.45em 0.8em; }
}

/* --- Carte (page-carte) --- */
#map {
    width: 100%;
    height: 70vh;
    margin: 2em 0;
    border-radius: 12px;
    box-shadow: 0 2px 8px #0003;
}
.page-carte .continuer-aventure {
    text-align: center;
    margin: 2em 0;
}
.btn-continuer {
    font-size: 1.3em;
    padding: 0.7em 2em;
}
.test-links-margin { margin: 2em 0; }
.test-links-title { font-size: 1.1em; color: #f5fff5; }
.test-link-item { padding: 0.4em 1em; }

/* Popup état point fait */
.point-deja-fait { color: #c00; font-weight: 600; }

/* --- Modale de proximité --- */
.proximity-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}
.proximity-modal-box {
    background: #fff;
    padding: 2em 2em 1.5em 2em;
    border-radius: 16px;
    max-width: 90vw;
    text-align: center;
    box-shadow: 0 2px 16px #0009;
}
.proximity-modal-link { font-size: 1.2em; padding: 0.6em 2em; display:inline-block; }
.proximity-modal-close { margin-top: 1em; background:#6B7B8C; color:#fff; width:auto; padding:0.5em 1.4em; }
.proximity-modal-close:hover { background:#5B6C7D; }
