/* 基本スタイル */
body {
    font-family: sans-serif;
    margin: 0;
    background-color: #f0f2f5;
    color: #1A1A1A;
}
.grid-item.image-align-right img {
    object-position: right;
}

.grid-item.image-align-top img {
    object-position: top;
}

.grid-item.image-align-bottom img {
    object-position: bottom;
}

.grid-item.image-align-left img {
    object-position: left;
}

.grid-item.image-align-center img {
    object-position: center;
}

/* .gallery-container {
    display: flex;
} */

/* 遅延読み込みされる画像の初期状態（透明） */
.grid-item img.lazy {
    opacity: 0;
}

/* 読み込みが完了した画像のスタイル */
.grid-item img.loaded {
    opacity: 1;
    transition: opacity 0.4s ease-in-out; /* 0.4秒かけて表示 */
}

.copy{
    text-align: center;
    font-size: 0.65rem;
}

.gallery-top-menu{
    display: flex;
    flex-direction: column;
}
.filters{
    display: flex;
}

.logo{
    width: 100%;
    height: auto;
    max-width: 10vw;
    padding-bottom: 1rem;
    display: block;
}

/* サイドバー */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 300px;
    height: 100%; /* 画面の高さに合わせる */
    background-color: #1A1A1A;
    border-right: 1px solid #ddd;
    box-sizing: border-box;
    display: grid;
    grid-template-rows: auto 1fr;
    color: #f8f9fa;
}

#current-costume-title{
    color: #1A1A1A;
}

.filters{
    color: #1A1A1A;
}

.sidebar h1 {
    font-size: 1.5em;
    margin: 0;
    padding: 2rem 1rem;
    background-color: #1A1A1A;
}


.sidebar nav {
    overflow-y: auto; 
    min-height: 0;
        background-color: #434343;
}


#costume-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

#costume-menu li {
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#costume-menu li:hover {
    background-color: #222222;
}

#costume-menu li.active {
    background-color: #2B2B2B;
    color: #fff;
}

/* メインコンテンツ */
.main-content {
    margin-left: 300px; 
    padding: 20px;
    overflow-y: auto;
    box-sizing: border-box;
    min-width: 0;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #ddd;
}

.filters select {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin: 0 10px;
    width: 20vw;
}

/* 画像グリッド */
.image-grid {
    display: grid;
    /* ▼▼▼ 変更点：グリッド表示の崩れを修正 ▼▼▼ */
    grid-template-columns: repeat(4, minmax(0, 1fr));
    /* ▲▲▲ 変更ここまで ▲▲▲ */
    gap: 15px;
}

.grid-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.2s;
    background-color: #fff;
    height: 30vw;
}
.grid-item:hover {
    transform: scale(1.05);
}

.grid-item img {
   width: 100%;
   height: 100%;
   object-fit: cover;   /* デスクトップ既定 */
   display: block;
}

.grid-item.hidden {
    display: none;
}

.version-label,
.character-label {
    position: absolute;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    text-align: center;
    padding: 4px 0;
    font-size: 14px;
    font-weight: bold;
    user-select: none;
}

.version-label {
    top: 0;
}

.character-label {
    bottom: 0;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
}

.pagination button {
    padding: 8px 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    background-color: #f8f9fa;
    margin: 0 10px;
}

.pagination button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}


/* ポップアップ */
.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90vw;
    max-height: 90vh;
    width: 65vw;
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 1001;
    display: none; /* 初期状態は非表示 */
    grid-template-rows: 1fr auto 1fr; 
grid-template-columns: 1fr;
align-items: center; 
}

.popup img {
    max-width: 100%;
    max-height: calc(90vh - 40px); /* Padding分を考慮 */
    display: grid;
        grid-row: 2;
            margin: 0 auto;
    text-align: center;
}

.popup-close {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 30px;
    font-weight: bold;
    color: #555;
    cursor: pointer;
}

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: none; /* 初期状態は非表示 */
}

.popup-nav {
    cursor: pointer;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    padding: 16px;
    color: white;
    background-color: rgba(0, 0, 0, 0.4);
    font-weight: bold;
    font-size: 20px;
    transition: 0.3s;
    user-select: none;
}
.popup-nav:hover {
    background-color: rgba(0, 0, 0, 0.8);
}
.prev { left: 25px; } /* 位置を調整 */
.next { right: 25px; } /* 位置を調整 */
.pagination button:not(:disabled):hover {
    background-color: #222222;
    color: #f8f9fa;
}

/* NEWマークのスタイル */
.new-mark {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 6px;
    background-color: #ff4500; /* オレンジレッド */
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    border-radius: 4px;
    vertical-align: middle;
    line-height: 1;
}

/* #costume-menu li.active .new-mark {
    background-color: #fff;
    color: #0056b3;
} */

/* ---------------------------------- */
/* レスポンシブ & ハンバーガーメニュー */
/* ---------------------------------- */

/* デスクトップでは非表示 */
.hamburger-menu,
.sidebar-close,
.menu-overlay {
    display: none;
}

/* 画面幅が768px以下の場合に適用 */
@media (max-width: 768px) {
    .grid-item {
        height: 60vw;
    }
    .logo{
        max-width: 30vw;
    }
    .gallery-container {
        flex-direction: column;
    }
    .main-content{
        margin: 0;
    }
    .image-grid{
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .sidebar {
        width: 280px; /* モバイルでの幅 */
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 2000;
        transform: translateX(-100%); /* 初期状態は画面外に隠す */
        transition: transform 0.3s ease-in-out;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }

    .sidebar.is-open {
        transform: translateX(0); /* is-openクラスが付いたら表示 */
    }

    .hamburger-menu {
position: fixed;
        display: block;
        top: 3vw;
        width: 28px;
        height: 22px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        margin-right: 15px;
        z-index: 3;
    }
    .version-label, .character-label{
        font-size: 12px;
    }
    .hamburger-menu span {
        width: 100%;
        height: 3px;
        background-color: #333;
        border-radius: 2px;
        display: block;
                margin-bottom: 4px;
    }
    .gallery-header{
        align-items: flex-start;
        position: relative;
    }
    .filters{
            font-size: 0.75rem;
            display: flex;
    }
    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }
    .sidebar-close {
        display: block;
        background: none;
        border: none;
        font-size: 30px;
        cursor: pointer;
        padding: 0 10px;
        color: #888;
    }
    .filters select{
        margin: 0;
        width: 44vw;
                padding: 8px 0;
    }

    .menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
    }
    .menu-overlay.is-open {
        display: block;
        opacity: 1;
        visibility: visible;
    }

    .popup {
    max-width: 95vw;
    max-height: 90vh;
    width: 90vw !important;
    height: 60vh !important;
    padding: 10px;
grid-template-rows: 1fr auto 1fr; 
grid-template-columns: 1fr;
align-items: center; 
}

.popup img {
    max-height: calc(60vh - 20px);
    grid-row: 2;
}

.popup-close {
    top: 5px;
    right: 10px;
    font-size: 24px;
}

.popup-nav {
    font-size: 16px;
    padding: 8px;
}

.prev {
    left: 10px;
}

.next {
    right: 10px;
}
}