:root {
    --paper: #fafbfc;
    --white: #ffffff;
    --ink: #231f20;
    --ink-soft: #4a4546;
    --accent-purple: #9169ad;
    --accent-cyan: #5bc0da;
    --accent-blue: #436eb6;
    --accent-green: #4eba6d;
    --accent-lime: #c1d036;
    --accent-orange: #f57f25;
    --accent-pink: #ed4691;
    --accent-red: #ef3b50;

    --primary: var(--ink);
    --primary-light: #f0f1f2;
    --accent-orange-hover: #d96f16;
    --accent-gold: var(--accent-orange);
    --bg-color: var(--paper);
    --surface: #ffffff;
    --text-main: var(--ink);
    --text-muted: #5f595b;
    --border-color: rgba(35, 31, 32, 0.16);
    --nav-bg: rgba(250, 251, 252, 0.96);
    --hero-bg: var(--paper);
    --card-dark: var(--ink);
    --card-dark-text: #ffffff;
    --card-light: #ffffff;
    --card-light-text: var(--ink);
    --circle-opacity: rgba(35, 31, 32, 0.03);
    
    --radius: 4px;
    --shadow-sm: 0 1px 3px rgba(35, 31, 32, 0.05);
    --shadow-md: 0 8px 18px rgba(35, 31, 32, 0.08);
    --shadow-lg: 0 16px 30px rgba(35, 31, 32, 0.12);
}

/* Smooth Scrolling and Navbar Offset */
html {
    scroll-behavior: smooth;
    /* This prevents the sticky navbar from covering the section titles when you scroll to them */
    scroll-padding-top: 100px; 
}

/* Dark Theme Overrides */
[data-theme="dark"] {
    --primary: var(--paper);
    --primary-light: #4a4546;
    --accent-orange-hover: #ff9a49;
    --bg-color: var(--ink);
    --surface: #322e2f;
    --text-main: var(--paper);
    --text-muted: #c9c3c4;
    --border-color: rgba(250, 251, 252, 0.18);
    --nav-bg: rgba(35, 31, 32, 0.96);
    --hero-bg: var(--ink);
    --card-dark: #383334;
    --card-dark-text: #ffffff;
    --card-light: var(--paper);
    --card-light-text: var(--ink);
    --circle-opacity: rgba(250, 251, 252, 0.025);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 18px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 30px rgba(0, 0, 0, 0.38);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Manrope', sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* ================= Premium Navbar ================= */
.premium-nav {
    padding: 7px 5%;
    display: flex;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    background-color: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    width: 100%;
    max-width: 1200px;
    border-radius: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 10px 1px 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.logo a {
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.045em;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 24px;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    transition: color 0.3s;
}

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

.nav-links a.active {
    border-bottom: 2px solid var(--accent-gold);
    padding-bottom: 4px;
}

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

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
}

.theme-toggle:hover {
    background-color: var(--border-color);
    transform: rotate(15deg) scale(1.1);
}

.btn-primary {
    background-color: var(--accent-orange);
    color: var(--ink);
    text-decoration: none;
    padding: 14px 20px;
    border: 1px solid var(--accent-orange);
    border-radius: var(--radius);
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.btn-primary:hover {
    background-color: var(--accent-orange-hover);
    border-color: var(--accent-orange-hover);
    color: var(--ink);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background-color: var(--accent-orange);
}

/* ================= Hero Section ================= */
.hero {
    position: relative;
    padding: 60px 5% 120px;
    background-color: var(--hero-bg);
    overflow: hidden;
    transition: background-color 0.4s ease;
    border-bottom: 1px solid var(--border-color);
}

.hero-bg-circles {
    position: absolute;
    top: -20%;
    left: -10%;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, transparent 20%, var(--circle-opacity) 21%, transparent 22%),
                radial-gradient(circle, transparent 40%, var(--circle-opacity) 41%, transparent 42%),
                radial-gradient(circle, transparent 60%, var(--circle-opacity) 61%, transparent 62%);
    z-index: 0;
    pointer-events: none;
}

.hero-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    position: relative;
    z-index: 1;
}

.availability-badge {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 30px;
}

.red-dot {
    width: 6px;
    height: 6px;
    background-color: #ef4444;
    border-radius: 50%;
}

.hero-title {
    font-size: 4.5rem;
    line-height: 1.1;
    color: var(--text-main);
    font-weight: 600;
    margin-bottom: 30px;
    letter-spacing: -2px;
}

.italic-serif {
    font-family: 'Manrope', sans-serif;
    font-style: italic;
    color: var(--text-main);
    font-weight: 500;
}

.hero-description {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-muted);
    max-width: 500px;
    margin-bottom: 40px;
}

.hero-buttons {
    display: flex;
    gap: 15px;
}

.btn-outline {
    border: 1px solid var(--border-color);
    color: var(--text-main);
    text-decoration: none;
    padding: 12px 28px;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: 0.3s;
}

.btn-outline:hover {
    background: var(--border-color);
}

.btn-secondary {
    background-color: var(--text-main);
    border: 1px solid var(--border-color);
    color: var(--bg-color);
    text-decoration: none;
    padding: 12px 28px;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: 0.3s;
}

.btn-secondary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* ================= Hero Visuals (Cards) ================= */
.hero-visuals {
    position: relative;
    height: 100%;
}

.dark-card {
    background-color: var(--card-dark);
    padding: 30px;
    border-radius: 16px;
    width: 280px;
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 1;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.dark-card .card-subtitle {
    font-family: 'Manrope', sans-serif;
    font-size: 0.85rem;
    color: var(--card-dark-text);
    opacity: 0.7;
}

.dark-card h3 {
    color: var(--card-dark-text);
    font-size: 1.75rem;
    margin: 15px 0;
    font-weight: 500;
    line-height: 1.2;
}

.dark-card p {
    font-size: 0.9rem;
    color: var(--card-dark-text);
    opacity: 0.8;
    margin-bottom: 20px;
}

.card-link {
    color: var(--card-dark-text);
    text-decoration: none;
    font-size: 0.8rem;
    letter-spacing: 1px;
    font-weight: 600;
    transition: opacity 0.2s;
}
.card-link:hover { opacity: 0.8; }

.light-card {
    background-color: var(--card-light);
    color: var(--card-light-text);
    padding: 24px;
    border-radius: 12px;
    width: 220px;
    position: absolute;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(0,0,0,0.05);
}

.card-num {
    color: #a0a0a0;
    font-size: 0.85rem;
    font-weight: 500;
}

.light-card h4 {
    font-family: 'Manrope', sans-serif;
    font-size: 1.3rem;
    margin: 15px 0;
    font-weight: 600;
    line-height: 1.2;
}

.light-card ul {
    list-style: none;
}

.light-card ul li {
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 8px;
}

/* Staggering the cards */
.card-1 { bottom: 20px; left: 200px; z-index: 2; }
.card-2 { bottom: 120px; left: 350px; z-index: 3; }
.card-3 { bottom: 220px; left: 500px; z-index: 4; }

/* ================= Book Section Banner ================= */
.book-header-banner {
    display: flex;
    align-items: center;
    gap: 3rem;
    margin-bottom: 3rem;
    background: var(--surface);
    padding: 2.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.book-cover-wrapper {
    flex-shrink: 0;
    perspective: 1000px;
}

.book-cover-img {
    width: 200px; 
    height: auto;
    border-radius: 4px;
    box-shadow: -8px 8px 20px rgba(0,0,0,0.15);
    transform: rotate(-4deg); 
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
}

[data-theme="dark"] .book-cover-img {
    box-shadow: -8px 8px 20px rgba(0,0,0,0.4);
}

.book-cover-img:hover {
    transform: rotate(0deg) scale(1.05); /* Straightens and enlarges on hover */
    box-shadow: -12px 12px 25px rgba(0,0,0,0.2);
}

/* Responsive adjustment for Mobile */
@media (max-width: 768px) {
    .book-header-banner {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
        padding: 1.5rem;
    }
    .book-header-text .section-title {
        text-align: center !important;
    }
    .book-cover-img {
        width: 160px;
    }
}

/* ================= Back Button ================= */
.back-btn, 
.back-btn:visited {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none !important; 
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    transition: color 0.3s ease, transform 0.3s ease;
}

.back-btn:hover, 
.back-btn:active {
    color: var(--accent-blue);
    text-decoration: none;
    transform: translateX(-5px); /* Slides slightly left on hover */
}

/* ================= Main Content Container ================= */
.container {
    max-width: 1200px;
    margin: 4rem auto;
    padding: 0 24px;
}

.section-title {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--ink);
    font-weight: 700;
    font-size: 2.5rem;
    letter-spacing: -1px;
}

/* Advanced Search Bar */
.search-container {
    margin: 0 auto 3rem auto;
    display: flex;
    justify-content: center;
    max-width: 600px;
    position: relative;
}

.search-container::before {
    content: '🔍';
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    opacity: 0.5;
}

#search-bar {
    width: 100%;
    padding: 16px 24px 16px 50px;
    font-size: 1.05rem;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    background: var(--surface);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#search-bar::placeholder {
    color: var(--text-muted);
}

#search-bar:focus {
    outline: none;
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 4px rgba(217, 119, 67, 0.15);
    transform: translateY(-2px);
}

/* ================= Video Grid & Cards ================= */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2.5rem;
}

.video-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    opacity: 0;
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.video-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.thumbnail-container {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.thumbnail-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.video-card:hover .thumbnail-container img {
    transform: scale(1.05);
}

.module-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.video-info {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.video-info h3 {
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
    line-height: 1.4;
    font-weight: 600;
}

.video-info p {
    font-size: 0.95rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ================= Video Details Page & Resources ================= */
.video-player-container {
    width: 100%;
    max-width: 1000px; 
    margin: 0 auto 3rem auto; 
    aspect-ratio: 16 / 9; 
}

.video-player-container iframe {
    width: 100%;
    height: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: none;
}

.resources-section {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.resources-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.5rem;
}

.resources-list a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-color);
    color: var(--primary);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.resources-list a:hover {
    background: var(--accent-orange);
    color: #fff;
    border-color: var(--accent-orange);
    transform: translateY(-2px);
}

/* General Pages Content */
.page-content {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

/* Advanced Search Bar */
.search-container {
    margin: 0 auto 3rem auto;
    display: flex;
    justify-content: center;
    max-width: 600px;
    position: relative;
}

.search-container::before {
    content: '🔍';
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    opacity: 0.5;
}

#search-bar::placeholder, #search-games-bar::placeholder {
    color: var(--text-muted);
}

#search-bar, #search-games-bar {
    width: 100%;
    padding: 16px 24px 16px 50px;
    font-size: 1.05rem;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    background: var(--surface);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#search-bar:focus, #search-games-bar:focus {
    outline: none;
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 4px rgba(217, 119, 67, 0.15);
    transform: translateY(-2px);
}

/* Make sure to also update this existing surface elements rule */
.video-card, .resources-section, .page-content, #search-bar, #search-games-bar {
    background: var(--surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

/* Game Details Styling */
.game-details-body p {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

.game-details-body strong {
    color: var(--text-main);
}

.game-content-img {
    width: 100%;
    max-width: 600px;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    margin: 2rem auto;
    display: block;
    border: 1px solid var(--border-color);
}

/* ================= Games Layout & Sidebar Filters ================= */
.games-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 2.5rem;
    align-items: start;
}

.games-sidebar {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    position: sticky;
    top: 100px; /* Sticks to the top as you scroll past it */
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.filter-title {
    font-size: 1.05rem;
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: var(--text-main);
    cursor: pointer;
    transition: color 0.2s;
}

.filter-label:hover {
    color: var(--accent-blue);
}

.filter-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-orange);
    cursor: pointer;
}

/* Responsive adjustment for Mobile & Tablets */
@media (max-width: 968px) {
    .games-layout {
        grid-template-columns: 1fr; /* Stacks the sidebar above the games on small screens */
    }
    .games-sidebar {
        position: static;
    }
}

/* ================= Interactive Number Maze ================= */
.interactive-game-wrapper {
    /* Games always play on a light mat, so they use the light palette in both themes. */
    --primary: #0f172a;
    --bg-color: #f8fafc;
    --surface: #ffffff;
    --text-main: #334155;
    --text-muted: #64748b;
    --border-color: rgba(0, 0, 0, 0.1);
    color: var(--text-main);
    background: var(--primary-light);
    padding: 2rem;
    border-radius: var(--radius);
    margin: 2rem 0;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.maze-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.maze-btn-reset {
    background-color: #cbd5e1;
    color: #334155;
    border: none;
    padding: 10px 24px;
    min-height: 44px;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

[data-theme="dark"] .maze-btn-reset {
    background-color: #475569;
    color: #f1f5f9;
}

.maze-btn-reset:hover {
    opacity: 0.8;
    transform: translateY(-2px);
}

.maze-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    background: var(--border-color);
    padding: 8px;
    border-radius: 8px;
    max-width: 400px;
    width: 100%;
}

.maze-btn-solve {
    background-color: var(--accent-orange);
    color: var(--ink);
    border: none;
    padding: 10px 24px;
    min-height: 44px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(35, 31, 32, 0.12);
}

.maze-btn-solve:hover {
    background-color: var(--accent-orange-hover);
    transform: translateY(-1px);
}

.maze-cell {
    aspect-ratio: 1 / 1;
    background-color: var(--accent-orange);
    color: var(--ink);
    font-size: 2rem;
    font-weight: 800;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    cursor: not-allowed;
    transition: all 0.3s ease;
    user-select: none;
    position: relative;
    border: 2px solid rgba(0,0,0,0.1);
    text-shadow: none;
}

.maze-cell.start { background-color: var(--accent-green); }
.maze-cell.end { background-color: var(--accent-blue); color: var(--white); }

.maze-cell.active {
    transform: scale(0.95);
    box-shadow: inset 0 4px 8px rgba(0,0,0,0.3);
    border-color: var(--text-main);
}

.maze-cell.path {
    background-color: var(--accent-orange);
    opacity: 0.8;
    color: var(--ink);
}

.maze-cell.valid-move {
    cursor: pointer;
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.4);
}

.maze-cell.valid-move:hover {
    transform: scale(1.05);
    background-color: #fef08a;
    color: var(--ink);
    text-shadow: none;
}

.cell-label {
    font-size: 0.6rem;
    position: absolute;
    top: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.maze-status {
    margin-top: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    height: 24px;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* maze 2 */
/* ================= Colour Maze Specifics ================= */
.maze-cell.color-W { background-color: #f8fafc; color: #334155; border: 2px solid #cbd5e1; }
.maze-cell.color-Bu { background-color: #60a5fa; color: #ffffff; border: 2px solid #3b82f6; }
.maze-cell.color-R { background-color: #f87171; color: #ffffff; border: 2px solid #ef4444; }
.maze-cell.color-S { background-color: #4ade80; color: #ffffff; border: 2px solid #22c55e; }
.maze-cell.color-E { background-color: #fbbf24; color: #ffffff; border: 2px solid #f59e0b; }

/* The player arrow that rotates based on direction */
.player-arrow {
    position: absolute;
    font-size: 1.8rem;
    z-index: 10;
    transition: transform 0.3s ease;
    text-shadow: 0px 2px 4px rgba(0,0,0,0.5);
    line-height: 1;
}

/* Adjust cell sizes for 4x4 grids to keep them looking nice */
.maze-board.grid-4x4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ================= Pixel Art Game Specifics ================= */
.pixel-board-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    width: 100%;
}

.pixel-board {
    display: grid;
    grid-template-columns: repeat(15, 1fr); /* 15x9 grid to accommodate the Cup puzzle */
    gap: 1px;
    background: var(--border-color);
    border: 4px solid var(--border-color);
    border-radius: 4px;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.pixel-cell {
    aspect-ratio: 1 / 1;
    background-color: #ffffff; /* White (1) */
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.pixel-cell.black {
    background-color: #000000; /* Black (0) */
}

.pixel-data-output {
    background: var(--surface);
    padding: 1rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-main);
    overflow-x: auto;
}

.pixel-data-row {
    display: flex;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
    margin-bottom: 0.25rem;
}

.pixel-data-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.data-label {
    color: var(--accent-blue);
    font-weight: bold;
    width: 60px;
    flex-shrink: 0;
}

.data-binary {
    color: var(--text-muted);
    width: 140px;
    flex-shrink: 0;
}

.data-rle {
    color: var(--primary);
    font-weight: bold;
}

/* ================= Footer ================= */
.premium-footer {
    background-color: var(--hero-bg);
    border-top: 1px solid var(--border-color);
    padding: 80px 5% 30px;
    position: relative;
    overflow: hidden;
    transition: background-color 0.4s ease;
}

.footer-bg-circles {
    position: absolute;
    bottom: -50%;
    right: -10%;
    width: 1000px;
    height: 1000px;
    background: radial-gradient(circle, transparent 20%, var(--circle-opacity) 21%, transparent 22%),
                radial-gradient(circle, transparent 40%, var(--circle-opacity) 41%, transparent 42%),
                radial-gradient(circle, transparent 60%, var(--circle-opacity) 61%, transparent 62%);
    z-index: 0;
    pointer-events: none;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.5fr;
    gap: 40px;
    margin-bottom: 80px;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
    font-weight: 700;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.brand-col p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.footer-heading {
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 1.5px;
    margin-bottom: 20px;
    font-weight: 600;
    text-transform: uppercase;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 12px;
}

.footer-links a {
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.3s;
}

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

.footer-email {
    color: var(--text-main);
    text-decoration: none;
    font-size: 1rem;
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
}

.footer-email:hover {
    color: var(--accent-blue);
}

.footer-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px 24px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footer-credit {
    opacity: 0.8;
    letter-spacing: 0.02em;
}

.footer-credit span {
    color: var(--accent-gold);
    font-family: 'Manrope', sans-serif;
    font-style: normal;
    font-size: 1.05rem;
}

/* ================= Animations & Responsive ================= */
@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

@media (max-width: 968px) {
    .hero-container { grid-template-columns: 1fr; }
    .hero-visuals { height: 400px; margin-top: 40px; }
    .card-3 { left: 40%; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .nav-links { display: none; }
    .hero-title { font-size: 3rem; }
    .footer-grid { grid-template-columns: 1fr; }
    .card-1 { left: 0; }
    .card-2 { left: 10%; }
    .card-3 { left: 20%; }
}

/* ================= Chess Maze Specifics ================= */
.chess-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0px; /* No gap so it looks like a real chessboard */
    border: 4px solid var(--primary-light);
    border-radius: 4px;
    max-width: 400px;
    width: 100%;
    margin-bottom: 1.5rem;
}

.chess-cell {
    aspect-ratio: 1 / 1;
    font-size: 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: not-allowed;
    transition: all 0.3s ease;
    user-select: none;
    position: relative;
    color: var(--primary);
}

/* Checkered Backgrounds */
.chess-cell.light-square { background-color: #f1f5f9; }
.chess-cell.dark-square { background-color: #cbd5e1; }

[data-theme="dark"] .chess-cell.light-square { background-color: #e2e8f0; }
[data-theme="dark"] .chess-cell.dark-square { background-color: #94a3b8; }

/* Active and Path States */
.chess-cell.active {
    background-color: #4ade80 !important;
    transform: scale(0.95);
    z-index: 10;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.chess-cell.path {
    background-color: var(--accent-orange) !important;
    color: var(--ink);
}

.chess-cell.valid-move {
    cursor: pointer;
    animation: pulse-chess 1.5s infinite;
    z-index: 5;
}

.chess-cell.valid-move:hover {
    transform: scale(1.05);
    background-color: #fef08a !important;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.chess-label {
    font-size: 0.65rem;
    position: absolute;
    top: 4px;
    font-family: 'Manrope', sans-serif;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
}

@keyframes pulse-chess {
    0% { box-shadow: inset 0 0 0 0 rgba(74, 222, 128, 0.8); }
    70% { box-shadow: inset 0 0 0 6px rgba(74, 222, 128, 0); }
    100% { box-shadow: inset 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* ================= Parity Bits Game ================= */
.parity-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
    max-width: 450px;
    margin: 0 auto;
    background-color: var(--border-color);
    border: 3px solid var(--border-color);
    border-radius: 4px;
    width: 100%;
}

.parity-cell {
    aspect-ratio: 1 / 1;
    background-color: #ffffff;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.parity-cell.black {
    background-color: #000000;
}

.parity-cell:hover{
transform: scale(0.96);
}

/* Distinctive styling for the parity edge cells */
.parity-cell.is-parity {
    border: 3px dashed var(--accent-orange);
    background-clip: padding-box; 
}

.parity-status {
    text-align: center;
    margin-top: 1.5rem;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--primary);
    min-height: 48px;
}

.parity-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

/* ================= Chota Shatranj Game ================= */
.cs-container {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2.5rem;
    box-shadow: var(--shadow-sm);
    text-align: center;
    max-width: 650px; /* Expands the container width */
    margin: 0 auto; /* Centers the container */
}

.bp-activity-card {
    padding: 1.5rem;
}

.bp-activity-frame {
    box-sizing: border-box;
    width: 100%;
    padding: 3rem 1rem;
}

.cs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap; /* Prevents buttons from squishing the title */
    gap: 1rem;
}

.cs-inventory {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}

.cs-piece-btn {
    background: #ffffff;
    color: #000000; /* Forces text to be black against the white button */
    border: 2px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    transition: all 0.2s;
}

.cs-piece-btn.active {
    border-color: var(--accent-orange);
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.cs-piece-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cs-piece-icon {
    font-size: 2.5rem; /* Larger inventory icons */
    line-height: 1;
}

.cs-piece-count {
    font-size: 0.95rem;
    font-weight: 600;
    margin-top: 0.4rem;
    color: #111111;
}

.cs-board-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 2.5rem;
}

.cs-board {
    display: grid;
    gap: 6px; /* Slightly more space between cells */
    background: #334155;
    padding: 10px;
    border-radius: 8px;
}

.cs-cell {
    width: 75px; /* Increased from 60px */
    height: 75px; /* Increased from 60px */
    background: #ffffff;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem; /* Huge chess pieces on the board */
    cursor: pointer;
    transition: all 0.2s;
}

.cs-cell.removed {
    background: transparent;
    cursor: default;
}

.cs-cell.conflict {
    background: #fca5a5 !important;
    animation: shake 0.4s ease-in-out;
}

.cs-builder-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
}

.cs-counter-input {
    width: 50px;
    text-align: center;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* ================= Building Puzzle Game ================= */

.bp-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface);
    padding: 2.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    max-width: 900px; /* Wide enough for both grids */
    margin: 0 auto;
}

.bp-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 4rem;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 2rem;
}

/* --- 2D Interactive Grid --- */
.bp-grid {
    display: grid;
    --bp-cell-size: 68px;
    --bp-grid-gap: 6px;
    /* Grid size dynamically set by JS */
    gap: 5px;
}

.bp-grid[data-size="4"] {
    --bp-cell-size: 56px;
}

.bp-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 4px;
}

.bp-clue {
    background: transparent;
    color: var(--text-main);
    font-size: 1.2rem;
}

.bp-interactive {
    background: #ffffff;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.1s;
    color: #000000;
}

.bp-interactive:hover { 
    transform: scale(0.95); 
}

/* Colors for 2D Grid */
.bp-val-1 { background: #ef4444; color: #ffffff; border-color: #b91c1c; } /* Red */
.bp-val-2 { background: #eab308; color: #000000; border-color: #a16207; } /* Yellow */
.bp-val-3 { background: #22c55e; color: #ffffff; border-color: #15803d; } /* Green */
.bp-val-4 { background: #3b82f6; color: #ffffff; border-color: #1d4ed8; } /* Blue */

/* --- 3D Isometric View --- */
.bp-3d-container {
    perspective: 1500px;
    padding-top: 4rem; 
    padding-right: 2rem;
}

.bp-3d-container[data-size="3"] {
    transform: scale(1.25);
}

.bp-3d-container[data-size="4"] {
    transform: scale(1.1);
}

.bp-3d-grid {
    display: grid;
    gap: 4px;
    transform: rotateX(60deg) rotateZ(-45deg);
    transform-style: preserve-3d;
    background: var(--border-color);
    padding: 8px;
    border-radius: 6px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.25);
}

.bp-3d-grid[data-size="3"] {
    --bp-3d-cell-size: 60px;
}

.bp-3d-grid[data-size="4"] {
    --bp-3d-cell-size: 50px;
}

.bp-3d-cell {
    width: 100%;
    height: 100%;
    aspect-ratio: 1/1; 
    position: relative;
    transform-style: preserve-3d;
}

.bp-3d-cell::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    transform: translateZ(-1px); 
}

/* Base Wrapper for the Building */
.bp-3d-building {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: all 0.2s ease-in-out;
    transform: translateZ(var(--h, 0px));
}

.bp-3d-face {
    position: absolute;
    display: block;
    border: 1px solid rgba(0,0,0,0.15);
    box-sizing: border-box;
    backface-visibility: hidden; 
    transition: all 0.2s ease-in-out;
}

.bp-3d-roof {
    width: 100%;
    height: 100%;
    top: 0; 
    left: 0;
    background-color: var(--face-top);
}

.bp-3d-wall-left {
    width: var(--h, 0px);
    height: 100%;
    top: 0; 
    right: 100%;
    background-color: var(--face-left);
    transform-origin: right center;
    transform: rotateY(-90deg);
}

.bp-3d-wall-front {
    width: 100%;
    height: var(--h, 0px);
    top: 100%; 
    left: 0;
    background-color: var(--face-front);
    transform-origin: top center;
    transform: rotateX(-90deg);
}

/* Heights and Explicit Colors for 3D Buildings */
.bp-3d-val-1 { 
    --face-top: #ef4444; 
    --face-left: #dc2626; 
    --face-front: #b91c1c; 
    --h: 40px; 
} /* Red */

.bp-3d-val-2 { 
    --face-top: #eab308; 
    --face-left: #ca8a04; 
    --face-front: #a16207; 
    --h: 80px; 
} /* Yellow */

.bp-3d-val-3 { 
    --face-top: #22c55e; 
    --face-left: #16a34a; 
    --face-front: #15803d; 
    --h: 120px; 
} /* Green */

.bp-3d-val-4 { 
    --face-top: #3b82f6; 
    --face-left: #2563eb; 
    --face-front: #1d4ed8; 
    --h: 160px; 
} /* Blue */

/* ================= Advanced Mobile Responsiveness ================= */

/* General Mobile Tweaks */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
        margin-top: 2rem;
    }
    
    .section-title {
        font-size: 2rem;
    }

    .page-content {
        padding: 1.5rem;
    }
}

/* Fix Interactive Game Boards for Phones */
@media (max-width: 500px) {
    /* Stack game controls on tiny screens */
    .maze-controls {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }

    .maze-btn-reset, .maze-btn-solve {
        width: 100%;
        padding: 12px;
    }

    /* Shrink the Number & Colour Maze cells */
    .maze-board {
        gap: 4px;
        padding: 4px;
    }

    .maze-cell {
        font-size: 1.2rem;
        border-width: 1px;
    }

    .cell-label {
        font-size: 0.5rem;
    }
}

/* Shared 3030 / CCL presentation */
html {
    scroll-padding-top: 84px;
}

body {
    font-family: 'Manrope', sans-serif;
}

.premium-nav {
    padding: 0 clamp(16px, 4vw, 48px);
    border-bottom: 1px solid var(--border-color);
    background: var(--nav-bg);
}

.nav-container {
    position: relative;
    max-width: 1280px;
    min-height: 68px;
    padding: 10px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.logo a {
    color: var(--text-main);
    font-size: 1rem;
    letter-spacing: -0.045em;
}

.nav-links {
    align-items: center;
    gap: clamp(12px, 1.8vw, 24px);
}

.nav-links a {
    color: var(--text-main);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}

.nav-links a:hover,
.nav-links a:focus-visible,
.footer-links a:hover,
.footer-links a:focus-visible {
    color: var(--accent-blue);
}

.nav-links a.active {
    border-bottom: 2px solid var(--accent-orange);
}

.nav-actions {
    gap: 10px;
}

.theme-toggle {
    flex: none;
    width: 44px;
    height: 44px;
}

.nav-toggle {
    display: none;
    flex: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-main);
    font: 600 1.25rem/1 Manrope, sans-serif;
    cursor: pointer;
}

.btn-outline,
.btn-secondary {
    border-radius: var(--radius);
}

.hero {
    background-color: var(--hero-bg);
}

.hero-title,
.section-title,
.video-info h3,
.footer-logo {
    font-family: 'Manrope', sans-serif;
    letter-spacing: -0.045em;
}

.section-title {
    font-size: clamp(1.875rem, 3vw, 2.75rem);
    line-height: 1.16;
}

.search-container input,
#search-games-bar {
    border-radius: var(--radius);
    font-family: 'Manrope', sans-serif;
}

#search-bar:focus,
#search-games-bar:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(67, 110, 182, 0.2);
    transform: none;
}

.video-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
    gap: clamp(1.25rem, 2.5vw, 2rem);
}

.video-card {
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.video-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.thumbnail-container img {
    background: var(--paper);
}

.video-info {
    padding: 1.25rem;
}

.video-info h3 {
    color: var(--text-main);
}

.book-header-banner {
    border-radius: var(--radius);
    box-shadow: none;
}

.premium-footer {
    padding: 64px 24px 28px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
}

.footer-bg-circles {
    display: none;
}

.footer-container {
    max-width: 1280px;
}

.footer-grid {
    grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(140px, 1fr));
    gap: 32px;
    margin-bottom: 48px;
}

.footer-heading {
    color: var(--text-muted);
    font-family: 'Manrope', sans-serif;
    letter-spacing: 0.08em;
}

.footer-links li {
    margin-bottom: 10px;
}

.footer-links a {
    font-size: 0.875rem;
}

.footer-email,
.footer-links a {
    overflow-wrap: anywhere;
}

.footer-bottom {
    border-color: var(--border-color);
}

.footer-credit span {
    color: var(--accent-purple);
    font-family: 'Manrope', sans-serif;
    font-style: normal;
}

:focus-visible {
    outline: 3px solid var(--accent-blue);
    outline-offset: 3px;
}

@media (max-width: 900px) {
    .premium-nav .nav-links {
        display: none;
        position: absolute;
        z-index: 1001;
        top: 100%;
        right: 0;
        left: 0;
        align-items: stretch;
        gap: 0;
        padding: 8px 20px 16px;
        border: 1px solid var(--border-color);
        border-top: 0;
        background: var(--bg-color);
        box-shadow: var(--shadow-md);
    }

    .premium-nav .nav-links.is-open {
        display: flex;
        flex-direction: column;
    }

    .premium-nav .nav-links a {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 8px 0;
    }

    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .footer-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 32px 24px;
    }

    .bp-layout {
        flex-wrap: wrap !important;
        gap: 1rem !important;
    }
}

@media (max-width: 600px) {
    .premium-nav {
        padding-inline: 16px;
    }

    .nav-container {
        min-height: 60px;
    }

    .nav-actions .btn-primary {
        display: none;
    }

    .hero-title {
        font-size: clamp(2.5rem, 11vw, 3rem);
        letter-spacing: -0.045em;
    }

    .container {
        padding-inline: 16px;
    }

    .video-grid {
        gap: 20px;
    }

    .footer-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 28px;
        margin-bottom: 32px;
    }

    .premium-footer {
        padding: 40px 20px 24px;
    }

    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
    }
}

.chapter-viewer {
    height: 85vh;
}

.chapter-heading {
    min-width: 0;
}

#chapter-title,
#game-title,
#video-title {
    overflow-wrap: anywhere;
}

@media (max-width: 600px) {
    .container {
        margin-bottom: 3rem;
    }

    .section-title {
        font-size: clamp(1.65rem, 7vw, 2rem);
        line-height: 1.2;
    }

    #search-bar,
    #search-games-bar,
    .learn input,
    .learn select {
        min-height: 48px;
        font-size: 16px;
    }

    .filter-label {
        min-height: 44px;
    }

    .chapter-heading {
        flex-direction: column;
        align-items: stretch !important;
    }

    .chapter-heading > div:last-child,
    #chapter-download-btn {
        width: 100%;
    }

    #chapter-title,
    #game-title,
    #video-title {
        font-size: clamp(1.75rem, 8vw, 2.25rem) !important;
        line-height: 1.15;
    }

    .chapter-viewer {
        height: clamp(420px, 72svh, 720px);
    }

    #chapter-viewer-container img,
    #chapter-viewer-container iframe,
    .game-content-img {
        max-width: 100%;
    }

    #chapter-viewer-container table,
    #chapter-viewer-container pre {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .cs-container {
        padding: 1rem;
    }

    .cs-board-wrapper {
        max-width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
    }

    .cs-board {
        gap: 4px;
        padding: 6px;
    }

    .cs-cell {
        width: clamp(48px, 14vw, 60px);
        height: clamp(48px, 14vw, 60px);
        font-size: clamp(2rem, 10vw, 2.8rem);
    }

    .bp-activity-card {
        padding: 0.5rem;
    }

    .bp-activity-frame {
        padding: 0.5rem 0;
    }

    .bp-container {
        box-sizing: border-box;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        padding: 0.5rem;
    }

    .bp-layout {
        flex-wrap: wrap !important;
        max-width: 100%;
        gap: 1rem !important;
        margin-bottom: 1rem !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .bp-3d-container {
        padding: 0.5rem 0.25rem;
    }

    .bp-grid[data-size="3"] {
        --bp-cell-size: clamp(40px, calc((100vw - 120px) / 5), 68px);
        --bp-grid-gap: 2px;
    }

    .bp-grid[data-size="4"] {
        --bp-cell-size: clamp(34px, calc((100vw - 120px) / 6), 56px);
        --bp-grid-gap: 2px;
    }

    .bp-3d-container[data-size="3"] {
        transform: scale(0.8);
    }

    .bp-3d-container[data-size="4"] {
        transform: scale(0.7);
    }

    .bp-3d-grid[data-size="3"] {
        --bp-3d-cell-size: 48px;
    }

    .bp-3d-grid[data-size="4"] {
        --bp-3d-cell-size: 38px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .player-arrow {
        font-size: 1.2rem;
    }

    /* Shrink the Chess Maze cells */
    .chess-cell {
        font-size: 1.5rem;
    }

    .chess-label {
        font-size: 0.5rem;
        top: 2px;
    }

    /* Adjust Video/Game detail titles */
    #game-title, #video-title {
        font-size: 1.8rem !important;
    }
    
    /* Make resources wrap properly */
    .resources-list a {
        width: 100%;
        justify-content: center;
    }
}

/* ================= Related Activities Section ================= */
.related-section {
    margin-top: 5rem;
    padding-top: 3rem;
    border-top: 1px solid var(--border-color);
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

.related-section h3 {
    font-size: 2rem;
    font-weight: 500;
    margin-bottom: 2rem;
    color: var(--text-main);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.related-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.related-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.related-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-bottom: 1px solid var(--border-color);
}

.related-card-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.related-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0 0 0.75rem 0;
}

.related-card-desc {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-muted);
    margin: 0;
}