:root {
    --bg-primary: #080d1a;
    --bg-secondary: #0f172a;
    --card-bg: #111827;
    --card-border: rgba(255, 255, 255, 0.1);
    --card-border-hover: rgba(99, 102, 241, 0.5);
    --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
    --card-shadow-hover: 0 20px 35px -5px rgba(99, 102, 241, 0.25);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent-glow: rgba(99, 102, 241, 0.22);
    --accent-color: #6366f1;
    --accent-hover: #4f46e5;
    --tag-bg: rgba(255, 255, 255, 0.08);
    --tag-border: rgba(255, 255, 255, 0.14);
    --badge-bg: rgba(99, 102, 241, 0.18);
    --badge-text: #c7d2fe;
    --grid-line: rgba(255, 255, 255, 0.04);
}

html:not(.dark):not(.dark-mode) {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --card-bg: #ffffff;
    --card-border: rgba(15, 23, 42, 0.1);
    --card-border-hover: rgba(99, 102, 241, 0.4);
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 20px 30px -5px rgba(99, 102, 241, 0.15);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --accent-color: #4f46e5;
    --accent-hover: #4338ca;
    --tag-bg: #f1f5f9;
    --tag-border: #e2e8f0;
    --badge-bg: rgba(99, 102, 241, 0.12);
    --badge-text: #4f46e5;
    --grid-line: rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "HarmonyOS Sans SC", sans-serif;
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 50% 0%, var(--accent-glow) 0%, transparent 60%),
        linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
    background-size: 100% 100%, 32px 32px, 32px 32px;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    transition: background-color 0.2s ease, color 0.2s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.page-wrapper {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 20px 48px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 24px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.nav-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #ec4899);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px;
    border-radius: 9px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.action-btn:hover {
    color: var(--text-primary);
    border-color: var(--card-border-hover);
    transform: translateY(-1px);
}

.action-btn.icon-only {
    width: 38px;
    padding: 0;
}

.hero-banner {
    text-align: center;
    margin: 24px 0 36px;
}

.hero-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 9999px;
    background: var(--badge-bg);
    color: var(--badge-text);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.hero-title {
    font-size: clamp(28px, 5vw, 42px);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: clamp(14px, 2.5vw, 15px);
    color: var(--text-muted);
    max-width: 580px;
    margin: 0 auto;
    line-height: 1.6;
}

.stats-bar {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--tag-bg);
    border: 1px solid var(--tag-border);
    padding: 6px 14px;
    border-radius: 8px;
}

.stat-val {
    font-weight: 700;
    color: var(--text-primary);
}

.filters-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
}

.filters-pills {
    display: flex;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 4px;
    border-radius: 12px;
    gap: 6px;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.filters-pills::-webkit-scrollbar {
    display: none;
}

.filter-tab {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.filter-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.filter-tab.active {
    background: var(--accent-color);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 24px;
}

.game-card {
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--card-shadow);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.25s ease,
                box-shadow 0.25s ease;
    position: relative;
}

.game-card:hover {
    transform: translateY(-6px);
    border-color: var(--card-border-hover);
    box-shadow: var(--card-shadow-hover);
}

.card-preview {
    height: 150px;
    background: #090e1a;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--card-border);
}

.preview-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #1e293b;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
    flex: 1;
}

.tags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.game-tag {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--tag-bg);
    border: 1px solid var(--tag-border);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid var(--card-border);
}

.highscore-label {
    display: flex;
    flex-direction: column;
}

.highscore-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
}

.highscore-value {
    font-size: 14px;
    font-weight: 700;
    color: #f59e0b;
}

.play-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    background: var(--accent-color);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: background 0.15s ease, transform 0.15s ease;
}

.game-card:hover .play-action {
    background: var(--accent-hover);
    transform: scale(1.04);
}

.site-footer {
    text-align: center;
    margin-top: 56px;
    padding-top: 24px;
    border-top: 1px solid var(--card-border);
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.site-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.site-footer a:hover {
    color: var(--accent-color);
}

/* Animations for previews */
.preview-snake {
    width: 100%;
    height: 100%;
    background: #080d1a;
    position: relative;
    overflow: hidden;
}

.snake-grid {
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(to right, rgba(255,255,255,0.12) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.12) 1px, transparent 1px);
    background-size: 16px 16px;
}

.animated-snake-body {
    position: absolute;
    display: flex;
    top: 50%;
    left: 20%;
    transform: translateY(-50%);
    gap: 2px;
    animation: snakeCrawl 3s infinite linear;
}

.snake-segment {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.snake-segment.head {
    background: #34d399;
}

.animated-food {
    position: absolute;
    top: 50%;
    right: 25%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 10px #ef4444;
    animation: foodPulse 1.5s infinite ease-in-out;
}

@keyframes snakeCrawl {
    0% { transform: translate(-30px, -50%); }
    50% { transform: translate(40px, -50%); }
    100% { transform: translate(-30px, -50%); }
}

@keyframes foodPulse {
    0%, 100% { transform: translateY(-50%) scale(0.9); opacity: 0.8; }
    50% { transform: translateY(-50%) scale(1.15); opacity: 1; }
}

/* Tetris Preview */
.preview-tetris {
    width: 100%;
    height: 100%;
    background: #080d1a;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tetris-well {
    width: 120px;
    height: 100%;
    border-left: 2px solid rgba(255,255,255,0.14);
    border-right: 2px solid rgba(255,255,255,0.14);
    position: relative;
}

.falling-tetromino {
    position: absolute;
    top: 10px;
    left: 40px;
    display: grid;
    grid-template-columns: repeat(2, 16px);
    gap: 2px;
    animation: tetrisFall 2.4s infinite cubic-bezier(0.5, 0, 0.8, 1);
}

.tetris-block {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    background: #eab308;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3);
}

.tetris-block.cyan { background: #06b6d4; }
.tetris-block.purple { background: #a855f7; }
.tetris-block.orange { background: #f97316; }

.bottom-stack {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    gap: 2px;
}

@keyframes tetrisFall {
    0% { top: -20px; opacity: 0; }
    15% { opacity: 1; }
    80% { top: 75px; opacity: 1; }
    90% { top: 75px; opacity: 0.3; }
    100% { top: 75px; opacity: 0; }
}

/* 2048 Preview */
.preview-2048 {
    width: 100%;
    height: 100%;
    background: #181512;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-grid-2048 {
    display: grid;
    grid-template-columns: repeat(3, 34px);
    gap: 6px;
    padding: 8px;
    background: #bbada0;
    border-radius: 6px;
}

.tile-2048 {
    width: 34px;
    height: 34px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    color: #776e65;
    background: #eee4da;
}

.tile-2048.gold {
    background: #edc22e;
    color: #f9f6f2;
    box-shadow: 0 0 12px rgba(237, 194, 46, 0.6);
    animation: goldBounce 1.8s infinite ease-in-out;
}

.tile-2048.orange {
    background: #f59563;
    color: #f9f6f2;
}

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

/* Galgame Preview */
.preview-galgame {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 30%, #1e1b4b 0%, #090d16 90%);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-dialogue-chip {
    position: absolute;
    bottom: 12px;
    left: 14px;
    right: 14px;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(99, 102, 241, 0.4);
    font-size: 11px;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    backdrop-filter: blur(4px);
}

.galgame-avatar-preview {
    width: 70px;
    height: 90px;
    animation: avatarFloat 3s infinite ease-in-out;
}

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

/* Survivor Preview */
.preview-survivor {
    width: 100%;
    height: 100%;
    background: #070b14;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.survivor-core {
    width: 20px;
    height: 20px;
    background: #06b6d4;
    clip-path: polygon(100% 50%, 0 10%, 30% 50%, 0 90%);
    box-shadow: 0 0 16px #06b6d4;
    position: relative;
    animation: shipHover 2s infinite ease-in-out;
}

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

.survivor-orbit {
    position: absolute;
    width: 74px;
    height: 74px;
    border-radius: 50%;
    border: 1px dashed rgba(168, 85, 247, 0.4);
    animation: rotateOrbit 4s infinite linear;
}

.orbit-dot {
    position: absolute;
    top: -5px;
    left: calc(50% - 5px);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #c084fc;
    box-shadow: 0 0 12px #a855f7;
}

.enemy-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ef4444;
    box-shadow: 0 0 10px #ef4444;
    transform: rotate(45deg);
}

.enemy-dot.e1 { top: 25px; left: 40px; animation: enemyPulse 2s infinite ease-in-out; }
.enemy-dot.e2 { bottom: 30px; right: 45px; animation: enemyPulse 2.4s infinite ease-in-out 0.4s; }
.enemy-dot.e3 { top: 35px; right: 55px; animation: enemyPulse 1.8s infinite ease-in-out 0.8s; }

@keyframes rotateOrbit {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes enemyPulse {
    0%, 100% { transform: rotate(45deg) scale(0.9); opacity: 0.7; }
    50% { transform: rotate(45deg) scale(1.15); opacity: 1; }
}

@media (max-width: 640px) {
    .page-wrapper {
        padding: 16px 14px 36px;
    }
    .hero-title {
        font-size: 26px;
    }
    .games-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .card-preview {
        height: 130px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .animated-snake-body,
    .animated-food,
    .falling-tetromino,
    .tile-2048.gold {
        animation: none;
    }
}
