:root {
    --bg-dark: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-blue: #38bdf8;
    --accent-purple: #c084fc;
    --accent-pink: #f472b6;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --card-hover-transform: translateY(-5px);

    --font-main: 'Outfit', sans-serif;
}

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

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

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

/* Background Animation */
.background-globes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.globe {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s infinite alternate;
}

.globe-1 {
    width: 400px;
    height: 400px;
    background: var(--accent-purple);
    top: -100px;
    left: -100px;
}

.globe-2 {
    width: 500px;
    height: 500px;
    background: var(--accent-blue);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

.globe-3 {
    width: 300px;
    height: 300px;
    background: var(--accent-pink);
    top: 40%;
    left: 40%;
    animation-duration: 25s;
    opacity: 0.2;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(30px, 50px);
    }
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
}

.glass-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 5%;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
}

/* Navigation */
.logo {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(to right, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.logo-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 0 5px rgba(192, 132, 252, 0.5));
}

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

.nav-links a {
    font-weight: 600;
    color: var(--text-secondary);
    position: relative;
    padding-bottom: 5px;
}

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

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-purple);
    transition: width 0.3s ease;
}

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

.mobile-menu-btn {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Hero Section */
.hero-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8rem 5% 4rem;
    text-align: center;
}

.hero-content h1 {
    font-size: 3.5rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.gradient-text {
    background: linear-gradient(to right, var(--accent-blue), var(--accent-purple), var(--accent-pink));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 800;
}

.tagline {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin-bottom: 4rem;
}

/* Game Cards */
.games-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 3rem;
    width: 100%;
    max-width: 1000px;
    background: transparent;
}

.game-card {
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    min-height: 480px;
    position: relative;
    overflow: hidden;
}

.game-card:hover {
    transform: var(--card-hover-transform);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.game-card:hover::before {
    opacity: 1;
}

.card-content {
    z-index: 1;
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
}

.game-card h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.sub-title {
    color: var(--accent-blue);
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
}

.game-card .description {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.card-features {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.card-features span {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.card-actions {
    display: flex;
    gap: 1rem;
    z-index: 1;
}

.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(192, 132, 252, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Footer */
.glass-footer {
    padding: 3rem 0;
    text-align: center;
    color: var(--text-secondary);
    background: rgba(15, 23, 42, 0.5);
    border-top: 1px solid var(--glass-border);
}

.footer-content a {
    color: var(--accent-blue);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

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

.small-text {
    font-size: 0.85rem;
    margin-top: 0.5rem;
    opacity: 0.7;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        /* Add JS toggle later */
    }

    .mobile-menu-btn {
        display: block;
    }

    .hero-content h1 {
        font-size: 2.5rem;
    }

    .games-container {
        grid-template-columns: 1fr;
    }
}

/* Game Page Specific Styles */
.game-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    padding-top: 6rem;
    /* Account for fixed header */
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 4rem;
}

@media (min-width: 1024px) {
    .game-layout {
        grid-template-columns: 3fr 1fr;
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

.game-board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 600px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 2rem;
}

@media (max-width: 768px) {
    .game-board-container {
        padding: 1rem;
        min-height: auto;
    }
}

.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.info-panel {
    padding: 1.5rem;
}

.game-status {
    text-align: center;
    margin-bottom: 2rem;
}

.turn-indicator {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.turn-red {
    color: #ef4444;
}

.turn-black {
    color: var(--text-primary);
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mode-select {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.25rem;
    margin-bottom: 1rem;
}

.mode-btn {
    flex: 1;
    padding: 0.6rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.mode-btn.active {
    background: var(--accent-blue);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.history-log {
    height: 200px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 1rem;
    font-family: monospace;
    font-size: 0.9rem;
    margin-top: 1rem;
}

.history-item {
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Learn Section Styles */
.learn-section {
    padding: 4rem 5%;
    max-width: 1200px;
    margin: 0 auto;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
    font-size: 2.5rem;
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.rule-card {
    padding: 2rem;
}

.rule-card h3 {
    color: var(--accent-blue);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Canvas Styles */
canvas {
    background-color: transparent;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    max-width: 100%;
    height: auto;
    display: block;
    touch-action: none;
    /* Prevent default touch behaviors like scrolling */
}

.xiangqi-board-bg {
    background-color: #eecfa1;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiPgo8cmVjdCB3aWR0aD0iNCIgaGVpZ2h0PSI0IiBmaWxsPSIjZThjMjkxIi8+Cjwvc3ZnPg==');
}

.wuzi-board-bg {
    background-color: #DEB887;
    background-image: linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}