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

html, body {
    width: 100%;
    height: 100%;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
    color: #fff;
    overflow: hidden;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.game-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0;
    gap: 20px;
}

/* ESCRITORIO - Diseño por defecto */
@media (min-width: 768px) {
    .game-wrapper {
        padding: 20px;
    }

    .game-container {
        position: relative;
        width: 650px;
        height: 650px;
        background: rgba(13, 17, 23, 0.85);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-radius: 24px;
        overflow: hidden;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3),
                    0 0 0 1px rgba(255, 255, 255, 0.1) inset,
                    0 8px 32px rgba(102, 126, 234, 0.2);
        border: 2px solid rgba(255, 255, 255, 0.1);
        transform: translateZ(0);
        animation: floatIn 0.6s ease-out;
    }

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

    canvas {
        width: 100%;
        height: 100%;
        display: block;
    }

    .game-over {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.8);
        background: rgba(13, 17, 23, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 0;
        border-radius: 24px;
        display: none;
        opacity: 0;
        box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6),
                    0 0 0 1px rgba(255, 255, 255, 0.1) inset,
                    0 0 100px rgba(230, 57, 70, 0.3);
        border: 2px solid rgba(230, 57, 70, 0.4);
        z-index: 100;
        transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    .game-over.active {
        display: flex;
        justify-content: center;
        align-items: center;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    .game-over-content {
        text-align: center;
        padding: 40px 50px;
    }

    .game-over-content h2 {
        font-size: 42px;
        margin-bottom: 15px;
        background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        text-shadow: 0 4px 20px rgba(230, 57, 70, 0.6);
        animation: pulse 2s ease-in-out infinite;
    }

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

    .game-over-content p {
        font-size: 22px;
        margin-bottom: 25px;
        color: #e9ecef;
        font-weight: 500;
    }

    .game-over-content button {
        padding: 14px 36px;
        background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
        color: #fff;
        border: none;
        border-radius: 12px;
        font-size: 18px;
        font-weight: 700;
        letter-spacing: 0.5px;
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        box-shadow: 0 8px 25px rgba(230, 57, 70, 0.4),
                    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
        position: relative;
        overflow: hidden;
    }

    .game-over-content button::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.3);
        transform: translate(-50%, -50%);
        transition: width 0.6s, height 0.6s;
    }

    .game-over-content button:hover::before {
        width: 300px;
        height: 300px;
    }

    .game-over-content button:hover {
        transform: translateY(-3px) scale(1.05);
        box-shadow: 0 12px 35px rgba(230, 57, 70, 0.6);
    }

    .game-over-content button:active {
        transform: translateY(-1px) scale(0.98);
    }

    /* Ocultar controles en escritorio */
    .mobile-controls {
        display: none;
    }
}

/* TABLET - 600px a 767px */
@media (max-width: 767px) and (min-width: 600px) {
    .game-wrapper {
        padding: 10px;
    }

    .game-container {
        position: relative;
        width: 90vw;
        max-width: 550px;
        aspect-ratio: 1;
        background: linear-gradient(135deg, #0d1117, #161b22);
        border-radius: 15px;
        overflow: hidden;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
        border: 2px solid rgba(102, 126, 234, 0.3);
    }

    canvas {
        width: 100%;
        height: 100%;
        display: block;
    }

    .game-over {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: rgba(0, 0, 0, 0.95);
        padding: 0;
        border-radius: 15px;
        display: none;
        box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
        border: 2px solid rgba(230, 57, 70, 0.5);
        z-index: 100;
    }

    .game-over.active {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .game-over-content {
        text-align: center;
        padding: 30px 40px;
    }

    .game-over-content h2 {
        font-size: 28px;
        margin-bottom: 12px;
        color: #e63946;
        text-shadow: 0 2px 10px rgba(230, 57, 70, 0.5);
    }

    .game-over-content p {
        font-size: 16px;
        margin-bottom: 20px;
        color: #adb5bd;
    }

    .game-over-content button {
        padding: 10px 25px;
        background: linear-gradient(135deg, #e63946, #d62839);
        color: #fff;
        border: none;
        border-radius: 8px;
        font-size: 16px;
        font-weight: bold;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 4px 15px rgba(230, 57, 70, 0.4);
    }

    .game-over-content button:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(230, 57, 70, 0.6);
    }

    .game-over-content button:active {
        transform: translateY(0);
    }

    /* Controles móviles */
    .mobile-controls {
        display: flex;
        flex-direction: column;
        gap: 10px;
        align-items: center;
        justify-content: center;
    }

    .control-btn {
        width: 60px;
        height: 60px;
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.9), rgba(118, 75, 162, 0.9));
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 2px solid rgba(255, 255, 255, 0.2);
        border-radius: 14px;
        color: #fff;
        font-size: 24px;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4),
                    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
        display: flex;
        justify-content: center;
        align-items: center;
        touch-action: manipulation;
        position: relative;
        overflow: hidden;
    }

    .control-btn::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 100%;
        height: 100%;
        background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
        transform: translate(-50%, -50%) scale(0);
        transition: transform 0.5s;
    }

    .control-btn:active::after {
        transform: translate(-50%, -50%) scale(1.5);
    }

    .control-btn:active {
        transform: scale(0.92);
        box-shadow: 0 3px 10px rgba(102, 126, 234, 0.6);
    }

    .control-row {
        display: flex;
        gap: 10px;
        justify-content: center;
    }
}

/* MÓVIL - Menos de 600px */
@media (max-width: 599px) {
    .game-wrapper {
        padding: 8px;
        gap: 10px;
    }

    .game-container {
        position: relative;
        width: 100%;
        max-width: 500px;
        aspect-ratio: 1;
        background: linear-gradient(135deg, #0d1117, #161b22);
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
        border: 2px solid rgba(102, 126, 234, 0.3);
    }

    canvas {
        width: 100%;
        height: 100%;
        display: block;
    }

    .game-over {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: rgba(0, 0, 0, 0.95);
        padding: 0;
        border-radius: 12px;
        display: none;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
        border: 2px solid rgba(230, 57, 70, 0.5);
        z-index: 100;
        width: 90%;
        max-width: 320px;
    }

    .game-over.active {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .game-over-content {
        text-align: center;
        padding: 24px 30px;
    }

    .game-over-content h2 {
        font-size: 24px;
        margin-bottom: 10px;
        color: #e63946;
        text-shadow: 0 2px 8px rgba(230, 57, 70, 0.5);
    }

    .game-over-content p {
        font-size: 14px;
        margin-bottom: 16px;
        color: #adb5bd;
    }

    .game-over-content button {
        padding: 10px 20px;
        background: linear-gradient(135deg, #e63946, #d62839);
        color: #fff;
        border: none;
        border-radius: 8px;
        font-size: 15px;
        font-weight: bold;
        cursor: pointer;
        transition: all 0.2s ease;
        box-shadow: 0 4px 12px rgba(230, 57, 70, 0.4);
    }

    .game-over-content button:active {
        transform: scale(0.95);
        box-shadow: 0 2px 6px rgba(230, 57, 70, 0.6);
    }

    /* Controles móviles */
    .mobile-controls {
        display: flex;
        flex-direction: column;
        gap: 8px;
        align-items: center;
        justify-content: center;
        width: 100%;
    }

    .control-btn {
        width: 55px;
        height: 55px;
        background: linear-gradient(135deg, #667eea, #764ba2);
        border: none;
        border-radius: 10px;
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        transition: all 0.2s ease;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
        display: flex;
        justify-content: center;
        align-items: center;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .control-btn:active {
        transform: scale(0.92);
        box-shadow: 0 2px 6px rgba(102, 126, 234, 0.6);
    }

    .control-row {
        display: flex;
        gap: 8px;
        justify-content: center;
    }
}

/* MÓVIL PEQUEÑO - Menos de 480px */
@media (max-width: 479px) {
    .game-wrapper {
        padding: 5px;
        gap: 8px;
    }

    .game-container {
        width: 95vw;
        max-width: 420px;
    }

    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 18px;
        border-radius: 8px;
    }

    .game-over {
        width: 85%;
        max-width: 290px;
    }

    .game-over-content {
        padding: 20px 25px;
    }

    .game-over-content h2 {
        font-size: 20px;
        margin-bottom: 8px;
    }

    .game-over-content p {
        font-size: 13px;
        margin-bottom: 14px;
    }

    .game-over-content button {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* MÓVIL MUY PEQUEÑO - Menos de 360px */
@media (max-width: 359px) {
    .game-container {
        width: 95vw;
        max-width: 380px;
    }

    .control-btn {
        width: 48px;
        height: 48px;
        font-size: 16px;
    }

    .control-row {
        gap: 6px;
    }

    .game-over {
        width: 90%;
        max-width: 280px;
    }

    .game-over-content {
        padding: 18px 22px;
    }

    .game-over-content h2 {
        font-size: 18px;
    }

    .game-over-content p {
        font-size: 12px;
    }

    .game-over-content button {
        padding: 8px 14px;
        font-size: 12px;
    }
}
