/* ============================================================
   X LINES - Intégration omesjeux
   Présentation et couleurs inspirées de Pulse Pattern (néon),
   plateau en bois précieux dessiné dans le canvas.
   Tous les sélecteurs sont scopés sous #game-main.
   ============================================================ */

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

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

#game-main #game-container {
    width: 100%;
    max-width: 760px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 15px 24px;
    gap: 8px;
}

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

#game-main #game-title {
    font-size: 1.8rem;
    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: 4px;
}

#game-main .px-subtitle {
    margin: 0 0 8px;
    color: #b0b0ff;
    font-size: 0.82rem;
    font-style: italic;
}

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

#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;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

#game-main .px-dot {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.3);
}
#game-main .px-dot-black { background: radial-gradient(circle at 35% 30%, #555 0%, #000 70%); }
#game-main .px-dot-white { background: radial-gradient(circle at 35% 30%, #fff 0%, #b0b0b0 70%); }

/* --- Barre d'informations --- */
#game-main #info-bar {
    width: 100%;
    max-width: 500px;
    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;
}

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

#game-main #px-status {
    font-size: 0.95rem;
    font-weight: 500;
    color: #b0b0ff;
}

/* --- Contrôles --- */
#game-main .px-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 12px;
}

#game-main .px-ctrl {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #e0e0e0;
}

#game-main .px-ctrl-label {
    white-space: nowrap;
    color: #b0b0ff;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

/* Contrôle segmenté (groupe de pilules) */
#game-main .px-seg {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(123, 47, 247, 0.5);
    border-radius: 25px;
    padding: 3px;
    gap: 3px;
}

#game-main .px-seg-btn {
    border: none;
    background: transparent;
    color: #b9b9d8;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 22px;
    cursor: pointer;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

#game-main .px-seg-btn:hover {
    color: #fff;
}

#game-main .px-seg-btn:active {
    transform: scale(0.96);
}

#game-main .px-seg-btn.is-active {
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 210, 255, 0.35);
}

/* Bouton bascule IA / 2 joueurs */
#game-main .px-btn-ai {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 25px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.15s ease, border-color 0.15s ease;
}
#game-main .px-btn-ai .px-ai-led {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #1a1a3e;
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.6);
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
#game-main .px-btn-ai.is-off .px-ai-label::before { content: "\01F465  "; }
#game-main .px-btn-ai.is-on {
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    border-color: rgba(0, 210, 255, 0.6);
}
#game-main .px-btn-ai.is-on .px-ai-led {
    background: #9aff7a;
    box-shadow: 0 0 8px #6aff4a, inset 0 1px 2px rgba(255,255,255,0.4);
}
#game-main .px-btn-ai.is-on .px-ai-label::before { content: "\01F916  "; }
#game-main .px-btn-ai:active { transform: scale(0.95); }

/* --- Plateau --- */
#game-main .px-board-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 6px 0;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    border: 1px solid rgba(123, 47, 247, 0.4);
    box-shadow: 0 0 24px rgba(123, 47, 247, 0.25), inset 0 0 16px rgba(0,0,0,0.4);
    overflow: hidden;
    width: 100%;
    max-width: 100%;
}
#game-main #px-board {
    display: block;
    border-radius: 10px;
    cursor: pointer;
    touch-action: none;
}

/* --- Boutons de contrôle --- */
#game-main #controls-container {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 14px;
    padding: 8px 0;
    flex-wrap: wrap;
    flex-shrink: 0;
}

#game-main .game-btn {
    padding: 12px 32px;
    font-size: 1rem;
    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;
    -webkit-tap-highlight-color: transparent;
}
#game-main .game-btn:active { transform: scale(0.95); }

#game-main .game-btn:disabled,
#game-main .game-btn.is-disabled {
    opacity: 0.4;
    filter: grayscale(0.6);
    cursor: not-allowed;
    box-shadow: none;
    pointer-events: 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-stop {
    background: linear-gradient(135deg, #ff5252, #d50000);
    box-shadow: 0 4px 15px rgba(255, 82, 82, 0.3);
}
#game-main .btn-rules {
    background: linear-gradient(135deg, #ff6fd8, #7b2ff7);
    box-shadow: 0 4px 15px rgba(123, 47, 247, 0.3);
}

/* --- Modal Règles --- */
#game-main .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;
}
#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: 460px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

#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;
}
#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;
    text-align: center;
}

#game-main .modal-body {
    font-size: 0.88rem;
    line-height: 1.6;
    color: #ccc;
}
#game-main .modal-body ul { padding-left: 20px; margin-bottom: 8px; }
#game-main .modal-body ul ul { margin-top: 4px; }
#game-main .modal-body li { margin-bottom: 6px; }
#game-main .modal-body strong { color: #b0b0ff; }
#game-main .modal-body pre {
    background: #0f0c29;
    border: 1px solid rgba(123, 47, 247, 0.4);
    border-radius: 6px;
    padding: 6px 12px;
    margin: 6px 0;
    color: #00d2ff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    display: inline-block;
}

/* --- Modale fin de partie --- */
#game-main .px-prompt {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
#game-main .px-prompt-card {
    background: linear-gradient(135deg, #1a1a3e, #2a2a5e);
    border: 1px solid rgba(123, 47, 247, 0.4);
    border-radius: 16px;
    padding: 24px 20px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    text-align: center;
}
#game-main .px-prompt-card h2 {
    margin: 0 0 8px;
    font-size: 1.3rem;
    color: #fff;
}
#game-main .px-prompt-card p {
    margin: 0 0 14px;
    color: #ccc;
    font-size: 0.95rem;
}
#game-main .px-prompt-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* --- Responsive --- */
@media (max-width: 360px) {
    #game-main #game-title { font-size: 1.5rem; }
    #game-main .game-btn { padding: 10px 22px; font-size: 0.9rem; }
    #game-main #scores-container { gap: 18px; }
}

@media (min-width: 768px) {
    #game-main #game-title { font-size: 2.2rem; }
    #game-main .score-number { font-size: 1.7rem; }
}
