/* ============================================
   Pattern Pulse - Feuille de styles
   Design responsive et moderne
   ============================================ */

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

/*
#game-main{
    width: 100%;
    height: 100%;
    overflow: hidden;



    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

    touch-action: manipulation;
}
*/

#game-main{
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;


}



/* --- Conteneur principal --- */
#game-container {
    width: 100%;
    max-width: 500px;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 15px;
    gap: 8px;
}

/* --- En-tête --- */
#game-header {
    width: 100%;
    text-align: center;
    flex-shrink: 0;
}

#game-title {
    font-size: 1.6rem;
    font-weight: 700;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7, #ff6fd8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

/* --- Scores --- */
#scores-container {
    display: flex;
    justify-content: center;
    gap: 30px;
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

.score-number {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
}

/* --- Barre d'informations --- */
#info-bar {
    width: 100%;
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 6px 10px;
    flex-shrink: 0;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.info-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

.info-value {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
}

/* --- Message d'état --- */
#message-container {
    width: 100%;
    text-align: center;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#game-message {
    font-size: 1rem;
    font-weight: 500;
    color: #b0b0ff;
    transition: opacity 0.3s ease;
}

#game-message.fade-out {
    opacity: 0;
}

#game-message.fade-in {
    opacity: 1;
}

#game-message.success {
    color: #00e676;
}

#game-message.error {
    color: #ff5252;
}

/* --- Timer --- */
#timer-container {
    width: 100%;
    flex-shrink: 0;
    min-height: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

#timer-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#timer-bar.visible {
    opacity: 1;
}

#timer-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7);
    border-radius: 3px;
    transition: width 0.1s linear;
    transform-origin: left;
}

#timer-fill.warning {
    background: linear-gradient(90deg, #ff9800, #ff5252);
}

#timer-text {
    font-size: 0.75rem;
    color: #aaa;
    min-height: 16px;
}

/* --- Grille de jeu --- */
#grid-container {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

#game-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 6px;
    width: min(90vw, 90vh - 280px, 400px);
    height: min(90vw, 90vh - 280px, 400px);
    max-width: 400px;
    max-height: 400px;
}

/* --- Cases de la grille --- */
.grid-cell {
    background: rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    min-width: 0;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.grid-cell:active {
    transform: scale(0.93);
}

/* Case illuminée (affichage du motif) */
.grid-cell.highlighted {
    background: rgba(123, 47, 247, 0.7);
    border-color: rgba(123, 47, 247, 0.9);
    box-shadow: 0 0 18px rgba(123, 47, 247, 0.6), inset 0 0 12px rgba(123, 47, 247, 0.3);
    animation: pulse-glow 0.8s ease-in-out infinite alternate;
}

/* Case sélectionnée par le joueur */
.grid-cell.selected {
    background: rgba(0, 210, 255, 0.5);
    border-color: rgba(0, 210, 255, 0.8);
    box-shadow: 0 0 12px rgba(0, 210, 255, 0.4);
}

/* Case correcte */
.grid-cell.correct {
    background: rgba(0, 230, 118, 0.6);
    border-color: rgba(0, 230, 118, 0.9);
    box-shadow: 0 0 18px rgba(0, 230, 118, 0.5);
    animation: flash-correct 0.5s ease;
}

/* Case incorrecte */
.grid-cell.incorrect {
    background: rgba(255, 82, 82, 0.6);
    border-color: rgba(255, 82, 82, 0.9);
    box-shadow: 0 0 18px rgba(255, 82, 82, 0.5);
    animation: flash-incorrect 0.5s ease;
}

/* Grille inactive (écran accueil / game over) */
#game-grid.inactive .grid-cell {
    cursor: default;
    opacity: 0.4;
}

#game-grid.inactive .grid-cell:active {
    transform: none;
}

/* --- Animations --- */
@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 12px rgba(123, 47, 247, 0.4), inset 0 0 8px rgba(123, 47, 247, 0.2);
    }
    100% {
        box-shadow: 0 0 24px rgba(123, 47, 247, 0.8), inset 0 0 16px rgba(123, 47, 247, 0.4);
    }
}

@keyframes flash-correct {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes flash-incorrect {
    0% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
    100% { transform: translateX(0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.4s ease;
}

/* --- Boutons --- */
#controls-container {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 8px 0;
    flex-shrink: 0;
}

.game-btn {
    padding: 12px 36px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.game-btn:active {
    transform: scale(0.95);
}

.btn-play {
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

.btn-play:hover {
    box-shadow: 0 6px 20px rgba(0, 210, 255, 0.5);
}

.btn-stop {
    background: linear-gradient(135deg, #ff5252, #d50000);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 82, 82, 0.3);
}

.btn-stop:hover {
    box-shadow: 0 6px 20px rgba(255, 82, 82, 0.5);
}

/* --- Bouton Règle --- */
.btn-rules {
    background: linear-gradient(135deg, #ff6fd8, #7b2ff7);
    color: #fff;
    box-shadow: 0 4px 15px rgba(123, 47, 247, 0.3);
}

.btn-rules:hover {
    box-shadow: 0 6px 20px rgba(123, 47, 247, 0.5);
}

/* --- Modal Règles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    animation: fadeIn 0.25s ease;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a3e, #2a2a5e);
    border: 1px solid rgba(123, 47, 247, 0.4);
    border-radius: 16px;
    padding: 24px 20px;
    max-width: 440px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

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

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

.modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.modal-close:hover {
    color: #fff;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 14px;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

.modal-body {
    font-size: 0.88rem;
    line-height: 1.6;
    color: #ccc;
}

.modal-body h3 {
    font-size: 0.95rem;
    color: #b0b0ff;
    margin: 14px 0 6px;
    font-weight: 600;
}

.modal-body p {
    margin-bottom: 8px;
}

.modal-body ol,
.modal-body ul {
    padding-left: 20px;
    margin-bottom: 8px;
}

.modal-body li {
    margin-bottom: 4px;
}

/* --- Mini-grille d'exemple dans le modal --- */
.modal-example-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
    width: 160px;
    height: 160px;
    margin: 10px auto;
}

.ex-cell {
    background: rgba(255, 255, 255, 0.07);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.ex-cell.ex-highlight {
    background: rgba(123, 47, 247, 0.7);
    border-color: rgba(123, 47, 247, 0.9);
    box-shadow: 0 0 8px rgba(123, 47, 247, 0.5);
    animation: pulse-glow 0.8s ease-in-out infinite alternate;
}

.modal-example-caption {
    text-align: center;
    font-size: 0.8rem;
    color: #999;
    font-style: italic;
}

/* --- Utilitaires --- */
.hidden {
    display: none !important;
}

/* --- Responsive : petits écrans --- */
@media (max-height: 600px) {
    #game-container {
        padding: 5px 10px;
        gap: 4px;
    }

    #game-title {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }

    .score-number {
        font-size: 1.1rem;
    }

    #info-bar {
        padding: 4px 8px;
    }

    .info-label {
        font-size: 0.6rem;
    }

    .info-value {
        font-size: 0.85rem;
    }

    #game-message {
        font-size: 0.85rem;
    }

    #message-container {
        min-height: 24px;
    }

    .game-btn {
        padding: 10px 28px;
        font-size: 0.85rem;
    }
}

/* --- Responsive : grands écrans / tablettes --- */
@media (min-width: 768px) {
    #game-container {
        padding: 20px;
        gap: 12px;
    }

    #game-title {
        font-size: 2rem;
    }

    .score-number {
        font-size: 1.8rem;
    }

    #game-grid {
        gap: 8px;
    }

    .grid-cell {
        border-radius: 10px;
    }
}

/* --- Mode paysage mobile --- */
@media (orientation: landscape) and (max-height: 500px) {
    #game-container {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 5px 10px;
        gap: 4px;
        max-width: 100%;
        justify-content: center;
    }

    #game-header {
        width: 50%;
        order: 1;
    }

    #game-title {
        font-size: 1rem;
        margin-bottom: 2px;
    }

    .score-number {
        font-size: 1rem;
    }

    #info-bar {
        width: 50%;
        order: 2;
        padding: 3px 6px;
    }

    #message-container {
        width: 100%;
        order: 3;
        min-height: 20px;
    }

    #game-message {
        font-size: 0.8rem;
    }

    #timer-container {
        width: 100%;
        order: 4;
    }

    #grid-container {
        order: 5;
        flex: 0 0 auto;
        width: auto;
    }

    #game-grid {
        width: min(50vw, 80vh - 80px, 300px);
        height: min(50vw, 80vh - 80px, 300px);
    }

    #controls-container {
        order: 6;
        width: auto;
        flex-direction: column;
        padding: 0 10px;
    }

    .game-btn {
        padding: 8px 20px;
        font-size: 0.8rem;
    }
}
