/* thesecond.quest - 90s Pixel Art Retro Gaming */

/* ===== RESET ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== PALETTE ===== */
:root {
    --dungeon-dark: #1A1C2C;
    --stone-blue: #333C57;
    --quest-gold: #F4D35E;
    --fire-orange: #EE5A24;
    --forest-emerald: #0EAD69;
    --parchment-light: #E8E8E8;
    --royal-purple: #5D275D;
    --sky-cyan: #73BED3;
    --muted-gray: #71717A;
}

/* ===== BASE ===== */
html {
    scroll-behavior: smooth;
}

body {
    background: var(--dungeon-dark);
    color: var(--parchment-light);
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 15px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== PIXEL BORDER - Box-shadow stacking technique ===== */
.pixel-border {
    border: 4px solid var(--quest-gold);
    box-shadow:
        4px 0 0 0 var(--quest-gold),
        -4px 0 0 0 var(--quest-gold),
        0 4px 0 0 var(--quest-gold),
        0 -4px 0 0 var(--quest-gold);
}

/* ===== SECTION HEADING ===== */
.section-heading {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--quest-gold);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1.5rem;
}

/* ===== HERO ===== */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(26, 28, 44, 0.03) 2px,
            rgba(26, 28, 44, 0.03) 4px
        );
    pointer-events: none;
}

.hero-inner {
    max-width: 640px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.pixel-landscape {
    margin-bottom: 2rem;
}

.pixel-landscape svg {
    display: block;
    image-rendering: pixelated;
    image-rendering: -webkit-optimize-contrast;
}

.hero-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 2.4rem;
    color: var(--quest-gold);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 0.6rem;
    animation: bounceTitle 2s ease infinite;
}

@keyframes bounceTitle {
    0%, 100% { transform: translateY(0); }
    15% { transform: translateY(-6px); }
    30% { transform: translateY(0); }
    45% { transform: translateY(-3px); }
    60% { transform: translateY(0); }
}

.hero-sub {
    font-size: 1rem;
    color: var(--parchment-light);
    margin-bottom: 1.5rem;
    opacity: 0.85;
}

.start-btn {
    display: inline-block;
    background: var(--fire-orange);
    color: #FFFFFF;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.75rem 2rem;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.1s steps(1), background 0.15s;
    position: relative;
}

.start-btn:hover {
    background: #FF6B35;
    transform: scale(1.05);
}

.start-btn:active {
    transform: scale(0.97);
}

/* Blinking arrow - authentic retro blink with steps(1) */
.blink-arrow {
    display: inline-block;
    animation: blinkRetro 0.8s steps(1) infinite;
    margin-right: 0.25rem;
}

@keyframes blinkRetro {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ===== QUEST SELECT ===== */
.quests {
    max-width: 840px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

.quest-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.quest-card {
    background: var(--stone-blue);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s steps(2), box-shadow 0.15s;
    position: relative;
}

.quest-card:hover {
    transform: translateY(-4px);
    box-shadow:
        4px 0 0 0 var(--quest-gold),
        -4px 0 0 0 var(--quest-gold),
        0 4px 0 0 var(--quest-gold),
        0 -4px 0 0 var(--quest-gold),
        0 8px 0 0 rgba(0, 0, 0, 0.3);
}

.quest-card.locked {
    border-color: var(--muted-gray);
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow:
        4px 0 0 0 var(--muted-gray),
        -4px 0 0 0 var(--muted-gray),
        0 4px 0 0 var(--muted-gray),
        0 -4px 0 0 var(--muted-gray);
}

.quest-card.locked:hover {
    transform: none;
    box-shadow:
        4px 0 0 0 var(--muted-gray),
        -4px 0 0 0 var(--muted-gray),
        0 4px 0 0 var(--muted-gray),
        0 -4px 0 0 var(--muted-gray);
}

.quest-thumb {
    height: 80px;
    margin-bottom: 0.75rem;
    overflow: hidden;
    image-rendering: pixelated;
    image-rendering: -webkit-optimize-contrast;
}

.quest-thumb svg {
    image-rendering: pixelated;
    image-rendering: -webkit-optimize-contrast;
}

.quest-name {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--parchment-light);
    margin-bottom: 0.35rem;
}

.stars {
    margin-bottom: 0.5rem;
}

.star {
    font-size: 1.1rem;
    color: var(--muted-gray);
    margin: 0 1px;
}

.star.filled {
    color: var(--quest-gold);
}

.progress-bar {
    height: 10px;
    background: var(--dungeon-dark);
    border: 2px solid var(--muted-gray);
    margin-bottom: 0.3rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--forest-emerald);
    width: 0;
    transition: width 1.2s steps(20);
}

.progress-label {
    font-family: 'Fira Mono', monospace;
    font-weight: 500;
    font-size: 0.7rem;
    color: var(--sky-cyan);
}

/* ===== JOURNEY MAP ===== */
.journey {
    max-width: 840px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

.map-panel {
    background: var(--stone-blue);
    padding: 1.25rem;
}

.map-svg {
    display: block;
    image-rendering: auto;
}

/* Pulse animation on current node */
.pulse-node {
    animation: pulseNode 2s ease-in-out infinite;
}

@keyframes pulseNode {
    0%, 100% { r: 16; opacity: 1; }
    50% { r: 19; opacity: 0.85; }
}

/* ===== ACHIEVEMENTS ===== */
.achievements {
    max-width: 840px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

.badge-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    text-align: center;
}

.badge {
    padding: 0.75rem 0.5rem;
    position: relative;
}

.badge.earned .badge-icon {
    background: var(--stone-blue);
    border: 3px solid var(--quest-gold);
    box-shadow:
        3px 0 0 0 var(--quest-gold),
        -3px 0 0 0 var(--quest-gold),
        0 3px 0 0 var(--quest-gold),
        0 -3px 0 0 var(--quest-gold);
}

.badge-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--dungeon-dark);
    border: 3px solid var(--muted-gray);
}

.badge-icon.badge-locked {
    opacity: 0.4;
}

.badge-name {
    font-family: 'Fira Mono', monospace;
    font-weight: 500;
    font-size: 0.65rem;
    color: var(--parchment-light);
    display: block;
}

.badge:not(.earned) .badge-name {
    color: var(--muted-gray);
}

/* ===== ARENA / LEADERBOARD ===== */
.arena {
    max-width: 840px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

.leaderboard-panel {
    background: var(--stone-blue);
    padding: 1.25rem;
    overflow-x: auto;
}

.leaderboard {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard th {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--quest-gold);
    text-transform: uppercase;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 3px solid var(--quest-gold);
    letter-spacing: 0.05em;
}

.leaderboard td {
    padding: 10px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--dungeon-dark);
}

.mono {
    font-family: 'Fira Mono', monospace;
    font-weight: 500;
}

.gold {
    color: var(--quest-gold);
}

.rank-cell {
    width: 50px;
}

.rank-num {
    color: var(--sky-cyan);
}

.player-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Pixel heart icon using box-shadow stacking */
.pixel-heart {
    display: inline-block;
    width: 2px;
    height: 2px;
    background: transparent;
    box-shadow:
        2px 0 0 0 var(--muted-gray),
        4px 0 0 0 var(--muted-gray),
        8px 0 0 0 var(--muted-gray),
        10px 0 0 0 var(--muted-gray),
        0px 2px 0 0 var(--muted-gray),
        2px 2px 0 0 var(--muted-gray),
        4px 2px 0 0 var(--muted-gray),
        6px 2px 0 0 var(--muted-gray),
        8px 2px 0 0 var(--muted-gray),
        10px 2px 0 0 var(--muted-gray),
        12px 2px 0 0 var(--muted-gray),
        0px 4px 0 0 var(--muted-gray),
        2px 4px 0 0 var(--muted-gray),
        4px 4px 0 0 var(--muted-gray),
        6px 4px 0 0 var(--muted-gray),
        8px 4px 0 0 var(--muted-gray),
        10px 4px 0 0 var(--muted-gray),
        12px 4px 0 0 var(--muted-gray),
        2px 6px 0 0 var(--muted-gray),
        4px 6px 0 0 var(--muted-gray),
        6px 6px 0 0 var(--muted-gray),
        8px 6px 0 0 var(--muted-gray),
        10px 6px 0 0 var(--muted-gray),
        4px 8px 0 0 var(--muted-gray),
        6px 8px 0 0 var(--muted-gray),
        8px 8px 0 0 var(--muted-gray),
        6px 10px 0 0 var(--muted-gray);
    margin-right: 8px;
    flex-shrink: 0;
}

.pixel-heart.earned-heart {
    box-shadow:
        2px 0 0 0 var(--fire-orange),
        4px 0 0 0 var(--fire-orange),
        8px 0 0 0 var(--fire-orange),
        10px 0 0 0 var(--fire-orange),
        0px 2px 0 0 var(--fire-orange),
        2px 2px 0 0 var(--fire-orange),
        4px 2px 0 0 var(--fire-orange),
        6px 2px 0 0 var(--fire-orange),
        8px 2px 0 0 var(--fire-orange),
        10px 2px 0 0 var(--fire-orange),
        12px 2px 0 0 var(--fire-orange),
        0px 4px 0 0 var(--fire-orange),
        2px 4px 0 0 var(--fire-orange),
        4px 4px 0 0 var(--fire-orange),
        6px 4px 0 0 var(--fire-orange),
        8px 4px 0 0 var(--fire-orange),
        10px 4px 0 0 var(--fire-orange),
        12px 4px 0 0 var(--fire-orange),
        2px 6px 0 0 var(--fire-orange),
        4px 6px 0 0 var(--fire-orange),
        6px 6px 0 0 var(--fire-orange),
        8px 6px 0 0 var(--fire-orange),
        10px 6px 0 0 var(--fire-orange),
        4px 8px 0 0 var(--fire-orange),
        6px 8px 0 0 var(--fire-orange),
        8px 8px 0 0 var(--fire-orange),
        6px 10px 0 0 var(--fire-orange);
}

.active-row {
    background: rgba(244, 211, 94, 0.08);
}

.active-row td {
    border-bottom-color: var(--quest-gold);
}

.blink-cursor {
    animation: blinkRetro 0.8s steps(1) infinite;
    color: var(--quest-gold);
    font-family: 'Fira Mono', monospace;
    font-weight: 700;
}

/* ===== RPG DIALOG SECTION ===== */
.dialog-section {
    max-width: 840px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

.rpg-dialog {
    background: var(--stone-blue);
    padding: 1.25rem;
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
}

.dialog-portrait {
    flex-shrink: 0;
    border: 3px solid var(--royal-purple);
    background: var(--dungeon-dark);
}

.dialog-portrait svg {
    display: block;
    image-rendering: pixelated;
    image-rendering: -webkit-optimize-contrast;
}

.dialog-content {
    flex: 1;
    min-height: 60px;
}

.dialog-speaker {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--quest-gold);
    margin-bottom: 0.4rem;
}

.dialog-text {
    font-family: 'Fira Mono', monospace;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--parchment-light);
    min-height: 1.4em;
    line-height: 1.5;
}

.dialog-text::after {
    content: '\25AE';
    animation: blinkRetro 0.6s steps(1) infinite;
    color: var(--quest-gold);
    margin-left: 2px;
}

.dialog-source {
    display: none;
}

.dialog-choices {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.choice-btn {
    flex: 1;
    background: var(--dungeon-dark);
    color: var(--parchment-light);
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.6rem 1rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-align: left;
}

.choice-btn:hover {
    background: var(--fire-orange);
    color: #FFFFFF;
}

.choice-btn:active {
    transform: scale(0.97);
}

.choice-btn.selected {
    background: var(--forest-emerald);
    color: #FFFFFF;
    border-color: var(--forest-emerald);
    box-shadow:
        4px 0 0 0 var(--forest-emerald),
        -4px 0 0 0 var(--forest-emerald),
        0 4px 0 0 var(--forest-emerald),
        0 -4px 0 0 var(--forest-emerald);
}

/* ===== FOOTER ===== */
.footer {
    max-width: 840px;
    margin: 0 auto;
    padding: 2rem;
    text-align: center;
}

.footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.game-over-text {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 0.5rem;
}

.go-letter {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 2rem;
    color: var(--fire-orange);
    display: inline-block;
    animation: gameOverFlicker 3s ease-in-out infinite;
}

.go-letter:nth-child(1) { animation-delay: 0s; }
.go-letter:nth-child(2) { animation-delay: 0.15s; }
.go-letter:nth-child(3) { animation-delay: 0.3s; }
.go-letter:nth-child(4) { animation-delay: 0.45s; }
.go-letter:nth-child(6) { animation-delay: 0.7s; }
.go-letter:nth-child(7) { animation-delay: 0.85s; }
.go-letter:nth-child(8) { animation-delay: 1.0s; }
.go-letter:nth-child(9) { animation-delay: 1.15s; }

.go-space {
    width: 16px;
}

@keyframes gameOverFlicker {
    0%, 100% { opacity: 1; color: var(--fire-orange); }
    50% { opacity: 0.6; color: var(--quest-gold); }
}

.coin-dialog {
    background: var(--stone-blue);
    padding: 1.5rem 2rem;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.coin-text {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--quest-gold);
    animation: blinkRetro 1.5s steps(1) infinite;
}

.coin-counter {
    font-family: 'Fira Mono', monospace;
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--sky-cyan);
}

.coin-num {
    color: var(--quest-gold);
    font-size: 1.2rem;
}

.coin-btn {
    display: inline-block;
    background: var(--fire-orange);
    color: #FFFFFF;
    font-family: 'Fira Mono', monospace;
    font-weight: 500;
    font-size: 0.85rem;
    padding: 0.5rem 1.25rem;
    border: 2px solid var(--quest-gold);
    text-decoration: none;
    transition: background 0.15s;
}

.coin-btn:hover {
    background: #FF6B35;
}

.pixel-socials {
    display: flex;
    gap: 1.25rem;
    justify-content: center;
    align-items: center;
}

.pixel-social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--stone-blue);
    border: 2px solid var(--muted-gray);
    transition: border-color 0.15s, transform 0.15s;
}

.pixel-social-icon:hover {
    border-color: var(--quest-gold);
    transform: translateY(-2px);
}

.pixel-social-icon svg {
    image-rendering: pixelated;
    image-rendering: -webkit-optimize-contrast;
}

.footer-copy {
    font-family: 'Fira Mono', monospace;
    font-weight: 500;
    font-size: 0.7rem;
    color: var(--muted-gray);
}

/* ===== FADE IN ANIMATION ===== */
.fade-in {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .hero-title {
        font-size: 1.6rem;
    }

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

    .badge-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .dialog-choices {
        flex-direction: column;
    }

    .rpg-dialog {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .game-over-text .go-letter {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 1.25rem;
        letter-spacing: 0.06em;
    }

    .section-heading {
        font-size: 1.1rem;
    }

    .badge-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .leaderboard th,
    .leaderboard td {
        padding: 6px;
        font-size: 0.75rem;
    }

    .player-cell {
        gap: 0.25rem;
    }
}
