/* ============================================
   Cascade Color - Feuille de style
   ============================================ */

/* Reset et base */
/*
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
*/

#game-main {
    position: relative;
    width: 100%;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a2e;
    color: #eee;
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    touch-action: manipulation;
}

/* ============================================
   Écrans
   ============================================ */
.screen {
    display: none;
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.screen.overlay {
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
}

.screen-content {
    text-align: center;
    padding: 20px;
}

/* ============================================
   Écran d'accueil
   ============================================ */
.game-title {
    font-size: 3.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, #e74c3c, #3498db, #2ecc71, #f1c40f);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.1rem;
    color: #aaa;
    margin-bottom: 40px;
}

/* ============================================
   Boutons
   ============================================ */
.btn-main {
    display: inline-block;
    padding: 16px 50px;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #6c5ce7, #a855f7);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
    margin: 10px;
}

.btn-main:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.btn-secondary {
    display: inline-block;
    padding: 12px 40px;
    font-size: 1rem;
    font-weight: 600;
    color: #ccc;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    margin: 10px;
}

.btn-secondary:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

.btn-small {
    padding: 8px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #ccc;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s;
}

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

/* ============================================
   Score et infos
   ============================================ */
.best-score-display {
    margin-top: 20px;
    font-size: 0.95rem;
    color: #888;
}

.best-score-display span {
    color: #f1c40f;
    font-weight: 700;
}

/* ============================================
   En-tête du jeu
   ============================================ */
#game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#game-header .label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin-bottom: 2px;
}

#score-display {
    text-align: left;
    flex: 1;
}

#score-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #f1c40f;
}

#target-display {
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#target-color-box {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 3px solid #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
    transition: background-color 0.3s;
}

#lives-display {
    text-align: right;
    flex: 1;
}

#lives-value {
    font-size: 1.3rem;
}

#level-display {
    text-align: center;
    padding: 5px;
    font-size: 0.85rem;
    color: #a855f7;
    font-weight: 600;
    letter-spacing: 1px;
}

/* ============================================
   Grille de jeu
   ============================================ */
#grid-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

#grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 4px;
    aspect-ratio: 1 / 1;
    max-width: 95vw;
    max-height: 95vw;
    width: 100%;
}

.cell {
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: background-color 0.4s ease, transform 0.1s;
    min-width: 0;
    min-height: 0;
    background-color: #2d2d44;
}

.cell::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    border-radius: 8px;
    pointer-events: none;
}

.cell:active {
    transform: scale(0.92);
}

/* Couleurs des cases */
.cell.color-red {
    background-color: #e74c3c;
    box-shadow: inset 0 -3px 6px rgba(0,0,0,0.2), 0 2px 8px rgba(231, 76, 60, 0.3);
}

.cell.color-blue {
    background-color: #3498db;
    box-shadow: inset 0 -3px 6px rgba(0,0,0,0.2), 0 2px 8px rgba(52, 152, 219, 0.3);
}

.cell.color-green {
    background-color: #2ecc71;
    box-shadow: inset 0 -3px 6px rgba(0,0,0,0.2), 0 2px 8px rgba(46, 204, 113, 0.3);
}

.cell.color-yellow {
    background-color: #f1c40f;
    box-shadow: inset 0 -3px 6px rgba(0,0,0,0.2), 0 2px 8px rgba(241, 196, 15, 0.3);
}

.cell.color-none {
    background-color: #2d2d44;
    box-shadow: none;
}

/* ============================================
   Effets sur les cases
   ============================================ */

/* Flash correct */
.cell.flash-correct {
    animation: flashCorrect 0.4s ease-out;
}

@keyframes flashCorrect {
    0% { transform: scale(1); filter: brightness(1); }
    30% { transform: scale(1.15); filter: brightness(1.8); }
    100% { transform: scale(1); filter: brightness(1); }
}

/* Shake erreur */
.cell.flash-wrong {
    animation: shakeWrong 0.5s ease-out;
}

@keyframes shakeWrong {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-6px); }
    30% { transform: translateX(6px); }
    45% { transform: translateX(-4px); }
    60% { transform: translateX(4px); }
    75% { transform: translateX(-2px); }
    90% { transform: translateX(2px); }
}

/* Perte de vie */
.cell.flash-wrong {
    box-shadow: inset 0 0 20px rgba(255, 0, 0, 0.6) !important;
}

/* ============================================
   Effets flottants (+points)
   ============================================ */
#float-effects {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
}

.float-text {
    position: absolute;
    font-size: 1.4rem;
    font-weight: 800;
    color: #2ecc71;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    animation: floatUp 1s ease-out forwards;
    pointer-events: none;
}

.float-text.negative {
    color: #e74c3c;
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-60px) scale(1.3); }
}

/* ============================================
   Game Over
   ============================================ */
.gameover-title {
    font-size: 2.5rem;
    font-weight: 900;
    color: #e74c3c;
    margin-bottom: 30px;
    text-transform: uppercase;
}

.final-score {
    margin-bottom: 15px;
}

.final-score .label {
    display: block;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin-bottom: 5px;
}

#final-score-value {
    font-size: 3rem;
    font-weight: 900;
    color: #f1c40f;
}

#new-record {
    font-size: 1.3rem;
    color: #f1c40f;
    margin: 15px 0;
    animation: pulse 1s ease-in-out infinite;
}

.hidden {
    display: none !important;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

/* ============================================
   Écran de jeu en layout flex
   ============================================ */
#screen-game {
    flex-direction: column;
}

#screen-game.active {
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
}

#game-footer {
    padding: 8px;
    text-align: center;
}

/* ============================================
   Responsive : paysage
   ============================================ */
@media (orientation: landscape) {
    #grid {
        max-width: min(95vh, 60vw);
        max-height: 80vh;
    }

    #grid-container {
        padding: 5px;
    }

    #game-header {
        padding: 5px 15px;
    }

    #level-display {
        padding: 2px;
    }
}

/* ============================================
   Responsive : grands écrans
   ============================================ */
@media (min-width: 600px) {
    #grid {
        max-width: 450px;
        max-height: 450px;
        gap: 6px;
    }

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

/* ============================================
   Modal des règles
   ============================================ */
#modal-rules {
    z-index: 150;
    align-items: center;
    justify-content: center;
    padding: 15px;
    overflow-y: auto;
}

#modal-rules.active {
    display: flex;
}

.modal-box {
    background: #1e1e36;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 28px 22px;
    max-width: 420px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.modal-box h2 {
    font-size: 1.6rem;
    margin-bottom: 18px;
    color: #fff;
}

.rules-content {
    text-align: left;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #ccc;
}

.rules-content p {
    margin-bottom: 14px;
}

.rules-content ul {
    list-style: none;
    padding: 0;
    margin: 14px 0 20px;
}

.rules-content ul li {
    padding: 6px 0 6px 22px;
    position: relative;
}

.rules-content ul li::before {
    content: '▸';
    position: absolute;
    left: 4px;
    color: #a855f7;
    font-weight: 700;
}

/* Exemple visuel dans les règles */
.rules-example {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 14px;
    margin: 14px 0;
}

.example-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    justify-content: center;
}

.example-target {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 2px solid #fff;
    vertical-align: middle;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    max-width: 180px;
    margin: 0 auto;
}

.ex-cell {
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.example-caption {
    text-align: center;
    font-size: 0.78rem;
    color: #999;
    margin-top: 10px;
    margin-bottom: 0 !important;
}

/* ============================================
   Animation d'entrée de vague
   ============================================ */
.cell.wave-enter {
    animation: waveEnter 0.5s ease-out;
}

@keyframes waveEnter {
    0% { transform: scale(0.7); opacity: 0.5; }
    60% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}
