/* =========================================
   CORE CONFIGURATION & VARIABLES
   ========================================= */
:root {
    /* 霓虹复古配色方案 */
    --primary-color: #ff00ff; /* 霓虹粉 */
    --secondary-color: #00ffff; /* 赛博蓝 */
    --accent-color: #ffff00; /* 电光黄 */
    --bg-dark: #0a0a12; /* 深邃黑 */
    --bg-card: rgba(255, 255, 255, 0.05);
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    
    /* 尺寸与间距 */
    --nav-height: 80px;
    --container-width: 1200px;
    --card-gap: 2rem;
    
    /* 字体 */
    --font-pixel: 'Courier New', monospace; /* 降级方案，实际可引入 Press Start 2P */
    --font-body: 'Segoe UI', system-ui, sans-serif;
    
    /* 动画与特效 */
    --glass-blur: 10px;
    --transition-speed: 0.3s;
    --glow-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color);
}

/* =========================================
   GLOBAL RESET & UTILITIES
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    cursor: none; /* 隐藏默认光标，使用自定义光标 */
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    overflow-x: hidden;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

/* =========================================
   CUSTOM CURSOR
   ========================================= */
.cursor-dot,
.cursor-outline {
    position: fixed;
    top: 0;
    left: 0;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    z-index: 9999;
    pointer-events: none;
}

.cursor-dot {
    width: 8px;
    height: 8px;
    background-color: var(--secondary-color);
}

.cursor-outline {
    width: 40px;
    height: 40px;
    border: 2px solid var(--primary-color);
    transition: width 0.2s, height 0.2s, background-color 0.2s;
}

body:hover .cursor-outline {
    opacity: 1;
}

/* 悬停时的光标变形 */
.hover-active .cursor-outline {
    width: 60px;
    height: 60px;
    background-color: rgba(255, 0, 255, 0.1);
    border-color: var(--secondary-color);
}

/* =========================================
   BACKGROUND ANIMATION
   ========================================= */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.6;
}

/* =========================================
   3D FLOATING HEADER
   ========================================= */
header {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: var(--container-width);
    height: var(--nav-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    background: rgba(20, 20, 30, 0.6);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    z-index: 100;
    transition: transform 0.3s ease, width 0.3s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

header.scrolled {
    width: 95%;
    top: 10px;
    background: rgba(10, 10, 10, 0.9);
}

.logo {
    font-family: var(--font-pixel);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--secondary-color);
    text-shadow: 2px 2px 0 var(--primary-color);
    letter-spacing: 2px;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links li a {
    position: relative;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: color 0.3s;
}

.nav-links li a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.3s;
    box-shadow: 0 0 5px var(--primary-color);
}

.nav-links li a:hover,
.nav-links li a.active {
    color: var(--secondary-color);
}

.nav-links li a:hover::after,
.nav-links li a.active::after {
    width: 100%;
}

/* Mobile Menu Icon (Hidden on Desktop) */
.mobile-menu-icon {
    display: none;
}

/* =========================================
   HERO SECTION
   ========================================= */
.hero {
    height: 60vh;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    padding: 80px 1rem 0;
    perspective: 1000px;
}

.hero-content {
    z-index: 1;
    transform-style: preserve-3d;
}

.hero h1 {
    font-family: var(--font-pixel);
    font-size: clamp(2rem, 8vw, 5rem);
    line-height: 1.1;
    margin-bottom: 1.5rem;
    background: linear-gradient(90deg, var(--secondary-color), var(--text-main), var(--primary-color));
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientText 3s linear infinite;
}

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

.hero p {
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: var(--text-muted);
    margin-bottom: 3rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* 3D Button */
.btn-3d {
    display: inline-block;
    padding: 1rem 3rem;
    font-family: var(--font-pixel);
    font-size: 1rem;
    color: var(--bg-dark);
    background: var(--secondary-color);
    border: none;
    position: relative;
    transition: transform 0.1s;
    transform-style: preserve-3d;
    box-shadow: 0 0 0 4px rgba(0, 255, 255, 0.2);
    text-transform: uppercase;
    font-weight: bold;
}

.btn-3d::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    transform: translate(6px, 6px);
    z-index: -1;
    transition: transform 0.1s;
}

.btn-3d:hover {
    transform: translate(-2px, -2px);
}

.btn-3d:hover::before {
    transform: translate(10px, 10px);
}

.btn-3d:active {
    transform: translate(4px, 4px);
}

.btn-3d:active::before {
    transform: translate(2px, 2px);
}

/* Floating Decorations */
.floating-element {
    position: absolute;
    pointer-events: none;
    animation: float 6s ease-in-out infinite;
    opacity: 0.8;
}

.float-1 { top: 20%; left: 10%; width: 60px; height: 60px; border: 2px solid var(--primary-color); transform: rotate(45deg); }
.float-2 { bottom: 20%; right: 10%; width: 40px; height: 40px; background: var(--secondary-color); clip-path: polygon(50% 0%, 0% 100%, 100% 100%); }
.float-3 { top: 30%; right: 20%; font-size: 3rem; color: var(--accent-color); font-family: var(--font-pixel); }

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(10deg); }
}

/* =========================================
   STATS BAR (Real-time Dashboard)
   ========================================= */
.stats-bar {
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem 0;
    overflow: hidden;
    white-space: nowrap;
}

.stats-content {
    display: inline-block;
    animation: scrollStats 20s linear infinite;
}

.stat-item {
    display: inline-block;
    margin: 0 2rem;
    font-family: var(--font-pixel);
    font-size: 0.9rem;
}

.stat-value {
    color: var(--secondary-color);
    margin-left: 0.5rem;
}

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

/* =========================================
   NEW SECTIONS: CATEGORIES & NEW ARRIVALS
   ========================================= */
.categories-section, .new-arrivals-section {
    padding: 3rem 1rem;
    max-width: var(--container-width);
    margin: 0 auto;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    justify-content: center;
}

.category-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.category-card:hover {
    border-color: var(--secondary-color);
    background: rgba(0, 255, 255, 0.1);
    transform: translateY(-5px);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
}

.category-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

.category-name {
    font-family: var(--font-pixel);
    font-size: 0.9rem;
    color: var(--text-main);
}

.category-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* =========================================
   CATEGORY MODULES
   ========================================= */
#category-modules-container {
    padding: 0 1rem;
    max-width: var(--container-width);
    margin: 0 auto;
}

.module-section {
    margin-bottom: 4rem;
}

.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.module-title {
    font-family: var(--font-pixel);
    font-size: 1.5rem;
    color: var(--secondary-color);
    text-transform: uppercase;
}

.view-all-btn {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.3rem 1rem;
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.view-all-btn:hover {
    background: var(--primary-color);
    color: #fff;
}

/* Horizontal Scroll / Grid for Modules */
.module-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.module-card {
    height: 320px;
}

.module-card .card-image {
    height: 200px;
}

/* =========================================
   GAME SHOWCASE (Grid & Cards)
   ========================================= */
.games-section {
    padding: 3rem 1rem 5rem;
    max-width: var(--container-width);
    margin: 0 auto;
}

.section-title {
    font-family: var(--font-pixel);
    font-size: 2rem;
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    display: inline-block;
    left: 50%;
    transform: translateX(-50%);
}

.section-title::after {
    content: '';
    display: block;
    width: 60%;
    height: 4px;
    background: var(--primary-color);
    margin: 0.5rem auto 0;
    box-shadow: 0 0 10px var(--primary-color);
}

/* Filter Tags */
.filter-tags {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.tag-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.tag-btn:hover, .tag-btn.active {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

/* Grid Layout */
.games-grid {
    display: grid;
    grid-template-columns: repeat(4,1fr);
    gap: 2rem;
}

/* 3D Flip Card */
.game-card {
    height: auto; /* Let content dictate height */
    perspective: 1000px;
    opacity: 0; /* JS Fade in */
    transform: translateY(20px);
    transition: opacity 0.6s, transform 0.6s;
    width: 100%; /* Force fill grid column */
    min-width: 0; /* Prevent grid blowout */
}

.game-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%; /* Fill grid item */
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
    cursor: none;
    display: flex; /* Flex to stretch */
    flex-direction: column;
}

.game-card:hover .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    width: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-front {
    position: relative; /* Relative drives height */
    background: #1a1a24;
    display: flex;
    flex-direction: column;
    height: 100%; /* Fill inner */
}

.card-back {
    position: absolute; /* Absolute sits on top */
    top: 0;
    left: 0;
    height: 100%; /* Match front height */
}

.card-image {
    width: 100%;
    height: 180px; /* Fixed height desktop */
    object-fit: cover;
    flex-shrink: 0; /* Prevent shrinking */
    display: block; /* Ensure no inline spacing */
    max-width: 100%; /* Safety check */
}

.card-info {
    padding: 1rem; /* Reduced padding */
    text-align: left;
    flex: 1; /* Occupy remaining space */
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Align to top */
}

.card-info h3 {
    font-family: var(--font-pixel);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-rating {
    color: var(--accent-color);
    font-size: 0.9rem;
}

.card-back {
    background: linear-gradient(135deg, #2a0845, #6441a5);
    color: white;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.card-back h3 {
    font-family: var(--font-pixel);
    margin-bottom: 1rem;
}

.card-back p {
    font-size: 0.9rem;
    margin-bottom: 2rem;
    color: rgba(255, 255, 255, 0.8);
}

.play-btn {
    padding: 0.8rem 2rem;
    background: var(--secondary-color);
    color: #000;
    font-weight: bold;
    border-radius: 30px;
    font-family: var(--font-pixel);
    transition: transform 0.2s, box-shadow 0.2s;
}

.play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--secondary-color);
}

/* =========================================
   FOOTER
   ========================================= */
footer {
    background: #050508;
    padding: 4rem 1rem 2rem;
    margin-top: 4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-content {
    max-width: var(--container-width);
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 3rem;
}

.footer-col h4 {
    font-family: var(--font-pixel);
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.footer-col ul li {
    margin-bottom: 0.8rem;
}

.footer-col ul li a {
    color: var(--text-muted);
    transition: color 0.3s;
}

.footer-col ul li a:hover {
    color: var(--secondary-color);
}

.newsletter-form {
    display: flex;
    gap: 0.5rem;
}

.newsletter-form input {
    flex: 1;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 4px;
}

.newsletter-form button {
    padding: 0 1.2rem;
    background: var(--primary-color);
    border: none;
    color: white;
    font-weight: bold;
    border-radius: 4px;
}

.copyright {
    text-align: center;
    margin-top: 4rem;
    padding-top: 2rem;
    padding-bottom: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* =========================================
   RESPONSIVE (MOBILE)
   ========================================= */
@media (max-width: 768px) {
    :root {
        --nav-height: 60px;
        --container-width: 100%;
    }

    /* 移动端调整字体大小 */
    body {
        font-size: 14px;
    }

    header {
        width: 100%;
        top: 0;
        left: 0; /* Reset left position */
        transform: none; /* Reset transform */
        border-radius: 0;
        padding: 1.5rem 1.5rem; /* Further increased vertical padding */
        position: absolute;
        background: transparent;
        backdrop-filter: none;
        border: none;
        box-shadow: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        z-index: 1000;
        flex-wrap: nowrap; /* Prevent wrapping */
        box-sizing: border-box; /* Ensure padding is included in width */
    }
    
    header.scrolled {
        background: rgba(10, 10, 10, 0.95);
        position: fixed;
        top: 0;
        width: 100%;
        padding: 1rem 1.5rem;
        box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    }
    
    .logo {
        font-size: 1.1rem; /* Reduced logo size */
        white-space: nowrap; /* Prevent wrapping */
        line-height: 1;
    }

    .mobile-menu-icon {
        display: block;
        font-size: 1.5rem; /* Reduced icon size */
        color: var(--secondary-color);
        cursor: pointer;
        z-index: 1001;
        line-height: 1;
    }

    .nav-links {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        height: 100vh;
        background: rgba(5, 5, 8, 0.98);
        padding-top: 5rem;
        padding-left: 2rem;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -5px 0 15px rgba(0,0,0,0.5);
        gap: 2rem;
        z-index: 999;
    }

    .nav-links.active {
        right: 0;
    }

    .nav-links li a {
        font-size: 1.2rem;
        display: block;
        padding: 0.5rem 0;
    }

    .hero {
        height: 40vh; /* Reduced height */
        min-height: 300px;
        padding-top: 60px; /* Space for header */
    }

    .hero h1 {
        font-size: 1.8rem; /* Reduced font size */
        margin-bottom: 0.5rem;
    }

    .hero p {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }

    .module-header {
        align-items: center;
        margin-bottom: 1rem;
    }

    .module-title {
        font-size: 1rem;
        white-space: nowrap;
    }
    
    .view-all-btn {
        font-size: 0.6rem;
        padding: 0.3rem 0.8rem;
        white-space: nowrap;
    }
    
    /* 2 Column Layout for Modules */
    .module-grid, .games-grid {
        grid-template-columns: repeat(2, 1fr); /* Force 2 columns */
        gap: 0.8rem;
    }

    .module-card, .game-card {
        height: auto; /* Ensure flexibility */
        min-height: auto; 
        /* Remove aspect-ratio here too as logic changed */
        width: 100%; /* Force fill column */
        min-width: 0; /* Allow shrinking below content size */
    }

    .module-card .card-image, .game-card .card-image {
        height: 120px; /* Fixed image height on mobile */
        max-width: 100%; /* Ensure image doesn't overflow */
    }

    .module-card .card-info, .game-card .card-info {
        padding: 0.6rem 0.8rem; /* Reduced padding */
    }

    .module-card h3, .game-card h3 {
        font-size: 0.8rem;
        margin-bottom: 0.1rem; /* Reduced margin */
    }
    
    .module-card .card-rating, .game-card .card-rating {
        font-size: 0.7rem;
    }

    footer {
        padding: 3rem 1.5rem 1.5rem;
    }

    .footer-content {
        gap: 1.75rem;
    }

    .newsletter-form {
        flex-direction: column;
        gap: 0.75rem;
    }

    .newsletter-form input {
        width: 100%;
    }

    .newsletter-form button {
        width: 100%;
        padding: 0.85rem 1.2rem;
    }


    .card-back {
        padding: 1rem; /* Reduced padding on back */
    }

    .card-back h3 {
        margin-bottom: 0.5rem; /* Reduced margin */
    }

    .card-back p {
        margin-bottom: 1rem; /* Reduced margin */
        font-size: 0.8rem;
        line-height: 1.4;
    }

    /* Adjust Categories Grid */
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .category-card {
        padding: 0.8rem;
    }

    .category-icon {
        font-size: 1.5rem;
    }
    
    .category-name {
        font-size: 0.7rem;
    }

    .category-count {
        font-size: 0.6rem;
    }
    
    /* 移动端取消光标效果，因为没有鼠标 */
    .cursor-dot, .cursor-outline {
        display: none;
    }
    
    * {
        cursor: auto;
    }

    /* 移动端卡片翻转改为点击或简化交互 */
    .game-card:hover .card-inner {
        transform: none; /* Disable hover flip on mobile for better UX */
    }
    
    .newsletter-form {
        flex-direction: column;
    }
}
