/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Common Header and Navigation */
/* 共通のハンバーガーメニューボタン */
.hamburger-menu, .hamburger {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1002;
    width: 40px;
    height: 40px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 50%;
    padding: 0;
}

/* メニューボタンのアイコン */
.hamburger-menu .material-icons,
.hamburger .material-icons {
    color: #000;
    font-size: 24px;
}

/* Episodes ページのヘッダー */
.header {
    display: none;
}

.header h1 {
    margin: 0 auto;
    font-family: 'Roboto Slab', serif;
    font-size: 24px;
    font-weight: 600;
}

.header h1 a {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.header h1 a:hover {
    opacity: 0.8;
}

.nav-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: white;
    padding: 80px 20px 20px;
    transition: left 0.3s ease;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    z-index: 1001;
}

.nav-menu.open {
    left: 0;
}

.nav-menu a {
    display: flex;
    align-items: center;
    padding: 15px 0;
    color: #333;
    text-decoration: none;
    font-size: 16px;
    border-bottom: 1px solid #eee;
}

.nav-menu a:hover {
    color: #000;
    background: #f5f5f5;
}

.nav-menu .material-icons {
    margin-right: 10px;
    font-size: 20px;
}

.menu-spacer {
    height: 30px;
    margin: 0;
    padding: 0;
    border: none;
}

/* Top Page Styles */
body.top-page {
    background: #000;
    color: #fff;
    font-family: 'Roboto Slab', sans-serif;
    overflow: hidden;
    padding: 0;
}

/* 垂直スクロール関連 */
.vertical-scroll-container {
    height: 100vh;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.vertical-scroll-content {
    height: auto;
}

.carousel-section {
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
}

.carousel-container {
    width: 100%;
    height: 100vh;
    overflow-x: hidden; /* scrollからhiddenに変更 */
    overflow-y: hidden;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.carousel-content {
    display: flex;
    height: 100%;
    width: fit-content;
    transform: translate3d(0, 0, 0);
    will-change: transform;
    transition: transform 0.3s ease-out;
}

.carousel-item {
    flex: 0 0 100vw;
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.episode-image {
    width: 100%;
    height: 100vh;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

.episode-image.loaded {
    opacity: 1;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.3));
    z-index: 2;
}

.current-caption {
    position: fixed;
    top: max(env(safe-area-inset-top, 0px) + 12px, 20px);
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 3px 5px;
    border-radius: 6px;
    z-index: 1000;
    width: 150px;
    height: 25px;
    overflow: hidden;
}

/* スクロールテキストのコンテナ */
.caption-text-wrapper {
    display: inline-block;
    white-space: nowrap;
    animation: marquee 20s linear infinite;
    padding-left: 5px;
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-100%);
    }
}

/* モバイル対応 */
@supports (-webkit-touch-callout: none) {
    .current-caption {
        margin-top: env(safe-area-inset-top, 0px);
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 768px) {
    .current-caption {
        right: 12px;
        font-size: 11px;
        padding: 3px 5px;
    }
}

/* ビューポートの高さが小さい場合の調整 */
@media (max-height: 600px) {
    .current-caption {
        top: max(env(safe-area-inset-top, 0px) + 8px, 12px);
    }
}
.episode-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
    text-align: center;
    width: 100%;
    padding: 0 20px;
    pointer-events: none;
}

.episode-content > * {
    pointer-events: auto;
}

.episode-title {
    font-family: 'Roboto Slab', serif;
    font-size: 48px;
    font-weight: 800;
}

.episode-subtitle {
    font-size: 12px;
    margin-bottom: 30px !important;
    font-weight: 400;
}

.all-episodes-btn {
    display: inline-block;
    padding: 10px 20px;
    background: #fff;
    color: #000;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 400;
    transition: background-color 0.3s;
    z-index: 12;
}

.all-episodes-btn:hover {
    background: #f0f0f0;
}

.click-area {
    position: absolute;
    top: 0;
    height: 100%;
    width: 50%;
    z-index: 10;
    cursor: pointer;
}

.click-area.prev {
    left: 0;
    cursor: w-resize;
}

.click-area.next {
    right: 0;
    cursor: e-resize;
}

.swipe-indicator {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    display: flex;
    gap: 8px;
}

.swipe-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transition: background 0.3s ease;
}

.swipe-dot.active {
    background: #fff;
}

/* Hide scrollbars */
.carousel-container::-webkit-scrollbar {
    display: none;
}

.carousel-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Episodes Page Styles */
body:not(.top-page) {
    background-color: #f5f5f5;
    min-height: 100vh;
    padding: 0;
}

/* Site Title for Episodes Page */
.site-title {
    text-align: center;
    font-family: 'Roboto Slab', serif;
    font-size: 24px;
    font-weight: 800;
    margin: 80px auto 0;
}

.site-title a {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.site-title a:hover {
    opacity: 0.8;
}

/* Filter Header */
.filter-header {
    max-width: 1200px;
    margin: 20px auto 40px;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.episode-count {
    font-size: 16px;
    color: #333;
}

.episode-count span {
    font-weight: 600;
}

.sort-buttons {
    display: flex;
    gap: 10px;
}

.sort-button {
    padding: 6px 12px;
    background: none;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #666;
    text-decoration: none;
}

.sort-button:hover {
    background: rgba(0, 0, 0, 0.05);
}

.sort-button.active {
    background: #000;
    color: white;
    border-color: #000;
}

.sort-button .material-icons {
    font-size: 16px;
}

/* Grid Layout */
.grid-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1px;
    padding: 0;
}

.grid-item {
    position: relative;
    overflow: hidden;
    background: white;
    transition: transform 0.2s ease;
}

.grid-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.grid-item img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
}

.grid-item-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 15px;
}

.grid-item-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}

/* Download Button */
.download-button {
    width: 100%;
    padding: 6px 12px;
    background-color: #000;
    color: white;
    border: none;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.download-button:hover {
    background-color: #333;
}

.download-button .material-icons {
    font-size: 16px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    z-index: 2000;
    padding: 20px;
    overflow: auto;
}

.modal-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: auto;
    max-width: 98%;
    height: 100%;
}

.modal-content {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

.modal-close {
    position: fixed;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 30px;
    cursor: pointer;
}

.modal-download {
    margin-top: 10px;
}

.modal-download .download-button {
    background-color: white;
    color: black;
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 6px 12px;
}

.modal-download .download-button:hover {
    background-color: #f5f5f5;
}

/* Responsive Styles */
@media (max-width: 1200px) {
    .grid-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 992px) {
    .grid-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .hamburger-menu, .hamburger {
        top: 12px;
        left: 12px;
    }

    .site-title {
        margin-top: 50px;
        font-size: 24px;
    }

    .carousel-caption {
        top: 12px;
        right: 12px;
    }

    .nav-menu {
        width: 100%;
        left: -100%;
    }

    .episode-title {
        font-size: 36px;
    }

    .grid-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1px;
        padding: 0;
    }

    .filter-header {
        margin: 15px auto 30px;
        padding: 0 12px;
    }

    .episode-count {
        font-size: 14px;
    }

    .sort-button {
        padding: 6px 12px;
        font-size: 12px;
    }

    .modal {
        padding: 10px;
    }

    .modal-container {
        max-width: 100%;
    }

    .modal-content {
        max-width: 100%;
        max-height: 90vh;
    }

    .modal-close {
        top: 10px;
        right: 10px;
    }
}

/* Top Page Styles内に追加 */
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s;
}

.carousel-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.carousel-nav.prev {
    left: 20px;
}

.carousel-nav.next {
    right: 20px;
}

.carousel-nav .material-icons {
    color: white;
    font-size: 36px;
}

@media (max-width: 768px) {
    .carousel-nav {
        width: 40px;
        height: 40px;
    }
    
    .carousel-nav .material-icons {
        font-size: 24px;
    }
    
    .carousel-nav.prev {
        left: 10px;
    }
    
    .carousel-nav.next {
        right: 10px;
    }
}
.download-button {
    margin: 0;
}
/* ウォールペーパーボタンのスタイル */
.wallpaper-button {
    width: 100%;
    padding: 6px 12px;
    border: none;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

/* アクティブなウォールペーパーボタン */
.wallpaper-button.active {
    background-color: #2e75ff;
    color: white;
}

.wallpaper-button.active:hover {
    background-color: #1976D2;
}

/* 無効化されたウォールペーパーボタン */
.wallpaper-button.disabled {
    background-color: #E0E0E0;
    color: #9E9E9E;
    cursor: not-allowed;
}

/* ボタンアイコンのサイズ調整 */
.wallpaper-button .material-icons {
    font-size: 16px;
}