:root {
    --bg-dark: #141013;
    --bg-brick: #20181b;
    --brick-border: #0a0809;
    --accent-gold: #ffcc00;
    --accent-red: #cc2929;
    --text-main: #e0d8c0;
    --text-dim: #8b8070;
    --font-pixel: 'Press Start 2P', cursive;

    --shadow-color: rgba(0, 0, 0, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    image-rendering: pixelated;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-pixel);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Dungeon Background Pattern */
.dungeon-bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    background-color: var(--bg-dark);
    background-image:
        linear-gradient(335deg, var(--brick-border) 23px, transparent 23px),
        linear-gradient(155deg, var(--brick-border) 23px, transparent 23px),
        linear-gradient(335deg, var(--brick-border) 23px, transparent 23px),
        linear-gradient(155deg, var(--brick-border) 23px, transparent 23px);
    background-size: 58px 58px;
    background-position: 0px 2px, 4px 35px, 29px 31px, 34px 6px;
    opacity: 0.4;
}

.torch-glow {
    position: fixed;
    top: 0;
    left: 20%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(255, 100, 0, 0.1) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
    animation: glowPulse 4s infinite alternate;
}

.vignette {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle, transparent 40%, #000 100%);
    pointer-events: none;
    z-index: -1;
}

@keyframes glowPulse {
    0% {
        opacity: 0.5;
        transform: scale(1);
    }

    100% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

/* Navbar */
.pixel-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 4px solid var(--brick-border);
    background: var(--bg-brick);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.5);
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.2rem;
    color: var(--text-main);
    text-shadow: 2px 2px 0 #000;
}

.logo .accent {
    color: var(--accent-gold);
}

.pixel-link {
    color: var(--text-dim);
    text-decoration: none;
    margin-left: 30px;
    font-size: 0.8rem;
    transition: color 0.2s;
}

.pixel-link:hover {
    color: var(--text-main);
    text-decoration: underline;
    text-decoration-thickness: 2px;
}

/* Hero Section */
.hero-section {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    position: relative;
}

.hero-title-box {
    margin-bottom: 2rem;
    border: 4px solid var(--text-main);
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 8px 8px 0 #000;
}

.hero-section h1 {
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--accent-gold);
    text-shadow: 4px 4px 0 #8b0000;
    line-height: 1.4;
}

.flicker-text {
    animation: textFlicker 3s infinite;
}

@keyframes textFlicker {

    0%,
    100% {
        opacity: 1;
    }

    95% {
        opacity: 1;
    }

    96% {
        opacity: 0.8;
    }

    97% {
        opacity: 1;
    }

    98% {
        opacity: 0.9;
    }

    99% {
        opacity: 1;
    }
}

.hero-sub {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 3rem;
    background: #000;
    padding: 10px;
}

/* Pixel Button */
.pixel-btn {
    display: inline-flex;
    align-items: center;
    gap: 15px;
    padding: 20px 30px;
    background: var(--accent-red);
    color: #fff;
    text-decoration: none;
    font-size: 1.2rem;
    border: 4px solid #fff;
    box-shadow:
        inset -4px -4px 0 rgba(0, 0, 0, 0.4),
        4px 4px 0 #000;
    transition: transform 0.1s, box-shadow 0.1s;
    text-shadow: 2px 2px 0 #000;
}

.pixel-btn:hover {
    transform: translate(2px, 2px);
    box-shadow:
        inset -4px -4px 0 rgba(0, 0, 0, 0.4),
        2px 2px 0 #000;
    background: #e63939;
}

.pixel-btn:active {
    transform: translate(4px, 4px);
    box-shadow: none;
}

/* Deco */
.hero-deco {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    overflow: hidden;
}

.floating-sprite {
    font-size: 3rem;
    position: absolute;
    animation: floatSprite 4s ease-in-out infinite;
    filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.5));
}

.skeleton {
    bottom: 20%;
    left: 8%;
    animation-delay: 0s;
}

.chest {
    bottom: 30%;
    right: 8%;
    animation-delay: 2s;
}

.gem {
    top: 25%;
    left: 15%;
    animation-delay: 1s;
    font-size: 2rem;
}

.shield {
    top: 20%;
    right: 15%;
    animation-delay: 3s;
    font-size: 2rem;
}

.ghost {
    bottom: 15%;
    right: 25%;
    animation-delay: 1.5s;
    font-size: 2.5rem;
    opacity: 0.7;
}

.potion {
    bottom: 10%;
    left: 25%;
    animation-delay: 0.5s;
    font-size: 2rem;
}

@keyframes floatSprite {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

/* Floor (Games Section) */
.dungeon-floor {
    padding: 60px 20px;
    background: #1a1517;
    border-top: 8px solid var(--brick-border);
    border-bottom: 8px solid var(--brick-border);
}

.floor-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 60px;
}

.floor-header h2 {
    font-size: 1.5rem;
    color: var(--text-main);
    text-decoration: underline;
    text-decoration-color: var(--accent-gold);
    text-decoration-thickness: 4px;
    text-align: center;
    line-height: 1.4;
}

/* Improved Torches */
.torch-holder {
    position: relative;
    width: 24px;
    height: 40px;
}

.torch-base {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 25px;
    background: #5c4033;
    border: 2px solid #221100;
}

.flame-container {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 30px;
}

.flame {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50% 50% 20% 20%;
    animation: flameMoving 0.3s infinite alternate ease-in-out;
}

.flame.red {
    width: 18px;
    height: 25px;
    background: #cc2929;
    box-shadow: 0 0 10px #cc2929;
    opacity: 0.8;
}

.flame.orange {
    width: 12px;
    height: 18px;
    background: #ff5500;
    box-shadow: 0 0 15px #ff5500;
    bottom: 2px;
    animation-delay: 0.1s;
}

.flame.yellow {
    width: 6px;
    height: 10px;
    background: #ffcc00;
    box-shadow: 0 0 10px #ffcc00;
    bottom: 5px;
    animation-delay: 0.2s;
}

@keyframes flameMoving {
    0% {
        transform: translateX(-50%) scale(1) rotate(-2deg);
    }

    100% {
        transform: translateX(-50%) scale(1.1) rotate(2deg);
    }
}

/* Filter Bar */
.filter-bar {
    max-width: 1200px;
    margin: -20px auto 40px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border: 4px solid var(--brick-border);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.7rem;
    color: var(--accent-gold);
    min-width: 100px;
}

.filter-tags {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-tag {
    background: var(--bg-brick);
    color: var(--text-dim);
    border: 2px solid var(--brick-border);
    padding: 6px 12px;
    font-family: var(--font-pixel);
    font-size: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tag:hover {
    color: var(--text-main);
    border-color: var(--text-dim);
}

.filter-tag.active {
    background: var(--accent-gold);
    color: #000;
    border-color: #fff;
    box-shadow: 2px 2px 0 #000;
}

/* Game Grid */

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.game-scroll {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s;
    position: relative;
}

.game-scroll:hover {
    transform: translateY(-5px);
}

.game-link-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.scroll-border {

    background: #e6d8ad;
    /* Parchment color */
    border: 4px solid #5c4033;
    padding: 10px;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.scroll-border::after {
    /* Nail header */
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    background: #444;
    border-radius: 50%;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
}

.game-thumb {
    height: 180px;
    background: #2d2d2d;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 4px solid #5c4033;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.memory-thumb {
    background: #2a2a4a;
}

.snake-thumb {
    background: #0f2a15;
}

.thumb-emoji {
    font-size: 5rem;
    filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.5));
}

.game-info {
    text-align: center;
    padding: 0 10px;
    color: #3b2d25;
    /* Ink color */
}

.game-info h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.category-badge {
    display: inline-block;
    font-size: 0.6rem;
    color: var(--accent-gold);
    background: #000;
    padding: 4px 10px;
    border: 2px solid var(--accent-gold);
    margin-bottom: 12px;
    letter-spacing: 2px;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
    font-weight: bold;
}

.desc {
    font-size: 0.8rem;
    line-height: 1.6;
    margin-bottom: 20px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

.game-tags-list {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}

.mini-tag {
    font-size: 0.5rem;
    background: rgba(139, 0, 0, 0.1);
    color: #8b0000;
    padding: 2px 8px;
    border: 1px solid #8b0000;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

.mini-tag:hover {
    background: #8b0000;
    color: #fff;
    transform: scale(1.1);
}

.no-results {

    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    background: rgba(0, 0, 0, 0.5);
    border: 4px dashed var(--accent-red);
    color: var(--accent-red);
    font-size: 1rem;
}


.play-tag {

    display: inline-block;
    background: #8b0000;
    color: #fff;
    padding: 10px 15px;
    font-size: 0.8rem;
    margin-bottom: 10px;
    box-shadow: 2px 2px 0 #000;
}

.game-scroll:hover .play-tag {
    background: #cc0000;
}

/* Footer */
.dungeon-footer {
    padding: 40px;
    text-align: center;
    background: #0a0809;
}

.footer-border {
    display: inline-block;
    border: 2px dashed #333;
    padding: 20px 40px;
    max-width: 90%;
}

.hosting-promo {
    margin: 15px 0;
    font-size: 0.7rem;
    color: var(--text-dim);
    line-height: 1.6;
}

.pixel-link-alt {
    color: var(--accent-gold);
    text-decoration: none;
    border-bottom: 2px solid var(--accent-gold);
    padding-bottom: 2px;
    transition: all 0.2s;
}

.pixel-link-alt:hover {
    color: #fff;
    border-bottom-color: #fff;
}



@media (max-width: 600px) {
    .pixel-nav {
        padding: 10px;
    }

    .logo {
        font-size: 1rem;
    }

    .hero-title-box {
        padding: 15px;
        margin-bottom: 1.5rem;
    }

    .hero-section h1 {
        font-size: 1.8rem;
    }

    .hero-sub {
        font-size: 0.7rem;
        margin-bottom: 2rem;
    }

    .pixel-btn {
        padding: 15px 20px;
        font-size: 1rem;
    }

    .floating-sprite {
        display: none;
        /* Hide sprites on mobile to avoid overlap */
    }

    .floor-header {
        gap: 10px;
        margin-bottom: 30px;
    }

    .floor-header h2 {
        font-size: 1.2rem;
    }

    .torch-holder {
        transform: scale(0.6);
        /* Scale down torches further */
    }
}

/* Loading State */
.pixel-loader-container {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px;
    gap: 30px;
    min-height: 300px;
}

.pixel-spinner-box {
    position: relative;
    width: 60px;
    height: 60px;
}

.pixel-spinner {
    width: 100%;
    height: 100%;
    background-color: var(--accent-gold);
    box-shadow: 4px 4px 0 #000;
    animation: pixel-spin 1.2s infinite steps(4);
}

.pixel-spinner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 4px solid var(--accent-red);
    box-sizing: border-box;
    animation: pixel-border-flash 0.6s infinite steps(2);
}

.loading-text {
    font-family: var(--font-pixel);
    color: var(--text-dim);
    font-size: 1.2rem;
    letter-spacing: 2px;
    animation: text-pulse 1s infinite alternate;
    text-shadow: 2px 2px 0 #000;
}

@keyframes pixel-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes pixel-border-flash {

    0%,
    100% {
        border-color: var(--accent-red);
    }

    50% {
        border-color: transparent;
    }
}

@keyframes text-pulse {
    from {
        opacity: 0.6;
    }

    to {
        opacity: 1;
    }
}