/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F7;
    --bg-tertiary: #FAFAFA;
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --accent-primary: #007AFF;
    --accent-hover: #0051D5;
    --border-color: #D2D2D7;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
    --game-bg: #F5F5F7;
    --game-obstacle: #1C1C1E;
    --game-text: #1D1D1F;
    --game-text-secondary: #86868B;
}

[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #1C1C1E;
    --bg-tertiary: #2C2C2E;
    --text-primary: #F5F5F7;
    --text-secondary: #98989D;
    --accent-primary: #0A84FF;
    --accent-hover: #409CFF;
    --border-color: #38383A;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.7);
    --game-bg: #1C1C1E;
    --game-obstacle: #F5F5F7;
    --game-text: #F5F5F7;
    --game-text-secondary: #98989D;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    font-size: 17px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== Particle Background ===== */
#particleCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

[data-theme="dark"] #particleCanvas {
    opacity: 0.4;
}

/* ===== Header ===== */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.28, 0.11, 0.32, 1);
}

[data-theme="dark"] #header {
    background: rgba(28, 28, 30, 0.72);
}

.header-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Ensures vertical alignment */
}

/* ... existing styles ... */

/* ===== Hack Overlay ===== */
.hack-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: black;
    z-index: 9999;
    display: none;
    /* Hidden by default */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: red;
    font-family: 'Courier New', Courier, monospace;
    text-align: center;
    padding: 2rem;
}

.hack-content {
    max-width: 800px;
    border: 2px solid red;
    padding: 2rem;
    background: rgba(20, 0, 0, 0.9);
    box-shadow: 0 0 50px red;
}

.hack-demand {
    margin-top: 2rem;
    color: white;
}

.venmo-container {
    margin: 20px 0;
    background: white;
    padding: 10px;
    border-radius: 12px;
    display: inline-block;
}

.unlock-btn {
    background: red;
    color: white;
    border: 2px solid white;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    cursor: pointer;
    font-family: inherit;
    margin-top: 2rem;
    text-transform: uppercase;
    font-weight: bold;
}

.unlock-btn:hover {
    background: white;
    color: red;
}

.blink {
    animation: blink-red 0.5s infinite;
}

@keyframes blink-red {

    0%,
    100% {
        color: red;
    }

    50% {
        color: transparent;
    }
}

.logo {
    font-size: clamp(1.2rem, 5vw, 1.5rem);
    font-weight: 700;
    letter-spacing: -0.5px;
    z-index: 1001;
}

.logo-bold {
    font-weight: 600;
    color: var(--text-primary);
}

.logo-light {
    font-weight: 300;
    color: var(--text-secondary);
}

nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

nav a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: opacity 0.2s ease;
    opacity: 0.8;
}

nav a:hover {
    opacity: 1;
}

/* Theme Switch Toggle */
.theme-switch {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 48px;
    height: 28px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    padding: 2px;
}

.theme-switch::after {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    position: absolute;
    left: 4px;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);

    /* Sun Icon (Simple SVG) */
    background: white url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%23333333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg>') no-repeat center center;
}

[data-theme="dark"] .theme-switch::after {
    transform: translateX(20px);

    /* Moon Icon (Simple SVG) */
    background: white url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%23333333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>') no-repeat center center;
}

.theme-switch:hover {
    border-color: var(--text-primary);
}

/* SVG Icons & Images */
.icon {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    margin-bottom: 0.5rem;
}

.game-card-icon {
    width: 100%;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 0;
}

.game-card-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.game-card:hover .game-card-icon img {
    transform: scale(1.05);
    /* Slight zoom on hover */
}

.download-icon {
    font-size: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ===== Sections ===== */
.section {
    min-height: 100vh;
    padding: 120px 2rem;
    display: flex;
    align-items: center;
    opacity: 1;
    transform: none;
    transition: opacity 0.8s cubic-bezier(0.28, 0.11, 0.32, 1),
        transform 0.8s cubic-bezier(0.28, 0.11, 0.32, 1);
}

.section.visible {
    opacity: 1;
    transform: translateY(0);
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

.section-title {
    font-size: 3.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    text-align: center;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.section-subtitle {
    font-size: 1.375rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 5rem;
    font-weight: 400;
}

/* ===== Hero Section ===== */
.hero-section {
    background: var(--bg-primary);
}

.hero-content {
    text-align: center;
    max-width: 900px;
    margin: 0 auto;
}

.hero-greeting {
    font-size: 4rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.hero-site-name {
    color: var(--accent-primary);
}

.cursor {
    display: inline-block;
    width: 2px;
    height: 3.5rem;
    background: var(--accent-primary);
    margin-left: 4px;
    animation: blink 1s step-end infinite;
    vertical-align: middle;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

.hero-subtitle {
    font-size: 1.75rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 3rem;
}

.hero-decoration {
    display: none;
}

/* ===== Downloads Section ===== */
.downloads-section {
    background: var(--bg-secondary);
}

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

.download-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 2.5rem 2rem;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.28, 0.11, 0.32, 1);
    opacity: 1;
    transform: translateY(0);
}

.download-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.download-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

.download-icon {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
}

.download-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.download-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1rem;
    line-height: 1.5;
}

.download-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 0.75rem 1.75rem;
    border-radius: 980px;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.download-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

/* ===== Game Section ===== */
.game-section {
    background: var(--bg-primary);
}

.game-container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: var(--shadow-md);
}

.game-canvas-wrapper {
    background: #F5F5F7;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    position: relative;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
}

.game-info {
    text-align: center;
}

.game-info h3 {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.game-info p {
    color: var(--text-secondary);
    font-size: 1.0625rem;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto 1.5rem;
}

.game-controls {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-style: italic;
}

/* ===== AI Section ===== */
.ai-section {
    background: var(--bg-secondary);
}

.ai-container {
    max-width: 800px;
    margin: 0 auto;
}

.ai-chat {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.ai-messages {
    height: 450px;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--bg-tertiary);
}

.ai-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.ai-message.user {
    flex-direction: row-reverse;
}

.message-content {
    background: var(--bg-primary);
    padding: 0.875rem 1.25rem;
    border-radius: 18px;
    max-width: 75%;
    font-size: 1rem;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.ai-message.user .message-content {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.ai-message.bot .message-content {
    background: var(--bg-secondary);
}

.ai-input-container {
    display: flex;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    gap: 1rem;
    background: var(--bg-primary);
}

.ai-input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 980px;
    padding: 0.75rem 1.25rem;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.ai-input:focus {
    border-color: var(--accent-primary);
    background: var(--bg-primary);
}

.ai-send-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 0.75rem 1.75rem;
    border-radius: 980px;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.ai-send-btn:hover {
    background: var(--accent-hover);
}

/* ===== Contact Section ===== */
.contact-section {
    background: var(--bg-primary);
}

.contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.contact-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 3.5rem 2.5rem;
    text-align: center;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s cubic-bezier(0.28, 0.11, 0.32, 1);
}

.contact-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

.contact-icon {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
}

.contact-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.contact-card p {
    color: var(--text-secondary);
    font-size: 1.0625rem;
}

/* ===== Footer ===== */
.footer {
    background: var(--bg-secondary);
    padding: 2rem 0;
    /* Vertical padding only, container handles horizontal */
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.footer-links {
    display: flex;
    gap: 2rem;
    margin-bottom: 0;
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
    font-weight: 500;
}

.footer-link:hover {
    color: var(--text-primary);
}

.footer-icon {
    width: 20px;
    height: 20px;
    stroke-width: 2;
    transform: translateY(1px);
    /* Optical alignment */
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 6px;
    border: 3px solid var(--bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    nav {
        gap: 1rem;
    }

    nav a {
        font-size: 0.8125rem;
    }

    .hero-greeting {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1.25rem;
    }

    .section-title {
        font-size: 2.5rem;
    }

    .section-subtitle {
        font-size: 1.125rem;
        margin-bottom: 3rem;
    }

    .downloads-grid {
        grid-template-columns: 1fr;
    }

    .cursor {
        height: 2.5rem;
    }

    .game-container {
        padding: 2rem;
    }
}

/* ===== Game Library ===== */
.game-library-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.active-game-container {
    background: var(--bg-primary);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.game-canvas-wrapper {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 4/3;
    max-height: 600px;
}

.game-canvas-wrapper iframe {
    width: 100%;
    height: 100%;
    display: block;
}

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

.game-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.game-card:hover {
    transform: translateY(-2px);
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-md);
}

.game-card.active {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.game-card-icon {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.game-card h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.game-card.local-loader {
    border-style: dashed;
}

@media (max-width: 480px) {
    .header-content {
        padding: 1rem 1.25rem;
    }

    .section {
        padding: 100px 1.25rem;
    }

    .logo {
        font-size: 1.125rem;
    }

    nav {
        gap: 0.75rem;
    }

    nav a {
        font-size: 0.75rem;
    }

    .game-container {
        padding: 1.5rem;
    }

    /* Single column games on phone */
    .game-grid {
        grid-template-columns: 1fr;
    }

    .hack-demand {
        margin-top: 1rem;
    }
}

/* ===== Fullscreen Button ===== */
.fullscreen-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 100;
}

.game-canvas-wrapper:hover .fullscreen-btn {
    opacity: 1;
}

.fullscreen-btn:hover {
    background: rgba(0, 122, 255, 0.8);
    transform: scale(1.08);
    border-color: rgba(255, 255, 255, 0.4);
}

.fullscreen-btn .icon {
    width: 22px;
    height: 22px;
    stroke: white;
    margin-bottom: 0;
}

/* Fullscreen Mode Styles */
.game-canvas-wrapper:fullscreen,
.game-canvas-wrapper:-webkit-full-screen,
.game-canvas-wrapper:-moz-full-screen,
.game-canvas-wrapper:-ms-fullscreen {
    width: 100vw;
    height: 100vh;
    max-height: none;
    aspect-ratio: unset;
    border-radius: 0;
    background: #000;
}

.game-canvas-wrapper:fullscreen iframe,
.game-canvas-wrapper:-webkit-full-screen iframe,
.game-canvas-wrapper:-moz-full-screen iframe,
.game-canvas-wrapper:-ms-fullscreen iframe {
    width: 100%;
    height: 100%;
}

.game-canvas-wrapper:fullscreen #localGameContainer,
.game-canvas-wrapper:-webkit-full-screen #localGameContainer,
.game-canvas-wrapper:-moz-full-screen #localGameContainer,
.game-canvas-wrapper:-ms-fullscreen #localGameContainer {
    width: 100% !important;
    height: 100vh !important;
}

.game-canvas-wrapper:fullscreen .fullscreen-btn,
.game-canvas-wrapper:-webkit-full-screen .fullscreen-btn,
.game-canvas-wrapper:-moz-full-screen .fullscreen-btn,
.game-canvas-wrapper:-ms-fullscreen .fullscreen-btn {
    opacity: 0;
    bottom: 20px;
    right: 20px;
}

.game-canvas-wrapper:fullscreen:hover .fullscreen-btn,
.game-canvas-wrapper:-webkit-full-screen:hover .fullscreen-btn,
.game-canvas-wrapper:-moz-full-screen:hover .fullscreen-btn,
.game-canvas-wrapper:-ms-fullscreen:hover .fullscreen-btn {
    opacity: 1;
}

/* Touch devices - always show fullscreen button */
@media (hover: none) {
    .fullscreen-btn {
        opacity: 0.8;
    }

    .game-canvas-wrapper:fullscreen .fullscreen-btn,
    .game-canvas-wrapper:-webkit-full-screen .fullscreen-btn {
        opacity: 0.8;
    }
}