:root {
    --bg-color: #050505;
    --text-color: #f0f0f0;
    --accent-color: #e63946;
    --secondary-color: #a8dadc;
    --card-bg: rgba(20, 20, 20, 0.85);
    --font-main: 'Zen Kaku Gothic New', sans-serif;
    --font-heading: 'Noto Sans JP', sans-serif;
    --transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    overflow: hidden;
    /* Handled by scroll container */
    height: 100vh;
    width: 100vw;
}

#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
}

.loader .glitch {
    font-size: 2rem;
    font-weight: bold;
    letter-spacing: 0.2em;
    position: relative;
    color: white;
}

/* Scroll Container */
main#app {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    position: relative;
}

/* Header Section (First Slide) */
.main-header {
    height: 100vh;
    width: 100%;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #1a1a1a 0%, #000 100%);
    text-align: center;
    position: relative;
}

.main-header h1 {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: linear-gradient(45deg, #fff, #888);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2rem;
}

.main-header .subtitle {
    font-size: 1.5rem;
    font-weight: 300;
    color: #888;
    display: block;
    margin-top: 0.5rem;
}

.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    opacity: 0.7;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

    60% {
        transform: translateY(-5px);
    }
}

/* Work Section */
section.work-item {
    height: 100vh;
    width: 100%;
    scroll-snap-align: start;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 2rem;
}

/* Dynamic Background */
.work-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(20px) brightness(0.3);
    transform: scale(1.1);
    z-index: 0;
    transition: transform 10s ease;
}

section.work-item:hover .work-bg {
    transform: scale(1.05);
    /* Gentle zoom reduction on hover or active */
}

.work-content {
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    max-width: 1200px;
    width: 100%;
    align-items: center;
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease-out;
}

section.work-item.visible .work-content {
    opacity: 1;
    transform: translateY(0);
}

.work-visual {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    aspect-ratio: 16/9;
    background: #222;
}

.work-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    cursor: pointer;
}

.work-visual:hover img {
    transform: scale(1.03);
}

.work-info {
    color: #fff;
    text-align: left;
}

.work-tags {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.tag {
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 100px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    letter-spacing: 0.05em;
}

.tag.genre {
    color: #a8dadc;
    border-color: #a8dadc;
}

.tag.difficulty {
    color: #e63946;
    border-color: #e63946;
}

.work-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
    background: linear-gradient(90deg, #fff, #ddd);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.work-meta {
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: #aaa;
    display: flex;
    gap: 1.5rem;
}

.work-meta span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.work-desc {
    font-size: 1rem;
    line-height: 1.8;
    color: #ddd;
    margin-bottom: 2rem;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 1rem;
}

/* Custom Scrollbar for description */
.work-desc::-webkit-scrollbar {
    width: 4px;
}

.work-desc::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.work-desc::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.work-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn {
    padding: 1rem 2rem;
    background: #fff;
    color: #000;
    text-decoration: none;
    font-weight: 700;
    border-radius: 4px;
    transition: var(--transition);
    display: inline-block;
}

.btn:hover {
    background: #ccc;
    transform: translateY(-2px);
}

.creator-info {
    font-size: 0.9rem;
    color: #888;
}

.creator-info a {
    color: #aaa;
    text-decoration: none;
    border-bottom: 1px dotted #aaa;
    transition: color 0.3s;
}

.creator-info a:hover {
    color: #fff;
}

/* Modal */
#image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}

#image-modal.active {
    display: flex;
    opacity: 1;
}

#image-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

.close-modal {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: none;
    border: none;
    color: white;
    font-size: 3rem;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .main-header h1 {
        font-size: 2rem;
    }

    section.work-item {
        padding: 1rem;
        align-items: flex-start;
        /* Fit content from top */
    }

    .work-content {
        grid-template-columns: 1fr;
        gap: 1rem;
        /* Compact gap */
        text-align: center;
        transform: translateY(10px);
        /* Reduce init slide distance */
    }

    .work-info {
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    /* Reordering: Tags(1) -> Title(2) -> Meta(3) -> Actions(4) -> Desc(5) */
    .work-tags {
        justify-content: center;
        margin-bottom: 0.5rem;
        gap: 0.5rem;
        order: 1;
    }

    .tag {
        font-size: 0.65rem;
        padding: 0.3rem 0.6rem;
    }

    .work-title {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
        order: 2;
    }

    .work-meta {
        justify-content: center;
        margin-bottom: 0.8rem;
        font-size: 0.8rem;
        order: 3;
    }

    .work-actions {
        justify-content: center;
        flex-direction: column;
        margin-bottom: 1rem;
        /* Add space below button */
        order: 4;
        /* Move ABOVE description */
    }

    .work-visual {
        max-height: 25vh;
        margin-bottom: 0.5rem;
        margin-left: auto;
        margin-right: auto;
        width: auto;
        max-width: 100%;
        height: auto;
        aspect-ratio: auto;
        background: transparent;
        box-shadow: none;
    }

    .work-visual img {
        width: auto;
        height: auto;
        max-height: 25vh;
        max-width: 100%;
        display: block;
        margin: 0 auto;
    }

    .work-desc {
        font-size: 0.85rem;
        line-height: 1.5;
        max-height: 15vh;
        /* Strictly limit text height */
        margin-bottom: 1rem;
        order: 5;
        /* Move BELOW button */
    }

    .btn {
        padding: 0.8rem 2rem;
    }
}

/* Additions for Index Section */

.index-view {
    display: flex;
    flex-direction: column;
    padding-top: 1rem;
    overflow-y: hidden;
}

/* Override default work-item center alignment for this specific section */
#top-section {
    justify-content: flex-start;
    align-items: center;
    background: radial-gradient(circle at top center, #222 0%, #050505 80%);
}

.compact-header {
    text-align: center;
    margin-bottom: 2rem;
    z-index: 20;
}

.compact-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.compact-header .subtitle {
    font-size: 1rem;
    color: #aaa;
    display: block;
    font-weight: 300;
}

.index-container {
    width: 100%;
    max-width: 1400px;
    height: calc(100vh - 150px);
    /* Fill remaining height */
    overflow-y: auto;
    /* Scrollable grid */
    padding: 0 2rem 4rem;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.index-container::-webkit-scrollbar {
    width: 6px;
}

.index-container::-webkit-scrollbar-track {
    background: transparent;
}

.index-container::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
}

.index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
    padding-bottom: 3rem;
}

/* Index Items */
.index-item {
    background: #222;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-align: left;
    position: relative;
    aspect-ratio: 16/10;
}

.index-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.index-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.index-item:hover img {
    opacity: 1;
}

.index-item .index-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0.8rem;
    background: linear-gradient(transparent, #000 90%);
    color: #fff;
}

.index-item .index-title {
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.index-item .index-id {
    font-size: 0.7rem;
    color: var(--secondary-color);
    margin-bottom: 0.2rem;
    display: block;
}

.scroll-prompt {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    animation: fadePulse 3s infinite;
}

@keyframes fadePulse {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.8;
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .index-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }

    .compact-header h1 {
        font-size: 1.5rem;
    }

    .index-item .index-title {
        font-size: 0.75rem;
    }
}

/* Navigation Buttons */
.top-nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.nav-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.nav-btn.active {
    background: #fff;
    color: #000;
    font-weight: bold;
    pointer-events: none;
}