/* Estilos CSS para Rompe Bloques - ES6 Version */
/* Desarrollado por Ian Palomares - 2º DAW */

/* Variables CSS (CSS Custom Properties) - Reutilización de valores */
:root {
    /* Paleta de colores principal */
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    
    /* Gradientes reutilizables */
    --gradient-primary: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    --gradient-game: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    
    /* Propiedades de diseño común */
    --border-radius: 15px;
    --box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
    
    /* Tipografía */
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Reset universal y box-sizing */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box; /* Incluir padding y border en el ancho */
}

body {
    font-family: var(--font-family);
    background: var(--gradient-primary);
    min-height: 100vh;
    color: var(--dark-color);
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.15);
    padding: 25px;
    border-radius: var(--border-radius);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--box-shadow);
}

.header h1 {
    font-size: 3em;
    color: white;
    margin-bottom: 10px;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
}

.header p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2em;
    font-weight: 500;
}

/* Formulario de usuario */
.user-form-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
}

.form-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 50px;
    border-radius: 25px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    text-align: center;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    max-width: 500px;
    width: 100%;
}

.form-card h2 {
    margin-bottom: 35px;
    color: var(--dark-color);
    font-size: 2.2em;
    font-weight: 700;
}

.input-group {
    margin-bottom: 30px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--dark-color);
    font-size: 1.1em;
}

.input-with-button {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-group input {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    transition: var(--transition);
    background: #fff;
}

.random-name-btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 15px 20px;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    min-width: 60px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.random-name-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.random-name-btn:active {
    transform: translateY(0);
}

.random-name-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

/* Selector de dificultad */
.difficulty-selector {
    margin-bottom: 35px;
    text-align: left;
}

.difficulty-selector > label {
    display: block;
    margin-bottom: 15px;
    font-weight: 600;
    color: var(--dark-color);
    font-size: 1.1em;
}

.difficulty-options {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.difficulty-options input[type="radio"] {
    display: none;
}

.difficulty-label {
    padding: 12px 25px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
    background: white;
    color: var(--dark-color);
}

.difficulty-options input[type="radio"]:checked + .difficulty-label {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.difficulty-label:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.start-btn {
    background: var(--gradient-primary);
    color: white;
    padding: 18px 40px;
    border: none;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(102, 126, 234, 0.4);
}

/* Contenedor del juego */
.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 25px;
    padding: 30px;
    box-shadow: var(--box-shadow);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.game-header {
    margin-bottom: 25px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.player-stats {
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
}

.stat {
    font-size: 16px;
    color: var(--dark-color);
    padding: 8px 15px;
    background: var(--light-color);
    border-radius: 20px;
    border-left: 4px solid var(--primary-color);
}

.stat strong {
    color: var(--primary-color);
    font-weight: 700;
}

.game-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    background: var(--light-color);
    color: var(--dark-color);
    border: 2px solid #e0e0e0;
}

.control-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/* Canvas del juego */
.canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    margin-bottom: 25px;
}

#gameCanvas {
    border: 4px solid var(--dark-color);
    border-radius: 15px;
    background: #000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    max-width: 100%;
    height: auto;
}

/* Overlay del juego */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.overlay-content {
    text-align: center;
    color: white;
    padding: 30px;
    max-width: 400px;
}

.overlay-content h3 {
    font-size: 2.5em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
    color: #fff;
}

.overlay-content p {
    font-size: 1.2em;
    margin-bottom: 25px;
    color: rgba(255, 255, 255, 0.9);
}

.overlay-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.game-btn {
    padding: 15px 25px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.game-btn.primary {
    background: var(--gradient-primary);
    color: white;
}

.game-btn.secondary {
    background: linear-gradient(45deg, var(--warning-color), #ff8c00);
    color: white;
}

.game-btn.success {
    background: linear-gradient(45deg, var(--success-color), #20c997);
    color: white;
}

.game-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Información de controles */
.controls-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

.control-section h4,
.power-ups-info h4 {
    margin-bottom: 15px;
    color: var(--dark-color);
    font-size: 1.3em;
    font-weight: 700;
}

.control-methods {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-method {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background: var(--light-color);
    border-radius: 10px;
    border-left: 4px solid var(--info-color);
}

.control-icon {
    font-size: 1.2em;
}

.power-up-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.power-up {
    padding: 8px 12px;
    background: var(--light-color);
    border-radius: 8px;
    font-size: 0.9em;
    border-left: 4px solid var(--success-color);
}

/* Tabla de puntuaciones */
.leaderboard-container {
    display: flex;
    justify-content: center;
    margin-top: 30px;
}

.leaderboard-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 25px;
    box-shadow: var(--box-shadow);
    backdrop-filter: blur(15px);
    min-width: 600px;
    max-width: 800px;
    width: 100%;
}

.leaderboard-card h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--dark-color);
    font-size: 2.2em;
    font-weight: 700;
}

.filter-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    background: white;
    color: var(--dark-color);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.filter-btn.active,
.filter-btn:hover {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.scores-container {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 25px;
}

.scores-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.score-item {
    display: grid;
    grid-template-columns: 60px 1fr auto auto;
    align-items: center;
    padding: 15px 20px;
    background: var(--light-color);
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
    gap: 15px;
}

.score-item:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.score-item.current-player {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-left-color: var(--success-color);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.score-rank {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.2em;
    text-align: center;
}

.score-name {
    font-weight: 600;
    color: var(--dark-color);
    font-size: 1.1em;
}

.score-points {
    font-weight: 700;
    color: var(--success-color);
    font-size: 1.2em;
}

.score-difficulty {
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: 600;
    color: white;
}

.score-difficulty.easy {
    background: var(--success-color);
}

.score-difficulty.normal {
    background: var(--warning-color);
}

.score-difficulty.hard {
    background: var(--danger-color);
}

.leaderboard-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.new-game-btn,
.clear-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.new-game-btn {
    background: var(--gradient-primary);
    color: white;
    flex: 1;
    min-width: 200px;
}

.clear-btn {
    background: linear-gradient(45deg, var(--danger-color), #c82333);
    color: white;
}

.new-game-btn:hover,
.clear-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.empty-scores {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 40px 20px;
    font-size: 1.1em;
}

/* Scrollbar personalizada */
.scores-container::-webkit-scrollbar {
    width: 8px;
}

.scores-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.scores-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.scores-container::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        padding: 15px;
    }
    
    #gameCanvas {
        max-width: 100%;
        width: 100%;
        height: auto;
    }
    
    .controls-info {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .leaderboard-card {
        min-width: auto;
        padding: 25px;
    }
    
    .score-item {
        grid-template-columns: 50px 1fr auto;
        gap: 10px;
    }
    
    .score-difficulty {
        grid-column: 2 / 4;
        justify-self: start;
        margin-top: 5px;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 2.2em;
    }
    
    .form-card {
        padding: 30px 25px;
        margin: 0 10px;
    }
    
    .form-card h2 {
        font-size: 1.8em;
    }
    
    .difficulty-options {
        flex-direction: column;
        align-items: stretch;
    }
    
    .difficulty-label {
        text-align: center;
    }
    
    .game-container {
        padding: 20px 15px;
    }
    
    .game-info {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .player-stats {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .overlay-content h3 {
        font-size: 2em;
    }
    
    .overlay-buttons {
        flex-direction: column;
    }
    
    .game-btn {
        width: 100%;
    }
    
    .leaderboard-actions {
        flex-direction: column;
    }
    
    .new-game-btn,
    .clear-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.8em;
    }
    
    .header p {
        font-size: 1em;
    }
    
    .form-card h2 {
        font-size: 1.5em;
    }
    
    .overlay-content h3 {
        font-size: 1.6em;
    }
    
    .stat {
        font-size: 14px;
        padding: 6px 12px;
    }
    
    .control-method {
        padding: 8px 12px;
        font-size: 0.9em;
    }
    
    .power-up {
        padding: 6px 10px;
        font-size: 0.85em;
    }
}

/* Animaciones adicionales */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.game-btn:active {
    animation: pulse 0.2s ease-in-out;
}

/* Efectos de partículas (opcional para power-ups) */
.particle-effect {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    animation: particleFloat 1s ease-out forwards;
}

@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--x, 0), var(--y, -50px)) scale(0);
    }
}

/* Estilos para validación de formularios */
.validation-error {
    animation: slideIn 0.3s ease-out;
}

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

.input-group input.input-error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.25) !important;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.input-group input:valid {
    border-color: #28a745;
    box-shadow: 0 0 0 4px rgba(40, 167, 69, 0.1);
}

.input-group input:invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.1);
}

/* Estilos específicos para Game Over */
.game-overlay.game-over {
    background: rgba(139, 0, 0, 0.95);
    animation: gameOverPulse 2s ease-in-out infinite alternate;
}

.game-overlay.game-over .overlay-content h3 {
    font-size: 3.5em;
    color: #ff4444;
    text-shadow: 
        0 0 10px #ff0000,
        0 0 20px #ff0000,
        0 0 30px #ff0000,
        2px 2px 8px rgba(0, 0, 0, 0.8);
    animation: gameOverGlow 1.5s ease-in-out infinite alternate;
}

.game-overlay.game-over .overlay-content p {
    font-size: 1.3em;
    color: #ffcccc;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 25px;
}

@keyframes gameOverPulse {
    0% { background: rgba(139, 0, 0, 0.95); }
    100% { background: rgba(139, 0, 0, 0.85); }
}

@keyframes gameOverGlow {
    0% {
        text-shadow: 
            0 0 10px #ff0000,
            0 0 20px #ff0000,
            0 0 30px #ff0000,
            2px 2px 8px rgba(0, 0, 0, 0.8);
    }
    100% {
        text-shadow: 
            0 0 15px #ff4444,
            0 0 25px #ff4444,
            0 0 35px #ff4444,
            2px 2px 8px rgba(0, 0, 0, 0.8);
    }
}