/* ============================================================
   SUB NAVIGATION (Sticky Bar)
   ============================================================ */
.sub-nav-container {
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    position: sticky;
    top: var(--header-height, 77px);
    z-index: 90;
    width: 100%;
}

.sub-nav-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 1400px;
    margin: 0 auto;
    border-left: 1px solid #333;
    width: fit-content;
}

/* キャラ選択トリガー */
.char-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-right: 1px solid #333;
    background: linear-gradient(to bottom, #5e0156 0%, #35002c 100%);
    min-width: 160px;
    height: 50px;
    position: relative;
    cursor: pointer;
    transition: 0.3s;
}

.char-selector::after {
    content: var(--current-char-name, "Character");
    display: flex;
    align-items: center;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    padding: 0 25px 0 10px;
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="white"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: calc(100% - 5px) center;
    background-size: 18px;
}

.char-selector:hover {
    background: linear-gradient(to bottom, #99008c 0%, #35002c 100%);
}

.nav-links { display: flex; }

.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px; /* パディングを少し狭めて余裕を持たせる */
    height: 50px;
    color: #ccc;
    text-decoration: none;
    font-size: 14px;
    transition: 0.3s;
    border-bottom: 3px solid transparent;
    border-right: 1px solid #333;
    background-color: #1a1a1a;
    box-sizing: border-box;

    /* --- ここから追加・修正 --- */
    white-space: nowrap;       /* 絶対に改行させない */
    flex-shrink: 1;            /* 親の幅が狭まった時に自分も縮む */
    min-width: 0;              /* flexアイテムがコンテンツサイズ以下に縮めるようにする */
    overflow: hidden;          /* 万が一はみ出た場合に表示をカット */
    /* text-overflow: ellipsis; */ /* 必要なら末尾を「...」にする */
}

/* 画面がかなり狭い時に文字サイズ自体を小さくする（さらに安全策） */
@media (max-width: 900px) {
    .nav-item {
        font-size: 12px;
        padding: 0 8px;
    }
}

.nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.nav-item.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 3px solid #ff00f2;
}

/* ============================================================
   CHARACTERS GRID MODAL (調整版)
   ============================================================ */

.char-modal-overlay {
    position: fixed;
    top: calc(var(--header-height, 77px) + 50px);
    left: 0;
    width: 100%;
    height: calc(100vh - (var(--header-height, 77px) + 50px));
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 20px;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.char-modal-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

.char-modal-content {
    width: 95%;
    max-width: 1100px; /* 余白分を含めて少し広めに設定 */
    max-height: 90%;
    background: #080808;
    border: 1px solid #333;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,1);
    -ms-overflow-style: none; scrollbar-width: none;
}
.char-modal-content::-webkit-scrollbar { display: none; }

.char-modal-header {
    position: sticky;
    top: 0;
    padding: 10px 20px;
    background: linear-gradient(to right, #5e0156, #000);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #ff8800;
    z-index: 110;
}

.modal-title { font-family: 'Anton'; color: #fff; font-size: 1.1rem; letter-spacing: 0.1em; }
.char-modal-close { background: none; border: none; color: #fff; font-size: 28px; cursor: pointer; transition: 0.2s; }
.char-modal-close:hover { color: #ff8800; transform: scale(1.1); }

/* 共通6列グリッド (はみ出し防止用の左右パディング追加) */
.modal-grid-override {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
    justify-content: center !important;
    column-gap: 0 !important;
    row-gap: 15px !important;
    padding: 40px 50px !important; /* 左右に十分な余白を確保 */
    width: 100% !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
}

/* --- キャラクターカード装飾 --- */
.chara-card {
    position: relative;
    display: block;
    width: 110%;
    margin-left: -5%;
    aspect-ratio: 10 / 19;
    background: #080808;
    z-index: 1;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), clip-path 0.3s ease;
    clip-path: polygon(20% 0, 100% 0, 80% 100%, 0% 100%);
    overflow: hidden;
}

.chara-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    clip-path: polygon(20% 0, 100% 0, 80% 100%, 0% 100%);
    z-index: 5;
    pointer-events: none;
    transition: all 0.3s;
}

/* ホバー演出（拡大率を1.08に微調整して余白内に収めやすく） */
.chara-card:hover {
    z-index: 10;
    clip-path: polygon(10% 0, 100% 0, 90% 100%, 0% 100%);
    transform: scale(1.08);
}
.chara-card:hover::before {
    border: 2px solid #ff8800;
    background: rgba(255, 136, 0, 0.1);
    box-shadow: inset 0 0 15px rgba(255, 136, 0, 0.5);
    clip-path: polygon(10% 0, 100% 0, 90% 100%, 0% 100%);
}

.chara-img-wrapper { position: absolute; inset: 0; z-index: 2; }
.chara-img { width: 100%; height: 100%; object-fit: cover; }

/* 現在のキャラの強調 */
.chara-card.is-current::before {
    border: 2px solid #ff8800;
    background: rgba(255, 136, 0, 0.2);
    clip-path: polygon(10% 0, 100% 0, 90% 100%, 0% 100%);
}

/* キャラ名（レスポンシブ対応版） */
.chara-name-en {
    position: absolute;
    left: 80%; bottom: 0%;
    white-space: nowrap;
    
    /* clamp(最小サイズ, 推奨サイズ, 最大サイズ) 
       推奨サイズに 4vw を入れることで画面幅に応じて伸縮させます
    */
    font-size: clamp(1rem, 4vw, 2.2rem); 
    
    font-weight: 900;
    color: #fff;
    font-family: 'Anton', sans-serif;
    z-index: 100;
    opacity: 0;
    transition: all 0.3s ease;
    transform: rotate(-90deg) skewY(3deg);
    transform-origin: left center;
    
    /* 視認性強化 */
    text-shadow: 
        0 0 8px rgba(0, 0, 0, 1),
        0 0 15px rgba(0, 0, 0, 1),
        2px 2px 2px rgba(0, 0, 0, 1);
}

/* モバイル用のメディアクエリ内も調整 */
@media (max-width: 768px) {
    .chara-name-en {
        /* スマホ時はさらに計算式を小さめに調整（あるいはclampに任せるなら削除でもOK） */
        font-size: clamp(0.7rem, 3vw, 1.2rem); 
        text-shadow: 0 0 5px rgba(0, 0, 0, 1);
    }
}
.chara-card:hover .chara-name-en { opacity: 1; }

/* スマホ個別調整 */
@media (max-width: 768px) {
    .sub-nav-inner { justify-content: flex-start; overflow-x: auto; width: 100%; border-left: none; }
    .char-selector { min-width: 120px; height: 45px; }
    .nav-item { height: 45px; padding: 0 10px; white-space: nowrap; }

    .char-modal-overlay {
        top: calc(var(--header-height, 60px) + 45px); 
        height: calc(100vh - (var(--header-height, 60px) + 45px));
    }

    .modal-grid-override {
        grid-template-columns: repeat(6, 1fr) !important;
        padding: 20px 15px !important; /* スマホ用余白 */
        row-gap: 10px !important;
    }
    .chara-name-en { 
        font-size: 0.8rem; 
        text-shadow: 0 0 5px rgba(0, 0, 0, 1);
    }
}