/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #0b0e17;
    color: #e0e0e0;
    line-height: 1.6;
    overflow-x: hidden;
    transition: background 0.3s, color 0.3s;
}

/* Dark mode (default) */
:root {
    --bg-primary: #0b0e17;
    --bg-secondary: #131826;
    --bg-card: rgba(25, 30, 48, 0.75);
    --bg-glass: rgba(20, 25, 45, 0.6);
    --text-primary: #e8e8f0;
    --text-secondary: #a0a8c0;
    --accent: #f77b5e;
    --accent2: #d946ef;
    --accent3: #3b82f6;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: 0.3s ease;
}

/* Light mode */
@media (prefers-color-scheme: light) {
    :root {
        --bg-primary: #f0f2f8;
        --bg-secondary: #ffffff;
        --bg-card: rgba(255, 255, 255, 0.75);
        --bg-glass: rgba(255, 255, 255, 0.5);
        --text-primary: #1a1d2e;
        --text-secondary: #5a5f7a;
        --accent: #e85d3a;
        --accent2: #b825d6;
        --accent3: #2563eb;
        --border: rgba(0, 0, 0, 0.08);
        --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #d95a3e;
}

/* ============ LAYOUT ============ */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    transition: background 0.3s;
}

nav {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    flex-wrap: wrap;
    gap: 0.5rem;
}

nav h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent2), var(--accent3));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 1px;
    text-shadow: none;
    white-space: nowrap;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    align-items: center;
}

nav ul li a {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 0.4rem 0.9rem;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    background: transparent;
    backdrop-filter: none;
    border: 1px solid transparent;
    white-space: nowrap;
}

nav ul li a:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(247, 123, 94, 0.3);
    transform: translateY(-2px);
}

/* Main grid */
main {
    max-width: 1280px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 2rem;
    flex: 1;
}

@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }
    aside {
        order: 2;
    }
}

/* ============ SECTIONS ============ */
section {
    margin-bottom: 3rem;
    animation: fadeUp 0.8s ease both;
}

section h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============ CARDS ============ */
article {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius);
    padding: 1.2rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

article:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(247, 123, 94, 0.2);
    border-color: var(--accent);
}

article img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 0.6rem;
    background: linear-gradient(145deg, #1e2438, #0b0e17);
    transition: transform 0.4s ease;
}

article:hover img {
    transform: scale(1.02);
}

article h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.2rem 0;
}

article p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ============ HOT SECTION (grid) ============ */
#hot {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.2rem;
}
#hot h2 {
    grid-column: 1 / -1;
    margin-bottom: 0.5rem;
}

/* ============ RECOMMEND SECTION ============ */
#recommend {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
}
#recommend h2 {
    grid-column: 1 / -1;
}

/* ============ DETAIL ============ */
#detail article {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-start;
}
#detail article img {
    width: 220px;
    aspect-ratio: 3/4;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
}
#detail article > *:not(img) {
    flex: 1 1 300px;
}
#detail article h3 {
    font-size: 1.6rem;
    margin-bottom: 0.3rem;
}
#detail article p {
    margin-bottom: 0.3rem;
    line-height: 1.7;
}

/* ============ CHARACTERS ============ */
#characters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.2rem;
}
#characters h2 {
    grid-column: 1 / -1;
}
#characters article img {
    aspect-ratio: 1/1;
    border-radius: 50%;
    width: 80%;
    margin: 0 auto 0.8rem;
    object-fit: cover;
}
#characters article h3 {
    text-align: center;
}
#characters article p {
    text-align: center;
}

/* ============ PLATFORM ============ */
#platform p {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    line-height: 1.8;
}

/* ============ APP ============ */
#app {
    text-align: center;
    background: linear-gradient(145deg, rgba(247, 123, 94, 0.1), rgba(217, 70, 239, 0.08));
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
}
#app h2 {
    border-bottom: none;
}
#app p {
    max-width: 600px;
    margin: 0 auto 1.5rem;
    color: var(--text-secondary);
}
#app button {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.8rem 2rem;
    border-radius: 40px;
    margin: 0.3rem 0.5rem;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 4px 20px rgba(247, 123, 94, 0.3);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.15);
}
#app button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 28px rgba(247, 123, 94, 0.5);
}

/* ============ REVIEWS ============ */
#reviews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}
#reviews h2 {
    grid-column: 1 / -1;
}
#reviews article {
    padding: 1rem;
    gap: 0.2rem;
}
#reviews article p:first-child {
    font-weight: 600;
    color: var(--accent);
}
#reviews article p:nth-child(2) {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* ============ ASIDE ============ */
aside {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    height: fit-content;
    position: sticky;
    top: 100px;
    transition: all var(--transition);
}
aside:hover {
    border-color: var(--accent);
}
aside h2 {
    font-size: 1.2rem;
    margin: 1rem 0 0.6rem;
    border-bottom: 1px solid var(--accent);
    padding-bottom: 0.3rem;
    background: linear-gradient(135deg, var(--accent2), var(--accent3));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
}
aside h2:first-child {
    margin-top: 0;
}
aside ol {
    padding-left: 1.2rem;
    color: var(--text-secondary);
    line-height: 1.9;
}
aside ol li {
    transition: color 0.2s;
}
aside ol li:hover {
    color: var(--accent);
    cursor: default;
}
aside p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0.3rem 0;
}

/* ============ FOOTER ============ */
footer {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 2rem 1.5rem;
    margin-top: auto;
    text-align: center;
}
footer h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}
footer ul {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.2rem;
    margin-bottom: 1.2rem;
}
footer ul li a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}
footer ul li a:hover {
    color: var(--accent);
}
footer p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.7;
    margin: 0.2rem 0;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    nav {
        flex-direction: column;
        align-items: flex-start;
    }
    nav ul {
        width: 100%;
        justify-content: center;
        gap: 0.2rem;
        margin-top: 0.3rem;
    }
    nav ul li a {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }
    main {
        padding: 0 1rem;
        margin: 1rem auto;
        gap: 1.5rem;
    }
    #hot {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.8rem;
    }
    #recommend {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    #characters {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
    #reviews {
        grid-template-columns: 1fr;
    }
    #detail article {
        flex-direction: column;
    }
    #detail article img {
        width: 100%;
        max-width: 300px;
    }
    aside {
        position: static;
        margin-top: 1rem;
    }
    section h2 {
        font-size: 1.4rem;
    }
    #app button {
        display: block;
        width: 80%;
        margin: 0.5rem auto;
    }
}

@media (max-width: 480px) {
    nav h1 {
        font-size: 1.4rem;
    }
    #hot {
        grid-template-columns: repeat(2, 1fr);
    }
    #recommend {
        grid-template-columns: 1fr;
    }
    #characters {
        grid-template-columns: repeat(2, 1fr);
    }
    article {
        padding: 0.8rem;
    }
    article h3 {
        font-size: 1rem;
    }
}

/* ============ ANIMATIONS ============ */
@keyframes fadeUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scroll-triggered fade (via Intersection Observer fallback - pure CSS only for demo) */
section, aside, footer {
    animation: fadeUp 0.8s ease both;
}
section:nth-child(2) { animation-delay: 0.1s; }
section:nth-child(3) { animation-delay: 0.2s; }
section:nth-child(4) { animation-delay: 0.3s; }
section:nth-child(5) { animation-delay: 0.4s; }
section:nth-child(6) { animation-delay: 0.5s; }
section:nth-child(7) { animation-delay: 0.6s; }
aside { animation-delay: 0.3s; }

/* Gradient banner effect for header */
header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent2), var(--accent3), var(--accent));
    background-size: 300% 100%;
    animation: gradientMove 4s linear infinite;
    z-index: 10;
}
@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

/* Extra hover effects on cards */
article {
    position: relative;
    overflow: hidden;
}
article::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 30%, rgba(247,123,94,0.05), transparent 60%);
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}
article:hover::before {
    opacity: 1;
}

/* Smooth image loading */
img {
    transition: opacity 0.4s;
}
img[loading="lazy"] {
    opacity: 0.9;
}
img[loading="lazy"]:not([src]) {
    opacity: 0;
}