:root {
    --bg-color: #0f0f1e;
    --panel-bg: rgba(15, 23, 42, 0.5);
    --accent-primary: #06b6d4;
    --accent-secondary: #f43f5e;
    --accent-gold: #22c55e;
    --text-color: #ffffff;
    --glass-border: rgba(6, 182, 212, 0.3);
    --glow-primary: rgba(6, 182, 212, 0.8);
    --glow-secondary: rgba(244, 63, 94, 0.8);
    
    /* Colores dinámicos para fondo */
    --bg-accent-1: rgba(6, 182, 212, 0.01);
    --bg-accent-2: rgba(244, 63, 94, 0.08);
    --bg-accent-3: rgba(6, 182, 212, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image: 
        repeating-linear-gradient(
            0deg,
            var(--bg-accent-1) 0px,
            var(--bg-accent-1) 1px,
            transparent 1px,
            transparent 2px
        ),
        radial-gradient(ellipse at 20% 50%, var(--bg-accent-2) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, var(--bg-accent-3) 0%, transparent 50%);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Efecto de vignette global */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(10, 14, 39, 0.8) 100%);
    pointer-events: none;
    z-index: 1;
}

#hud {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    z-index: 10;
    pointer-events: none;
}

.stat-box {
    background: rgba(20, 35, 70, 0.6);
    backdrop-filter: blur(8px);
    padding: 15px 30px;
    border-radius: 15px;
    border: 2px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 
        0 0 15px rgba(6, 182, 212, 0.4),
        inset 0 0 15px rgba(6, 182, 212, 0.1);
    pointer-events: auto;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.shop-trigger {
    cursor: pointer;
    transition: all 0.3s ease;
}

.shop-trigger:hover {
    transform: scale(1.1);
    border-color: var(--accent-gold);
    box-shadow: 0 0 25px rgba(34, 197, 94, 0.5);
}

.shop-icon {
    font-size: 2rem;
    margin-top: 5px;
    animation: float 2s ease-in-out infinite;
}

.hud-menu-button {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 11;
    width: 76px;
    min-height: 82px;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #fff;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 800;
    background: rgba(20, 35, 70, 0.9);
    border: 2px solid var(--glass-border);
    border-radius: 15px;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.4), inset 0 0 15px rgba(6, 182, 212, 0.1);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.hud-menu-button:hover,
.hud-menu-button:focus-visible {
    transform: translateY(-2px);
    border-color: var(--accent-secondary);
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.45);
    outline: none;
}

.hud-menu-icon {
    width: 30px;
    height: 30px;
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (max-width: 900px) {
    .hud-menu-button {
        top: 132px;
        right: 12px;
        width: 64px;
        min-height: 72px;
    }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

/* Estilos para el modal de la tienda */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 30, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: rgba(20, 35, 70, 0.9);
    backdrop-filter: blur(20px);
    padding: 30px;
    border-radius: 20px;
    border: 2px solid var(--glass-border);
    box-shadow: 0 0 30px rgba(6, 182, 212, 0.4);
    width: min(94vw, 1100px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.shop-items {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
    max-height: 65vh;
    min-height: 0;
    overflow-y: auto;
    padding-right: 6px;
}

.shop-category {
    grid-column: 1 / -1;
    margin: 18px 0 0;
    padding-bottom: 4px;
    color: #06b6d4;
    font-size: 0.95rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(6, 182, 212, 0.35);
}

.shop-category:first-child {
    margin-top: 0;
}

.shop-item {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.shop-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    border-color: var(--accent-gold);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.3);
}

.shop-item h3 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    color: var(--accent-gold);
}

.shop-item p {
    margin: 0 0 15px 0;
    color: #ccc;
    font-size: 0.9rem;
    line-height: 1.4;
}

.shop-item-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: auto;
}

.price-tag {
    background: linear-gradient(135deg, var(--accent-gold), #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    font-size: 1.1rem;
}

.buy-btn {
    background: linear-gradient(135deg, var(--accent-gold), #f59e0b);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.buy-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.6);
}

.buy-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

@media (max-width: 900px) {
    .shop-items {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .modal-content {
        width: 96vw;
        max-height: 94vh;
        padding: 20px;
    }

    .shop-items {
        grid-template-columns: minmax(0, 1fr);
        max-height: 75vh;
    }
}

.hidden {
    display: none !important;
}

.pause-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
}

.pause-content {
    width: min(100%, 430px);
    padding: 32px 28px;
    text-align: center;
    background: rgba(15, 23, 42, 0.94);
    border: 2px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 0 30px rgba(6, 182, 212, 0.25);
}

.pause-status {
    color: var(--accent-primary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 3px;
}

.pause-content h2 {
    margin: 8px 0;
    font-size: clamp(2.5rem, 10vw, 4rem);
    font-weight: 900;
    letter-spacing: 5px;
}

.pause-content > p:not(.pause-status) {
    color: #cbd5e1;
}

.pause-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 24px;
}

.pause-button {
    padding: 11px 16px;
    color: #fff;
    font: inherit;
    font-weight: 800;
    background: rgba(20, 35, 70, 0.9);
    border: 1px solid var(--glass-border);
    border-radius: 9px;
    cursor: pointer;
}

.pause-button:hover,
.pause-button:focus-visible {
    border-color: var(--accent-primary);
    outline: none;
}

.pause-button-primary {
    background: linear-gradient(135deg, var(--accent-primary), #0891b2);
}

.pause-button kbd {
    margin-left: 5px;
    padding: 2px 5px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 4px;
    font: inherit;
    font-size: 0.7rem;
}

.shop-pause-label {
    margin-left: auto;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.game-paused #gameCanvas {
    pointer-events: none;
}

body.rage-mode::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 52%, rgba(220, 38, 38, 0.12) 78%, rgba(220, 38, 38, 0.42) 100%);
    box-shadow: inset 0 0 80px rgba(220, 38, 38, 0.35);
}

body.rage-mode #gameCanvas {
    cursor: none;
}

.rage-indicator {
    display: inline-block;
    margin-left: 5px;
    padding: 2px 6px;
    color: #fff;
    background: #be123c;
    border-radius: 999px;
    font-size: 0.65rem;
    letter-spacing: 1px;
    vertical-align: 1px;
}

.stat-box::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%); }
    100% { transform: translateX(100%) translateY(100%); }
}

.stat-box:hover {
    border-color: var(--accent-secondary);
    box-shadow: 
        0 0 25px rgba(244, 63, 94, 0.5),
        inset 0 0 15px rgba(244, 63, 94, 0.15);
    transform: translateY(-5px);
}

.stat-box .label {
    font-size: 0.7rem;
    color: var(--accent-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 5px;
    font-weight: 700;
    text-shadow: 0 0 10px var(--glow-secondary);
}

.stat-box .value {
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px var(--glow-primary);
    animation: valuePulse 0.5s ease-out;
}

canvas {
    position: relative;
    z-index: 2;
    display: block;
    width: 100vw;
    height: 100vh;
    cursor: crosshair;
}

#game-over {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 15, 30, 0.95);
    backdrop-filter: blur(25px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: all 0.3s ease;
}

#game-over.hidden {
    display: none;
    opacity: 0;
}

.overlay-content {
    text-align: center;
    animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 1001;
}

@keyframes popIn {
    0% { 
        transform: scale(0.3) rotateZ(-5deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotateZ(2deg);
    }
    100% { 
        transform: scale(1) rotateZ(0deg);
        opacity: 1; 
    }
}

.overlay-content h2 {
    font-size: 4rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(244, 63, 94, 0.6);
    font-weight: 900;
    letter-spacing: 3px;
    animation: textGlitch 0.5s ease;
}

@keyframes textGlitch {
    0%, 100% { text-shadow: 0 0 30px rgba(244, 63, 94, 0.6); }
    50% { text-shadow: 0 0 50px rgba(6, 182, 212, 0.8), -3px 0 0 rgba(244, 63, 94, 0.4), 3px 0 0 rgba(6, 182, 212, 0.4); }
}

.overlay-content p {
    font-size: 1.2rem;
    color: var(--accent-secondary);
    margin-bottom: 30px;
    letter-spacing: 1px;
    text-shadow: 0 0 15px var(--glow-secondary);
}

.overlay-content button {
    margin-top: 20px;
    padding: 15px 50px;
    background: linear-gradient(135deg, var(--accent-secondary), #ec4899);
    color: white;
    border: 2px solid var(--accent-secondary);
    border-radius: 10px;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.5);
    position: relative;
    overflow: hidden;
}

.overlay-content button::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.overlay-content button:hover {
    background: linear-gradient(135deg, #ec4899, var(--accent-secondary));
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 0 30px rgba(244, 63, 94, 0.8), inset 0 0 20px rgba(255, 255, 255, 0.15);
}

.overlay-content button:hover::before {
    left: 100%;
}

.overlay-content button:active {
    transform: scale(0.98) translateY(0);
}

.bar-container {
    width: 220px;
    align-items: stretch !important;
}

.bar-bg {
    width: 100%;
    height: 16px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    margin-top: 8px;
    overflow: hidden;
    border: 2px solid rgba(6, 182, 212, 0.35);
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.9);
    position: relative;
}

.bar-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 2px,
        rgba(255, 255, 255, 0.05) 2px,
        rgba(255, 255, 255, 0.05) 4px
    );
    pointer-events: none;
}

#bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-secondary), #fb7185, var(--accent-secondary));
    background-size: 200% 100%;
    box-shadow: 
        0 0 12px rgba(244, 63, 94, 0.7),
        inset 0 0 6px rgba(255, 255, 255, 0.2);
    transition: width 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: barFill 1s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

#bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: barShine 2s infinite;
}

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

@keyframes barShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

#level-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), #4ade80, var(--accent-gold));
    background-size: 200% 100%;
    box-shadow: 
        0 0 12px rgba(34, 197, 94, 0.8),
        inset 0 0 6px rgba(255, 255, 255, 0.2);
    transition: width 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: levelFill 1s ease-in-out infinite;
    position: relative;
}

#level-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: barShine 2s infinite reverse;
}

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

.level-bar {
    border-color: rgba(34, 197, 94, 0.5) !important;
}

/* =============== ANIMACIONES JUICY GLOBALES =============== */

@keyframes score-pop {
    0% { 
        transform: scale(1) translateY(0);
        opacity: 1;
    }
    50% { 
        transform: scale(1.25) translateY(-10px);
        opacity: 1;
    }
    100% { 
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes valuePulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
        text-shadow: 0 0 30px var(--glow-primary), 0 0 60px var(--glow-secondary);
    }
    100% {
        transform: scale(1);
    }
}

.score-pop {
    animation: score-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

#puntos {
    display: inline-block;
}

/* Animación de entrada suave */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

body {
    animation: fadeInScale 0.5s ease-out;
}

/* Efectos en los inputs */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 0, 110, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(255, 0, 110, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 110, 0);
    }
}

/* Scrollbar personalizada */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 217, 255, 0.1);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent-primary), var(--accent-gold));
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #67e8f9, #4ade80);
}

#w-points-timer {
    position: fixed;
    top: 22px;
    left: 22px;
    z-index: 25;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    background: rgba(10, 14, 39, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 8px 12px;
    box-shadow: 0 0 18px rgba(34, 197, 94, 0.45);
}

.w-points-badge {
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #86efac;
    font-weight: 800;
}

#w-points-time {
    font-size: 1.1rem;
    font-weight: 900;
    color: #e2f7d8;
    text-shadow: 0 0 12px rgba(34, 197, 94, 0.7);
}
