/* ====== BACKGROUND CANVAS (Enhanced Cyberpunk Effects with more layers and glitch) ====== */
#bgCanvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% 50%, rgba(45, 10, 60, 0.9) 0%, rgba(8, 2, 10, 1) 80%),
                radial-gradient(circle at 25% 25%, rgba(255, 0, 180, 0.12) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(0, 200, 255, 0.10) 0%, transparent 55%),
                radial-gradient(circle at 70% 70%, rgba(170, 80, 255, 0.08) 0%, transparent 60%),
                radial-gradient(circle at 40% 80%, var(--accent-color) 0%, transparent 40%); /* Added accent layer */
    background-blend-mode: overlay, screen, lighten, lighten, color-dodge;
    animation: bgPulse 15s infinite alternate ease-in-out, bgShift 50s infinite ease-in-out, glitchBg 5s infinite steps(1);
}
@keyframes glitchBg {
    0% { transform: skew(0deg); }
    5% { transform: skew(2deg); }
    10% { transform: skew(-1deg); }
    15% { transform: skew(1deg); }
    20% { transform: skew(0deg); }
    100% { transform: skew(0deg); }
}
@keyframes bgPulse {
    0% { opacity: 0.85; filter: brightness(1) saturate(1.1); }
    50% { opacity: 1; filter: brightness(1.1) saturate(1.3); }
    100% { opacity: 0.85; filter: brightness(1) saturate(1.1); }
}
@keyframes bgShift {
    0% { background-position: 50% 50%, 20% 25%, 80% 20%, 75% 75%, 40% 80%; }
    50% { background-position: 52% 48%, 24% 27%, 76% 18%, 71% 71%, 42% 78%; }
    100% { background-position: 50% 50%, 20% 25%, 80% 20%, 75% 75%, 40% 80%; }
}
#bgCanvas::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 100%),
                radial-gradient(circle at 60% 40%, rgba(255, 0, 255, 0.03) 0%, transparent 60%);
    mix-blend-mode: screen;
    animation: particlesDrift 80s infinite linear, glitchParticles 4s infinite steps(1);
}
@keyframes glitchParticles {
    0% { clip-path: inset(0 0 0 0); }
    5% { clip-path: inset(2% 0 5% 0); }
    10% { clip-path: inset(1% 0 3% 0); }
    15% { clip-path: inset(0 0 0 0); }
    100% { clip-path: inset(0 0 0 0); }
}
@keyframes particlesDrift {
    0% { transform: translate(0, 0) scale(1); opacity: 0.4; }
    50% { transform: translate(70px, 25px) scale(1.06); opacity: 0.45; }
    100% { transform: translate(0, 0) scale(1); opacity: 0.4; }
}
#bgCanvas::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 40% 60%, rgba(255, 0, 200, 0.06), transparent 70%);
    mix-blend-mode: color-dodge;
    animation: glowShift 35s infinite alternate ease-in-out, glowPulse 8s infinite alternate;
}
@keyframes glowPulse {
    0% { filter: brightness(1); }
    100% { filter: brightness(1.2); }
}
@keyframes glowShift {
    0% { transform: translate(0,0) scale(1); opacity: 0.35; }
    50% { transform: translate(35px,-35px) scale(1.06); opacity: 0.55; }
    100% { transform: translate(0,0) scale(1); opacity: 0.35; }
}

/* ====== APP CONTAINER (Added hover scale and neon border) ====== */
#app {
    position: relative;
    z-index: 10;
    isolation: isolate;
    width: min(100% - 48px, 1300px);
    margin: 48px auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-rows: auto 1fr;
    gap: 1.5rem 2rem;
    background: linear-gradient(135deg, rgba(18,13,25,0.72), rgba(22,15,30,0.5));
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--shadow-dark), 0 0 40px var(--neon-glow-primary), inset 0 0 0.5px rgba(255,255,255,0.25);
    backdrop-filter: blur(12px) saturate(160%);
    transform: translateZ(0);
    will-change: transform, box-shadow, backdrop-filter;
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
    contain: layout style paint;
    content-visibility: auto;
    contain-intrinsic-size: 800px;
}
#app:hover {
    transform: scale(1.015) translateZ(0);
    box-shadow: 0 12px 48px var(--shadow-dark), 0 0 65px var(--neon-glow-primary), inset 0 0 1px rgba(255,255,255,0.38);
    border-color: var(--neon-glow-secondary);
}
#app:focus-within {
    outline: 2px solid rgba(156, 39, 176, 0.55);
    outline-offset: 4px;
    box-shadow: 0 0 20px var(--accent-color);
}
@media (max-width: 1200px) {
    #app { max-width: 1100px; }
}
@media (max-width: 960px) {
    #bgCanvas {
        animation: none !important;
    }
    #app {
        backdrop-filter: none !important;
        grid-template-columns: 1fr !important;
        grid-template-rows: auto 1fr auto;
        margin: 24px auto;
        padding: 1.5rem;
    }
}

/* ====== MAIN & STATS PANELS (Added smooth scroll and overscroll effects) ====== */
.main-content, .stats-panel-container {
    overflow-y: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    will-change: scroll-position, opacity;
    transform: translateZ(0);
    contain: layout paint;
    overscroll-behavior: contain; /* Prevent overscroll bleed */
}
.stats-panel-container {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    position: sticky;
    top: 48px;
    height: calc(100vh - 96px);
}
@media (max-width: 960px) {
    .stats-panel-container {
        position: relative;
        height: auto;
        top: 0;
        grid-column: 1 / -1;
        grid-row: auto;
    }
}
header { grid-column: 1 / -1; grid-row: 1 / 2; }

/* ====== HEADER (Enhanced animation with glitch effect) ====== */
header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    min-height: 150px;
}
h1 {
    font-family: var(--font-title);
    color: var(--primary-color);
    font-size: 1.9rem;
    margin: 0;
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    user-select: none;
    text-align: center;
    animation: softMove 3s ease-in-out infinite, glitchText 4s infinite steps(1);
}
@keyframes glitchText {
    0% { text-shadow: 2px 0 0 var(--secondary-color), -2px 0 0 var(--error-color); }
    5% { text-shadow: -2px 0 0 var(--secondary-color), 2px 0 0 var(--error-color); }
    10% { text-shadow: 2px 0 0 var(--secondary-color), -2px 0 0 var(--error-color); }
    15% { text-shadow: none; }
    100% { text-shadow: none; }
}
@keyframes softMove {
    0% { transform: translate(0, 0) skewX(0deg); }
    20% { transform: translate(-1px, 1px) skewX(0.5deg); }
    40% { transform: translate(1px, -1px) skewX(-0.5deg); }
    60% { transform: translate(-0.5px, 0.5px) skewX(0.3deg); }
    80% { transform: translate(0.5px, -0.5px) skewX(-0.3deg); }
    100% { transform: translate(0, 0) skewX(0deg); }
}
h1::after {
    content: "";
    height: 2px;
    flex: 1;
    background: linear-gradient(90deg, transparent, rgba(187,134,252,0.48), transparent);
    margin-left: 10px;
    border-radius: 2px;
    animation: glowLine 10s infinite linear;
}
.subtitle { font-size: 0.95rem; color: var(--text-muted); margin-top: 2px; }
.instructions-btn { position: absolute; top: 0px; right: 0px; background: rgba(187,134,252,0.12); border: 1px solid rgba(187,134,252,0.22); color: var(--primary-color); width: 36px; height: 36px; border-radius: 50%; font-size: 1.3rem; font-weight: bold; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--transition-fast); box-shadow: 0 0 12px var(--neon-glow-primary); }
.instructions-btn:hover { background: rgba(187,134,252,0.22); box-shadow: 0 0 18px var(--neon-glow-primary); transform: scale(1.08) rotate(5deg); }

/* ====== FOOTER ====== */
.footer { display:flex; align-items:center; justify-content:space-between; gap:12px; color: rgba(230,230,230,0.55); font-size:0.86rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid rgba(187,134,252,0.12); flex-wrap: wrap; }

/* ====== LOGIN PANEL CENTERING ====== */
#app.not-logged-in {
    grid-template-rows: auto auto;
}
.welcome-info-panel-container {
    align-items: flex-start;
}
.main-content .panel[v-if="!isLoggedIn"]:focus-within {
    border-color: rgba(3, 218, 198, 0.45);
    box-shadow:
        0 8px 35px rgba(0,0,0,0.65),
        0 0 35px rgba(3, 218, 198, 0.32),
        inset 0 0 18px rgba(3, 218, 198, 0.12);
    transition: all 0.3s ease-in-out;
}
.main-content .panel[v-if="!isLoggedIn"] {
    transition: all 0.35s ease-in-out;
}

/* ====== RESPONSIVE (Layout-Specific Overrides) ====== */
@media (max-width: 960px) {
    #app { grid-template-columns: 1fr; grid-template-rows: auto auto; }
    .stats-panel-container { grid-column: 1 / -1; order: 1; position: static; height: auto; }
    .main-content {
        grid-column: 1 / -1;
        order: 2;
        overflow-y: visible;
        padding-right: 0;
    }
}
@media (max-width: 768px) {
    #app {
        width: 100%;
        margin: 0;
        padding: 1rem 1rem 40px 1rem;
        border-radius: 0;
        height: auto;
        overflow-y: visible;
    }
    header { gap: 4px; }
    h1 { font-size: 1.4rem; gap: 8px; }
    h1::after { display: none; }
    .subtitle { font-size: 0.85rem; }
    .footer { flex-direction: column; align-items: center; text-align: center; gap: 6px; }
    .instructions-btn { top: -5px; right: -5px; width: 32px; height: 32px; font-size: 1.1rem; }
}