/* Reset y Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Paleta de colores Pseudomorph (del logo) */
    --cyan-primary: #00d4ff;
    --cyan-dark: #0099cc;
    --red-primary: #ff3366;
    --red-dark: #cc1a47;
    --green-primary: #00ff88;
    --green-dark: #00cc6a;
    --bg-dark: #0a0a0a;
    --bg-panel: #1a1a1a;
    --bg-light: #2a2a2a;
    --text-light: #ffffff;
    --text-muted: #888888;
    --border-color: #333333;
    --circuit-green: #00ff88;
    --circuit-cyan: #00d4ff;
    --cell-size: 60px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    background-image: 
        linear-gradient(90deg, var(--circuit-cyan) 1px, transparent 1px),
        linear-gradient(180deg, var(--circuit-cyan) 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: 0 0, 0 0;
    min-height: 100vh;
    padding: 20px;
    color: var(--text-light);
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 20% 50%, rgba(0, 255, 136, 0.05) 0%, transparent 50%),
                radial-gradient(circle at 80% 50%, rgba(0, 212, 255, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Container Principal */
.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    background: var(--bg-panel);
    border-radius: 15px;
    box-shadow: 0 0 40px rgba(0, 212, 255, 0.3),
                0 0 80px rgba(0, 255, 136, 0.2);
    overflow: hidden;
    border: 2px solid var(--border-color);
    position: relative;
    z-index: 1;
}

/* Panel de Juego */
.game-panel {
    padding: 30px;
    background: var(--bg-dark);
    position: relative;
}

.game-panel h1 {
    color: var(--cyan-primary);
    font-size: 2.5em;
    margin-bottom: 10px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 900;
    text-shadow: 0 0 20px var(--cyan-primary),
                 0 0 40px var(--cyan-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.logo-container {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 10px var(--cyan-primary));
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 30px;
    font-size: 1.1em;
}

.board-section {
    margin-bottom: 30px;
}

.board-section h2 {
    font-size: 1.3em;
    margin-bottom: 15px;
    color: var(--cyan-primary);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
}

/* Tableros */
.board {
    display: grid;
    gap: 2px;
    background-color: var(--bg-dark);
    padding: 2px;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4),
                inset 0 0 20px rgba(0, 0, 0, 0.5);
    margin: 0 auto;
    width: fit-content;
    border: 2px solid var(--border-color);
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    color: var(--text-muted);
    position: relative;
}

.cell::before {
    content: '';
    position: absolute;
    inset: 0;
    background: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cell:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px currentColor;
}

.cell:hover::before {
    opacity: 0.3;
}

/* Colores del juego - Paleta Pseudomorph */
.cell.ROJO { 
    background-color: var(--red-primary);
    box-shadow: inset 0 0 10px rgba(255, 51, 102, 0.5);
}
.cell.AZUL { 
    background-color: var(--cyan-primary);
    box-shadow: inset 0 0 10px rgba(0, 212, 255, 0.5);
}
.cell.VERDE { 
    background-color: var(--green-primary);
    box-shadow: inset 0 0 10px rgba(0, 255, 136, 0.5);
}
.cell.NEGRO { 
    background-color: var(--bg-dark);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}
.cell.BLANCO { 
    background-color: #e0e0e0;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.3);
}

.level-info {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-light);
    border-left: 4px solid var(--green-primary);
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}

.level-info p {
    color: var(--text-light);
    margin: 0;
}

.level-info strong {
    color: var(--green-primary);
}

/* Panel de Código */
.code-panel {
    padding: 30px;
    background: var(--bg-panel);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    border-left: 2px solid var(--border-color);
}

.code-panel h2 {
    color: var(--cyan-primary);
    font-size: 1.5em;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
}

/* Editor de Código */
.editor-container {
    flex-grow: 1;
    margin-bottom: 20px;
}

#code-editor {
    width: 100%;
    height: 300px;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    background-color: var(--bg-dark);
    color: #d4d4d4;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    resize: vertical;
    outline: none;
    line-height: 1.6;
}

#code-editor:focus {
    border-color: var(--cyan-primary);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

/* Botones */
.button-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.btn {
    flex: 1;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--cyan-primary) 0%, var(--cyan-dark) 100%);
    color: var(--bg-dark);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}

.btn-primary:hover {
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.6);
}

.btn-success {
    background: linear-gradient(135deg, var(--green-primary) 0%, var(--green-dark) 100%);
    color: var(--bg-dark);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.4);
}

.btn-success:hover {
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.6);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--bg-light) 0%, var(--border-color) 100%);
    color: var(--text-light);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.2);
}

/* Área de Mensajes */
.message-area {
    min-height: 60px;
    padding: 15px;
    background-color: var(--bg-dark);
    border-radius: 8px;
    border: 2px solid var(--border-color);
    margin-bottom: 20px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #d4d4d4;
    overflow-y: auto;
    max-height: 150px;
}

.message-area.error {
    border-color: var(--red-primary);
    background-color: rgba(255, 51, 102, 0.1);
    box-shadow: 0 0 15px rgba(255, 51, 102, 0.3);
}

.message-area.success {
    border-color: var(--green-primary);
    background-color: rgba(0, 255, 136, 0.1);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
}

.message-area .error-text {
    color: var(--red-primary);
    text-shadow: 0 0 10px var(--red-primary);
}

.message-area .success-text {
    color: var(--green-primary);
    text-shadow: 0 0 10px var(--green-primary);
}

.message-area .info-text {
    color: var(--cyan-primary);
    text-shadow: 0 0 10px var(--cyan-primary);
}

/* Sección de Ayuda */
.help-section {
    background-color: var(--bg-dark);
    padding: 15px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

.help-section h3 {
    color: var(--cyan-primary);
    margin-bottom: 10px;
    font-size: 1.1em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.help-content {
    font-size: 13px;
    line-height: 1.8;
}

.help-content p {
    margin-top: 10px;
    margin-bottom: 5px;
    color: var(--text-muted);
}

.help-content strong {
    color: var(--green-primary);
}

.help-content code {
    display: block;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 8px;
    border-radius: 4px;
    color: var(--cyan-primary);
    margin-bottom: 10px;
    font-family: 'Courier New', monospace;
    border: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    :root {
        --cell-size: 50px;
    }
}

@media (max-width: 768px) {
    :root {
        --cell-size: 40px;
    }
    
    body {
        padding: 10px;
    }
    
    .game-panel, .code-panel {
        padding: 20px;
    }
    
    .game-panel h1 {
        font-size: 2em;
    }
    
    #code-editor {
        height: 200px;
        font-size: 12px;
    }
    
    .button-container {
        flex-direction: column;
    }
}

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

.cell.matched {
    animation: pulse 0.5s ease-in-out;
    box-shadow: 0 0 30px var(--green-primary);
}

/* Efecto de circuito en esquinas */
.container::before,
.container::after {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border-style: solid;
    border-color: var(--circuit-cyan);
    opacity: 0.5;
}

.container::before {
    top: -2px;
    left: -2px;
    border-width: 2px 0 0 2px;
}

.container::after {
    bottom: -2px;
    right: -2px;
    border-width: 0 2px 2px 0;
}
