:root {
    --classic-bg: #0b1118;
    --classic-bg-alt: #111a24;
    --classic-surface: #152332;
    --classic-line: #2f4760;
    --classic-text: #e4eef8;
    --classic-text-muted: #9eb3c8;
    --classic-mint: #3ed5a3;
    --classic-shadow: #061018cc;
    --radius: 16px;
    --radius-sm: 12px;
    --max-width: 1120px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    color: var(--classic-text);
    background:
        radial-gradient(1100px 700px at 8% -15%, #2a455f 0%, #0b1118 55%),
        radial-gradient(900px 600px at 105% 0%, #2f3d2f 0%, #0b1118 60%),
        var(--classic-bg);
    min-height: 100vh;
    overflow-x: hidden;
}

.backdrop {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.backdrop::before,
.backdrop::after {
    content: "";
    position: absolute;
    border-radius: 9999px;
    filter: blur(2px);
    animation: drift 16s ease-in-out infinite;
}

.backdrop::before {
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, #3ed5a344 0%, #00000000 72%);
    top: 8%;
    right: -70px;
}

.backdrop::after {
    width: 340px;
    height: 340px;
    background: radial-gradient(circle, #f2b5632f 0%, #00000000 70%);
    left: -100px;
    bottom: -60px;
    animation-delay: 3s;
}

.grid-lines {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(#7ea6ca14 1px, transparent 1px),
        linear-gradient(90deg, #7ea6ca14 1px, transparent 1px);
    background-size: 42px 42px;
    opacity: 0.8;
}

@keyframes drift {
    0%,
    100% {
        transform: translateY(0) translateX(0);
    }
    50% {
        transform: translateY(-14px) translateX(8px);
    }
}

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

.page {
    position: relative;
    z-index: 1;
    width: min(var(--max-width), calc(100% - 2rem));
    margin: 0 auto;
    padding: 2.2rem 0 4rem;
}

.panel {
    border: 1px solid var(--classic-line);
    border-radius: var(--radius);
    background: linear-gradient(145deg, #152332d9 0%, #122130f2 100%);
    box-shadow: 0 20px 50px -34px var(--classic-shadow);
    backdrop-filter: blur(6px);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 1.1rem;
    margin-bottom: 1.25rem;
    animation: riseIn 0.45s ease both;
}

.top-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.tag {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    color: var(--classic-mint);
    text-transform: uppercase;
}

.top-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.chip-link {
    text-decoration: none;
    color: var(--classic-text);
    border: 1px solid var(--classic-line);
    border-radius: 9999px;
    background: #17283a;
    padding: 0.4rem 0.8rem;
    font-size: 0.84rem;
    transition: 0.2s ease;
}

.chip-link:hover {
    border-color: #4d6f8f;
    background: #1f3349;
    transform: translateY(-1px);
}

.mode-switch {
    display: inline-flex;
    border: 1px solid #3b5874;
    border-radius: 999px;
    padding: 0.2rem;
    background: #122130;
    gap: 0.25rem;
}

.mode-btn {
    border: 0;
    border-radius: 999px;
    padding: 0.38rem 0.72rem;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.74rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #b6cae0;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.mode-btn.active {
    color: #f4faff;
    background: #27435e;
}

.hero {
    padding: 2.1rem;
    animation: riseIn 0.55s ease both;
    animation-delay: 0.06s;
}

.hero p {
    color: var(--classic-text-muted);
    margin: 0;
    max-width: 760px;
    line-height: 1.65;
    font-size: 1.02rem;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 3.7vw, 3.6rem);
    line-height: 1.05;
    letter-spacing: -0.01em;
}

.subtitle {
    margin-top: 0.8rem;
    margin-bottom: 1rem;
    font-size: clamp(1rem, 2vw, 1.28rem);
    color: #b9d2ea;
    font-weight: 500;
}

.accent {
    color: var(--classic-mint);
}

.cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.35rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 0.6rem 1rem;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: 0.2s ease;
}

.btn-primary {
    background: linear-gradient(120deg, #2bc594 0%, #1fa97d 100%);
    color: #052016;
}

.btn-primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.btn-secondary {
    border-color: #426482;
    color: var(--classic-text);
    background: #1a2b3d;
}

.btn-secondary:hover {
    background: #21384f;
    border-color: #567b9d;
}

.quick-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem;
    margin-top: 1rem;
    animation: riseIn 0.6s ease both;
    animation-delay: 0.12s;
}

.stat-card {
    padding: 1rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #eaf4ff;
    margin: 0;
}

.stat-label {
    margin: 0.2rem 0 0;
    color: var(--classic-text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.section {
    margin-top: 1.2rem;
    padding: 1.4rem;
    animation: riseIn 0.65s ease both;
    animation-delay: 0.18s;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

h2 {
    margin: 0;
    font-size: clamp(1.3rem, 2.1vw, 1.85rem);
    letter-spacing: -0.01em;
}

.section-head p {
    margin: 0;
    color: var(--classic-text-muted);
    max-width: 720px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-btn {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.8rem;
    border-radius: 999px;
    border: 1px solid #3b5874;
    color: #cce0f4;
    background: #152636;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    transition: 0.2s ease;
}

.filter-btn:hover {
    border-color: #5a7f9f;
    background: #1a3146;
}

.filter-btn.active {
    background: #2f4f69;
    border-color: #7eb2de;
    color: #f3f9ff;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}

.project-card {
    padding: 1rem;
    border: 1px solid var(--classic-line);
    border-radius: var(--radius-sm);
    background: linear-gradient(145deg, #152434ef 0%, #132131f8 100%);
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.project-card:hover {
    transform: translateY(-2px);
    border-color: #4f7597;
    box-shadow: 0 14px 30px -22px #26425ecc;
}

.project-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.project-title {
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.25;
}

.project-kind {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    border: 1px solid #486788;
    color: #cbe1f7;
    white-space: nowrap;
    text-transform: uppercase;
}

.summary {
    margin: 0;
    color: var(--classic-text-muted);
    line-height: 1.55;
    font-size: 0.95rem;
    min-height: 4.6em;
}

.stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.stack span {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.74rem;
    border-radius: 7px;
    background: #1d3044;
    border: 1px solid #3c5873;
    color: #d4e6f8;
    padding: 0.2rem 0.45rem;
}

.project-actions {
    margin-top: auto;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.artifact-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
}

.artifact-card {
    border: 1px solid var(--classic-line);
    border-radius: var(--radius-sm);
    background: linear-gradient(145deg, #152434ef 0%, #132131f8 100%);
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    min-height: 320px;
}

.artifact-title {
    margin: 0;
    font-size: 0.96rem;
    color: #e6f2ff;
}

.artifact-caption {
    margin: 0.35rem 0 0.6rem;
    color: var(--classic-text-muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.artifact-viewport {
    width: 100%;
    min-height: 220px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    border: 1px solid #3f5a74;
    background: #0c1826;
    overflow: hidden;
    margin-top: auto;
}

.monster-stage img,
.icon-stage img {
    max-width: 100%;
    max-height: 260px;
    object-fit: contain;
    image-rendering: pixelated;
}

.symbol-canvas-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 1px solid #3f5a74;
    border-radius: 10px;
    overflow: hidden;
    background: #09111d;
    display: grid;
    place-items: center;
}

#symbol-crop-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
}

.sprite-swarm-stage {
    width: 100%;
    height: 220px;
    border-radius: 10px;
    background: linear-gradient(180deg, #13273a, #0d1d2d 65%);
    border: 1px solid #3f5a74;
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
}

.sprite-swarm-stage::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 22px;
    height: 2px;
    background: #6284a6;
    opacity: 0.5;
}

.sprite-swarm-track {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.35rem;
    align-items: end;
    padding: 0 0.35rem;
}

.sprite-actor {
    width: 32px;
    height: 48px;
    margin: 0 auto;
    background-repeat: no-repeat;
    background-size: 352px 5664px;
    image-rendering: pixelated;
    transform: translateY(-8px);
}

.mini-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    border: 1px solid #44607d;
    background: #1a2f44;
    color: #ecf5ff;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.45rem 0.68rem;
    cursor: pointer;
    transition: 0.2s ease;
}

.mini-btn:hover {
    background: #23405a;
    border-color: #668cad;
}

.mini-btn.primary {
    background: #2ec495;
    color: #042116;
    border-color: #32cd9c;
}

.mini-btn.primary:hover {
    background: #39d6a4;
}

.insights {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
}

.insight {
    padding: 0.95rem;
}

.insight h3 {
    margin: 0;
    font-size: 1rem;
    color: #eaf4ff;
}

.insight p {
    margin: 0.35rem 0 0;
    color: var(--classic-text-muted);
    line-height: 1.5;
    font-size: 0.92rem;
}

footer {
    margin-top: 1.3rem;
    padding: 1rem 0.3rem 0;
    color: #8fa6bc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
}

.footer-links {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: #b8d2e9;
    text-decoration: none;
}

.footer-links a:hover {
    color: #e8f4ff;
    text-decoration: underline;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: #04090fcc;
}

.modal.open {
    display: flex;
}

.modal-inner {
    width: min(760px, 100%);
    max-height: 90vh;
    overflow: auto;
    border: 1px solid #3f5e79;
    border-radius: var(--radius);
    background: linear-gradient(150deg, #132332fc 0%, #101e2afc 100%);
    box-shadow: 0 18px 42px -24px #050f18;
    padding: 1.2rem;
}

.modal-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.modal h3 {
    margin: 0;
    font-size: 1.28rem;
}

.close {
    border: 1px solid #4a6884;
    background: #173046;
    color: #dbebfb;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    cursor: pointer;
}

.close:hover {
    background: #214460;
}

.modal p,
.modal li {
    color: #b8cde0;
    line-height: 1.6;
}

.modal ul {
    margin: 0.55rem 0 0.7rem;
    padding-left: 1.15rem;
}

.modal h4 {
    margin: 0.8rem 0 0.25rem;
    color: #f0f7ff;
}

@media (max-width: 980px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .top-right {
        width: 100%;
        justify-content: flex-start;
    }

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

    .artifact-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sprite-swarm-track {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .quick-stats,
    .insights {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .page {
        width: min(var(--max-width), calc(100% - 1.2rem));
        padding-top: 1rem;
        padding-bottom: 2.5rem;
    }

    .topbar,
    .hero,
    .section {
        padding: 1rem;
    }

    .top-right {
        gap: 0.5rem;
    }

    .mode-switch {
        width: 100%;
        justify-content: space-between;
    }

    .mode-btn {
        flex: 1;
        text-align: center;
    }

    .hero p {
        font-size: 0.97rem;
    }

    h1 {
        font-size: 2rem;
    }

    .summary {
        min-height: auto;
    }

    .artifact-row {
        grid-template-columns: 1fr;
    }

    .sprite-swarm-track {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
