/* ============================================================
   LES CLÉS DE GABRIELLE — Style Global Thème Égypte Antique
   ============================================================ */

/* --- Import Police Pixel Art --- */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Cinzel:wght@700&display=swap');

:root {
    /* Couleurs Égyptiennes */
    --ocre: #C8A951;
    --or: #FFD700;
    --bleu-nuit: #0A1931;
    --turquoise: #1ABCB4;
    --terre-sienne: #A0522D;
    --sable: #F4E4BA;
    --sable-fonce: #D4B876;
    --noir: #0D0D0D;
    --blanc: #F5F0E1;
    --rouge: #C0392B;
    --vert: #27AE60;
    --violet: #6C3483;

    /* Configuration */
    --font-pixel: 'Press Start 2P', monospace;
    --border-egyptian: 4px solid var(--ocre);
    --shadow-pixel: 4px 4px 0px rgba(0, 0, 0, 0.5);
    --transition-speed: 0.3s;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--noir);
    font-family: var(--font-pixel);
    color: var(--blanc);
    image-rendering: pixelated;
    -ms-interpolation-mode: nearest-neighbor;
    cursor: default;
    min-width: 1280px;
    min-height: 720px;
}

/* --- Écran Titre --- */
#title-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, #1a0a2e 0%, #000 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    overflow: hidden;
}

#title-screen::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background:
        repeating-linear-gradient(90deg, transparent, transparent 80px, rgba(0, 0, 0, 0.1) 80px, rgba(0, 0, 0, 0.1) 82px),
        linear-gradient(0deg, var(--sable-fonce) 0%, var(--terre-sienne) 100%);
    clip-path: polygon(0 30%, 10% 20%, 20% 35%, 35% 10%, 45% 25%, 55% 5%, 65% 20%, 80% 15%, 90% 25%, 100% 20%, 100% 100%, 0 100%);
}

.title-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background: radial-gradient(1px 1px at 10% 10%, var(--or) 50%, transparent),
        radial-gradient(1px 1px at 30% 20%, var(--blanc) 50%, transparent),
        radial-gradient(2px 2px at 50% 5%, var(--or) 50%, transparent),
        radial-gradient(1px 1px at 70% 15%, var(--blanc) 50%, transparent),
        radial-gradient(1px 1px at 90% 25%, var(--or) 50%, transparent),
        radial-gradient(1px 1px at 15% 35%, var(--blanc) 50%, transparent),
        radial-gradient(2px 2px at 85% 8%, var(--or) 50%, transparent),
        radial-gradient(1px 1px at 45% 30%, var(--blanc) 50%, transparent),
        radial-gradient(1px 1px at 25% 5%, var(--or) 50%, transparent),
        radial-gradient(1px 1px at 60% 25%, var(--blanc) 50%, transparent),
        radial-gradient(1px 1px at 75% 40%, var(--or) 50%, transparent),
        radial-gradient(1px 1px at 5% 20%, var(--blanc) 50%, transparent);
    animation: twinkle 3s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

.title-pyramids {
    position: absolute;
    bottom: 15%;
    width: 100%;
    height: 30%;
    z-index: 1;
}

.title-pyramids::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    width: 0;
    height: 0;
    border-left: 120px solid transparent;
    border-right: 120px solid transparent;
    border-bottom: 180px solid #8B6914;
    filter: brightness(0.8);
}

.title-pyramids::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 0;
    border-left: 80px solid transparent;
    border-right: 80px solid transparent;
    border-bottom: 120px solid #9B7924;
    filter: brightness(0.9);
}

.title-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.title-egyptian-border {
    padding: 30px 50px;
    border: 4px solid var(--or);
    background: rgba(10, 25, 49, 0.85);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3),
        inset 0 0 30px rgba(255, 215, 0, 0.05);
    position: relative;
}

.title-egyptian-border::before,
.title-egyptian-border::after {
    content: '𓂀 𓃭 𓆣 𓋹 𓁹';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    color: var(--or);
    letter-spacing: 10px;
    opacity: 0.7;
}

.title-egyptian-border::before {
    top: 8px;
}

.title-egyptian-border::after {
    bottom: 8px;
}

#title-screen h1 {
    font-size: 28px;
    color: var(--or);
    text-shadow: 3px 3px 0px var(--terre-sienne), 0 0 20px rgba(255, 215, 0, 0.5);
    letter-spacing: 3px;
    margin: 20px 0 5px;
    line-height: 1.6;
}

#title-screen h2 {
    font-size: 12px;
    color: var(--ocre);
    letter-spacing: 5px;
    margin-bottom: 30px;
    font-weight: normal;
    opacity: 0.8;
}

.title-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

/* --- Boutons génériques --- */
.btn-egyptian {
    font-family: var(--font-pixel);
    font-size: 11px;
    padding: 14px 40px;
    background: linear-gradient(180deg, var(--ocre) 0%, var(--terre-sienne) 100%);
    color: var(--blanc);
    border: 3px solid var(--or);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: var(--shadow-pixel);
    transition: all var(--transition-speed);
    position: relative;
    min-width: 280px;
}

.btn-egyptian:hover {
    background: linear-gradient(180deg, var(--or) 0%, var(--ocre) 100%);
    color: var(--bleu-nuit);
    transform: translateY(-2px);
    box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.5);
}

.btn-egyptian:active {
    transform: translateY(2px);
    box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
}

.btn-egyptian.btn-secondary {
    background: linear-gradient(180deg, var(--bleu-nuit) 0%, #152a4a 100%);
    border-color: var(--turquoise);
}

.btn-egyptian.btn-secondary:hover {
    background: linear-gradient(180deg, #152a4a 0%, var(--bleu-nuit) 100%);
    color: var(--turquoise);
}

.btn-egyptian.btn-small {
    font-size: 9px;
    padding: 10px 20px;
    min-width: 150px;
}

.btn-egyptian:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.title-credits {
    position: absolute;
    bottom: 20px;
    font-size: 8px;
    color: var(--ocre);
    opacity: 0.5;
    letter-spacing: 1px;
    z-index: 2;
}

/* --- Canvas du jeu --- */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    background: var(--noir);
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    -ms-interpolation-mode: nearest-neighbor;
}

/* --- HUD --- */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 100;
    pointer-events: none;
}

#hud>* {
    pointer-events: auto;
}

.hud-panel {
    background: rgba(10, 25, 49, 0.9);
    border: 3px solid var(--or);
    padding: 8px 15px;
    box-shadow: var(--shadow-pixel);
    display: flex;
    align-items: center;
    gap: 10px;
}

.hud-keys {
    font-size: 11px;
    color: var(--or);
}

.hud-keys .key-icon {
    color: var(--or);
    font-size: 14px;
    animation: glow-key 2s ease-in-out infinite;
}

/* --- Menu de sélection des jeux (Hubs) --- */
.game-menu {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin: 30px auto;
    max-width: 800px;
}

.btn-game {
    height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 15px;
    font-size: 14px;
    line-height: 1.4;
    transition: all 0.2s ease;
}

.btn-game small {
    display: block;
    margin-top: 8px;
    font-size: 10px;
    opacity: 0.8;
}

.btn-game:hover {
    transform: scale(1.05);
    background-color: var(--or);
    color: var(--noir);
}

@media (max-width: 900px) {
    .game-menu {
        grid-template-columns: 1fr;
    }
}

@keyframes glow-key {

    0%,
    100% {
        text-shadow: 0 0 5px var(--or);
    }

    50% {
        text-shadow: 0 0 15px var(--or), 0 0 25px rgba(255, 215, 0, 0.5);
    }
}

.hud-zone {
    font-size: 9px;
    color: var(--sable);
    letter-spacing: 1px;
}

/* Mini-carte */
#minimap {
    width: 150px;
    height: 150px;
    border: 3px solid var(--or);
    background: rgba(10, 25, 49, 0.9);
    box-shadow: var(--shadow-pixel);
    image-rendering: pixelated;
}

/* Bouton son */
.hud-sound-btn {
    background: rgba(10, 25, 49, 0.9);
    border: 3px solid var(--or);
    color: var(--or);
    font-size: 18px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-pixel);
    transition: all var(--transition-speed);
    font-family: var(--font-pixel);
}

.hud-sound-btn:hover {
    background: var(--or);
    color: var(--bleu-nuit);
}

/* --- Menu Pause --- */
#pause-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 8000;
}

#pause-menu.active {
    display: flex;
}

#pause-menu h2 {
    font-size: 20px;
    color: var(--or);
    margin-bottom: 30px;
    text-shadow: 2px 2px 0px var(--terre-sienne);
    letter-spacing: 3px;
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pause-volume {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 15px 0;
    font-size: 10px;
    color: var(--ocre);
}

.pause-volume input[type="range"] {
    width: 150px;
    accent-color: var(--or);
}

/* --- Notifications Toast --- */
#toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9500;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(10, 25, 49, 0.95);
    border: 3px solid var(--or);
    padding: 12px 20px;
    font-family: var(--font-pixel);
    font-size: 9px;
    color: var(--sable);
    box-shadow: var(--shadow-pixel);
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.17, 0.67, 0.29, 1.2);
    max-width: 350px;
    line-height: 1.6;
}

.toast.show {
    transform: translateX(0);
}

.toast.toast-key {
    border-color: var(--or);
    color: var(--or);
}

.toast.toast-zone {
    border-color: var(--turquoise);
    color: var(--turquoise);
}

.toast.toast-error {
    border-color: var(--rouge);
    color: var(--rouge);
}

.toast.toast-success {
    border-color: var(--vert);
    color: var(--vert);
}

/* --- Overlay Mini-jeux (dans les pages level) --- */
#minigame-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    z-index: 5000;
    background: rgba(0, 0, 0, 0.9);
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#minigame-overlay.active {
    display: flex;
}

.minigame-container {
    background: linear-gradient(180deg, var(--bleu-nuit) 0%, #152a4a 100%);
    border: 4px solid var(--or);
    padding: 25px;
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.2);
    position: relative;
    margin: 100px auto 20px auto;
    /* Centrage et marge HUD */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.minigame-container::before {
    content: '𓆣 𓋹 𓂀 𓋹 𓆣';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: var(--or);
    letter-spacing: 8px;
    opacity: 0.5;
}

.minigame-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--ocre);
}

.minigame-header h2 {
    font-size: 16px;
    color: var(--or);
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
    margin-bottom: 8px;
}

.minigame-header .timer {
    font-size: 14px;
    color: var(--turquoise);
}

.minigame-header .timer.warning {
    color: var(--rouge);
    animation: blink 0.5s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.minigame-header .lives {
    font-size: 12px;
    color: var(--rouge);
    margin-top: 5px;
}

.minigame-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid var(--ocre);
}

/* --- Level select (pages internes) --- */
.level-hub {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.level-hub-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.level-hub-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.level-hub h1 {
    font-size: 18px;
    color: var(--or);
    text-shadow: 2px 2px 0px var(--terre-sienne);
    margin-bottom: 30px;
    letter-spacing: 2px;
}

.game-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    max-width: 800px;
}

.game-card {
    background: rgba(10, 25, 49, 0.9);
    border: 3px solid var(--ocre);
    padding: 20px;
    width: 220px;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-align: center;
    position: relative;
}

.game-card:hover {
    border-color: var(--or);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(255, 215, 0, 0.2);
}

.game-card.completed {
    border-color: var(--vert);
    opacity: 0.7;
}

.game-card.completed::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 16px;
    color: var(--vert);
}

.game-card.locked {
    border-color: var(--rouge);
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.game-card h3 {
    font-size: 10px;
    color: var(--or);
    margin-bottom: 8px;
}

.game-card p {
    font-size: 8px;
    color: var(--sable);
    line-height: 1.6;
}

.game-card .reward {
    margin-top: 10px;
    font-size: 10px;
    color: var(--or);
}

.back-btn {
    margin-top: 25px;
}

/* --- Quiz --- */
.quiz-question {
    font-size: 11px;
    color: var(--sable);
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.8;
}

.quiz-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
}

.quiz-choice {
    font-family: var(--font-pixel);
    font-size: 9px;
    padding: 12px;
    background: rgba(200, 169, 81, 0.1);
    border: 2px solid var(--ocre);
    color: var(--sable);
    cursor: pointer;
    transition: all var(--transition-speed);
    text-align: center;
    line-height: 1.5;
}

.quiz-choice:hover {
    background: rgba(200, 169, 81, 0.3);
    border-color: var(--or);
}

.quiz-choice.correct {
    background: rgba(39, 174, 96, 0.3);
    border-color: var(--vert);
    color: var(--vert);
}

.quiz-choice.wrong {
    background: rgba(192, 57, 43, 0.3);
    border-color: var(--rouge);
    color: var(--rouge);
}

.quiz-progress {
    text-align: center;
    font-size: 9px;
    color: var(--ocre);
    margin-top: 15px;
}

/* --- Memory --- */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 500px;
    margin: 0 auto;
}

.memory-card {
    aspect-ratio: 1;
    background: var(--terre-sienne);
    border: 3px solid var(--ocre);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    transition: transform 0.4s;
    transform-style: preserve-3d;
    position: relative;
}

.memory-card.flipped {
    transform: rotateY(180deg);
    background: var(--bleu-nuit);
    border-color: var(--or);
}

.memory-card.matched {
    background: rgba(39, 174, 96, 0.3);
    border-color: var(--vert);
    cursor: default;
}

.memory-card .card-back {
    font-size: 24px;
    color: var(--or);
    backface-visibility: hidden;
}

.memory-card .card-front {
    position: absolute;
    backface-visibility: hidden;
    transform: rotateY(180deg);
    font-size: 32px;
}

/* --- Casse-brique --- */
#breakout-canvas {
    display: block;
    margin: 0 auto;
    border: 3px solid var(--or);
    background: var(--bleu-nuit);
    image-rendering: pixelated;
}

/* --- Puzzle --- */
.puzzle-wrapper {
    display: flex;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.puzzle-grid {
    display: grid;
    gap: 3px;
    border: 3px solid var(--or);
    background: var(--terre-sienne);
    padding: 3px;
}

.puzzle-grid-3x3 {
    grid-template-columns: repeat(3, 100px);
    grid-template-rows: repeat(3, 100px);
}

.puzzle-grid-4x4 {
    grid-template-columns: repeat(4, 80px);
    grid-template-rows: repeat(4, 80px);
}

.puzzle-piece {
    background: var(--bleu-nuit);
    border: 2px solid var(--ocre);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: all 0.2s;
    font-size: 10px;
    color: var(--sable);
    overflow: hidden;
}

.puzzle-piece:hover {
    border-color: var(--or);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.puzzle-piece.correct {
    border-color: var(--vert);
    background: rgba(39, 174, 96, 0.2);
}

.puzzle-piece.dragging {
    opacity: 0.6;
    cursor: grabbing;
}

.puzzle-preview {
    border: 3px solid var(--ocre);
    padding: 5px;
    background: rgba(10, 25, 49, 0.5);
}

.puzzle-preview canvas {
    display: block;
    image-rendering: pixelated;
}

/* --- Simon --- */
.simon-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    max-width: 350px;
    margin: 0 auto;
}

.simon-btn {
    aspect-ratio: 1;
    border: 4px solid rgba(255, 255, 255, 0.2);
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    border-radius: 0;
}

.simon-btn:hover {
    filter: brightness(1.2);
}

.simon-btn.active {
    filter: brightness(1.8);
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
}

.simon-btn.btn-ra {
    background: #C0392B;
}

.simon-btn.btn-anubis {
    background: #2C3E50;
}

.simon-btn.btn-isis {
    background: #1ABC9C;
}

.simon-btn.btn-bastet {
    background: #8E44AD;
}

.simon-info {
    text-align: center;
    margin: 15px 0;
    font-size: 10px;
    color: var(--ocre);
}

/* --- Scarabées --- */
#scarab-canvas {
    display: block;
    margin: 0 auto;
    border: 3px solid var(--or);
    background: var(--sable-fonce);
    image-rendering: pixelated;
}

/* --- Maths --- */
.math-problem {
    text-align: center;
    margin: 20px 0;
}

.math-problem .question {
    font-size: 11px;
    color: var(--sable);
    margin-bottom: 20px;
    line-height: 1.8;
}

.math-input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.math-input {
    font-family: var(--font-pixel);
    font-size: 16px;
    padding: 10px 20px;
    width: 150px;
    text-align: center;
    background: rgba(200, 169, 81, 0.1);
    border: 3px solid var(--ocre);
    color: var(--or);
    outline: none;
}

.math-input:focus {
    border-color: var(--or);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.math-score {
    text-align: center;
    margin-top: 15px;
    font-size: 10px;
    color: var(--turquoise);
}

/* --- Cibles Archers --- */
#archer-canvas {
    display: block;
    margin: 0 auto;
    border: 3px solid var(--or);
    background: #1a0a2e;
    cursor: crosshair;
}

/* --- Labyrinthe --- */
#maze-canvas {
    display: block;
    margin: 0 auto;
    border: 3px solid var(--or);
    background: var(--terre-sienne);
    image-rendering: pixelated;
}

/* --- Boss Final --- */
#boss-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, #1a0a2e 0%, var(--noir) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    overflow: hidden;
}

.boss-rose {
    margin-bottom: 30px;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
    animation: pulse-rose 2s ease-in-out infinite;
}

@keyframes pulse-rose {

    0%,
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
    }

    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.8));
    }
}

.boss-code {
    font-size: 36px;
    color: var(--or);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    margin: 15px 0;
    letter-spacing: 10px;
}

.boss-hieroglyphs {
    font-size: 42px;
    margin: 10px 0;
    color: var(--or);
}

.boss-message {
    font-size: 11px;
    color: var(--sable);
    text-align: center;
    line-height: 2;
    max-width: 600px;
    margin: 15px 0;
}

/* Confettis */
.confetti {
    position: fixed;
    width: 8px;
    height: 8px;
    z-index: 9999;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-10vh) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}

/* --- Tutoriel --- */
#tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 8500;
}

#tutorial-overlay.active {
    display: flex;
}

.tutorial-box {
    background: var(--bleu-nuit);
    border: 4px solid var(--or);
    padding: 30px 40px;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.2);
}

.tutorial-box h2 {
    font-size: 14px;
    color: var(--or);
    margin-bottom: 20px;
}

.tutorial-box p {
    font-size: 9px;
    color: var(--sable);
    line-height: 2;
    margin-bottom: 15px;
}

.tutorial-keys {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 15px 0;
}

.tutorial-key {
    width: 40px;
    height: 40px;
    border: 3px solid var(--ocre);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--or);
    background: rgba(200, 169, 81, 0.1);
}

/* --- Écran de transition (noir) --- */
#transition-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--noir);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#transition-screen.active {
    opacity: 1;
    pointer-events: auto;
}

#transition-screen p {
    font-size: 12px;
    color: var(--ocre);
    animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

/* --- Scrollbar custom --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bleu-nuit);
}

::-webkit-scrollbar-thumb {
    background: var(--ocre);
    border: 1px solid var(--or);
}

/* --- Animations utilitaires --- */
.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.scale-in {
    animation: scaleIn 0.3s ease forwards;
}

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

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Gate locked animation */
.gate-locked-msg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(192, 57, 43, 0.95);
    border: 3px solid var(--rouge);
    padding: 20px 30px;
    font-size: 10px;
    color: var(--blanc);
    z-index: 7000;
    text-align: center;
    line-height: 2;
    box-shadow: var(--shadow-pixel);
    animation: shakeAndFade 2s ease forwards;
}

@keyframes shakeAndFade {

    0%,
    100% {
        opacity: 0;
    }

    5% {
        transform: translate(-52%, -50%);
        opacity: 1;
    }

    10% {
        transform: translate(-48%, -50%);
    }

    15% {
        transform: translate(-51%, -50%);
    }

    20% {
        transform: translate(-49%, -50%);
    }

    25% {
        transform: translate(-50%, -50%);
    }

    80% {
        opacity: 1;
    }
}

/* Door unlock animation */
.gate-unlock-msg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(39, 174, 96, 0.95);
    border: 3px solid var(--vert);
    padding: 20px 30px;
    font-size: 10px;
    color: var(--blanc);
    z-index: 7000;
    text-align: center;
    line-height: 2;
    box-shadow: var(--shadow-pixel);
    animation: fadeInOut 3s ease forwards;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }

    15% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    85% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* --- Level background themes --- */
.bg-desert {
    background: linear-gradient(180deg, #1a0a2e 0%, #2d1b4e 20%, #8B6914 60%, var(--sable-fonce) 100%);
}

.bg-temple {
    background: linear-gradient(180deg, #0a1931 0%, #152a4a 30%, #1a3a5c 100%);
}

.bg-pyramide {
    background: linear-gradient(180deg, #2d1b00 0%, #5c3a1e 50%, #8B6914 100%);
}

.bg-palais {
    background: linear-gradient(180deg, #1a0a2e 0%, #3d1a5c 50%, #6C3483 100%);
}

.bg-sanctuaire {
    background: linear-gradient(180deg, #001a1a 0%, #003333 50%, #00574B 100%);
}

.bg-tombeau {
    background: linear-gradient(180deg, #0D0D0D 0%, #1a0a0a 50%, #2d1b1b 100%);
}

.bg-boss {
    background: radial-gradient(ellipse at center, #1a0a2e 0%, #0D0D0D 70%);
}

/* --- Bouton Retour --- */
.btn-back {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(10, 25, 49, 0.9);
    border: 2px solid var(--or);
    color: var(--or);
    padding: 10px 20px;
    font-family: var(--font-pixel);
    font-size: 12px;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-back:hover {
    background: var(--or);
    color: var(--bleu-nuit);
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

/* --- Quiz Styles --- */
.quiz-question {
    font-size: 18px;
    color: var(--blanc);
    text-align: center;
    margin: 20px 0 40px 0;
    line-height: 1.6;
    text-shadow: 1px 1px 0 #000;
    max-width: 800px;
}

.quiz-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    width: 100%;
    max-width: 800px;
}

@media (max-width: 768px) {
    .quiz-choices {
        grid-template-columns: 1fr;
    }
}

.quiz-choice {
    background: rgba(10, 25, 49, 0.8);
    border: 2px solid var(--ocre);
    color: var(--sable);
    padding: 15px 20px;
    font-family: var(--font-pixel);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.quiz-choice:hover {
    background: rgba(200, 169, 81, 0.2);
    border-color: var(--or);
    color: var(--or);
    transform: scale(1.02);
}

.quiz-choice.correct {
    background: rgba(39, 174, 96, 0.8);
    border-color: var(--vert);
    color: white;
}

.quiz-choice.wrong {
    background: rgba(192, 57, 43, 0.8);
    border-color: var(--rouge);
    color: white;
}

/* --- Styles Généraux Mini-Jeux (pour standardisation) --- */
.minigame-footer {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.btn-egyptian {
    background: linear-gradient(180deg, var(--ocre) 0%, #8d7334 100%);
    border: 3px solid var(--or);
    color: var(--bleu-nuit);
    padding: 15px 30px;
    font-family: var(--font-pixel);
    font-size: 14px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 5px 0 #5c4a22;
    transition: all 0.1s;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
    position: relative;
}

.btn-egyptian:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 7px 0 #5c4a22;
}

.btn-egyptian:active {
    transform: translateY(2px);
    box-shadow: 0 3px 0 #5c4a22;
}

.btn-secondary {
    background: rgba(10, 25, 49, 0.8);
    border-color: var(--ocre);
    color: var(--ocre);
    box-shadow: none;
}

.btn-secondary:hover {
    background: rgba(200, 169, 81, 0.2);
    color: var(--or);
    border-color: var(--or);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

/* --- Memory Styles --- */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin: 20px 0;
    perspective: 1000px;
}

.memory-card {
    width: 80px;
    height: 80px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    cursor: pointer;
}

.memory-card.flipped {
    transform: rotateY(180deg);
}

.memory-card.matched {
    transform: rotateY(180deg);
    opacity: 0.5;
    cursor: default;
    box-shadow: 0 0 10px var(--vert);
    border-radius: 5px;
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    border: 2px solid var(--or);
    border-radius: 8px;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}

.card-back {
    background: linear-gradient(135deg, var(--bleu-nuit), #34495E);
    color: var(--ocre);
    font-size: 24px;
}

.card-front {
    background: #F5F0E1;
    color: var(--noir);
    transform: rotateY(180deg);
}

/* --- Puzzle Styles --- */
.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    background: var(--or);
    border: 4px solid var(--or);
    margin: 20px auto;
    width: 306px;
    /* 3 * 100 + 2*2 gap + border? Adjusted for 100px pieces */
}

/* Sphinx 4x4 override */
.puzzle-grid-4x4 {
    grid-template-columns: repeat(4, 1fr);
    width: 326px;
    /* 4 * 80 + 3*2 */
}

.puzzle-piece {
    width: 100px;
    height: 100px;
    cursor: grab;
    position: relative;
    background: #000;
}

.puzzle-grid-4x4 .puzzle-piece {
    width: 80px;
    height: 80px;
}

.puzzle-piece:active {
    cursor: grabbing;
}

.puzzle-piece.dragging {
    opacity: 0.5;
}

.puzzle-piece.correct {
    filter: brightness(1.2);
    z-index: 1;
}

.puzzle-wrapper {
    display: flex;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.puzzle-preview {
    border: 2px solid var(--ocre);
    background: #000;
    padding: 5px;
}

/* --- Simon Styles --- */
.simon-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 30px auto;
    max-width: 400px;
}

.simon-btn {
    width: 120px;
    height: 120px;
    border-radius: 15px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    font-size: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.1s;
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 8px 0 rgba(0, 0, 0, 0.3);
}

.simon-btn:active {
    transform: translateY(4px);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}

.simon-btn.active {
    transform: scale(1.05);
    filter: brightness(1.5);
    box-shadow: 0 0 30px currentColor;
    border-color: #FFF;
}

.btn-ra {
    background-color: #C0392B;
    color: #C0392B;
}

.btn-anubis {
    background-color: #2C3E50;
    color: #2C3E50;
}

.btn-isis {
    background-color: #1ABC9C;
    color: #1ABC9C;
}

.btn-bastet {
    background-color: #8E44AD;
    color: #8E44AD;
}

.simon-info {
    font-size: 14px;
    color: var(--sable);
    text-align: center;
    margin-top: 15px;
    min-height: 20px;
}

/* --- Math Styles --- */
.math-problem {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    margin: 30px 0;
    width: 100%;
}

.math-problem .question {
    font-size: 24px;
    color: var(--or);
    text-align: center;
    line-height: 1.5;
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--ocre);
    width: 80%;
}

.math-input-group {
    display: flex;
    gap: 15px;
    align-items: center;
}

.math-input {
    background: rgba(10, 25, 49, 0.9);
    border: 3px solid var(--or);
    color: var(--blanc);
    font-family: var(--font-pixel);
    font-size: 24px;
    padding: 10px;
    width: 150px;
    text-align: center;
    outline: none;
}

.math-input:focus {
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.math-score {
    font-size: 12px;
    color: var(--turquoise);
    margin-top: 20px;
}

/* --- General Minigame Utils --- */
.minigame-stats {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-bottom: 15px;
    font-size: 12px;
    color: var(--ocre);
}

.minigame-help {
    font-size: 10px;
    color: var(--sable);
    opacity: 0.8;
    margin-top: 15px;
    text-align: center;
    max-width: 600px;
    line-height: 1.6;
}

/* --- Fonds d'écran des niveaux --- */
.level-bg {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

.level-temple {
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45)),
        url('../assets/background_temple.png');
}

.level-pyramide {
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45)),
        url('../assets/background_pyramid.png');
}

.level-palais {
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45)),
        url('../assets/background_palace.png');
}

.level-spawn {
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45)),
        url('../assets/background_spawn.png');
}

/* Niveaux sans image dédiée : réutilisation des images existantes */
.level-sanctuaire {
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
        url('../assets/background_temple.png');
}

.level-tombeau {
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.55)),
        url('../assets/background_pyramid.png');
}