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

body {
    font-family: 'Roboto', sans-serif;
    background: #000000; /* Fond noir pour la page */
    overflow: hidden;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Canvas container */
#canvasContainer {
    position: relative;
    width: 1280px;
    height: 768px;
    border: 2px solid #333333;
    box-shadow: 0 0 30px rgba(255, 107, 107, 0.3);
}

#menuCanvas {
    display: block;
    cursor: pointer;
}

/* Hidden input elements for interaction */
input, select {
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
    pointer-events: none;
}

/* Screen management - kept for game screen compatibility */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.screen.hidden {
    display: none;
}

/* Loading screen */
#loadingScreen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-content h1 {
    font-family: 'Fredoka One', cursive;
    font-size: 3rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255,255,255,0.3);
    border-top: 5px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Menu screen */
#menuScreen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem;
}

.menu-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.game-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2.5rem;
    text-align: center;
    color: #667eea;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.game-subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

/* Game creator panel */
.creator-panel {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 2px solid #e9ecef;
}

.creator-panel h2 {
    color: #495057;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.settings-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
}

.setting-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

.setting-group input,
.setting-group select {
    padding: 0.5rem;
    border: 2px solid #dee2e6;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.setting-group input:focus,
.setting-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* URL sharing */
.url-share {
    margin-top: 1rem;
}

.url-share label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

.url-container {
    display: flex;
    gap: 0.5rem;
}

.url-container input {
    flex: 1;
    padding: 0.5rem;
    border: 2px solid #dee2e6;
    border-radius: 5px;
    font-size: 0.9rem;
}

.url-container button {
    padding: 0.5rem 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.url-container button:hover {
    background: #5a6fd8;
}

/* Players section */
.players-section {
    margin-bottom: 2rem;
}

.players-section h3 {
    color: #495057;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.players-list {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 1rem;
    min-height: 60px;
    border: 2px solid #e9ecef;
}

.player-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.player-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 0.5rem;
    border: 2px solid #dee2e6;
}

.player-name {
    flex: 1;
    font-weight: 500;
    color: #495057;
}

.player-score {
    font-weight: bold;
    color: #667eea;
}

/* Action buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#joinGameSection {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#playerName {
    padding: 0.75rem;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

#playerName:focus {
    outline: none;
    border-color: #667eea;
}

/* Color picker */
.color-picker label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
    display: block;
}

.color-options {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: #495057;
}

.color-option.selected {
    border-color: #667eea;
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

/* Buttons */
.btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
}

/* Game screen */
#gameScreen {
    background: #000;
    padding: 0;
}

#gameCanvas {
    display: block;
    width: 1280px;  /* Taille fixe */
    height: 768px;  /* Taille fixe */
    background: #87CEEB; /* Default sky blue */
    border: 2px solid #333; /* Bordure pour délimiter le jeu */
    margin: 0 auto; /* Centrage horizontal */
}

/* Game UI overlay */
.game-ui {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 1280px;
    height: 768px;
    pointer-events: none;
    z-index: 10;
}

/* Scoreboard - compact and transparent */
.scoreboard {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    padding: 0.5rem;
    min-width: 150px;
    pointer-events: auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    backdrop-filter: blur(5px);
}

.scoreboard h3 {
    margin-bottom: 0.3rem;
    color: #FFFFFF;
    font-size: 0.9rem;
    text-align: center;
    font-weight: 600;
}

.score-item {
    display: flex;
    align-items: center;
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.score-item:last-child {
    border-bottom: none;
}

.score-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.score-name {
    flex: 1;
    font-size: 0.8rem;
    color: #FFFFFF;
    font-weight: 500;
}

.score-points {
    font-weight: bold;
    color: #4ECDC4;
    font-size: 0.8rem;
}

/* Help button */
.help-button {
    position: absolute;
    bottom: 15px;
    right: 65px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.help-button:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.1);
}

/* Controls info - hidden by default */
.controls-info {
    position: absolute;
    bottom: 65px;
    right: 15px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 10px;
    padding: 1rem;
    pointer-events: auto;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: none;
    min-width: 200px;
}

.controls-info.show {
    display: block;
    animation: slideUp 0.3s ease-out;
}

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

.controls-info h4 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.controls span {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Quit button - top left */
.quit-button {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(220, 53, 69, 0.8);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    z-index: 20;
}

.quit-button:hover {
    background: rgba(220, 53, 69, 1);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

/* Music toggle button - bottom right */
.music-toggle-btn {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.music-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.music-toggle-btn.muted {
    opacity: 0.5;
    background: rgba(255, 0, 0, 0.7);
}

.music-toggle-btn.muted:hover {
    background: rgba(255, 0, 0, 0.9);
}

/* Game status */
.game-status {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 20px;
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
    pointer-events: none;
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Game over screen */
#gameOverScreen {
    background: rgba(0, 0, 0, 0.9);
}

.game-over-content {
    text-align: center;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    padding: 3rem;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.game-over-content h1 {
    font-family: 'Fredoka One', cursive;
    font-size: 3rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.final-scores {
    margin-bottom: 2rem;
}

.final-score-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    min-width: 300px;
}

.final-score-left {
    display: flex;
    align-items: center;
}

.final-score-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.final-score-name {
    font-weight: 500;
}

.final-score-points {
    font-weight: bold;
    font-size: 1.2rem;
}

/* Session management styles */
.session-info {
    margin-bottom: 1rem;
}

.session-display {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 1rem;
    border: 2px solid #e9ecef;
}

.session-player {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.session-color {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    margin-right: 0.75rem;
    border: 2px solid #dee2e6;
}

.session-name {
    font-weight: 600;
    color: #495057;
    font-size: 1.1rem;
    flex: 1;
}

.btn-change-name,
.btn-clear-session {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 0.5rem;
}

.btn-change-name {
    background: #667eea;
    color: white;
}

.btn-change-name:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.btn-clear-session {
    background: #6c757d;
    color: white;
}

.btn-clear-session:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.btn-clear-session:last-child {
    margin-right: 0;
}

/* Session info responsive */
@media (max-width: 768px) {
    .session-display {
        padding: 0.75rem;
    }
    
    .btn-change-name,
    .btn-clear-session {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .menu-container {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    .color-options {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .scoreboard {
        top: 10px;
        right: 10px;
        min-width: 150px;
        padding: 0.75rem;
    }
    
    .controls-info {
        bottom: 10px;
        left: 10px;
        padding: 0.75rem;
    }
}

/* Animations */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.bounce {
    animation: bounce 0.6s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}
