:root {
    --font-pixel: 'PixelMplus12', sans-serif;
    --font-noto: 'YakuHanJP', 'Noto Sans JP', sans-serif;
}

.font-noto {
    font-family: var(--font-noto);
}

@font-face {
    font-family: 'PixelMplus12';
    src: url('assets/fonts/pixelmplus12-subset.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'PixelMplus12';
    src: url('assets/fonts/pixelmplus12-subset-bold.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
}

body {
    font-family: var(--font-pixel), var(--font-noto);
    font-weight: bold;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #000;
    background-image: url('assets/images/background.webp');
    background-size: 94% auto;
    background-position: center 100px;
    background-repeat: no-repeat;
    background-attachment: fixed;
    font-weight: bold;
}

@media (max-width: 1000px) {
    body {
        background-size: cover;
        background-position: center center;
    }
}

.pacman-container {
    z-index: 50;
}


.pacman-track {
    display: flex;
    flex-direction: row;
    animation: scroll 25s linear infinite;
    /* Adjusted to 25s */
    width: max-content;
    white-space: nowrap;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

@keyframes scroll {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }

    /* Assuming content is duplicated */
}

.character-unit {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 12px;
}

.character {
    width: 32px;
    height: 32px;
    background-size: contain;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}


/* Cookie / dandanbank */
.cookie {
    background-image: url('assets/images/dandanbank.svg');
}

/* Pac-Man Animation */
.pacman {
    animation: pacman-anim 0.25s steps(1) infinite;
    /* Optimized to 0.25s */
    background-position: right center;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

@keyframes pacman-anim {
    0% {
        background-image: url('assets/images/Pac-Man1.svg');
    }

    25% {
        background-image: url('assets/images/Pac-Man2.svg');
    }

    50% {
        background-image: url('assets/images/Pac-Man3.svg');
    }

    75% {
        background-image: url('assets/images/Pac-Man2.svg');
    }
}

/* Ghost Base Animation */
.ghost {
    animation: ghost-anim 0.2s steps(1) infinite;
    /* Slowed down from 0.15s */
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

@keyframes ghost-anim {

    0%,
    100% {
        /* Handled individually below */
    }
}

/* Individual Ghost Frames */
.blinky {
    animation: blinky-anim 0.18s steps(1) infinite;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

@keyframes blinky-anim {
    0% {
        background-image: url('assets/images/Blinky1.svg');
    }

    50% {
        background-image: url('assets/images/Blinky2.svg');
    }
}

.inky {
    animation: inky-anim 0.18s steps(1) infinite;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

@keyframes inky-anim {
    0% {
        background-image: url('assets/images/Inky1.svg');
    }

    50% {
        background-image: url('assets/images/Inky2.svg');
    }
}

.pinky {
    animation: pinky-anim 0.18s steps(1) infinite;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

@keyframes pinky-anim {
    0% {
        background-image: url('assets/images/Pinky1.svg');
    }

    50% {
        background-image: url('assets/images/Pinky2.svg');
    }
}

.clyde {
    animation: clyde-anim 0.18s steps(1) infinite;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

@keyframes clyde-anim {
    0% {
        background-image: url('assets/images/Clyde1.svg');
    }

    50% {
        background-image: url('assets/images/Clyde2.svg');
    }
}


.pixel-button {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background-color: #0000ff;
    color: white;
    text-decoration: none;
    padding: 18px 56px;
    font-size: 32px;
    position: relative;
    margin: 10px;
    transition: transform 0.1s;
    user-select: none;
    cursor: pointer;
    font-family: var(--font-pixel), var(--font-noto);
    font-weight: bold;

    /* Pixel-perfect border-image via SVG */
    border-style: solid;
    border-width: 4px;
    /* Maintaining the sharper 4px look */
    border-image-slice: 2;
    border-image-source: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="6" height="6"><path d="M2 0h2v2h2v2h-2v2h-2v-2h-2v-2h2z" fill="white"/></svg>');
    background-clip: padding-box;
}

.pixel-button:active {
    transform: scale(0.96);
}

.pixel-arrow {
    width: 24px;
    height: 24px;
    background-image: url('assets/images/arrow.svg');
    background-size: contain;
    background-repeat: no-repeat;
    display: inline-block;
    vertical-align: middle;
}









/* Transition Animations */
.nes-disappear {
    animation: nes-step-fade 0.6s steps(6) forwards;
    pointer-events: none;
}

@keyframes nes-step-fade {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.fade-in {
    animation: fade-in-anim 0.8s steps(6) forwards;
}

@keyframes fade-in-anim {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.pixel-shadow {
    box-shadow: 10px 10px 0 0 rgba(0, 0, 0, 0.5);
}


/* Scroll Fade-in Animation Classes */
.scroll-fade-up {
    opacity: 0;
}

.scroll-fade-up.is-visible {
    animation: scroll-fade-step 0.6s steps(6) forwards;
}

@keyframes scroll-fade-step {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Back to Top Button */
.back-to-top::before {
    content: '';
    width: 24px;
    height: 24px;
    background-image: url('assets/images/arrow.svg');
    background-size: contain;
    background-repeat: no-repeat;
    filter: brightness(0);
    /* Makes the white SVG black */
    transform: rotate(-90deg);
    /* Rotates to point UP */
    margin-bottom: 5px;
    image-rendering: pixelated;
}

.back-to-top {
    position: fixed;
    bottom: 120px;
    right: 30px;
    width: 90px;
    height: 90px;
    background-color: #ffff00;
    color: #000;
    display: flex;
    /* Always flex but hidden via opacity */
    opacity: 0;
    pointer-events: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    z-index: 100;
    cursor: pointer;
    font-family: var(--font-pixel), var(--font-noto);
    font-size: 13px;
    font-weight: bold;
    line-height: 1;

    /* Authentic Pixelated Circle Shape (Staircase corners) */
    clip-path: polygon(20% 0%, 80% 0%,
            80% 10%, 90% 10%, 90% 20%, 100% 20%,
            100% 80%, 90% 80%, 90% 90%, 80% 90%, 80% 100%, 20% 100%,
            20% 90%, 10% 90%, 10% 80%, 0% 80%,
            0% 20%, 10% 20%, 10% 10%, 20% 10%);
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.6s steps(6), transform 0.6s steps(6);
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.back-to-top:hover {
    transform: scale(1.1);
}

.back-to-top span {
    font-weight: bold;
}

/* Mission Section Styles */
.mission-box-smooth {
    border: 4px solid #F56400;
    border-radius: 24px;
}

.mission-tab-smooth {
    border-radius: 12px;
    /* Background color is handled in HTML */
}

.pixelated {
    image-rendering: pixelated;
}

/* Character Animations (NES-style frame swaps) - Synchronized with track */
.ani-pacman {
    width: 24px;
    height: 24px;
    background-repeat: no-repeat;
    background-size: contain;
    background-position: right center;
    /* Anchor to the right as requested */
    display: inline-block;
    vertical-align: middle;
    animation: pacman-cycle 0.25s steps(1) infinite;
    image-rendering: pixelated;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

@keyframes pacman-cycle {
    0% {
        background-image: url('assets/images/Pac-Man1.svg');
    }

    25% {
        background-image: url('assets/images/Pac-Man2.svg');
    }

    50% {
        background-image: url('assets/images/Pac-Man3.svg');
    }

    75% {
        background-image: url('assets/images/Pac-Man2.svg');
    }
}

.ani-ghost {
    width: 48px;
    height: 48px;
    background-repeat: no-repeat;
    background-size: contain;
    display: inline-block;
    image-rendering: pixelated;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.ani-blinky {
    animation: blinky-cycle 0.18s steps(1) infinite;
}

.ani-inky {
    animation: inky-cycle 0.18s steps(1) infinite;
}

.ani-pinky {
    animation: pinky-cycle 0.18s steps(1) infinite;
}

.ani-clyde {
    animation: clyde-cycle 0.18s steps(1) infinite;
}

@keyframes blinky-cycle {
    0% {
        background-image: url('assets/images/Blinky1.svg');
    }

    50% {
        background-image: url('assets/images/Blinky2.svg');
    }
}

@keyframes inky-cycle {
    0% {
        background-image: url('assets/images/Inky1.svg');
    }

    50% {
        background-image: url('assets/images/Inky2.svg');
    }
}

@keyframes pinky-cycle {
    0% {
        background-image: url('assets/images/Pinky1.svg');
    }

    50% {
        background-image: url('assets/images/Pinky2.svg');
    }
}

@keyframes clyde-cycle {
    0% {
        background-image: url('assets/images/Clyde1.svg');
    }

    50% {
        background-image: url('assets/images/Clyde2.svg');
    }
}

.pixel-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #F56400;
    color: white;
    font-family: var(--font-pixel);
    clip-path: polygon(0 10%, 10% 10%, 10% 0, 90% 0, 90% 10%, 100% 10%,
            100% 90%, 90% 90%, 90% 100%, 10% 100%, 10% 90%, 0% 90%);
}

.pixel-circle {
    clip-path: polygon(20% 0%, 80% 0%,
            80% 10%, 90% 10%, 90% 20%, 100% 20%,
            100% 80%, 90% 80%, 90% 90%, 80% 90%, 80% 100%, 20% 100%,
            20% 90%, 10% 90%, 10% 80%, 0% 80%,
            0% 20%, 10% 20%, 10% 10%, 20% 10%);
}

.pixel-frame {
    border-style: solid;
    border-width: 4px;
    border-image-slice: 2;
    border-image-source: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="6" height="6"><path d="M2 0h2v2h2v2h-2v2h-2v-2h-2v-2h2z" fill="%23F56400"/></svg>');
    background-clip: padding-box;
}

.image-block-frame {
    width: 100%;
    border: 4px solid #ffd800;
    box-shadow: 10px 10px 0 0 rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    background: #1B1464;
    overflow: hidden;
}

.hanging-indent {
    padding-left: 1em;
    text-indent: -1em;
    display: block;
    font-family: var(--font-noto);
}

.annotation {
    font-family: var(--font-noto);
    font-size: 16px;
    line-height: 1.6;
    font-weight: 500;
}

@media (max-width: 768px) {
    .annotation {
        font-size: 12px;
    }
}

/* Responsive adjustments for mobile devices */
@media (max-width: 768px) {
    .pixel-button {
        padding: 10px 24px;
        font-size: 20px;
        gap: 6px;
    }

    .pixel-arrow {
        width: 16px;
        height: 16px;
    }

    .mission-box-smooth {
        border-radius: 16px;
    }

    .back-to-top {
        bottom: 80px;
        right: 15px;
        width: 70px;
        height: 70px;
        font-size: 11px;
    }

    .back-to-top::before {
        width: 20px;
        height: 20px;
    }
}

/* Q5 Slider Styles */
.q5-slider-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.q5-slider-container::-webkit-scrollbar {
    display: none;
}

.q5-sticky-text {
    position: sticky;
    left: 0;
    width: var(--sticky-width, 100%);
    z-index: 10;
    box-sizing: border-box;
}

.q5-progress-bar-bg {
    width: 100%;
    height: 12px;
    background: #444;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.q5-progress-bar-fill {
    height: 100%;
    background: #F56400;
    width: 0%;
    transition: width 0.3s ease-out;
}



#main-content {
    scroll-behavior: smooth;
}