@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

:root {
    --primary-color: #1e1f26;
    --secondary-color: #ff0000;
    --accent-color: #ff5722;
    --dark-color: #455a64;
    --light-color: #ffffff;
    --text-color: #263238;
    --card-bg: #f5f5f5;
}

/* Loading Screen Styles */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeOut 1.5s ease-out 4s forwards;
    opacity: 1;
    overflow: hidden;
}

.loading-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    pointer-events: none;
    z-index: 0;
}

.loading-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    opacity: 0;
}

.loading-container {
    text-align: center;
    color: #ffffff;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1;
    padding: 2rem;
}

/* Desktop improvements for loading screen */
@media (min-width: 1024px) {
    .loading-container {
        padding: 4rem;
        max-width: 1200px;
        margin: 0 auto;
    }
    
    .loading-logo {
        margin-bottom: 6rem;
        transform: translateY(-8vh);
    }
    
    .loading-title {
        font-size: 5rem;
        margin-bottom: 3rem;
        letter-spacing: 0.4em;
        text-shadow: 
            0 0 30px rgba(255, 255, 255, 0.9),
            0 0 60px rgba(255, 255, 255, 0.7),
            0 0 90px rgba(255, 255, 255, 0.5),
            0 0 120px rgba(255, 255, 255, 0.3),
            0 0 150px rgba(255, 255, 255, 0.1);
    }
    
    .loading-subtitle {
        font-size: 1.5rem;
        margin-bottom: 5rem;
        letter-spacing: 0.6em;
        text-shadow: 0 0 25px rgba(255, 255, 255, 0.5);
    }
    
    .loading-animation {
        width: 600px;
        height: 600px;
        max-width: 600px;
        max-height: 600px;
        margin: 0 auto 5rem;
    }
    
    .fragment {
        width: 40px;
        height: 40px;
        box-shadow: 
            0 0 35px rgba(255, 255, 255, 0.9),
            0 0 70px rgba(255, 255, 255, 0.6),
            0 0 105px rgba(255, 255, 255, 0.3),
            inset 0 0 20px rgba(255, 255, 255, 0.4);
    }
    
    .loading-bar-container {
        width: 700px;
        margin: 0 auto 4rem;
    }
    
    .loading-bar {
        height: 16px;
        border: 3px solid rgba(255, 255, 255, 0.5);
        box-shadow: 
            0 0 40px rgba(255, 255, 255, 0.4),
            inset 0 0 20px rgba(0, 0, 0, 0.4);
    }
    
    .loading-progress {
        box-shadow: 
            0 0 40px rgba(255, 255, 255, 0.9),
            0 0 80px rgba(255, 255, 255, 0.6),
            0 0 120px rgba(255, 255, 255, 0.4);
    }
    
    .loading-text {
        margin-top: 3rem;
        font-size: 1.6rem;
        text-shadow: 
            0 0 20px rgba(255, 255, 255, 0.7),
            0 0 40px rgba(255, 255, 255, 0.4);
    }
    
    .loading-particles {
        background-image: 
            radial-gradient(6px 6px at 10% 20%, rgba(255, 255, 255, 0.5), transparent),
            radial-gradient(4px 4px at 80% 30%, rgba(255, 255, 255, 0.4), transparent),
            radial-gradient(3px 3px at 40% 80%, rgba(255, 255, 255, 0.6), transparent),
            radial-gradient(5px 5px at 90% 70%, rgba(255, 255, 255, 0.4), transparent),
            radial-gradient(6px 6px at 20% 90%, rgba(255, 255, 255, 0.5), transparent),
            radial-gradient(3px 3px at 60% 10%, rgba(255, 255, 255, 0.5), transparent),
            radial-gradient(4px 4px at 30% 50%, rgba(255, 255, 255, 0.3), transparent),
            radial-gradient(2px 2px at 70% 60%, rgba(255, 255, 255, 0.4), transparent);
        background-size: 500px 400px, 400px 300px, 600px 500px, 350px 250px, 450px 350px, 300px 200px, 550px 450px, 250px 150px;
        opacity: 0.9;
    }
    
    .loading-animation::before {
        width: 85%;
        height: 85%;
        border: 4px solid rgba(255, 255, 255, 0.4);
        border-top: 4px solid rgba(255, 255, 255, 0.9);
        border-right: 4px solid rgba(255, 255, 255, 0.7);
        box-shadow: 0 0 50px rgba(255, 255, 255, 0.4);
    }
    
    .loading-animation::after {
        width: 65%;
        height: 65%;
        border: 3px solid rgba(255, 255, 255, 0.3);
        border-bottom: 3px solid rgba(255, 255, 255, 0.8);
        border-left: 3px solid rgba(255, 255, 255, 0.6);
        box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.3);
    }
}

/* Ultra-wide and large desktop improvements */
@media (min-width: 1440px) {
    .loading-container {
        padding: 6rem;
        max-width: 1400px;
    }
    
    .loading-title {
        font-size: 6rem;
        margin-bottom: 4rem;
        letter-spacing: 0.5em;
        text-shadow: 
            0 0 40px rgba(255, 255, 255, 0.9),
            0 0 80px rgba(255, 255, 255, 0.7),
            0 0 120px rgba(255, 255, 255, 0.5),
            0 0 160px rgba(255, 255, 255, 0.3),
            0 0 200px rgba(255, 255, 255, 0.1);
    }
    
    .loading-subtitle {
        font-size: 1.8rem;
        margin-bottom: 6rem;
        letter-spacing: 0.8em;
    }
    
    .loading-animation {
        width: 700px;
        height: 700px;
        max-width: 700px;
        max-height: 700px;
        margin: 0 auto 6rem;
    }
    
    .fragment {
        width: 45px;
        height: 45px;
        box-shadow: 
            0 0 45px rgba(255, 255, 255, 0.9),
            0 0 90px rgba(255, 255, 255, 0.6),
            0 0 135px rgba(255, 255, 255, 0.3),
            inset 0 0 25px rgba(255, 255, 255, 0.5);
    }
    
    .loading-bar-container {
        width: 800px;
        margin: 0 auto 5rem;
    }
    
    .loading-bar {
        height: 20px;
        border: 4px solid rgba(255, 255, 255, 0.6);
    }
    
    .loading-text {
        font-size: 2rem;
        margin-top: 4rem;
    }
}

.loading-logo {
    margin-bottom: 1rem;
    margin-top: 8vh;
    animation: glowPulse 3s ease-in-out infinite alternate;
    transform: none;
}

.loading-title {
    font-size: clamp(2rem, 6vw, 4rem);
    margin-bottom: 2rem;
    text-shadow: 
        0 0 20px rgba(255, 255, 255, 0.9),
        0 0 40px rgba(255, 255, 255, 0.7),
        0 0 60px rgba(255, 255, 255, 0.5),
        0 0 80px rgba(255, 255, 255, 0.3),
        0 0 100px rgba(255, 255, 255, 0.1);
    letter-spacing: 0.3em;
    font-weight: bold;
    background: linear-gradient(45deg, #ffffff, #e8e8e8, #ffffff, #f5f5f5);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textShine 3s ease-in-out infinite;
    position: relative;
}

.loading-title::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
    border-radius: 10px;
    animation: titleBorder 4s ease-in-out infinite;
    z-index: -1;
}

.loading-subtitle {
    font-size: clamp(0.8rem, 2vw, 1.2rem);
    color: #c0c0c0;
    letter-spacing: 0.5em;
    text-transform: uppercase;
    margin-bottom: 4rem;
    opacity: 0.9;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
    animation: subtitleGlow 2s ease-in-out infinite alternate;
}

.loading-animation {
    position: relative;
    width: 200px;
    height: 200px;
    margin: -2rem auto 0rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-animation::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: 2px solid transparent;
    border-radius: 50%;
    border-top: 2px solid rgba(255, 255, 255, 0.8);
    transform: translate(-50%, -50%);
    animation: rotate 2s linear infinite;
}

.loading-animation::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70%;
    height: 70%;
    border: 1px solid transparent;
    border-radius: 50%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
    transform: translate(-50%, -50%);
    animation: rotate 3s linear infinite reverse;
}

.fragment {
    position: absolute;
    width: clamp(12px, 3vw, 20px);
    height: clamp(12px, 3vw, 20px);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    animation: fragmentOrbit 8s linear infinite;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
}

.fragment::before {
    display: none;
}

.fragment::after {
    display: none;
}

.fragment-1 { animation-delay: 0s; }
.fragment-2 { animation-delay: 0.4s; }
.fragment-3 { animation-delay: 0.8s; }
.fragment-4 { animation-delay: 1.2s; }
.fragment-5 { animation-delay: 1.6s; }
.fragment-6 { animation-delay: 2s; }
.fragment-7 { animation-delay: 2.4s; }
.fragment-8 { animation-delay: 2.8s; }
.fragment-9 { animation-delay: 3.2s; }
.fragment-10 { animation-delay: 3.6s; }
.fragment-11 { animation-delay: 4s; }
.fragment-12 { animation-delay: 4.4s; }

.loading-bar-container {
    position: relative;
    width: min(80vw, 600px);
    margin: 3rem auto 2rem;
}

.loading-bar {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.4);
    box-shadow: 
        0 0 30px rgba(255, 255, 255, 0.3),
        inset 0 0 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #ffffff 0%, #e8e8e8 25%, #ffffff 50%, #f5f5f5 75%, #ffffff 100%);
    background-size: 400% 100%;
    animation: progressFill 3s ease-out forwards, progressShine 2s linear infinite;
    border-radius: 6px;
    box-shadow: 
        0 0 30px rgba(255, 255, 255, 0.9),
        0 0 60px rgba(255, 255, 255, 0.5),
        0 0 90px rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.loading-progress::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    animation: progressGlow 2.5s ease-in-out infinite;
    border-radius: 6px;
}

.loading-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 40%, rgba(255, 255, 255, 0.3) 50%, transparent 60%);
    animation: progressReflection 3s ease-in-out infinite;
    border-radius: 6px;
}

.loading-text {
    margin-top: 2rem;
    font-size: clamp(0.9rem, 2.5vw, 1.3rem);
    color: #e0e0e0;
    letter-spacing: 0.2em;
    animation: textBlink 2s ease-in-out infinite alternate;
    text-shadow: 
        0 0 15px rgba(255, 255, 255, 0.6),
        0 0 30px rgba(255, 255, 255, 0.3);
    font-weight: 500;
    text-transform: uppercase;
}

.loading-particles {
    display: none;
}

.main-content {
    opacity: 0;
    animation: fadeIn 1.5s ease-out 5s forwards;
}

/* Animations */
@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

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

@keyframes backgroundShift {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 100% 50%;
    }
}

@keyframes starsMove {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    100% {
        transform: translateY(-100vh) rotate(360deg);
    }
}

@keyframes glowPulse {
    0% {
        text-shadow: 
            0 0 20px rgba(255, 255, 255, 0.9),
            0 0 40px rgba(255, 255, 255, 0.7),
            0 0 60px rgba(255, 255, 255, 0.5),
            0 0 80px rgba(255, 255, 255, 0.3);
        transform: translateY(-10vh) scale(1);
    }
    100% {
        text-shadow: 
            0 0 30px rgba(255, 255, 255, 1),
            0 0 60px rgba(255, 255, 255, 0.9),
            0 0 90px rgba(255, 255, 255, 0.7),
            0 0 120px rgba(255, 255, 255, 0.5);
        transform: translateY(-10vh) scale(1.05);
    }
}

@keyframes textShine {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes titleBorder {
    0%, 100% {
        opacity: 0;
        transform: scale(0.95);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

@keyframes subtitleGlow {
    0% {
        text-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
        opacity: 0.8;
    }
    100% {
        text-shadow: 0 0 25px rgba(255, 255, 255, 0.6);
        opacity: 1;
    }
}

@keyframes fragmentOrbit {
    0% {
        transform: rotate(0deg) translateX(min(35vh, 35vw, 200px)) rotate(0deg);
    }
    100% {
        transform: rotate(360deg) translateX(min(35vh, 35vw, 200px)) rotate(-360deg);
    }
}

@keyframes innerGlow {
    0% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.3);
    }
}

@keyframes auraGlow {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

@keyframes rotate {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes progressFill {
    0% {
        width: 0%;
    }
    100% {
        width: 100%;
    }
}

@keyframes progressShine {
    0% {
        background-position: -400% 0;
    }
    100% {
        background-position: 400% 0;
    }
}

@keyframes progressGlow {
    0%, 100% {
        transform: translateX(-100%);
        opacity: 0;
    }
    50% {
        transform: translateX(100%);
        opacity: 1;
    }
}

@keyframes progressReflection {
    0%, 100% {
        transform: translateX(-200%);
        opacity: 0;
    }
    50% {
        transform: translateX(200%);
        opacity: 0.8;
    }
}

@keyframes textBlink {
    0% {
        opacity: 0.7;
        transform: translateY(0);
    }
    100% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

@keyframes particleFloat {
    0%, 100% {
        transform: translateY(0px) translateX(0px);
        opacity: 0.8;
    }
    33% {
        transform: translateY(-40px) translateX(20px);
        opacity: 1;
    }
    66% {
        transform: translateY(-20px) translateX(-15px);
        opacity: 0.9;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .loading-container {
        padding: 1rem;
    }
    
    .loading-logo {
        margin-bottom: 3rem;
        transform: translateY(-5vh);
    }
    
    .loading-title {
        font-size: clamp(1.5rem, 8vw, 2.5rem);
        margin-bottom: 1rem;
        letter-spacing: 0.2em;
    }
    
    .loading-subtitle {
        font-size: clamp(0.7rem, 3vw, 1rem);
        letter-spacing: 0.3em;
        margin-bottom: 2rem;
    }
    
    .loading-animation {
        width: min(60vh, 80vw);
        height: min(60vh, 80vw);
        margin-bottom: 2rem;
    }
    
    .loading-bar-container {
        width: 90vw;
        margin-bottom: 2rem;
    }
    
    .loading-bar {
        height: 10px;
    }
    
    .fragment {
        width: clamp(15px, 5vw, 25px);
        height: clamp(15px, 5vw, 25px);
    }
    
    .loading-text {
        font-size: clamp(0.8rem, 3vw, 1.1rem);
        margin-top: 1rem;
        letter-spacing: 0.1em;
    }
    
    @keyframes fragmentOrbit {
        0% {
            transform: rotate(0deg) translateX(min(25vh, 30vw, 120px)) rotate(0deg);
        }
        100% {
            transform: rotate(360deg) translateX(min(25vh, 30vw, 120px)) rotate(-360deg);
        }
    }
    
    .loading-animation::before {
        width: 70%;
        height: 70%;
        border-width: 2px;
    }
    
    .loading-animation::after {
        width: 50%;
        height: 50%;
        border-width: 1px;
    }
}

@media (max-width: 480px) {
    .loading-logo {
        transform: translateY(-3vh);
    }
    
    .loading-title {
        font-size: clamp(1.2rem, 6vw, 2rem);
        letter-spacing: 0.15em;
    }
    
    .loading-subtitle {
        font-size: clamp(0.6rem, 2.5vw, 0.9rem);
        letter-spacing: 0.2em;
    }
    
    .loading-animation {
        width: min(50vh, 70vw);
        height: min(50vh, 70vw);
    }
    
    .fragment {
        width: clamp(12px, 4vw, 20px);
        height: clamp(12px, 4vw, 20px);
    }
    
    @keyframes fragmentOrbit {
        0% {
            transform: rotate(0deg) translateX(min(20vh, 25vw, 100px)) rotate(0deg);
        }
        100% {
            transform: rotate(360deg) translateX(min(20vh, 25vw, 100px)) rotate(-360deg);
        }
    }
}

@media (orientation: landscape) and (max-height: 600px) {
    .loading-container {
        padding: 1rem;
    }
    
    .loading-logo {
        margin-bottom: 2rem;
        transform: translateY(-2vh);
    }
    
    .loading-title {
        font-size: clamp(1.5rem, 5vh, 2.5rem);
        margin-bottom: 1rem;
    }
    
    .loading-subtitle {
        font-size: clamp(0.7rem, 2vh, 1rem);
        margin-bottom: 1.5rem;
    }
    
    .loading-animation {
        width: min(40vh, 40vw);
        height: min(40vh, 40vw);
        margin-bottom: 1.5rem;
    }
    
    .loading-bar-container {
        margin-bottom: 1rem;
    }
    
    .loading-text {
        font-size: clamp(0.8rem, 2vh, 1rem);
        margin-top: 0.5rem;
    }
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Press Start 2P", cursive;
    background-color: var(--light-color);
    color: var(--text-color);
    padding: 2rem;
    line-height: 1.6;
    font-display: swap;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* Responsive body styles */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0.5rem;
    }
    
    .lore-container {
        border: none;
        padding: 1rem;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        background-color: var(--light-color);
    }
}

/* Styles pour PC - optimisation du loading */
@media (min-width: 769px) {
    .loading-logo {
        margin-bottom: 0rem;
        margin-top: 10vh;
        transform: none;
    }
    
    .loading-animation {
        margin: -3rem auto 0rem;
    }
    
    .loading-bar-container {
        margin: 4rem auto 1rem;
    }
}

/* Effet de reflet simple et efficace */
.card {
    contain: layout style paint;
    transform: translateZ(0);
    backface-visibility: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Effet de surbrillance au hover sur les cartes - plus visible */
.card:hover {
    transform: translateY(-8px);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.3), 
        0 0 25px rgba(255, 255, 255, 0.3),
        0 0 50px rgba(255, 255, 255, 0.1);
}

.card-img {
    will-change: background-position;
    transform: translateZ(0);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    position: relative;
    overflow: hidden;
}

/* Effet holographique 45° naturel sur card-img */
.card-img::before {
    content: '';
    position: absolute;
    top: -100%;
    left: -100%;
    width: 300%;
    height: 300%;
    background: linear-gradient(
        45deg,
        transparent 0%,
        rgba(255, 255, 255, 0.1) 30%,
        rgba(255, 255, 255, 0.4) 50%,
        rgba(255, 255, 255, 0.1) 70%,
        transparent 100%
    );
    transform: translate(-100%, -100%) rotate(45deg);
    transition: transform 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
    z-index: 100;
    opacity: 0;
}

.card:hover .card-img::before {
    transform: translate(100%, 100%) rotate(45deg);
    opacity: 1;
}

/* Effet de reflet automatique pour mobile lors du scroll */
@media (max-width: 768px) {
    .card.scroll-shine .card-img::before {
        transform: translate(100%, 100%) rotate(45deg);
        opacity: 1;
        transition: transform 0.8s ease-out, opacity 0.8s ease-out;
    }
    
    .card.scroll-shine {
        transform: translateY(-5px);
        box-shadow: 
            0 15px 35px rgba(0, 0, 0, 0.2), 
            0 0 20px rgba(255, 255, 255, 0.2);
        transition: transform 0.8s ease-out, box-shadow 0.8s ease-out;
    }
}

.popup-overlay {
    contain: layout style paint;
    transform: translateZ(0);
    will-change: opacity, visibility;
}

.popup-img {
    will-change: background-position;
    transform: translateZ(0);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.avatar, .popup-avatar-static, .popup-avatar-alt object {
    contain: layout style paint;
    transform: translateZ(0);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    transition: all 0.3s ease;
}

/* Effets sur les avatars au hover */
.card:hover .avatar {
    transform: scale(1.1) rotate(2deg);
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3));
}

/* Optimisation pour les animations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Optimisations de rendu pour les éléments critiques */
.cards-container {
    contain: layout;
    transform: translateZ(0);
}

.card-content {
    contain: layout style;
}

.card-footer {
    contain: layout style;
}

/* Optimisation des scrolling */
.popup-details {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Optimisation des transitions */
.card, .popup-overlay, .popup-content {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Nouveau styles pour la page univers */
.hero-section {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: white;
    padding: 4rem 2rem;
    border-radius: 20px;
    margin-bottom: 3rem;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.1) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(255,255,255,0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,215,0,0.2);
    position: relative;
    z-index: 1;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 10px rgba(255,215,0,0.3);
}

.stat-label {
    font-size: 0.7rem;
    opacity: 0.8;
}

.territories-section {
    margin-bottom: 4rem;
}

.territories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.territory-card {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.territory-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
}

.territory-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.territory-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
}

.territory-name {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.territory-desc {
    font-size: 0.7rem;
    line-height: 1.4;
    color: #666;
    margin-bottom: 1.5rem;
}

.territory-tag {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.6rem;
    font-weight: bold;
    text-transform: uppercase;
    position: absolute;
    bottom: 1rem;
    right: 1rem;
}

.territory-tag.glacial { background: linear-gradient(45deg, #87CEEB, #B0E0E6); color: #1e3a8a; }
.territory-tag.mystique { background: linear-gradient(45deg, #98fb98, #90EE90); color: #166534; }
.territory-tag.antique { background: linear-gradient(45deg, #daa520, #ffd700); color: #92400e; }
.territory-tag.spectral { background: linear-gradient(45deg, #9370db, #dda0dd); color: #581c87; }
.territory-tag.noble { background: linear-gradient(45deg, #ff69b4, #ffc0cb); color: #be185d; }
.territory-tag.sauvage { background: linear-gradient(45deg, #8fbc8f, #228b22); color: #14532d; }
.territory-tag.post-apocalyptique { background: linear-gradient(45deg, #ff6347, #ff4500); color: #7f1d1d; }
.territory-tag.guerrier { background: linear-gradient(45deg, #dc143c, #b22222); color: #7f1d1d; }
.territory-tag.technologique { background: linear-gradient(45deg, #00bfff, #87cefa); color: #1e3a8a; }
.territory-tag.aquatique { background: linear-gradient(45deg, #20b2aa, #48d1cc); color: #0c4a6e; }
.territory-tag.élevé { background: linear-gradient(45deg, #696969, #a9a9a9); color: #1f2937; }
.territory-tag.aride { background: linear-gradient(45deg, #daa520, #f4a460); color: #92400e; }

.prophecy-section {
    margin: 4rem 0;
}

.prophecy-card {
    background: linear-gradient(135deg, #2c1810 0%, #4a2c2a 50%, #1a1a2e 100%);
    color: white;
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,215,0,0.2);
}

.prophecy-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,215,0,0.1) 0%, transparent 70%);
    animation: prophetic-glow 3s ease-in-out infinite;
}

@keyframes prophetic-glow {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(180deg); }
}

.prophecy-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: float 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.prophecy-quote {
    font-size: 1.2rem;
    font-style: italic;
    margin: 2rem 0;
    padding: 1rem 2rem;
    border-left: 4px solid #ffd700;
    background: rgba(255,215,0,0.1);
    position: relative;
    z-index: 1;
}

.prophecy-text {
    font-size: 0.8rem;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.timeline-section {
    margin: 4rem 0;
}

.timeline-horizontal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2rem;
    overflow-x: auto;
    padding: 2rem 0;
}

.timeline-item {
    flex: 0 0 auto;
    text-align: center;
    padding: 1.5rem;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    min-width: 150px;
    transition: transform 0.3s ease;
    position: relative;
}

.timeline-item:hover {
    transform: translateY(-5px);
}

.timeline-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.1);
}

.timeline-item.active::before {
    content: '★';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    color: #ffeb3b;
}

.timeline-year {
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #667eea;
}

.timeline-item.active .timeline-year {
    color: #ffeb3b;
}

.timeline-event {
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.timeline-desc {
    font-size: 0.6rem;
    opacity: 0.7;
}

.timeline-connector {
    flex: 1;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    margin: 0 1rem;
    border-radius: 2px;
    position: relative;
}

.timeline-connector::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid #764ba2;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
}

/* Responsive design pour les nouveaux éléments */
@media (max-width: 768px) {
    .hero-section {
        padding: 2rem 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
    
    .territories-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .territory-card {
        padding: 1.5rem;
    }
    
    .prophecy-card {
        padding: 2rem 1rem;
    }
    
    .timeline-horizontal {
        flex-direction: column;
        gap: 1rem;
    }
    
    .timeline-connector {
        width: 3px;
        height: 30px;
        margin: 0;
    }
    
    .timeline-connector::after {
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        border-top: 8px solid #764ba2;
        border-bottom: none;
    }
}

/* Styles pour la fonctionnalité de territoire sélectionné */
.selected-territory-section {
    margin: 4rem 0;
}

.selected-territory-display {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #ccc;
    border-radius: 15px;
    padding: 2rem;
    background: #f9f9f9;
    transition: all 0.3s ease;
}

.territory-instruction {
    color: #666;
    font-size: 0.8rem;
    text-align: center;
    font-style: italic;
}

.selected-territory-card {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    border: 3px solid #667eea;
    position: relative;
    overflow: hidden;
}

.selected-territory-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.selected-territory-card .territory-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.selected-territory-card .territory-name {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    text-transform: uppercase;
}

.selected-territory-card .territory-desc {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #333;
    margin-bottom: 2rem;
}

.selected-territory-card .territory-tag {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    position: static;
    margin-bottom: 1rem;
}

/* Styles pour les marqueurs de région */
.region-marker {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 10;
}

.region-marker:hover {
    transform: scale(1.3);
    background: #764ba2;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.region-marker.active {
    background: #ff6b6b;
    transform: scale(1.2);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 107, 107, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0);
    }
}

.region-marker::after {
    content: attr(title);
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.region-marker:hover::after {
    opacity: 1;
}

/* Responsive pour les nouveaux éléments */
@media (max-width: 768px) {
    .selected-territory-display {
        min-height: 150px;
        padding: 1rem;
    }
    
    .selected-territory-card {
        padding: 1.5rem;
    }
    
    .selected-territory-card .territory-icon {
        font-size: 3rem;
    }
    
    .selected-territory-card .territory-name {
        font-size: 1.2rem;
    }
    
    .region-marker {
        width: 16px;
        height: 16px;
    }
}

/* Styles existants continuent... */

/* Optimisation mémoire pour les éléments cachés */
.avatar-alt, .popup-avatar-alt {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.1s ease;
}

.card:hover .avatar-alt, .popup-overlay.active .popup-avatar-alt {
    visibility: visible;
    opacity: 1;
}

/* Optimisation des fonts */
/* Press Start 2P font optimization is handled by Google Fonts import */

/* Optimisation du rendu des textes */
.card-title, .popup-title {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Optimisation des images SVG */
object[type="image/svg+xml"] {
    pointer-events: none;
    user-select: none;
}

/* Header & Navigation */
header {
    margin-bottom: 7rem;
    padding: 1rem;
    border-bottom: 4px solid var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    position: relative;
}

.header-logo {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

#header-logo {
    width: 100%;
    height: 100%;
    transition: filter 0.3s ease;
}

h1 {
    font-size: 2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--primary-color);
    animation: pulse 2s infinite;
    margin: 0;
    text-align: center;
    position: relative;
    z-index: 2;
}

.main-nav {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 1rem 0 0 0;
    padding: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    padding: 0.8rem 2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.nav-link {
    font-family: "Press Start 2P", cursive;
    text-decoration: none;
    color: var(--primary-color);
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.nav-link:hover {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
    transform: translateY(-2px);
}

.nav-link.active {
    border-color: var(--primary-color);
    background-color: rgba(0, 0, 0, 0.05);
}

/* Card Layout (index.html) */
.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    contain: layout;
    transform: translateZ(0);
}

.card {
    background-color: var(--card-bg);
    border: 4px solid var(--primary-color);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
    contain: layout style paint;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.card:hover {
    transform: translateY(-10px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    border-color: var(--secondary-color);
}

/* Card Images & Animation */
.card-img {
    width: 100%;
    height: 180px;
    background-position: 0 0;
    background-repeat: repeat-x;
    image-rendering: pixelated;
    border-bottom: 4px solid var(--primary-color);
    position: relative;
    overflow: hidden;
    background-size: cover;
}

.card:hover .card-img {
    border-color: var(--secondary-color);
    animation: scrollBackground 15s linear infinite;
    transform: perspective(1000px) translateZ(10px);
    transition: transform 0.3s ease;
}

/* Card Content */
.card-content {
    padding: 1rem;
}

.card-title {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    transition: all 0.3s ease;
    position: relative;
}

/* Effets sur le titre au hover */
.card:hover .card-title {
    transform: translateY(-2px);
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.card-title::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    transition: width 0.3s ease;
}

.card:hover .card-title::after {
    width: 100%;
}

/* Effets de titre spécifiques par territoire */
.card:has(.card-year.artique) .card-title::after {
    background: linear-gradient(90deg, #0066cc, #00aaff);
}

.card:has(.card-year.foret) .card-title::after {
    background: linear-gradient(90deg, #2e8b57, #32cd32);
}

.card:has(.card-year.temples) .card-title::after {
    background: linear-gradient(90deg, #b8860b, #ffd700);
}

.card:has(.card-year.manoir) .card-title::after {
    background: linear-gradient(90deg, #800080, #da70d6);
}

.card:has(.card-year.citadelle) .card-title::after {
    background: linear-gradient(90deg, #4b0082, #9370db);
}

.card:has(.card-year.taiga) .card-title::after {
    background: linear-gradient(90deg, #006400, #228b22);
}

.card:has(.card-year.ruines) .card-title::after {
    background: linear-gradient(90deg, #8b4513, #cd853f);
}

.card:has(.card-year.bataille) .card-title::after {
    background: linear-gradient(90deg, #8b0000, #dc143c);
}

.card:has(.card-year.metropole) .card-title::after {
    background: linear-gradient(90deg, #4682b4, #87ceeb);
}

.card:has(.card-year.abysses) .card-title::after {
    background: linear-gradient(90deg, #00008b, #0000ff);
}

.card:has(.card-year.montagnes) .card-title::after {
    background: linear-gradient(90deg, #696969, #a9a9a9);
}

.card:has(.card-year.desert) .card-title::after {
    background: linear-gradient(90deg, #cd853f, #f4a460);
}

.card-text {
    font-size: 0.6rem;
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: rgba(0, 0, 0, 0.05);
    font-size: 0.6rem;
}

.card-year {
    color: var(--accent-color);
}

.card-footer .card-year:contains("Artique") {
    color: #0066cc;
    /* Bleu froid */
}

/* Couleurs des card-year selon les régions */
.card-year.artique {
    color: #0066cc;
}

.card-year.foret {
    color: #2e8b57;
}

.card-year.temples {
    color: #b8860b;
}

.card-year.manoir {
    color: #800080;
}

.card-year.citadelle {
    color: #4b0082;
}

.card-year.taiga {
    color: #006400;
}

.card-year.ruines {
    color: #8b4513;
}

.card-year.bataille {
    color: #8b0000;
}

.card-year.metropole {
    color: #4682b4;
}

.card-year.abysses {
    color: #00008b;
}

.card-year.montagnes {
    color: #696969;
}

.card-year.desert {
    color: #cd853f;
}

.card-platform {
    color: var(--secondary-color);
}

/* Card Corner Details */
.card::before {
    content: "";
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: var(--light-color);
    top: 0;
    left: 0;
    z-index: 1;
}

.card::after {
    content: "";
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: var(--light-color);
    top: 0;
    right: 0;
    z-index: 1;
}

/* Pixel Effect Overlay */
.card-img::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='2' height='2' viewBox='0 0 2 2' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M1 0H0v1h1V0zm0 1H2v1H1V1z' fill='black' fill-opacity='0.05'/%3E%3C/svg%3E");
    background-size: 4px 4px;
    pointer-events: none;
    opacity: 0.3;
}

/* Avatar Styles */
.avatar {
    position: absolute;
    top: -5%;
    left: -5%;
    width: 110%;
    height: 110%;
    object-fit: contain;
    /* Note: loading and decoding are HTML attributes, not CSS properties */
}

.avatar-static {
    position: absolute;
    top: -5%;
    left: -5%;
    width: 110%;
    height: 110%;
    object-fit: contain;
}

.avatar-alt {
    display: none;
}

.card:hover .avatar-static {
    display: none;
}

.card:hover .avatar-alt {
    display: block;
}

.card:hover .avatar-frame1 {
    animation: toggle 1s step-end infinite;
}

.card:hover .avatar-frame2 {
    animation: toggle 1s step-end infinite reverse;
}

/* Popup Styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

.popup-content {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    background-color: var(--card-bg);
    border: 4px solid var(--primary-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.popup-img-container {
    width: 100%;
    height: 600px;
    position: relative;
    overflow: hidden;
    border-bottom: 4px solid var(--primary-color);
}

.popup-img {
    width: 100%;
    height: 100%;
    background-repeat: repeat-x;
    image-rendering: pixelated;
    background-size: auto 100%;
    position: relative;
}

.popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-family: "Press Start 2P", cursive;
    font-size: 16px;
    line-height: 32px;
    text-align: center;
    border-radius: 4px;
    z-index: 1001;
}

.popup-close:hover {
    background-color: var(--secondary-color);
}

.popup-details {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 300px;
}

.popup-title {
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
    color: var(--primary-color);
}

.popup-text {
    font-size: 0.8rem;
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.popup-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: rgba(0, 0, 0, 0.05);
}

.popup-year {
    color: var(--accent-color);
    font-size: 0.8rem;
}

.popup-platform {
    color: var(--secondary-color);
    font-size: 0.8rem;
}

/* Popup Avatar */
.popup-avatar-static,
.popup-avatar-alt object {
    position: absolute;
    top: -5%;
    left: -5%;
    width: 110%;
    height: 110%;
    object-fit: contain;
}

.popup-avatar-alt {
    display: none;
    position: absolute;
    top: -5%;
    left: -5%;
    width: 110%;
    height: 110%;
}

.popup-overlay.active .popup-avatar-static {
    display: none;
}

.popup-overlay.active .popup-avatar-alt {
    display: block;
}

.popup-overlay.active #popup-avatar1 {
    animation: toggle 1s step-end infinite;
}

.popup-overlay.active #popup-avatar2 {
    animation: toggle 1s step-end infinite reverse;
}

/* Skills Styles */
.popup-skills {
    margin-top: 1.5rem;
    border-top: 2px dotted rgba(0, 0, 0, 0.1);
    padding-top: 1.5rem;
}

.popup-skills-title {
    font-size: 0.8rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* Ajouter ces styles pour les popup-year */

/* Couleurs des popup-year selon les régions */
.popup-year.artique {
    color: #0066cc;
}

.popup-year.foret {
    color: #2e8b57;
}

.popup-year.temples {
    color: #b8860b;
}

.popup-year.manoir {
    color: #800080;
}

.popup-year.citadelle {
    color: #4b0082;
}

.popup-year.taiga {
    color: #006400;
}

.popup-year.ruines {
    color: #8b4513;
}

.popup-year.bataille {
    color: #8b0000;
}

.popup-year.metropole {
    color: #4682b4;
}

.popup-year.abysses {
    color: #00008b;
}

.popup-year.montagnes {
    color: #696969;
}

.popup-year.desert {
    color: #cd853f;
}

.skills-container {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.skill {
    flex: 1;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.5rem;
    border-radius: 4px;
    border-left: 4px solid var(--primary-color);
    font-size: 0.7rem;
}

.skill-name {
    color: var(--primary-color);
    font-weight: bold;
    margin-bottom: 0.2rem;
    display: block;
}

.skill-value {
    display: flex;
    margin-top: 0.3rem;
}

.skill-point {
    width: 8px;
    height: 8px;
    background-color: var(--accent-color);
    margin-right: 2px;
}

.skill-point.empty {
    background-color: rgba(0, 0, 0, 0.1);
}

.popup-description {
    margin-top: 1rem;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--dark-color);
}

/* Animation card delays */
.card:nth-child(1) {
    animation-delay: 0.1s;
}

.card:nth-child(2) {
    animation-delay: 0.2s;
}

.card:nth-child(3) {
    animation-delay: 0.3s;
}

.card:nth-child(4) {
    animation-delay: 0.4s;
}

.card:nth-child(5) {
    animation-delay: 0.5s;
}

.card:nth-child(6) {
    animation-delay: 0.6s;
}

.card:nth-child(7) {
    animation-delay: 0.7s;
}

.card:nth-child(8) {
    animation-delay: 0.8s;
}

.card:nth-child(9) {
    animation-delay: 0.9s;
}

.card:nth-child(10) {
    animation-delay: 1s;
}

.card:nth-child(11) {
    animation-delay: 1.1s;
}

.card:nth-child(12) {
    animation-delay: 1.2s;
}

/* Lore Container (univers.html) */
.lore-container {
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--card-bg);
    border: 4px solid var(--primary-color);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    animation: fadeInUp 0.6s ease-out;
}

/* Responsive styles for lore container */
@media (max-width: 768px) {
    .lore-container {
        border: 2px solid var(--primary-color);
        padding: 1.5rem;
        margin: 0 1rem;
        border-radius: 6px;
    }
}

@media (max-width: 480px) {
    .lore-container {
        border: none;
        padding: 1rem;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        background-color: var(--light-color);
    }
}

.section-title {
    color: var(--primary-color);
    font-size: 1.4rem;
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px dashed var(--accent-color);
}

/* Styles spécifiques pour les titres sur fond sombre */
.hero-section .section-title,
.prophecy-card .section-title {
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    border-bottom: 2px solid #ffd700;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: bold;
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

.hero-section .section-title::after,
.prophecy-card .section-title::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #ffd700, transparent);
    border-radius: 2px;
}

/* Styles pour les autres titres sur fond clair */
.selected-territory-section .section-title,
.timeline-section .section-title {
    color: #1a1a2e;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    border-bottom: 2px solid #667eea;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
    position: relative;
}

.selected-territory-section .section-title::after,
.timeline-section .section-title::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2, transparent);
    border-radius: 2px;
}

.section-title:first-child {
    margin-top: 0;
}

.lore-text {
    font-size: 0.7rem;
    margin-bottom: 1rem;
    color: var(--light-color);
    line-height: 1.8;
}

.map-container {
    margin: 2rem 0;
    text-align: center;
    position: relative
}

/* Remplacer les styles existants des marqueurs de région par ceux-ci */

.region-marker {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.9);
    border: 3px solid var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: pulse-marker-enhanced 2s infinite;
    z-index: 10;
    /* Assure que les marqueurs sont au-dessus de l'image */
    transform-origin: center;
}

.region-marker:hover {
    transform: scale(1.8);
    background-color: var(--secondary-color);
    border-color: white;
}

.region-marker::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background-color: var(--primary-color);
    border-radius: 50%;
}

@keyframes pulse-marker-enhanced {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.8);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 0 12px rgba(255, 0, 0, 0);
        transform: scale(1.1);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
        transform: scale(1);
    }
}

/* Ajouter ce style pour l'étiquette qui apparaît au survol */
.region-marker::after {
    content: attr(title);
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 4px;
    font-size: 9px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.region-marker:hover::after {
    opacity: 1;
}

.map-img {
    max-width: 100%;
    height: auto;
    border: 3px solid var(--accent-color);
    border-radius: 4px;
    image-rendering: pixelated;
}

.region {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--accent-color);
    border-radius: 4px;
}

.region-name {
    color: var(--accent-color);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* Timeline Styles */
.timeline {
    position: relative;
    margin: 2rem 0;
    padding-left: 20px;
}

.timeline::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 4px;
    background-color: var(--accent-color);
}

.timeline-event {
    margin-bottom: 1.5rem;
    position: relative;
}

.timeline-date {
    font-size: 0.8rem;
    color: var(--secondary-color);
    margin-bottom: 0.3rem;
}

.timeline-content {
    font-size: 0.7rem;
    padding-left: 1rem;
}

.timeline-event::before {
    content: "";
    position: absolute;
    left: -24px;
    top: 4px;
    width: 12px;
    height: 12px;
    background-color: var(--accent-color);
    border: 2px solid var(--card-bg);
    border-radius: 50%;
}

/* Region Colors */
.region-artique .region-name {
    color: #0066cc;
    /* Bleu froid */
}

.region-artique {
    border-left-color: #0066cc;
}

.region-foret .region-name {
    color: #2e8b57;
    /* Vert forêt */
}

.region-foret {
    border-left-color: #2e8b57;
}

.region-temples .region-name {
    color: #b8860b;
    /* Or foncé */
}

.region-temples {
    border-left-color: #b8860b;
}

.region-manoir .region-name {
    color: #800080;
    /* Violet */
}

.region-manoir {
    border-left-color: #800080;
}

.region-citadelle .region-name {
    color: #4b0082;
    /* Indigo */
}

.region-citadelle {
    border-left-color: #4b0082;
}

.region-taiga .region-name {
    color: #006400;
    /* Vert foncé */
}

.region-taiga {
    border-left-color: #006400;
}

.region-ruines .region-name {
    color: #8b4513;
    /* Brun terre */
}

.region-ruines {
    border-left-color: #8b4513;
}

.region-bataille .region-name {
    color: #8b0000;
    /* Rouge foncé */
}

.region-bataille {
    border-left-color: #8b0000;
}

.region-metropole .region-name {
    color: #4682b4;
    /* Bleu acier */
}

.region-metropole {
    border-left-color: #4682b4;
}

.region-abysses .region-name {
    color: #00008b;
    /* Bleu marine */
}

.region-abysses {
    border-left-color: #00008b;
}

.region-montagnes .region-name {
    color: #696969;
    /* Gris foncé */
}

.region-montagnes {
    border-left-color: #696969;
}

.region-desert .region-name {
    color: #cd853f;
    /* Ocre */
}

.region-desert {
    border-left-color: #cd853f;
}

/* Media Queries */
@media (max-width: 768px) {
    .cards-container {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    /* Header and navigation responsive */
    header {
        margin-bottom: 2rem;
        padding: 0.5rem;
        border-bottom: 3px solid var(--primary-color);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1rem;
    }
    
    .header-logo {
        width: 55px;
        height: 55px;
        position: relative;
        left: auto;
        top: auto;
        transform: none;
        order: 1;
    }
    
    h1 {
        font-size: 1.5rem;
        letter-spacing: 1px;
        order: 2;
        margin: 0;
    }
    
    .main-nav {
        gap: 1rem;
        flex-wrap: wrap;
        order: 3;
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 1rem;
    }
    
    .nav-link {
        font-size: 0.7rem;
        padding: 0.4rem 0.8rem;
    }
    
    /* Responsive styles for univers.html */
    .section-title {
        font-size: 1.2rem;
        margin: 1.5rem 0 0.8rem;
    }
    
    .lore-text {
        font-size: 0.6rem;
        line-height: 1.6;
    }
    
    .map-container {
        margin: 1.5rem 0;
    }
    
    .map-img {
        border: 2px solid var(--accent-color);
    }
    
    .region-marker {
        width: 16px;
        height: 16px;
        border: 2px solid var(--accent-color);
    }
    
    .region-marker::after {
        font-size: 8px;
        padding: 3px 6px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-item {
        text-align: center;
    }
    
    .territories-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .territory-card {
        padding: 1rem;
    }
    
    .territory-name {
        font-size: 0.8rem;
    }
    
    .territory-desc {
        font-size: 0.6rem;
    }
    
    .timeline-horizontal {
        flex-direction: column;
        align-items: stretch;
    }
    
    .timeline-connector {
        width: 2px;
        height: 20px;
        margin: 10px auto;
    }
    
    .timeline-item {
        text-align: center;
        margin-bottom: 1rem;
    }
}

@media (max-width: 480px) {
    /* Header responsive for small screens */
    header {
        margin-bottom: 4rem;
        padding: 0.5rem;
        border-bottom: 2px solid var(--primary-color);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.8rem;
    }
    
    .header-logo {
        width: 50px;
        height: 50px;
        position: relative;
        left: auto;
        top: auto;
        transform: none;
        order: 1;
    }
    
    h1 {
        font-size: 1rem;
        letter-spacing: 0.5px;
        margin: 0;
        text-align: center;
        position: relative;
        z-index: 2;
        order: 2;
    }
    
    .main-nav {
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        gap: 1rem;
        flex-direction: row;
        flex-wrap: nowrap;
        margin-top: 0.8rem;
        padding: 0.6rem 1.5rem;
        border-radius: 20px;
        order: 3;
    }
    
    .nav-link {
        font-size: 0.6rem;
        padding: 0.3rem 0.6rem;
        text-align: center;
    }
    
    .section-title {
        font-size: 1rem;
        margin: 1rem 0 0.5rem;
    }
    
    .lore-text {
        font-size: 0.55rem;
        line-height: 1.5;
    }
    
    .region-marker {
        width: 12px;
        height: 12px;
        border: 1px solid var(--accent-color);
    }
    
    .region-marker::after {
        font-size: 7px;
        padding: 2px 4px;
    }
    
    .map-img {
        border: 1px solid var(--accent-color);
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.6rem;
    }
    
    .territory-icon {
        font-size: 1.5rem;
    }
    
    .territory-name {
        font-size: 0.7rem;
    }
    
    .territory-desc {
        font-size: 0.55rem;
    }
    
    .prophecy-quote {
        font-size: 0.8rem;
    }
    
    .prophecy-text {
        font-size: 0.6rem;
    }
    
    .timeline-year {
        font-size: 0.7rem;
    }
    
    .timeline-event {
        font-size: 0.6rem;
    }
    
    .timeline-desc {
        font-size: 0.5rem;
    }
    
    .hero-section {
        padding: 1rem;
        margin: 1rem 0;
    }
    
    .prophecy-card {
        padding: 1rem;
        margin: 1rem 0;
    }
    
    .selected-territory-display {
        padding: 1rem;
        font-size: 0.6rem;
    }
    
    .territory-instruction {
        font-size: 0.6rem;
    }
}

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

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

@keyframes scrollBackground {
    from {
        background-position: 0 0;
    }

    to {
        background-position: -800% 0;
    }
}

@keyframes scrollBackgroundPopup {
    from {
        background-position: 0 0;
    }

    to {
        background-position: 800% 0;
    }
}

@keyframes toggle {

    0%,
    49.9% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0;
    }
}

@keyframes pulse {

    0%,
    100% {
        text-shadow: 2px 2px 0 rgb(218, 36, 36);
    }

    50% {
        text-shadow: 2px 2px 0 rgb(218, 36, 36), 0 0 10px var(--secondary-color);
    }
}

/* Ajoutez à votre style.css */
.region:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.timeline-event {
    transition: all 0.3s ease;
}

.timeline-event:hover {
    transform: scale(1.03);
}

@keyframes glow {
    0% {
        box-shadow: 0 0 5px var(--primary-color);
    }

    50% {
        box-shadow: 0 0 15px var(--primary-color);
    }

    100% {
        box-shadow: 0 0 5px var(--primary-color);
    }
}

.highlight {
    animation: glow 2s ease;
}

/* Personnalisation de la barre de défilement */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) rgba(0, 0, 0, 0.1);
}

*::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

*::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
}

*::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    border-radius: 6px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

*::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(45deg, var(--accent-color), var(--secondary-color));
    box-shadow: 0 0 10px rgba(255, 87, 34, 0.5);
}

*::-webkit-scrollbar-corner {
    background: rgba(0, 0, 0, 0.1);
}

/* Responsive styles pour popup-details */
@media (max-width: 768px) {
    .popup-details {
        padding: 1rem;
        overflow-x: hidden;
        word-wrap: break-word;
        hyphens: auto;
    }
    
    .popup-description {
        font-size: 0.75rem;
        line-height: 1.4;
        word-break: break-word;
    }
}

@media (max-width: 480px) {
    .popup-details {
        padding: 0.8rem;
        font-size: 0.85rem;
    }
    
    .popup-title {
        font-size: 1rem;
        word-break: break-word;
    }
    
    .popup-description {
        font-size: 0.7rem;
        line-height: 1.3;
    }
    
    .popup-skills-title {
        font-size: 0.75rem;
    }
    
    .skill-name {
        font-size: 0.7rem;
        word-break: break-word;
    }
}