@charset "utf-8";
:root {
    --bg: #0f1115;
    --bg-alt: #161922;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent: #60a5fa;
    --accent-dark: #3b82f6;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --z-background: -10;
    --z-content: 1;
    --z-game: 100;
    --z-overlay: 200;
    --z-dot: 1000;
}

@supports (color: color(display-p3 1 1 1)) {
    :root {
        --accent: color(display-p3 0.376 0.647 0.98);
        --accent-dark: color(display-p3 0.231 0.51 0.965);
    }
}

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

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Game Target Zone Styles */
.target-zone {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    width: 20px;
    height: 20px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: var(--z-content);
}

.target-zone.visible {
    opacity: 1;
}

.target-zone.active {
    border-color: var(--accent);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.2); opacity: 0.6; }
}

/* Game Container Styles */
.game-container {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    background: var(--bg-alt);
    border-radius: 1rem;
    z-index: var(--z-game);
    padding: 2rem;
}

.game-container.active {
    opacity: 1;
    visibility: visible;
}

/* Game Canvas Styles */
#gameCanvas {
    max-width: 100%;
    height: auto;
    border: 2px solid #333;
    background: #000;
    border-radius: 1rem;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.game-container.active #gameCanvas {
    opacity: 1;
    transform: scale(1);
}

/* Loading State */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 17, 21, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: var(--z-overlay);
    border-radius: 1rem;
}

.loading-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(96, 165, 250, 0.2);
    border-left-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* Content Styles */
.content {
    width: 100%;
    max-width: 110ch;
    margin: 0 auto;
    background: var(--bg-alt);
    padding: clamp(2rem, 4vw, 3rem);
    border-radius: 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1),
               0 2px 4px rgba(0, 0, 0, 0.1),
               0 4px 8px rgba(0, 0, 0, 0.1),
               0 8px 16px rgba(0, 0, 0, 0.1);
    display: grid;
    gap: clamp(1.5rem, 3vw, 2.5rem);
    opacity: 0;
    animation: fadeUpIn 0.75s ease-out forwards;
    animation-delay: .5s;
    position: relative;
    z-index: var(--z-content);
    transition: all 0.3s ease;
}

/* Game state transitions */
.content.game-active > *:not(.game-container):not(.loading-overlay) {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: visibility 0s, opacity 0.3s ease;
}

.content.game-active > *:not(.game-container):not(.loading-overlay) * {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: visibility 0s, opacity 0.3s ease;
}

.content:not(.game-active) > *:not(.game-container):not(.loading-overlay) {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition: visibility 0s, opacity 0.3s ease;
}

.content:not(.game-active) > *:not(.game-container):not(.loading-overlay) * {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition: visibility 0s, opacity 0.3s ease;
}

/* Game UI Elements */
#score, #lives {
    position: absolute;
    top: 1rem;
    color: var(--text);
    font-size: 1.25rem;
    z-index: calc(var(--z-game) + 1);
}

#score { left: 1rem; }
#lives { right: 1rem; }

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text);
    font-size: 3rem;
    text-align: center;
    display: none;
    z-index: calc(var(--z-game) + 2);
}

.game-over button {
    padding: 0.75rem 1.5rem;
    font-size: 1.25rem;
    margin: 1rem 0.5rem;
    cursor: pointer;
    background: var(--accent);
    border: none;
    color: white;
    border-radius: 0.5rem;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.game-over button:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.25);
}

.game-over button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(96, 165, 250, 0.25);
}

/* Physics Canvas - THESE ARE CRITICAL */
.physics-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: var(--z-dot);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.physics-canvas.active {
    cursor: grabbing;
    pointer-events: all;
}

.physics-canvas.interactive {
    pointer-events: all;
    cursor: grab;
}

.content.game-active ~ .physics-canvas {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Background Elements */
.gradient-bg {
    position: fixed;
    inset: 0;
    z-index: var(--z-background);
    opacity: 0.25;
}

.gradient-1, .gradient-2, .gradient-3 {
    position: absolute;
    inset: -50% -50%;
    background: radial-gradient(circle at center, var(--accent) 50%, transparent 100%);
    opacity: 0.1;
    will-change: transform;
}

.gradient-1 { 
    animation: moveGradient1 30s ease-in-out infinite paused;
    background: radial-gradient(circle at 30% 30%, var(--accent) 0%, transparent 90%);
}

.gradient-2 { 
    animation: moveGradient2 45s ease-in-out infinite paused;
    background: radial-gradient(circle at 70% 70%, var(--accent-dark) 0%, transparent 90%);
}

.gradient-3 { 
    animation: moveGradient3 60s ease-in-out infinite paused;
    background: radial-gradient(ellipse at center, var(--accent) 0%, transparent 90%);
}

@keyframes moveGradient1 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(25%, -15%) rotate(90deg); }
    50% { transform: translate(-10%, 25%) rotate(180deg); }
    75% { transform: translate(-25%, -25%) rotate(270deg); }
}

@keyframes moveGradient2 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(-20%, 25%) rotate(-120deg); }
    66% { transform: translate(25%, -15%) rotate(240deg); }
}

@keyframes moveGradient3 {
    0%, 100% { transform: scale(1) translate(0, 0); }
    25% { transform: scale(1.2) translate(10%, 10%); }
    50% { transform: scale(0.8) translate(-20%, 20%); }
    75% { transform: scale(1.1) translate(15%, -15%); }
}

@keyframes fadeUpIn {
    0% {
        opacity: 0;
        transform: translateY(50px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.organic-shapes {
    position: fixed;
    inset: 0;
    z-index: var(--z-background);
    opacity: 0.1;
    pointer-events: none;
}

.shape {
    position: absolute;
    animation: float 20s ease-in-out infinite;
    will-change: transform;
}

.shape-1 {
    top: 10%;
    left: 10%;
    animation-delay: -5s;
}

.shape-2 {
    bottom: 20%;
    right: 15%;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(50px, 30px) rotate(5deg); }
    50% { transform: translate(-20px, -50px) rotate(-5deg); }
    75% { transform: translate(30px, 20px) rotate(3deg); }
}

.grain {
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23noise)' opacity='0.075'/%3E%3C/svg%3E");
    pointer-events: none;
    opacity: 0.99;
    mix-blend-mode: overlay;
    z-index: var(--z-background);
}

/* Layout Elements */
.container {
    width: min(1400px, 100%);
    margin: 0 auto;
    padding: clamp(2rem, 5vw, 4rem);
    padding-left: calc(clamp(2rem, 5vw, 4rem) + 100px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

header {
    position: relative;
    margin-bottom: 2rem;
    align-self: flex-start;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 110ch;
    opacity: 0;
    animation: fadeUpIn 0.75s ease-out forwards;
}

h1 {
    font-size: clamp(2.5rem, 8vw, 6rem);
    line-height: 1;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    text-align: left;
    position: relative;
}

.dot-container {
    display: inline;
    position: relative;
}

.dot {
    position: absolute;
    width: 0.2em;
    height: 0.2em;
    background: var(--accent);
    border-radius: 50%;
    cursor: grab;
    transition: opacity 0.3s ease;
    bottom: 0.15em;
    user-select: none;
    touch-action: none;
    z-index: 100;
}

.dot.hidden {
    opacity: 0;
    pointer-events: none;
}

.dot-placeholder {
    position: absolute;
    width: 0.2em;
    height: 0.2em;
    border: 2px dashed rgba(226, 232, 240, 0.3);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
    bottom: 0.15em;
    pointer-events: none;
}

.dot-placeholder.visible {
    opacity: 1;
}

p {
    font-size: clamp(1.125rem, 1.5vw, 1.25rem);
    color: var(--text-secondary);
}

a {
    color: var(--accent);
    text-decoration: none;
    position: relative;
    padding: 0.1em 0;
    z-index: 2;
    pointer-events: auto;
}

a::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(96, 165, 250, 0.9);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s cubic-bezier(0.76, 0, 0.24, 0.8);
    z-index: -1;
    opacity: 0.4;
}

.content:not(.game-active) a:hover {
    color: var(--accent);
}

.content:not(.game-active) a:hover::after {
    transform: scaleX(1);
}

/* Media Queries */
@media (max-width: 768px) {
    .container {
        padding: 1.5rem;
    }
    
    .content {
        padding: 1.5rem;
    }

    header {
        transform: none;
    }

    .game-container {
        padding: 1rem;
    }

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

    .game-over {
        font-size: 2rem;
    }

    .game-over button {
        padding: 0.5rem 1rem;
        font-size: 1rem;
        margin: 0.5rem;
    }

    .target-zone {
        bottom: 1rem;
        right: 1rem;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .gradient-1, .gradient-2, .gradient-3, 
    .shape, .dot, .dot-placeholder,
    .target-zone, .game-container,
    #gameCanvas, .return-button {
        animation: none;
        transition: none;
    }
    
    .physics-canvas {
        transition: none;
    }

    header,
    .content {
        animation: none;
        opacity: 1;
    }

    .loading-spinner {
        animation: none;
    }

    .game-over button:hover {
        transform: none;
    }
}

/* Touch Device Optimizations */
@media (max-width: 620px) {
    .dot {
        width: 0.3em;
        height: 0.3em;
    }

    .target-zone {
        width: 30px;
        height: 30px;
    }

    .game-over button {
        padding: 1rem 2rem;
        margin: 1rem;
    }
    
    a {
        padding: 0.5em 0;
    }
    
    a::after {
        display: none;
    }

    .game-over button:hover {
        transform: none;
        box-shadow: none;
    }

    h1 {
        font-size: clamp(3rem, 10vw, 7rem);
    }
    
    html, body {
        height: 100vh;
        overflow: hidden;
        position: static;  
        width: 100%;
    }

    .container {
        height: auto;
        min-height: 100vh;
        display: block;
        padding: 2rem;
    }

    header {
        flex-shrink: initial;
    }
   
    .content {
        max-height: 300px;
        overflow-y: scroll;
    }

    .content::-webkit-scrollbar {
        width: 30px; /* Much wider */
    }
    
    .content::-webkit-scrollbar-track {
        background: var(--bg-alt);
        border-radius: 10px;
    }
    
    .content::-webkit-scrollbar-thumb {
        background: var(--accent);
        border-radius: 10px;
        border: 5px solid var(--bg-alt); /* Creates padding around the thumb */
    }
}

