/* ========================================
   カスタムフォント
   ======================================== */
@font-face {
    font-family: 'CustomFont';
    src: url('fonts/keifont.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* ========================================
   基本設定
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ========================================
   カスタマイズ設定（編集推奨）
   ======================================== */
:root {
    /* サムズアップ画像の位置とサイズ */
    --thumbs-up-size: 30px;
    --thumbs-up-top: 70px;
    --thumbs-up-left: 0px;
    
    /* カウント数字のデザイン */
    --count-font-size: 16px;
    --count-bg-color: rgba(255,255,255,1);
    --count-text-color: black;
    --count-border-radius: 2px; /* 丸型: 50%, 四角: 5px など */
    --count-show-circle: block; /* 背景を表示: block, 非表示: none */
    --count-top: 4px;
    --count-right: 65px;
    --count-padding: 0px 12px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* ========================================
   ハンバーガーメニュー
   ======================================== */
.hamburger-menu {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10000;
    width: 40px;
    height: 40px;
    background: #667eea;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    transition: all 0.3s;
}

.hamburger-menu:hover {
    background: #764ba2;
}

.hamburger-line {
    width: 24px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s;
}

.side-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    transition: left 0.3s;
    overflow-y: auto;
}

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

.side-menu-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 20px 20px 70px; /* 左側にハンバーガーメニュー分の余白を追加 */
    font-size: 20px;
    font-weight: bold;
}

.side-menu-list {
    list-style: none;
    padding: 0;
}

.side-menu-list li {
    border-bottom: 1px solid #e0e0e0;
}

.side-menu-list a {
    display: block;
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
    transition: background 0.3s;
}

.side-menu-list a:hover {
    background: #f0f0f0;
}

.side-menu-list .menu-item-disabled {
    display: block;
    padding: 15px 20px;
    color: #999; /* グレー表示 */
    text-decoration: none;
    cursor: default; /* ホバー時にカーソル変化なし */
    pointer-events: none; /* クリック無効 */
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: none;
}

.menu-overlay.active {
    display: block;
}

/* ========================================
   ヘッダー
   ======================================== */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px 20px 80px; /* 左側にハンバーガーメニュー分の余白 */
    position: sticky; /* 固定位置 */
    top: 0; /* 画面上部に固定 */
    z-index: 999; /* ツールチップより下 */
}

header h1 {
    font-size: 28px;
    margin-bottom: 15px;
}

.controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.controls input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ========================================
   ボタン
   ======================================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.btn:active {
    transform: translateY(0);
}

.btn {
    background: #4CAF50;
    color: white;
}

.btn-primary {
    background: #2196F3;
    color: white;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

/* ========================================
   モーダル
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 10px;
    max-width: 800px;
    max-height: 80vh;
    width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.modal-header {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    padding: 30px 30px 0 30px;
    border-radius: 10px 10px 0 0;
}

.modal-close {
    position: sticky; /* 固定位置 */
    top: 15px; /* ヘッダー内で固定 */
    right: 15px;
    width: 35px;
    height: 35px;
    border: none;
    background: #f44336;
    color: white;
    font-size: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    line-height: 1;
    padding: 0;
    float: right; /* 右寄せ */
    z-index: 11;
}

.modal-close:hover {
    background: #d32f2f;
    transform: none;
}

.modal-content h2 {
    font-size: 28px;
    color: #667eea;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 3px solid #667eea;
    clear: both; /* floatをクリア */
}

.modal-content h3 {
    font-size: 20px;
    color: #333;
    margin-top: 20px;
    margin-bottom: 10px;
}

.modal-body {
    color: #333;
    line-height: 1.8;
    padding: 0 30px 30px 30px;
    overflow-y: auto;
    flex: 1;
}

.modal-body p {
    margin-bottom: 15px;
}

.modal-body strong {
    color: #667eea;
}

.modal-body ul {
    margin-left: 20px;
    margin-bottom: 20px;
}

.modal-body li {
    margin-bottom: 8px;
}

/* スクロールバーのスタイル（Webkit系ブラウザ） */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* ========================================
   メインコンテンツ
   ======================================== */
.main-content {
    padding: 5px;
}

.characters-area {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* ========================================
   キャラクターセクション
   ======================================== */
.character-section {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    background: #f9f9f9;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.character-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.character-label {
    height: auto;
    width: 150px;
}

.character-label img {
    width: 100%;
    height: 100%;
}

/* キャラクター選択（モーダル形式） */
.character-select-wrapper {
    position: relative;
}

.character-select-button {
    width: 125px;
    height: 125px;
    border: 3px solid #667eea;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.3s;
}

.character-select-button:hover {
    border-color: #764ba2;
    transform: scale(1.05);
}

.character-select-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 7px;
}

.select-text {
    font-size: 14px;
    font-weight: bold;
    color: #667eea;
    text-align: center;
    padding: 10px;
}

/* モーダル形式のキャラクター選択 */
.character-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    display: none; /* 初期状態は非表示 */
    align-items: center;
    justify-content: center;
}

.character-modal.open {
    display: flex;
}

.character-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
}

.character-modal-content {
    position: relative;
    background: white;
    border-radius: 10px;
    max-width: 950px; /* 6列が収まる幅 */
    max-height: 80vh;
    width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.character-modal-header {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    padding: 20px 20px 10px 20px;
    border-radius: 10px 10px 0 0;
    border-bottom: 2px solid #667eea;
}

.character-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    border: none;
    background: #f44336;
    color: white;
    font-size: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    line-height: 1;
    padding: 0;
    z-index: 11;
}

.character-modal-close:hover {
    background: #d32f2f;
    transform: scale(1.1);
}

.character-modal-title {
    font-size: 20px;
    color: #667eea;
    font-weight: bold;
    margin: 0;
    padding-right: 50px; /* 閉じるボタンのスペース */
}

.character-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.character-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
    gap: 15px;
    justify-items: center;
}

/* モーダル内のキャラクターオプション */
.character-option {
    width: 125px;
    height: 125px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ddd;
    border-radius: 8px;
    transition: all 0.3s;
    position: relative;
    background: white;
}

.character-option:hover:not(.disabled) {
    border-color: #667eea;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.character-option.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: #f9f9f9;
}

.character-option-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

/* ツールチップ（名前表示） */
.character-option-name {
    position: fixed;
    bottom: auto;
    left: 0%;
    transform: translateX(50%);
    transform: translateY(-115%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 99999;
}

.character-option:hover .character-option-name {
    opacity: 1;
}

/* モーダルボディのスクロールバー */
.character-modal-body::-webkit-scrollbar {
    width: 12px;
}

.character-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
    margin: 5px 0;
}

.character-modal-body::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 5px;
    border: 2px solid #f1f1f1;
}

.character-modal-body::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* 小さい画面用の調整 */
@media (max-width: 768px) {
    .character-modal-content {
        max-width: 95%;
        max-height: 85vh;
    }
    
    .character-modal-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }
    
    .character-option {
        width: 100px;
        height: 100px;
    }
}

@media (max-width: 480px) {
    .character-modal-content {
        max-width: 95%;
        max-height: 90vh;
    }
    
    .character-modal-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 10px;
    }
    
    .character-option {
        width: 80px;
        height: 80px;
    }
    
    .character-modal-header {
        padding: 15px 15px 10px 15px;
    }
    
    .character-modal-body {
        padding: 15px;
    }
    
    .character-modal-title {
        font-size: 16px;
    }
}

/* 隠しselect（互換性のため） */
.character-select {
    display: none;
}

/* ========================================
   素質コンテナ
   ======================================== */
.potentials-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap; /* 改行を許可 */
    flex: 1;
    align-items: flex-start;
}

.potential-group {
    display: contents; /* レイアウトフローに影響しないようにする */
}

.potential-group-title {
    display: none; /* コア素質・サブ素質の文字を非表示 */
}

.potentials-grid {
    display: contents; /* レイアウトフローに影響しないようにする */
}

/* ========================================
   素質カード
   ======================================== */
.potential-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 5px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    position: relative; /* ツールチップの基準位置として追加 */
    /* カード全体のホバーアニメーションを削除 */
}

.potential-card.hidden {
    display: none;
}

.potential-image-wrapper {
    position: relative;
    width: 101px;
    height: 128px;
    cursor: pointer;
    transition: all 0.3s; /* ホバー用トランジション追加 */
}

/* 素質画像のホバーアニメーション */
.potential-image-wrapper:hover {
    transform: scale(1.05);
}

/* 素質画像のクリックアニメーション */
.potential-image-wrapper:active {
    transform: scale(0.95);
}

.potential-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0px;
    border: 0px solid #red;
}

/* グレーアウト状態（取得済み用：オーバーレイのみ） */
.potential-image-wrapper.grayed-out::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(128, 128, 128, 0.6); /* グレーのオーバーレイ */
    z-index: 1; /* 画像の上、カウント・サムズアップの下 */
    pointer-events: none;
    border-radius: 0px;
}

/* グレーアウト状態（取得しない用：オーバーレイ + グレースケール） */
.potential-image-wrapper.grayed-out-unobtained::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(128, 128, 128, 0.6); /* グレーのオーバーレイ */
    z-index: 1;
    pointer-events: none;
    border-radius: 0px;
}

.potential-image-wrapper.grayed-out-unobtained .potential-image {
    filter: grayscale(100%); /* グレースケールを追加 */
}

/* カウント表示のz-index調整 */
.potential-count {
    position: absolute;
    top: var(--count-top);
    right: var(--count-right);
    background: var(--count-bg-color);
    color: var(--count-text-color);
    font-weight: bold;
    font-size: var(--count-font-size);
    padding: var(--count-padding);
    border-radius: var(--count-border-radius);
    min-width: 28px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    display: var(--count-show-circle);
    z-index: 2; /* グレーアウトの上 */
}

/* レベル6のサムズアップ（画像版）のz-index調整 */
.thumbs-up {
    position: absolute;
    top: var(--thumbs-up-top);
    left: var(--thumbs-up-left);
    width: var(--thumbs-up-size);
    height: var(--thumbs-up-size);
    box-shadow: 0 0px 0px rgba(0, 0, 0, 0);
    z-index: 2; /* グレーアウトの上 */
}

.thumbs-up img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.potential-name {
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    color: #333;
    word-break: break-word;
}

/* 取得済み状態（コア素質） */
.potential-image-wrapper.obtained::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 1);
    pointer-events: none;
    z-index: 3; /* グレーアウトとカウントの上 */
}

.potential-image-wrapper.obtained::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5); /* 暗くする */
    z-index: 1;
    pointer-events: none;
    border-radius: 0px;
}

/* ツールチップ（説明文） */
.potential-tooltip {
    position: absolute;
    bottom: calc(100% + 5px); /* カード上部に表示 */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px;
    border-radius: 5px;
    font-size: 12px;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-width: 210px; 
    min-width: 210px; /* ツールチップ幅調整 */
    z-index: 10003; /* 最前面に表示 */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.potential-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* ステータスボタン */
.potential-status {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
}

.status-btn {
    padding: 6px 10px;
    font-size: 14px;
    font-weight: bold;
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
}

.status-btn:hover {
    background: #f0f0f0;
    transform: scale(1.05); /* ホバー時にスケール変更 */
}

.status-btn:active {
    transform: scale(0.95); /* クリック時にスケール変更 */
}

/* コア素質のステータスボタン */
.status-btn.active {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.status-btn.inactive {
    background: #f44336;
    color: white;
    border-color: #f44336;
}

/* サブ素質のステータスボタン（レベル別色分け） */
.sub-status-btn {
    padding: 6px 10px;
    font-size: 14px;
    font-weight: bold;
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    color: white;
}

.sub-status-btn.none {
    background: #999999;
    border-color: #999999;
}

.sub-status-btn.level1 {
    background: #00ff00;
    border-color: #00ff00;
    color: #333;
}

.sub-status-btn.level2 {
    background: #ffff00;
    border-color: #ffff00;
    color: #333;
}

.sub-status-btn.level6 {
    background: #ff9900;
    border-color: #ff9900;
}

.sub-status-btn:hover {
    opacity: 0.8;
    transform: scale(1.05); /* ホバー時にスケール変更 */
}

.sub-status-btn:active {
    transform: scale(0.95); /* クリック時にスケール変更 */
}

/* ========================================
   プリセットエリア（下段配置）
   ======================================== */
.presets-area {
    width: 100%;
    background: #f9f9f9;
    border-top: 2px solid #e0e0e0;
    padding: 20px;
    margin-top: 30px;
}

.presets-area h3 {
    font-size: 20px;
    color: #667eea;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.presets-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.preset-item {
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.preset-thumbnail {
    position: relative;
    width: 80px;
    height: 80px;
    background: #e0e0e0;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.preset-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preset-number {
    position: absolute;
    bottom: 3px;
    right: 3px;
    background: rgba(64, 64, 64, 0.9);
    color: white;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
}

.preset-actions {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.btn-save,
.btn-load {
    padding: 6px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-save {
    background: #4CAF50;
    color: white;
}

.btn-save:hover {
    background: #45a049;
}

.btn-load {
    background: #2196F3;
    color: white;
}

.btn-load:hover:not(:disabled) {
    background: #0b7dda;
}

.btn-load:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.5;
}

/* ========================================
   エラーメッセージ
   ======================================== */
.error-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #f44336;
    color: white;
    padding: 15px 30px;
    border-radius: 5px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    animation: slideDown 0.3s ease-out;
}

.error-message.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* ========================================
   レスポンシブ対応（一旦コメントアウト）
   ======================================== */
/*
@media (max-width: 1200px) {
    .main-content {
        flex-direction: column;
    }
    
    .presets-area {
        width: 100%;
        border-left: none;
        border-top: 2px solid #e0e0e0;
    }
}

@media (max-width: 768px) {
    .potentials-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}
*/
