/* ============================================
   2048 - Feuille de styles
   Thème néon inspiré de Pulse Pattern
   ============================================ */

#game-main * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

#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: flex-start;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

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

/* --- En-tête --- */
#game-main #game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#game-main #game-title {
    font-size: 2.4rem;
    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;
    line-height: 1;
}

/* --- Scores --- */
#game-main #scores-container {
    display: flex;
    gap: 12px;
}

#game-main .score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 8px 16px;
    min-width: 72px;
}

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

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

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

#game-main .game-btn {
    flex: 1;
    max-width: 160px;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #fff;
    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 .game-btn:disabled {
    opacity: 0.4;
    cursor: default;
    transform: none;
}

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

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

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

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

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

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

/* --- Options --- */
#game-main #options-panel {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 8px 12px;
    flex-shrink: 0;
}

#game-main .option-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #b0b0ff;
}

#game-main .option-group label {
    white-space: nowrap;
}

#game-main .option-group select {
    padding: 6px 10px;
    border: 2px solid rgba(123, 47, 247, 0.4);
    border-radius: 8px;
    background: rgba(15, 12, 41, 0.8);
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
}

/* --- Zone de jeu --- */
#game-main #canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-width: 460px;
    margin: 0 auto;
}

#game-main #game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 12px;
    touch-action: none;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

/* --- Overlays sur le canvas --- */
#game-main .overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 12, 41, 0.85);
    border-radius: 12px;
    z-index: 10;
    animation: oj2048-fadeIn 0.3s ease;
}

#game-main .overlay.hidden {
    display: none;
}

#game-main .overlay-content {
    text-align: center;
    padding: 24px;
}

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

#game-main .overlay-content p {
    font-size: 1.05rem;
    margin-bottom: 10px;
    color: #ccc;
}

#game-main .overlay-content .game-btn {
    margin: 6px;
    max-width: none;
    min-width: 140px;
    flex: none;
}

/* --- Meilleurs scores --- */
#game-main #high-scores {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(123, 47, 247, 0.3);
}

#game-main #high-scores h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #b0b0ff;
    font-weight: 600;
}

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

#game-main .score-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#game-main .score-entry:last-child {
    border-bottom: none;
}

#game-main .score-grid-info {
    color: #888;
    font-size: 0.85rem;
}

#game-main .score-value {
    font-weight: 700;
    color: #00d2ff;
}

#game-main .no-scores {
    color: #777;
    font-style: italic;
}

/* --- Modal Règles --- */
#game-main .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    animation: oj2048-fadeIn 0.25s ease;
}

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

#game-main .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: oj2048-slideUp 0.3s ease;
    text-align: center;
}

#game-main .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;
}

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

#game-main .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;
}

#game-main .modal-body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #ccc;
    text-align: left;
    margin-bottom: 16px;
}

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

#game-main .modal-body ul {
    padding-left: 20px;
    margin-bottom: 8px;
}

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

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

/* --- Animations --- */
@keyframes oj2048-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* --- Responsive --- */
@media (max-width: 400px) {
    #game-main #game-title {
        font-size: 1.8rem;
    }

    #game-main .score-box {
        padding: 6px 10px;
        min-width: 58px;
    }

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

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

    #game-main .option-group {
        font-size: 0.78rem;
    }
}
