.gallery-page-container {
    min-height: 100vh;
    background: linear-gradient(to bottom, #0b0d2b, #1a1f4b);
    background-image: url('img/japanese-paper_00165.jpg'); 
    background-size: cover;
    background-attachment: scroll;
    padding: 120px 20px 40px; /* ヘッダー分スペース確保 */
    color: #eee;
}

.gallery-page-title {
    text-align: center;
    font-size: 3em;
    margin-bottom: 60px;
    text-shadow: 0 0 20px #4a90e2;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 40px;
    max-width: 1400px;
    margin: 0 auto;
}

.category-stack {
    position: relative;
    height: 380px;                
    cursor: pointer;
    transition: transform 0.4s ease;
    padding: 20px;                /* 内側余白で全体を締める */
}

.category-stack:hover {
    transform: scale(1.05);
}

.category-title {
    position: absolute;
    bottom: 30px;                 
    left: 30px;                   
    font-size: 2.2em;             
    color: #ffffff;               
    text-shadow: 
        0 0 10px #000000,         /* 黒いグローで背景から浮かせる */
        0 2px 4px rgba(0,0,0,0.8),
        2px 2px 4px #000000;
    z-index: 5;
    font-weight: bold;
    margin: 0;
    transition: all 0.4s;
}

.stack-images {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 260px;                 
    height: 260px;                
}

.stack-images img {
    width: 100%;
    height: 100%;
    object-fit: cover;            /* 画像全体をきれいにフィット */
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.7);
    position: absolute;
    transition: all 0.5s ease;
}

/* ホバーで画像が広がってカッコよく */
.category-stack:hover .stack-images img {
    transform: rotate(0deg) translate(0,0) !important;
    opacity: 1;
    box-shadow: 0 20px 50px rgba(74, 144, 226, 0.4);
}
/* 詳細ビュー */
.category-detail {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 100px;
}

.detail-carousel {
    display: flex;
    overflow-x: auto;
    gap: 20px;
    padding: 20px;
    width: 90%;
    scroll-behavior: smooth;
}

.carousel-item img {
    height: 400px;
    object-fit: contain;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 0 20px #4a90e2;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

#lightbox-img {
    max-width: 90%;
    max-height: 70vh;
    border-radius: 20px;
    box-shadow: 0 0 50px #4a90e2;
}

#lightbox-caption {
    margin-top: 20px;
    font-size: 1.5em;
    color: #fff;
    text-align: center;          /* 明示的に中央揃えを指定（これが大事！） */
    max-width: 80%;              /* 幅を制限して中央に収める */
    margin-left: auto;           /* 自動マージンで横中央 */
    margin-right: auto;
    line-height: 1.6;            /* 行間を広げて読みやすく */
    white-space: pre-line;       /* \n対策の保険（そのまま残してOK） */
    word-wrap: break-word;       /* 長い単語も折り返し */
}

.prev, .next {
    position: absolute;
    top: 50%;
    font-size: 3em;
    color: #4a90e2;
    cursor: pointer;
}

.prev { left: 20px; }
.next { right: 20px; }

.close-btn, .close-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 3em;
    color: #fff;
    cursor: pointer;
}

.hidden { display: none; }

.close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 3em;
    color: #fff;                  /* 白で目立つ */
    background: none;             /* 背景なし（透過！） */
    border: none;                 /* 枠線なし */
    cursor: pointer;
    padding: 0;                   /* パディング除去 */
    line-height: 1;               /* 余計な高さをなくす */
    opacity: 0.8;                 /* 少し透明でエレガントに */
    transition: opacity 0.3s, transform 0.3s;
    z-index: 101;                 /* 最上位に */
}

.close-btn:hover {
    opacity: 1;
    transform: scale(1.1);        /* ホバーで少し拡大してカッコよく */
    color: #4a90e2;               /* ホバーで青く光る（ゲーム風） */
}

/* ホバーでタイトルがさらに目立つ */
.category-stack:hover .category-title {
    text-shadow: 
        0 0 20px #4a90e2,         /* 青く光るエフェクト */
        0 0 30px #4a90e2;
    transform: translateY(-5px);  /* 少し浮き上がる */
}