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

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #6366f1;
    --accent-hover: #818cf8;
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

#graphics-canvas {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
}

.canvas-container::before,
.canvas-container::after {
    content: "";
    position: absolute;
    display: none;
    width: 75vmax;
    height: 75vmax;
    border-radius: 50%;
    opacity: 0;
    will-change: transform;
}

/* ==========================================================================
   Home Page Content & Hero
   ========================================================================== */

.content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: 100vh;
    padding: 2rem;
}

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

.hero h1 {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero .subtitle {
    font-size: clamp(1rem, 3vw, 1.25rem);
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.6;
}

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

.links a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--accent);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    background: rgba(99, 102, 241, 0.1);
}

.links a:hover {
    background: var(--accent);
    transform: translateY(-2px);
}

.bottom-section {
    padding-top: 2rem;
    padding-bottom: 0.5rem;
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.subpage-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    border-bottom: 1px dashed rgba(161, 161, 170, 0.35);
    padding-bottom: 2px;
    transition: all 0.2s ease;
}

.subpage-link:hover {
    color: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* ==========================================================================
   Rerun Subpage
   ========================================================================== */

.rerun-page {
    position: relative;
    z-index: 1;
    height: 100vh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.25rem 1.25rem;
    max-width: 100%;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

.rerun-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.rerun-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.45rem 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background: rgba(18, 18, 26, 0.6);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.back-link:hover {
    color: var(--text-primary);
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.15);
}

.viewer-container {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    background: #000000;
    display: flex;
    position: relative;
}

.viewer-container iframe {
    width: 100%;
    height: 100%;
    flex: 1 1 0;
    min-height: 0;
    border: none;
    display: block;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-size: 1.25rem;
    color: var(--text-secondary);
}

@media (max-width: 768px), (pointer: coarse) {
    .canvas-container {
        background:
            radial-gradient(circle at 50% 45%, rgba(48, 50, 112, 0.3), transparent 56%),
            var(--bg-primary);
    }

    .canvas-container::before,
    .canvas-container::after {
        display: block;
        opacity: 1;
    }

    .canvas-container::before {
        top: -36vmax;
        left: -32vmax;
        background: radial-gradient(
            circle,
            rgba(99, 102, 241, 0.46) 0%,
            rgba(79, 70, 229, 0.2) 40%,
            transparent 68%
        );
        animation: mobile-orbit-one 9s ease-in-out infinite alternate;
    }

    .canvas-container::after {
        right: -40vmax;
        bottom: -34vmax;
        background: radial-gradient(
            circle,
            rgba(129, 140, 248, 0.38) 0%,
            rgba(67, 56, 202, 0.18) 42%,
            transparent 70%
        );
        animation: mobile-orbit-two 12s ease-in-out infinite alternate;
    }

    #graphics-canvas {
        opacity: 0.96;
    }
}

@keyframes mobile-orbit-one {
    from {
        transform: translate3d(0, 0, 0) scale(0.9);
    }
    to {
        transform: translate3d(58vw, 48vh, 0) scale(1.24);
    }
}

@keyframes mobile-orbit-two {
    from {
        transform: translate3d(0, 0, 0) scale(1.12);
    }
    to {
        transform: translate3d(-52vw, -44vh, 0) scale(0.82);
    }
}

@media (max-width: 768px) {
    .rerun-page {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .links {
        flex-direction: column;
        width: 100%;
    }

    .links a {
        justify-content: center;
    }

    .rerun-header {
        gap: 0.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .canvas-container::before,
    .canvas-container::after {
        animation: none;
        will-change: auto;
    }
}
