/* ─── Base & Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
}

body {
    background-color: #0B0714;
    color: #ECE7FB;
    -webkit-font-smoothing: antialiased;
}

::selection { background: #FF2E9A; color: #0B0714; }

/* ─── CRT overlays ─────────────────────────────────────────────── */
.crt-scanlines {
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0px,
        rgba(0, 0, 0, 0) 2px,
        rgba(0, 0, 0, 0.28) 3px
    );
}

.crt-vignette {
    position: fixed;
    inset: 0;
    z-index: 9997;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.55) 100%);
}

.crt-flicker {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    background: rgba(255, 46, 154, 0.02);
    animation: flicker 6s infinite;
}
@keyframes flicker {
    0%, 92%, 100% { opacity: 0; }
    93% { opacity: 1; }
    94% { opacity: 0; }
    96% { opacity: 0.6; }
    97% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .crt-flicker { animation: none; }
    * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}

/* ─── Pixel-notched corners ────────────────────────────────────── */
.pixel-corners {
    clip-path: polygon(
        0 12px, 12px 12px, 12px 0, calc(100% - 12px) 0, calc(100% - 12px) 12px, 100% 12px,
        100% calc(100% - 12px), calc(100% - 12px) calc(100% - 12px), calc(100% - 12px) 100%,
        12px 100%, 12px calc(100% - 12px), 0 calc(100% - 12px)
    );
}
.pixel-corners-sm {
    clip-path: polygon(
        0 6px, 6px 6px, 6px 0, calc(100% - 6px) 0, calc(100% - 6px) 6px, 100% 6px,
        100% calc(100% - 6px), calc(100% - 6px) calc(100% - 6px), calc(100% - 6px) 100%,
        6px 100%, 6px calc(100% - 6px), 0 calc(100% - 6px)
    );
}

.glow-primary {
    box-shadow: 0 0 30px rgba(255, 46, 154, 0.08);
    transition: box-shadow 0.4s ease;
}
.glow-primary:hover {
    box-shadow: 0 0 45px rgba(255, 46, 154, 0.2);
}

/* ─── Arcade buttons ───────────────────────────────────────────── */
.btn-arcade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 6px 0 #7A1252, 0 6px 20px rgba(255, 46, 154, 0.35);
    border: 2px solid #7A1252;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.btn-arcade:hover { filter: brightness(1.1); }
.btn-arcade:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #7A1252;
}

.btn-arcade-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #150C29;
    border: 2px solid #3A2A5C;
    box-shadow: 0 6px 0 #0E081C;
    transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.2s ease;
}
.btn-arcade-outline:hover { border-color: #29F1FF; color: #29F1FF; }
.btn-arcade-outline:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #0E081C;
}

/* ─── Hud bar / nav ────────────────────────────────────────────── */
.hud-bar {
    background: rgba(11, 7, 20, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid #3A2A5C;
}

.nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 6px 2px;
    transition: color 0.2s ease, text-shadow 0.2s ease;
}
.nav-link.nav-active {
    color: #29F1FF !important;
    text-shadow: 0 0 10px rgba(41, 241, 255, 0.45);
}
.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: #29F1FF;
    box-shadow: 0 0 8px #29F1FF, 0 0 14px rgba(41, 241, 255, 0.6);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    opacity: 0;
    pointer-events: none;
}
.nav-link.nav-active::after {
    transform: scaleX(1);
    opacity: 1;
}

/* ─── Mobile nav / hamburger ───────────────────────────────────── */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 4px;
}
.hamburger span {
    display: block;
    width: 24px;
    height: 3px;
    background: #ECE7FB;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.hamburger.open span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

.mobile-menu {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(11, 7, 20, 0.98);
    backdrop-filter: blur(16px);
    border-bottom: 2px solid #3A2A5C;
    z-index: 49;
}
.mobile-menu.open { display: flex; }
.mobile-menu a {
    padding: 18px 24px;
    color: #A79BD1;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: color 0.2s, background 0.2s;
}
.mobile-menu a:hover { color: #29F1FF; background: rgba(41, 241, 255, 0.05); }

@media (max-width: 1023px) {
    .hamburger { display: flex; }
}

/* ─── Score HUD counter ─────────────────────────────────────────── */
#score-value { letter-spacing: 2px; }

/* ─── Marquee ticker ───────────────────────────────────────────── */
.marquee {
    overflow: hidden;
    white-space: nowrap;
    padding: 6px 0;
}
.marquee-track {
    display: inline-flex;
    width: max-content;
    animation: marqueeScroll 30s linear infinite;
}
@keyframes marqueeScroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* ─── Hero ─────────────────────────────────────────────────────── */
.hero-section {
    min-height: 90vh;
    display: flex;
    align-items: center;
    padding-top: 40px;
    padding-bottom: 40px;
}

.retro-grid {
    position: absolute;
    inset: -10% -10% 0 -10%;
    background-image:
        linear-gradient(rgba(255, 46, 154, 0.18) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 46, 154, 0.18) 1px, transparent 1px);
    background-size: 48px 48px;
    transform: perspective(500px) rotateX(60deg);
    transform-origin: bottom;
    height: 60%;
    top: auto;
    bottom: 0;
    mask-image: linear-gradient(to top, rgba(0,0,0,1) 0%, transparent 90%);
    animation: gridScroll 8s linear infinite;
    opacity: 0.5;
    z-index: 0;
}
@keyframes gridScroll {
    from { background-position: 0 0; }
    to { background-position: 0 48px; }
}

.blink { animation: blink 1.2s step-end infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.term-cursor { color: #29F1FF; animation: blink 1s step-end infinite; }

/* Glitch title */
.glitch-text {
    position: relative;
    text-shadow: 2px 0 #FF2E9A, -2px 0 #29F1FF;
}

/* ─── Character card stat bars ─────────────────────────────────── */
.stat-row { display: flex; align-items: center; gap: 10px; }
.stat-row span { width: 90px; flex-shrink: 0; }
.stat-bar {
    flex: 1;
    height: 10px;
    background: #0E081C;
    border: 1px solid #3A2A5C;
    position: relative;
    overflow: hidden;
}
.stat-fill {
    height: 100%;
    background-image: repeating-linear-gradient(
        90deg,
        currentColor 0px, currentColor 6px, rgba(11,7,20,0.55) 6px, rgba(11,7,20,0.55) 8px
    );
    background-color: currentColor;
}

/* ─── Level headers ────────────────────────────────────────────── */
.level-header { max-width: 720px; }

/* ─── Quest tags / chips ───────────────────────────────────────── */
.quest-tag {
    display: inline-block;
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    padding: 6px 12px;
    letter-spacing: 0.5px;
}

.xp-chip {
    display: inline-block;
    font-family: 'VT323', monospace;
    font-size: 16px;
    color: #4CFF7A;
    background: rgba(76, 255, 122, 0.08);
    border: 1px solid #4CFF7A;
    padding: 4px 11px;
}

.tech-tag {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #A79BD1;
    background: #0E081C;
    border: 1px solid #3A2A5C;
    padding: 5px 12px;
    transition: border-color 0.2s, color 0.2s;
}
.tech-tag:hover { border-color: #29F1FF; color: #29F1FF; }

.tech-tag-sm {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #A79BD1;
    background: #0E081C;
    border: 1px solid #3A2A5C;
    padding: 3px 8px;
}

/* ─── Project filter tabs ──────────────────────────────────────── */
.filter-tab {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 11px 16px;
    background: #150C29;
    border: 2px solid #3A2A5C;
    color: #A79BD1;
    cursor: pointer;
    transition: all 0.2s ease;
}
.filter-tab:hover { border-color: #29F1FF; color: #29F1FF; }
.filter-tab.is-active {
    background: #FF2E9A;
    border-color: #FF2E9A;
    color: #0B0714;
}

/* ─── Cartridge cards ──────────────────────────────────────────── */
.cartridge {
    background: #150C29;
    border: 2px solid #3A2A5C;
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.cartridge:hover {
    transform: translateY(-4px);
    border-color: #29F1FF;
    box-shadow: 0 10px 30px rgba(41, 241, 255, 0.12);
}
.cartridge.is-hidden { display: none; }
.cartridge-label {
    display: inline-block;
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: #0B0714;
    padding: 6px 10px;
    margin-bottom: 12px;
    width: fit-content;
}
.cartridge-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 13px;
    color: #ECE7FB;
    margin-bottom: 10px;
    line-height: 1.5;
}
.cartridge-desc {
    font-size: 14px;
    color: #A79BD1;
    line-height: 1.6;
    margin-bottom: 14px;
    flex: 1;
}
.cartridge-link {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: #29F1FF;
    text-decoration: none;
}
.cartridge-link:hover { text-decoration: underline; }

/* ─── Skill slots ──────────────────────────────────────────────── */
.skill-slot {
    display: inline-block;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
    color: #ECE7FB;
    background: #0E081C;
    border: 2px solid #3A2A5C;
    padding: 9px 15px;
    transition: all 0.2s ease;
}
.skill-slot:hover {
    border-color: #29F1FF;
    box-shadow: 0 0 12px rgba(41, 241, 255, 0.35);
    transform: translateY(-2px);
}
.skill-slot.is-key {
    border-color: #FF2E9A;
    color: #FF2E9A;
    background: rgba(255, 46, 154, 0.08);
}

/* ─── Achievement cards ────────────────────────────────────────── */
.achievement {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: #150C29;
    border: 2px solid #3A2A5C;
    padding: 16px;
    transition: border-color 0.2s ease, transform 0.2s ease;
}
.achievement:hover { border-color: #FFE24C; transform: translateY(-2px); }
.achievement-title {
    font-size: 14px;
    color: #ECE7FB;
    line-height: 1.4;
    margin-bottom: 4px;
}
.achievement-meta {
    font-family: 'VT323', monospace;
    font-size: 15px;
    color: #A79BD1;
}

/* ─── Contact menu rows ────────────────────────────────────────── */
.contact-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 8px;
    color: #A79BD1;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s, background 0.2s;
}
.contact-row-arrow { color: transparent; transition: color 0.2s; }
.contact-row:hover { color: #ECE7FB; background: rgba(41, 241, 255, 0.05); }
.contact-row:hover .contact-row-arrow { color: #29F1FF; }

/* ─── Social icon buttons ──────────────────────────────────────── */
.social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: #0E081C;
    border: 2px solid #3A2A5C;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.social-btn:hover {
    background: rgba(255, 46, 154, 0.15);
    border-color: #FF2E9A;
    transform: translateY(-2px);
}
.social-btn svg { width: 18px; height: 18px; fill: #A79BD1; transition: fill 0.2s; }
.social-btn:hover svg { fill: #FF2E9A; }

/* ─── Reveal on scroll ─────────────────────────────────────────── */
.reveal-item {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal-item.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ─── Scroll-to-top button ─────────────────────────────────────── */
#scroll-top {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 52px;
    height: 52px;
    line-height: 1.3;
    background: #FF2E9A;
    color: #0B0714;
    border: 2px solid #7A1252;
    box-shadow: 0 4px 0 #7A1252, 0 4px 16px rgba(255, 46, 154, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.3s ease, transform 0.2s ease;
    z-index: 100;
}
#scroll-top.visible { opacity: 1; transform: translateY(0); }
#scroll-top:active { transform: translateY(4px); box-shadow: 0 0 0 #7A1252; }

/* ─── Konami easter egg ────────────────────────────────────────── */
.konami-mode {
    animation: konamiPulse 0.6s ease-in-out 3;
}
@keyframes konamiPulse {
    0%, 100% { filter: none; }
    50% { filter: hue-rotate(180deg) saturate(1.8); }
}
.konami-toast {
    position: fixed;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: #150C29;
    border: 2px solid #FFE24C;
    color: #FFE24C;
    font-family: 'Press Start 2P', monospace;
    font-size: 11px;
    padding: 14px 20px;
    z-index: 200;
    box-shadow: 0 0 30px rgba(255, 226, 76, 0.4);
    animation: toastPop 3.5s ease forwards;
}
@keyframes toastPop {
    0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    10%, 85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}
