/* ============================================
   Compte Est Bon - Feuille de styles
   Design responsive inspiré de pulsepattern
   ============================================ */

#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;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

#game-main * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

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

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

#game-main #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 --- */
#game-main #scores-container {
    display: flex;
    justify-content: center;
    gap: 30px;
}

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

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

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

/* --- Barre d'informations --- */
#game-main #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;
}

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

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

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

/* --- Sélecteur de niveau --- */
#game-main #level-selector {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 4px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

#game-main .level-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: bold;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.3s ease;
}

#game-main .level-btn.active {
    background: linear-gradient(45deg, #00d2ff, #7b2ff7);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.4);
}

#game-main .level-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --- Zone de jeu canvas --- */
#game-main #game-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 280px;
    position: relative;
    width: 100%;
}

#game-main #gameCanvas {
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    max-width: 100%;
    height: auto;
}

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

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

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

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

/* --- Clavier numérique --- */
#game-main #keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 4px;
    width: 100%;
    max-width: 500px;
    flex-shrink: 0;
}

#game-main .key {
    padding: 18px 10px;
    font-size: 1.4rem;
    font-weight: bold;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-main .key:active:not(:disabled) {
    transform: scale(0.95);
}

#game-main .key-op {
    background: linear-gradient(45deg, #00d2ff, #7b2ff7);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 210, 255, 0.3);
}

#game-main .key-op:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#game-main .key-op.selected {
    background: linear-gradient(45deg, #ff6fd8, #7b2ff7);
    box-shadow: 0 0 20px rgba(255, 111, 216, 0.6);
    transform: scale(1.05);
}

#game-main .key-action {
    font-size: 1rem;
}

#game-main .key-clear {
    grid-column: span 2;
    background: linear-gradient(45deg, #ff9f43, #ee5a5a);
    color: #fff;
    box-shadow: 0 4px 12px rgba(238, 90, 90, 0.3);
}

#game-main .key-giveup {
    grid-column: span 2;
    background: linear-gradient(45deg, #6c63ff, #a55eea);
    color: #fff;
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
}

#game-main .key-action:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

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

#game-main .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-main .game-btn:active {
    transform: scale(0.95);
}

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

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

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

#game-main .game-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- High scores --- */
#game-main #high-scores {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 15px;
    margin: 4px;
    text-align: center;
    width: 100%;
    flex-shrink: 0;
}

#game-main #high-scores h2 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #b0b0ff;
}

#game-main #high-scores-list {
    list-style: none;
    font-size: 0.9rem;
}

#game-main #high-scores-list li {
    padding: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#game-main #high-scores-list li:last-child {
    border-bottom: none;
}

/* --- Modals --- */
#game-main .ceb-modal,
.ceb-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: ceb-fadeIn 0.3s;
}

.ceb-modal-content {
    background: linear-gradient(135deg, #1a1a3e, #2a2a5e);
    border: 1px solid rgba(123, 47, 247, 0.4);
    border-radius: 16px;
    margin: 15% auto;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    animation: ceb-slideUp 0.3s ease;
}

.ceb-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

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

.ceb-modal h2 {
    color: #b0b0ff;
    margin-bottom: 20px;
}

.ceb-modal ul {
    text-align: left;
    margin: 20px 0;
    padding-left: 20px;
}

.ceb-modal li {
    margin: 10px 0;
    line-height: 1.5;
}

.ceb-modal p {
    margin: 10px 0;
    font-size: 1.1rem;
}

#final-level, #final-score, #final-round {
    color: #00e676;
    font-weight: bold;
    font-size: 1.3rem;
}

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

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

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

/* --- Responsive : petits écrans --- */
@media (max-width: 480px) {
    #game-main #game-title {
        font-size: 1.3rem;
    }

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

    #game-main #game-area {
        min-height: 220px;
    }

    #game-main .game-btn {
        padding: 10px 24px;
        font-size: 0.85rem;
    }

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

    #game-main .key {
        padding: 14px 8px;
        font-size: 1.2rem;
        min-height: 52px;
    }

    #game-main .key-action {
        font-size: 0.85rem;
    }

    #game-main .level-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .ceb-modal-content {
        margin: 20% auto;
        padding: 20px;
    }
}

@media (max-width: 320px) {
    #game-main #game-title {
        font-size: 1.1rem;
    }

    #game-main .score-number {
        font-size: 0.95rem;
    }

    #game-main .game-btn {
        padding: 8px 16px;
        font-size: 0.75rem;
    }

    #game-main .key {
        padding: 10px 6px;
        font-size: 1rem;
        min-height: 46px;
    }
}

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

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

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

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

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

    #game-main #level-selector {
        width: 100%;
        order: 3;
        padding: 2px;
    }

    #game-main #game-area {
        width: 55%;
        order: 4;
        min-height: 150px;
    }

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

    #game-main #keypad {
        width: 40%;
        order: 6;
    }

    #game-main #controls-container {
        width: 100%;
        order: 7;
        padding: 2px;
    }

    #game-main #high-scores {
        width: 100%;
        order: 8;
        margin: 2px;
    }

    #game-main .game-btn {
        padding: 8px 16px;
        font-size: 0.8rem;
    }

    #game-main .key {
        padding: 8px 6px;
        font-size: 1rem;
        min-height: 40px;
    }
}
