/* ============================================
   Moth & Flame Rush - Feuille de styles
   Design inspiré de Pulse Pattern
   ============================================ */

/* --- Reset et base --- */
#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;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

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

/* --- Header avec scores --- */
#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 2px solid rgba(123, 47, 247, 0.4);
    flex-shrink: 0;
}

.score-box, .level-box, .high-score-box {
    text-align: center;
}

.score-box .label, .level-box .label, .high-score-box .label {
    font-size: 0.65rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-box span, .level-box span, .high-score-box span {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
}

.score-box span:not(.label) {
    color: #00d2ff;
}

.level-box span:not(.label) {
    color: #ff6fd8;
}

.high-score-box span:not(.label) {
    color: #7b2ff7;
}

/* --- Canvas du jeu --- */
#gameCanvas {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    background: #0a0a1e;
    display: block;
    cursor: crosshair;
}

/* --- Affichage du motif --- */
#pattern-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 20px;
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid rgba(123, 47, 247, 0.3);
    flex-shrink: 0;
}

.pattern-label {
    font-size: 0.8rem;
    color: #888;
    margin-right: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#pattern-dots {
    display: flex;
    gap: 8px;
}

.pattern-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

.pattern-dot.completed {
    opacity: 0.3;
    transform: scale(0.8);
}

/* --- Boutons --- */
#controls-container {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 12px 0;
    background: rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

.game-btn {
    padding: 12px 28px;
    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;
    -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);
}

.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);
}

.btn-sound {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 10px 18px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.btn-sound:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-sound.active {
    background: linear-gradient(135deg, #00e676, #00c853);
    border-color: transparent;
    color: #000;
}

/* --- Overlay (menu principal / Game Over) --- */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 12, 41, 0.92);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay h2 {
    font-size: 2.2rem;
    margin-bottom: 20px;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7, #ff6fd8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.overlay p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    color: #ccc;
    text-align: center;
    max-width: 80%;
}

/* --- 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;
}

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

/* --- Responsive : petits écrans --- */
@media (max-width: 600px) {
    #header {
        padding: 8px 15px;
    }

    .score-box span, .level-box span, .high-score-box span {
        font-size: 1.1rem;
    }

    .score-box .label, .level-box .label, .high-score-box .label {
        font-size: 0.55rem;
    }

    #pattern-display {
        padding: 6px 15px;
        gap: 6px;
    }

    .pattern-label {
        font-size: 0.7rem;
    }

    .pattern-dot {
        width: 16px;
        height: 16px;
    }

    #controls-container {
        padding: 10px;
        gap: 10px;
    }

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

    .overlay h2 {
        font-size: 1.6rem;
    }

    .overlay p {
        font-size: 1rem;
    }
}

/* --- Responsive : petits écrans en hauteur --- */
@media (max-height: 600px) {
    #game-container {
        padding: 0;
    }

    #header {
        padding: 5px 10px;
    }

    .score-box span, .level-box span, .high-score-box span {
        font-size: 1rem;
    }

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