* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --neon-cyan: #00ffff;
    --neon-magenta: #ff00ff;
    --neon-yellow: #ffff00;
    --neon-green: #00ff00;
    --neon-orange: #ff9500;
    --neon-red: #ff0055;
    --neon-blue: #0080ff;
    --bg-dark: #0a0a1f;
    --bg-grid: #1a1a3e;
}

body {
    font-family: 'Orbitron', monospace;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a0a2e 100%);
    color: var(--neon-cyan);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 255, 255, 0.03) 2px, rgba(0, 255, 255, 0.03) 4px),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(0, 255, 255, 0.03) 2px, rgba(0, 255, 255, 0.03) 4px);
    pointer-events: none;
    animation: gridScroll 20s linear infinite;
}

@keyframes gridScroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(40px); }
}

.container {
    width: 100%;
    max-width: 900px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: relative;
    z-index: 1;
}

h1 {
    font-size: clamp(2rem, 8vw, 4rem);
    font-weight: 900;
    letter-spacing: 0.2em;
    text-align: center;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-magenta), var(--neon-yellow));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(0, 255, 255, 0.5);
    animation: glow 2s ease-in-out infinite alternate;
    margin-bottom: 10px;
}

@keyframes glow {
    from { filter: drop-shadow(0 0 10px rgba(0, 255, 255, 0.5)); }
    to { filter: drop-shadow(0 0 20px rgba(255, 0, 255, 0.8)); }
}

.game-wrapper {
    display: flex;
    gap: 20px;
    width: 100%;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.canvas-container {
    position: relative;
    background: rgba(26, 26, 62, 0.6);
    padding: 15px;
    border-radius: 15px;
    border: 2px solid var(--neon-cyan);
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.3),
        inset 0 0 30px rgba(0, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

canvas {
    display: block;
    border: 3px solid var(--neon-magenta);
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.5);
    background: #000;
    border-radius: 8px;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    transition: box-shadow 0.1s ease;
}

canvas:active {
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.8);
}

.info-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 180px;
}

.info-box {
    background: rgba(26, 26, 62, 0.6);
    padding: 15px;
    border-radius: 10px;
    border: 2px solid var(--neon-yellow);
    box-shadow: 0 0 20px rgba(255, 255, 0, 0.2);
    backdrop-filter: blur(10px);
}

.info-box h3 {
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    color: var(--neon-yellow);
    text-transform: uppercase;
}

.score-display {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--neon-cyan);
    text-align: center;
    text-shadow: 0 0 10px currentColor;
}

.next-piece {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 2px;
    background: #000;
    padding: 5px;
    border-radius: 5px;
}

.next-piece-cell {
    width: 100%;
    height: 100%;
    background: transparent;
    border-radius: 2px;
}

.controls {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 300px;
    margin-top: 20px;
}

/* Los controles táctiles NO se muestran en móvil */
@media (max-width: 768px) {
    .controls {
        display: none !important;
    }
}

.control-btn {
    background: rgba(26, 26, 62, 0.8);
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    font-family: 'Orbitron', monospace;
    font-size: 1.2rem;
    padding: 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
    touch-action: manipulation;
    user-select: none;
}

.control-btn:active {
    transform: scale(0.95);
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.6);
    background: rgba(0, 255, 255, 0.2);
}

.control-btn.rotate {
    grid-column: 2;
}

.control-btn.left {
    grid-column: 1;
    grid-row: 2;
}

.control-btn.down {
    grid-column: 2;
    grid-row: 2;
}

.control-btn.right {
    grid-column: 3;
    grid-row: 2;
}

.control-btn.drop {
    grid-column: 1 / -1;
    background: rgba(255, 0, 85, 0.3);
    border-color: var(--neon-red);
    color: var(--neon-red);
}

.start-overlay {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 8px;
}

.start-overlay.hide {
    display: none;
}

.start-btn {
    background: linear-gradient(135deg, var(--neon-magenta), var(--neon-cyan));
    border: none;
    color: #fff;
    font-family: 'Orbitron', monospace;
    font-size: 1.2rem;
    font-weight: 900;
    padding: 15px 40px;
    border-radius: 50px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.5);
    transition: all 0.3s;
    min-width: 200px;
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 50px rgba(255, 0, 255, 0.8);
}

.start-btn:active {
    transform: scale(0.98);
}

.game-over {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    z-index: 10;
    border-radius: 8px;
}

.game-over.show {
    display: flex;
    animation: fadeIn 0.3s;
}

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

.game-over h2 {
    font-size: 2.5rem;
    color: var(--neon-red);
    text-shadow: 0 0 20px currentColor;
    animation: pulse 1s infinite;
}

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

.instructions {
    text-align: center;
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    color: rgba(0, 255, 255, 0.6);
    max-width: 400px;
    line-height: 1.6;
}

.instructions strong {
    color: var(--neon-cyan);
}

.mobile-instructions {
    display: none;
}

.desktop-instructions {
    display: block;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
        gap: 15px;
    }

    h1 {
        margin-bottom: 5px;
        font-size: 2.5rem;
    }

    .game-wrapper {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .canvas-container {
        padding: 10px;
    }

    .start-overlay,
    .game-over {
        top: 10px;
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .start-btn {
        font-size: 1rem;
        padding: 12px 30px;
        min-width: 180px;
    }

    .game-over h2 {
        font-size: 2rem;
    }

    .info-panel {
        flex-direction: row;
        width: 100%;
        max-width: 280px;
        gap: 8px;
    }

    .info-box {
        flex: 1;
        padding: 10px;
    }

    .info-box h3 {
        font-size: 0.7rem;
        margin-bottom: 5px;
    }

    .score-display {
        font-size: 1.3rem;
    }

    .next-piece {
        width: 60px;
        height: 60px;
    }

    .instructions {
        font-size: 0.75rem;
        max-width: 300px;
    }

    .mobile-instructions {
        display: block;
    }

    .desktop-instructions {
        display: none;
    }

    .control-btn {
        padding: 15px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 2rem;
    }

    .canvas-container {
        padding: 8px;
    }

    canvas {
        border-width: 2px;
    }

    .start-overlay,
    .game-over {
        top: 8px;
        left: 8px;
        right: 8px;
        bottom: 8px;
    }

    .start-btn {
        font-size: 0.9rem;
        padding: 10px 25px;
        min-width: 160px;
    }

    .game-over h2 {
        font-size: 1.8rem;
    }

    .info-panel {
        max-width: 240px;
    }

    .control-btn {
        padding: 12px;
        font-size: 0.9rem;
    }
}