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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #10b981;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg: #ffffff;
    --bg-alt: #f3f4f6;
    --border: #e5e7eb;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

/* Layout */
.site-header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.main-nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

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

.nav-links a {
    color: var(--text);
    font-weight: 500;
}

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

/* Mobile Nav */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg);
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--border);
    }

    .nav-links.active {
        display: flex;
    }
}

/* Main Content */
main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

/* Hero */
.hero {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--bg-alt);
    border-radius: var(--radius);
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-light);
    max-width: 600px;
    margin: 0 auto;
}

/* Games Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.game-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
}

.game-card:hover {
    box-shadow: var(--shadow-lg);
}

.game-card h3 {
    margin-bottom: 0.5rem;
}

.game-card p {
    color: var(--text-light);
    margin-bottom: 1rem;
}

.btn-play,
.btn-learn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 500;
    margin-right: 0.5rem;
    transition: background 0.2s;
}

.btn-play {
    background: var(--primary);
    color: white;
}

.btn-play:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.btn-learn {
    background: var(--bg-alt);
    color: var(--text);
}

.btn-learn:hover {
    background: var(--border);
    text-decoration: none;
}

/* Content Sections */
section {
    margin-bottom: 3rem;
}

section h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.intro-content p {
    margin-bottom: 1rem;
    max-width: 800px;
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

.breadcrumbs a {
    color: var(--text-light);
}

.breadcrumbs span {
    color: var(--text);
}

/* Game Container */
.game-container {
    background: var(--bg-alt);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 2rem 0;
}

.game-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.game-controls button,
.game-controls select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    cursor: pointer;
    font-size: 1rem;
}

.game-controls button:hover {
    background: var(--bg-alt);
}

.game-board {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
    width: 100%;
}

/* Unified Game Board Sizing */
.game-board-container {
    width: min(90vw, 70vh, 700px);
    max-width: 700px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .game-board-container {
        width: min(95vw, 80vh, 600px);
    }
}

@media (max-width: 480px) {
    .game-board-container {
        width: min(100%, 90vh);
    }
}

.game-status {
    text-align: center;
    font-size: 1.125rem;
    margin-top: 1rem;
}

/* Related Links */
.related-links {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.related-links h3 {
    margin-bottom: 1rem;
}

.related-links ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Footer */
.site-footer {
    background: var(--bg-alt);
    border-top: 1px solid var(--border);
    padding: 2rem 1rem;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.footer-links a {
    color: var(--text-light);
}

.site-footer p {
    color: var(--text-light);
    font-size: 0.875rem;
}

/* Ad Containers */
.ad-container-top,
.ad-container-middle,
.ad-container-bottom {
    max-width: 1200px;
    margin: 1.5rem auto;
    padding: 0 1rem;
    text-align: center;
    overflow: hidden;
    min-height: 90px;
}

.ad-container-top {
    margin-top: 1rem;
}

.ad-container-bottom {
    margin-bottom: 2rem;
}

@media (max-width: 768px) {

    .ad-container-top,
    .ad-container-middle,
    .ad-container-bottom {
        margin: 1rem auto;
        min-height: 50px;
    }
}

/* Blog Styles */
.blog-article {
    max-width: 800px;
    margin: 0 auto;
}

.article-meta {
    margin-bottom: 2rem;
    color: var(--text-light);
}

.article-content h2 {
    margin: 2rem 0 1rem;
}

.article-content p {
    margin-bottom: 1.25rem;
}

.article-content ul,
.article-content ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.article-figure {
    margin: 2.5rem 0;
    text-align: center;
}

.article-image {
    width: 100%;
    max-width: 800px;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.article-caption {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-light);
    font-style: italic;
}