/* Rampart v2 - Styles principaux */
/* Inspiration pixel art moderne avec palette fidèle à l'original */

:root {
    /* Couleurs du jeu - Cohérence avec GameConstants.js */
    --color-water: #1e40af;
    --color-water-light: #3b82f6;
    --color-land: #22c55e;
    --color-wall: #6b7280;
    --color-castle: #dc2626;
    --color-cannon: #7c2d12;
    --color-ui-bg: #1f2937;
    --color-ui-text: #f9fafb;
    --color-accent: #fbbf24;
    
    /* Espacement */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Typography */
    --font-family: 'Courier New', 'Monaco', 'Lucida Console', monospace;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 2rem;
}

/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--color-ui-bg) 0%, #111827 100%);
    color: var(--color-ui-text);
    overflow: hidden;
    user-select: none;
}

/* Container principal */
#game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Canvas */
#game-canvas {
    flex: 1;
    background: var(--color-water);
    cursor: crosshair;
    border: none;
    border-radius: 0;
    margin: 0;
    min-width: 600px;
    min-height: 400px;
}

#game-canvas:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Layout principal avec UI à gauche et canvas à droite */
#game-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, var(--color-ui-bg) 0%, #111827 100%);
}

/* Interface utilisateur sur le côté gauche */
#game-ui-left {
    width: 280px;
    min-width: 280px;
    background: linear-gradient(180deg, rgba(31, 41, 55, 0.98) 0%, rgba(17, 24, 39, 0.98) 100%);
    border-right: 3px solid var(--color-accent);
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    overflow-y: auto;
}

#phase-display {
    text-align: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.05) 100%);
    padding: var(--spacing-md);
    border-radius: 12px;
    border: 2px solid var(--color-accent);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

/* Interface utilisateur superposée */
#game-ui {
    position: absolute;
    width: 100%;
    pointer-events: none;
}

#phase-title {
    font-size: var(--font-size-lg);
    color: var(--color-accent);
    font-weight: bold;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
    margin-bottom: var(--spacing-xs);
}

#phase-description {
    font-size: var(--font-size-sm);
    color: var(--color-ui-text);
    margin-bottom: var(--spacing-xs);
    opacity: 0.9;
}

#phase-timer {
    font-size: var(--font-size-base);
    color: var(--color-castle);
    font-weight: bold;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.7);
}

/* Statistiques de jeu */
#game-stats {
    background: linear-gradient(135deg, rgba(31, 41, 55, 0.8) 0%, rgba(17, 24, 39, 0.8) 100%);
    padding: var(--spacing-md);
    border-radius: 8px;
    border: 1px solid var(--color-wall);
}

#game-stats h3 {
    color: var(--color-accent);
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-base);
    text-align: center;
    border-bottom: 1px solid var(--color-wall);
    padding-bottom: var(--spacing-xs);
}

/* Contrôles et aide */
#game-controls {
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.8) 0%, rgba(31, 41, 55, 0.8) 100%);
    padding: var(--spacing-md);
    border-radius: 8px;
    border: 1px solid var(--color-wall);
    font-size: var(--font-size-sm);
}

#game-controls h3 {
    color: var(--color-accent);
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-base);
    text-align: center;
    border-bottom: 1px solid var(--color-wall);
    padding-bottom: var(--spacing-xs);
}

.control-item {
    margin-bottom: var(--spacing-xs);
    color: var(--color-ui-text);
    line-height: 1.4;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xs);
    font-size: var(--font-size-sm);
}

.stat-label {
    color: #d1d5db;
}

.stat-value {
    color: var(--color-accent);
    font-weight: bold;
    text-align: right;
    min-width: 40px;
}

/* Modales */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.modal-overlay.hidden {
    display: none;
}

/* Modale d'annonce de phase sans fond sombre */
.modal-overlay.phase-announcement {
    background: transparent; /* Pas de fond sombre */
    pointer-events: none; /* Ne bloque pas les interactions */
}

.modal-overlay.phase-announcement .modal-content {
    pointer-events: auto; /* Le contenu reste interactif */
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.8); /* Lueur bleue */
    border: 3px solid var(--color-accent);
    animation: phaseFlash 0.8s ease-out;
}

@keyframes phaseFlash {
    0% { 
        opacity: 0;
        transform: scale(0.8);
        box-shadow: 0 0 20px rgba(59, 130, 246, 0);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
        box-shadow: 0 0 40px rgba(59, 130, 246, 1);
    }
    100% { 
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
    }
}

.modal-content {
    background: var(--color-ui-bg);
    border: 3px solid var(--color-accent);
    border-radius: 12px;
    padding: var(--spacing-xl);
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
}

#modal-title {
    font-size: var(--font-size-2xl);
    color: var(--color-accent);
    margin-bottom: var(--spacing-lg);
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.7);
    font-weight: bold;
}

#modal-message {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-xl);
    line-height: 1.4;
}

#modal-buttons {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
}

/* Boutons */
.game-button,
#modal-buttons button {
    background: linear-gradient(135deg, var(--color-cannon) 0%, #92400e 100%);
    color: var(--color-ui-text);
    border: 2px solid var(--color-accent);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.7);
    pointer-events: auto;
}

.game-button:hover,
#modal-buttons button:hover {
    background: linear-gradient(135deg, #92400e 0%, var(--color-cannon) 100%);
    border-color: var(--color-ui-text);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.game-button:active,
#modal-buttons button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#start-button {
    position: absolute;
    bottom: var(--spacing-xl);
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--font-size-lg);
    padding: var(--spacing-md) var(--spacing-xl);
    z-index: 100;
}

/* Panel de debug */
.debug-panel {
    position: absolute;
    bottom: var(--spacing-md);
    left: var(--spacing-md);
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid var(--color-wall);
    border-radius: 6px;
    padding: var(--spacing-sm);
    font-size: var(--font-size-sm);
    font-family: 'Monaco', 'Menlo', monospace;
    min-width: 200px;
    z-index: 50;
    pointer-events: auto;
}

.debug-panel h3 {
    color: var(--color-accent);
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-base);
    border-bottom: 1px solid var(--color-wall);
    padding-bottom: var(--spacing-xs);
}

#debug-content p {
    margin-bottom: var(--spacing-xs);
    color: #d1d5db;
}

#debug-content span {
    color: var(--color-ui-text);
    font-weight: bold;
}

/* Messages d'erreur */
.error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--color-castle);
    color: var(--color-ui-text);
    padding: var(--spacing-lg);
    border-radius: 8px;
    border: 2px solid #dc2626;
    font-size: var(--font-size-lg);
    text-align: center;
    z-index: 1001;
    box-shadow: 0 8px 24px rgba(220, 38, 38, 0.3);
}

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

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Menu d'accueil */
.main-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, var(--color-ui-bg) 0%, #111827 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.menu-content {
    text-align: center;
    max-width: 600px;
    width: 90%;
    background: rgba(31, 41, 55, 0.9);
    border: 3px solid var(--color-accent);
    border-radius: 12px;
    padding: var(--spacing-xl);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.menu-title {
    font-size: 3rem;
    color: var(--color-accent);
    margin-bottom: var(--spacing-lg);
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.7);
    font-weight: bold;
}

.menu-subtitle {
    font-size: var(--font-size-lg);
    color: var(--color-ui-text);
    margin-bottom: var(--spacing-xl);
    opacity: 0.9;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.menu-button {
    font-size: var(--font-size-lg);
    padding: var(--spacing-lg) var(--spacing-xl);
    width: 100%;
    position: relative;
}

.menu-button.disabled {
    background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
    color: #9ca3af;
    cursor: not-allowed;
    border-color: #6b7280;
}

.menu-button.disabled:hover {
    background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
    border-color: #6b7280;
    transform: none;
    box-shadow: none;
}

.coming-soon {
    display: block;
    font-size: var(--font-size-sm);
    opacity: 0.7;
    font-style: italic;
}

.menu-info {
    text-align: left;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: var(--spacing-lg);
    border: 1px solid var(--color-wall);
}

.menu-info h3 {
    color: var(--color-accent);
    margin-bottom: var(--spacing-md);
    text-align: center;
}

.menu-info ul {
    list-style: none;
    padding: 0;
}

.menu-info li {
    margin-bottom: var(--spacing-sm);
    line-height: 1.4;
    color: var(--color-ui-text);
}

/* Classes utilitaires */
.hidden {
    display: none !important;
}

.pulsing {
    animation: pulse 1s infinite;
}

/* Responsive */
@media (max-width: 768px) {
    :root {
        --font-size-sm: 0.75rem;
        --font-size-base: 0.875rem;
        --font-size-lg: 1rem;
        --font-size-xl: 1.25rem;
        --font-size-2xl: 1.5rem;
    }
    
    #game-canvas {
        margin: var(--spacing-sm);
        min-width: 600px;
        min-height: 400px;
    }
    
    #game-layout {
        flex-direction: column;
    }
    
    #game-ui-left {
        width: 100%;
        min-width: unset;
        max-height: 200px;
        padding: var(--spacing-sm);
        border-right: none;
        border-bottom: 2px solid var(--color-accent);
        overflow-y: auto;
    }
    
    #phase-display {
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    #game-controls {
        display: none; /* Masquer les contrôles sur mobile */
    }
    
    .debug-panel {
        bottom: var(--spacing-sm);
        left: var(--spacing-sm);
        font-size: 0.7rem;
        min-width: 160px;
    }
}

@media (max-width: 480px) {
    #game-layout {
        flex-direction: column;
    }
    
    #game-ui-left {
        max-height: 150px;
        gap: var(--spacing-sm);
        flex-direction: row;
        justify-content: space-between;
    }
    
    #phase-display {
        flex: 1;
        margin-right: var(--spacing-sm);
    }
    
    #game-stats {
        flex: 0 0 120px;
    }
    
    #game-controls {
        display: none;
    }
    
    .debug-panel {
        display: none;
    }
}

/* Mode sombre amélioré */
@media (prefers-color-scheme: dark) {
    :root {
        --color-ui-bg: #0f172a;
        --color-ui-text: #f1f5f9;
    }
}