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

body {
    font-family: 'Roboto', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

/* Header */
.header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.app-title {
    font-family: 'Orbitron', monospace;
    font-size: 1.8rem;
    font-weight: 900;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.app-title i {
    margin-right: 0.5rem;
    color: #ffd700;
}

.search-container {
    position: relative;
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    background: white;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.search-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

/* Filter Bar */
.filter-bar {
    background: white;
    padding: 1rem;
    border-bottom: 1px solid #eee;
    overflow-x: auto;
}

.filter-buttons {
    display: flex;
    gap: 0.5rem;
    min-width: max-content;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #ddd;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.filter-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

/* Games Grid */
.games-container {
    padding: 1rem;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.game-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

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

.game-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.game-card:hover .game-image {
    transform: scale(1.05);
}

.game-content {
    padding: 1.25rem;
}

.game-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.game-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.game-genre {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: capitalize;
}

.game-year {
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
}

.game-rating {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: #ffd700;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    z-index: 2;
}

.game-description {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 10px;
    margin: 15px 0;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    overscroll-behavior-y: contain;
    scroll-behavior: smooth;
    padding: 20px 0;
    /* Empêche le défilement du fond */
    overscroll-behavior: contain;
}

/* État ouvert de la modale */
.modal.open {
    opacity: 1;
    pointer-events: auto;
}

/* Style quand la modale est ouverte */
body.modal-open {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Permet le défilement sur iOS */
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background-color: white;
    margin: 20px auto;
    padding: 0;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 900px;
    position: relative;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
    /* Permettre le défilement natif */
    overscroll-behavior: contain;
    /* Améliorer les performances */
    transform: translateZ(0);
    will-change: transform;
    /* Animation d'ouverture */
    animation: modalSlideIn 0.3s ease forwards;
}

/* Animation quand la modale est ouverte */
.modal.open .modal-content {
opacity: 1;
transform: translateY(0);
}

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

/* Animation de fermeture de la modale */
.modal.closing {
animation: modalFadeOut 0.3s ease forwards;
}

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

.close {
position: absolute;
top: 15px;
right: 20px;
color: white;
font-size: 28px;
font-weight: bold;
cursor: pointer;
z-index: 1001;
background: rgba(0, 0, 0, 0.5);
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.3s ease;
}

.close:hover {
background: rgba(0, 0, 0, 0.8);
}

.modal-body {
    padding: 0;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Permettre le défilement natif */
    overscroll-behavior-y: contain;
}

.modal-content-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: calc(90vh - 40px); /* Hauteur maximale moins les marges */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Défilement fluide sur iOS */
    overscroll-behavior: contain; /* Empêche le défilement du body en arrière-plan */
    /* Style de la barre de défilement */
    scrollbar-width: thin;
    scrollbar-color: #667eea rgba(0, 0, 0, 0.1);
}

/* Style de la barre de défilement pour WebKit (Chrome, Safari) */
.modal-content-wrapper::-webkit-scrollbar {
    width: 8px;
}

.modal-content-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.modal-content-wrapper::-webkit-scrollbar-thumb {
    background-color: #667eea;
    border-radius: 4px;
}

.modal-content-wrapper::-webkit-scrollbar-thumb:hover {
    background-color: #5a6fd8;
}

.game-image-container {
flex: 0 0 auto;
padding: 1.5rem 1.5rem 0;
}

.game-info {
flex: 1;
display: flex;
flex-direction: column;
padding: 1.5rem;
overflow: hidden;
position: relative;
}

.scrollable-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 1.5rem 1.5rem 1.5rem;
    margin-right: -1.5rem;
    overscroll-behavior-y: contain;
    /* Améliorer les performances */
    transform: translateZ(0);
    will-change: transform;
    /* Style de la barre de défilement */
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
    /* Hauteur maximale pour forcer le défilement */
    max-height: calc(90vh - 200px);
    min-height: 200px;
    /* Permettre le défilement fluide */
    scroll-behavior: smooth;
    /* Empêcher le défilement du contenu parent */
    overscroll-behavior: contain;
    /* Ajouter un peu d'espace à droite pour la barre de défilement */
    padding-right: 1.8rem;
    
    /* Masquer la barre de défilement par défaut */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Afficher la barre de défilement uniquement au survol */
.scrollable-content:hover {
    -ms-overflow-style: auto;  /* IE and Edge */
    scrollbar-width: thin;  /* Firefox */
}

/* Style personnalisé pour la barre de défilement */
.scrollable-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.scrollable-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
    margin: 10px 0;
}

.scrollable-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
    transition: background 0.3s ease;
}

.scrollable-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

@media (max-width: 767px) {
.scrollable-content {
margin-right: 0;
padding-right: 1rem;
}
}

/* Personnalisation de la barre de défilement */
.scrollable-content::-webkit-scrollbar {
width: 6px;
}

.scrollable-content::-webkit-scrollbar-track {
background: rgba(241, 241, 241, 0.5);
border-radius: 3px;
margin: 10px 0;
}

.scrollable-content::-webkit-scrollbar-thumb {
background: rgba(136, 136, 136, 0.5);
border-radius: 3px;
transition: background 0.3s ease;
}

.scrollable-content::-webkit-scrollbar-thumb:hover {
background: #555;
}

/* Masquer la barre de défilement par défaut sur mobile */
@media (max-width: 767px) {
.scrollable-content::-webkit-scrollbar {
display: none;
}

.scrollable-content {
-ms-overflow-style: none;
scrollbar-width: none;
}
}

/* Styles spécifiques pour les écrans larges */
@media (min-width: 768px) {
    .modal-content-wrapper {
        flex-direction: row;
        height: 100%;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Défilement fluide sur iOS */
        overscroll-behavior-y: contain; /* Empêche le défilement du body en arrière-plan */
    }
    
    .game-image-container {
        flex: 0 0 40%;
        max-width: 400px;
        padding: 2rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
        background-color: #f9f9f9;
        border-right: 1px solid #eee;
        margin-bottom: 0;
        border-radius: 0;
        border: none;
        box-shadow: none;
        position: relative;
        overflow: visible;
    }
    
    .game-image-container img {
        max-height: 300px;
        width: auto;
        max-width: 100%;
        height: auto;
        object-fit: contain;
        margin: 0 auto;
        transition: transform 0.3s ease;
    }
    
    .game-image-container:hover img {
        transform: scale(1.03);
    }
    
    .game-info {
        padding: 1rem;
        flex: 1;
        overflow-y: auto;
    }
    
    .game-info h2 {
        font-size: 2rem;
        font-weight: 700;
        margin-bottom: 1rem;
        color: #2c3e50;
    }
    
    .game-meta {
        display: flex;
        gap: 1rem;
        margin-bottom: 1rem;
        flex-wrap: wrap;
    }
    
    .game-genre,
    .game-year {
        background: #f8f9fa;
        padding: 0.25rem 0.75rem;
        border-radius: 15px;
        font-size: 0.85rem;
        font-weight: 600;
        color: #667eea;
    }
    
    .game-rating {
        position: absolute;
        top: 15px;
        right: 15px;
        background: rgba(0, 0, 0, 0.8);
        color: white;
        padding: 0.5rem;
        border-radius: 10px;
        font-weight: bold;
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }
    
    .game-description {
        color: #666;
        font-size: 1rem;
        line-height: 1.6;
        margin-bottom: 1.5rem;
    }
    
    .play-btn {
        background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
        color: white;
        border: none;
        padding: 12px 24px;
        font-size: 1.1rem;
        border-radius: 25px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        margin-top: 1.5rem;
        transition: all 0.3s ease;
        box-shadow: 0 4px 15px rgba(30, 60, 114, 0.3);
        width: 100%;
        max-width: 200px;
        align-self: center;
    }
    
    .play-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(30, 60, 114, 0.4);
    }
    
    .play-btn:active {
        transform: translateY(0);
        box-shadow: 0 2px 10px rgba(30, 60, 114, 0.3);
    }
}

/* Style pour les écrans larges */
@media (min-width: 768px) {
    .play-btn {
        margin-top: 1.5rem;
        align-self: flex-start;
    }
}

.game-details {
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #555;
}

.detail-item i {
    color: #667eea;
    width: 20px;
}

.play-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

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

/* Loading Spinner */
.loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-title {
        font-size: 1.5rem;
    }
    
    .modal-body {
        flex-direction: column;
        gap: 1rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem auto;
        max-height: none;
        height: auto;
    }
    
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1rem;
    }
    
    .filter-buttons {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .filter-btn {
        font-size: 0.9rem;
        padding: 0.6rem 1rem;
        flex-shrink: 0;
        min-width: auto;
    }
    
    .modal-content {
        width: 95%;
        margin: 1% auto;
        max-height: 98vh;
        border-radius: 15px;
    }
    
    .game-image-container {
        height: 200px;
        border-radius: 15px 15px 0 0;
    }
    
    .game-info {
        padding: 1.25rem;
    }
    
    .game-info h2 {
        font-size: 1.4rem;
        margin-bottom: 0.75rem;
    }
    
    .game-meta {
        margin-bottom: 1rem;
    }
    
    .game-description {
        font-size: 0.9rem;
        line-height: 1.5;
        margin-bottom: 1.25rem;
    }
    
    .game-details {
        gap: 0.5rem;
        margin: 1rem 0;
    }
    
    .detail-item {
        font-size: 0.85rem;
        padding: 0.5rem 0;
    }
    
    .detail-item i {
        font-size: 0.9rem;
        min-width: 20px;
    }
    
    .play-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
        width: 100%;
        margin-top: 1rem;
    }
    
    .close {
        top: 10px;
        right: 15px;
        width: 35px;
        height: 35px;
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.75rem;
    }
    
    .app-title {
        font-size: 1.3rem;
    }
    
    .search-input {
        font-size: 16px;
    }
    
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 0.75rem;
        padding: 0.5rem 0;
    }
    
    .game-card {
        margin: 0 auto;
        max-width: none;
        width: 100%;
    }
    
    .game-content {
        padding: 1rem;
    }
    
    .modal-content {
        width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .game-image-container {
        height: 180px;
        border-radius: 0;
    }
    
    .game-info {
        padding: 1rem;
        flex: 1;
        overflow-y: auto;
    }
    
    .game-info h2 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }
    
    .game-description {
        font-size: 0.85rem;
        margin-bottom: 1rem;
    }
    
    .game-details {
        margin: 0.75rem 0;
    }
    
    .detail-item {
        font-size: 0.8rem;
        padding: 0.4rem 0;
    }
    
    .play-btn {
        padding: 0.75rem;
        font-size: 0.9rem;
        position: sticky;
        bottom: 0;
        background: #667eea;
        margin: 1rem 0 0 0;
    }
    
    .close {
        top: 5px;
        right: 10px;
        width: 30px;
        height: 30px;
        font-size: 20px;
        background: rgba(0, 0, 0, 0.7);
    }
    
    .filter-buttons {
        gap: 0.4rem;
    }
    
    .filter-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
}

/* Animations et transitions supplémentaires */
.game-card {
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
    transform: translateY(30px);
}

.game-card:nth-child(1) { animation-delay: 0.1s; }
.game-card:nth-child(2) { animation-delay: 0.2s; }
.game-card:nth-child(3) { animation-delay: 0.3s; }
.game-card:nth-child(4) { animation-delay: 0.4s; }
.game-card:nth-child(5) { animation-delay: 0.5s; }

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

/* Scrollbar personnalisée */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}
