/**
 * TIC-TAC-TOE.EXE - Styles DOS/CRT retro
 * Palette: Noir, Vert (#00FF00), Cyan (#00AAAA), Jaune (#FFFF00)
 */

/* ===========================================
   BASE & RESET
   =========================================== */

@font-face {
    font-family: 'DOS';
    src: local('Perfect DOS VGA 437'), local('Px437 IBM VGA8'), local('Consolas'), local('Courier New');
}

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

body {
    font-family: 'DOS', 'Courier New', monospace;
    background: #000000;
    color: #00FF00;
    overflow: hidden;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ===========================================
   LAYOUT - Couches superposees (z-index)
   Three.js (2) < Phaser (1) < UI (3)
   =========================================== */

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#three-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    touch-action: none;
}

#three-container canvas {
    touch-action: none;
}

#phaser-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

#phaser-container canvas {
    opacity: 0;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

/* ===========================================
   COMPOSANTS DOS - Fenetres et boutons
   =========================================== */

.dos-window {
    position: absolute;
    background: #0000AA;
    border: 2px solid #AAAAAA;
    box-shadow: 4px 4px 0 #000000;
    pointer-events: auto;
}

.dos-title-bar {
    background: #00AAAA;
    color: #000000;
    padding: 4px 8px;
    font-weight: bold;
    text-transform: uppercase;
    border-bottom: 2px solid #AAAAAA;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dos-close {
    cursor: pointer;
    padding: 0 4px;
    background: #000000;
    color: #FFFFFF;
}

.dos-close:hover {
    background: #FF0000;
}

.dos-content {
    padding: 16px;
    color: #FFFFFF;
}

.dos-button {
    background: #000000;
    color: #00FF00;
    border: 2px solid #00FF00;
    padding: 8px 16px;
    margin: 4px;
    cursor: pointer;
    font-family: 'DOS', 'Courier New', monospace;
    font-size: 14px;
    text-transform: uppercase;
    transition: none;
    display: inline-block;
    min-width: 140px;
    text-align: center;
}

.dos-button:hover {
    background: #00FF00;
    color: #000000;
}

.dos-button.active {
    background: #FFFF00;
    color: #000000;
    border-color: #FFFF00;
}

.dos-button:active {
    position: relative;
    top: 2px;
    left: 2px;
}

/* ===========================================
   MENU PRINCIPAL
   =========================================== */

#main-menu {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 640px;
    max-width: 90vw;
}

.dos-header {
    text-align: center;
    padding: 20px 0;
    background: #000000;
    color: #FFFF00;
    border: 2px double #FFFF00;
    margin-bottom: 20px;
    font-size: 24px;
    letter-spacing: 4px;
}

.dos-ascii-art {
    font-size: 10px;
    line-height: 1;
    white-space: pre;
    color: #00FF00;
    text-align: center;
    margin: 10px 0;
}

.dos-menu-section {
    margin: 16px 0;
    border: 1px solid #AAAAAA;
    padding: 8px;
}

.dos-menu-title {
    color: #FFFF00;
    margin-bottom: 8px;
    padding: 4px;
    background: #000055;
    border-left: 4px solid #FFFF00;
}

/* ===========================================
   COLOR PICKER - Grille de couleurs
   =========================================== */

.dos-color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    padding: 8px;
}

.dos-color-swatch {
    width: 48px;
    height: 48px;
    border: 2px solid #AAAAAA;
    cursor: pointer;
    position: relative;
}

.dos-color-swatch:hover {
    border-color: #FFFFFF;
}

.dos-color-swatch.selected {
    border: 4px solid #FFFFFF;
}

.dos-color-swatch.selected::after {
    content: 'X';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000000;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #FFFFFF;
}

/* ===========================================
   STATS DISPLAY
   =========================================== */

.dos-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 8px;
    margin-bottom: 10px;
    background: #000055;
    border: 1px solid #AAAAAA;
    font-size: 12px;
    color: #00FFFF;
}

.dos-stats span {
    text-transform: uppercase;
}

.dos-reset-btn {
    background: transparent;
    color: #FF0000;
    border: none;
    cursor: pointer;
    font-family: 'DOS', 'Courier New', monospace;
    font-size: 12px;
    padding: 0 4px;
    margin-left: 8px;
}

.dos-reset-btn:hover {
    color: #FFFFFF;
}

/* ===========================================
   BOUTON MUTE
   =========================================== */

.dos-mute-btn {
    background: #000000;
    color: #00FF00;
    border: 2px solid #00FF00;
    padding: 4px 8px;
    cursor: pointer;
    font-family: 'DOS', 'Courier New', monospace;
    font-size: 12px;
    pointer-events: auto;
}

.dos-mute-btn:hover {
    background: #00FF00;
    color: #000000;
}

.dos-mute-btn.muted {
    color: #FF0000;
    border-color: #FF0000;
}

.dos-mute-btn.muted:hover {
    background: #FF0000;
    color: #000000;
}

.hud-mute {
    pointer-events: auto;
}

/* ===========================================
   BOUTON START - Animation clignotante
   =========================================== */

#start-game {
    display: block;
    margin: 20px auto 0;
    font-size: 18px;
    padding: 12px 40px;
    background: #000000;
    color: #FFFF00;
    border: 4px double #FFFF00;
    animation: blink-border 1s infinite;
}

@keyframes blink-border {
    0%, 50% { border-color: #FFFF00; }
    51%, 100% { border-color: #FF0000; }
}

#start-game:hover {
    background: #FFFF00;
    color: #000000;
}

/* ===========================================
   HUD - Barre d'information en jeu
   =========================================== */

#game-info {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: #0000AA;
    color: #FFFFFF;
    padding: 12px;
    border-bottom: 4px solid #00AAAA;
    font-size: 18px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

#game-info .hud-item {
    border: 2px solid #AAAAAA;
    padding: 4px 12px;
    background: #000000;
}

#game-info .hud-current-player {
    color: #FFFF00;
}

/* ===========================================
   PANNEAU PARAMETRES AUDIO
   =========================================== */

#settings-panel {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 280px;
}

#settings-panel .dos-content {
    padding: 12px;
}

.dos-slider-group {
    margin: 12px 0;
}

.dos-slider-label {
    display: block;
    color: #00FFFF;
    margin-bottom: 4px;
}

.dos-slider {
    width: 100%;
    height: 20px;
    background: #000000;
    border: 2px solid #AAAAAA;
    outline: none;
    -webkit-appearance: none;
}

.dos-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #00FF00;
    cursor: pointer;
    border: 2px solid #FFFFFF;
}

.dos-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #00FF00;
    cursor: pointer;
    border: 2px solid #FFFFFF;
}

/* ===========================================
   MODALE - Fin de partie
   =========================================== */

.dos-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 480px;
    max-width: 80vw;
    z-index: 1000;
}

.dos-modal-content {
    text-align: center;
    padding: 32px;
    font-size: 20px;
}

.dos-modal-message {
    color: #FFFF00;
    margin-bottom: 24px;
    padding: 16px;
    background: #000000;
    border: 2px solid #FFFF00;
}

.dos-modal-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
}

/* ===========================================
   EFFETS CRT - Scanlines et flicker
   =========================================== */

#scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
}

@keyframes flicker {
    0% { opacity: 0.97; }
    5% { opacity: 0.95; }
    10% { opacity: 0.98; }
    15% { opacity: 0.96; }
    20% { opacity: 0.97; }
    25% { opacity: 0.99; }
    30% { opacity: 0.97; }
    35% { opacity: 0.96; }
    40% { opacity: 0.98; }
    45% { opacity: 0.97; }
    50% { opacity: 0.99; }
    55% { opacity: 0.98; }
    60% { opacity: 0.97; }
    65% { opacity: 0.96; }
    70% { opacity: 0.98; }
    75% { opacity: 0.97; }
    80% { opacity: 0.99; }
    85% { opacity: 0.97; }
    90% { opacity: 0.96; }
    95% { opacity: 0.98; }
    100% { opacity: 0.97; }
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 255, 0, 0.02);
    pointer-events: none;
    animation: flicker 0.15s infinite;
    z-index: 9998;
}

/* ===========================================
   ECRAN DE BOOT
   =========================================== */

#boot-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    color: #AAAAAA;
    z-index: 10000;
    padding: 40px;
    font-size: 14px;
    line-height: 1.4;
}

.boot-line { color: #00FF00; }
.boot-error { color: #FF0000; }
.boot-ok { color: #00FF00; }

.cursor-blink {
    animation: cursor-blink 1s infinite;
}

@keyframes cursor-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ===========================================
   UTILITAIRES
   =========================================== */

.hidden {
    display: none !important;
}

/* ===========================================
   RESPONSIVE - Tablette
   =========================================== */

@media (max-width: 768px) {
    #main-menu {
        width: 95vw;
        max-height: 90vh;
        overflow-y: auto;
    }

    .dos-header {
        font-size: 18px;
        padding: 15px 0;
    }

    .dos-ascii-art {
        font-size: 8px;
    }

    .dos-content {
        padding: 12px;
    }

    .dos-button {
        font-size: 14px;
        padding: 14px 16px;
        min-width: 100%;
        display: block;
        width: 100%;
        margin: 8px 0;
        min-height: 48px;
    }

    .dos-color-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        justify-items: center;
    }

    .dos-color-swatch {
        width: 64px;
        height: 64px;
        min-width: 48px;
        min-height: 48px;
    }

    .dos-stats {
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }

    #game-info {
        font-size: 11px;
        padding: 4px 8px;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: space-between;
        gap: 4px;
        position: relative;
        z-index: 10;
    }

    #game-info .hud-item {
        padding: 2px 6px;
        white-space: nowrap;
    }

    #game-info .hud-item:first-child {
        display: none;
    }

    /* Cacher le panneau settings sur mobile en jeu */
    #settings-panel {
        display: none !important;
    }

    .dos-modal {
        width: 95vw;
    }

    .dos-modal-content {
        padding: 16px;
        font-size: 16px;
    }

    .dos-modal-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .dos-modal-buttons .dos-button {
        width: 100%;
    }

    #boot-screen {
        padding: 20px;
        font-size: 12px;
    }

    .dos-ascii-art {
        font-size: 6px;
    }
}

/* ===========================================
   RESPONSIVE - Mobile
   =========================================== */

@media (max-width: 480px) {
    .dos-header {
        font-size: 14px;
        letter-spacing: 1px;
        padding: 10px 0;
    }

    .dos-button {
        font-size: 13px;
        padding: 12px 10px;
        min-height: 48px;
    }

    .dos-color-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .dos-color-swatch {
        width: 56px;
        height: 56px;
    }

    #game-info {
        font-size: 10px;
        padding: 3px 6px;
        gap: 2px;
    }

    #game-info .hud-item {
        padding: 2px 4px;
        font-size: 9px;
    }

    #game-info .hud-item:first-child {
        display: none;
    }

    .dos-mute-btn {
        font-size: 9px;
        padding: 2px 4px;
    }

    .dos-menu-section {
        margin: 10px 0;
        padding: 6px;
    }

    .dos-menu-title {
        font-size: 12px;
        padding: 3px;
    }

    /* Cacher l'ASCII art sur petit mobile */
    #main-menu .dos-ascii-art {
        display: none;
    }

    .dos-stats {
        font-size: 10px;
        gap: 2px;
        padding: 6px;
    }
}
