/* ===================================
   素質シミュレーター専用スタイル
   =================================== */

/* カスタムフォント（動作確認だけして実際は入れてない） */
@font-face {
    font-family: 'CustomFont';
    src: url('fonts/keifont.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* 素質シミュ専用CSS変数 */
: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;
    --count-show-circle: block;
    --count-top: 4px;
    --count-right: 65px;
    --count-padding: 0px 12px;
}

/* 素質シミュ部分 */
.main-content {
    padding: 8px;
}

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

/* キャラクターセクション */
.character-section {
    border: 2px solid rgba(99,91,88,0.7);
    border-radius: 8px;
    padding: 12px;
    background: rgba(66,77,113,1);
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

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

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

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

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

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

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

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

.select-text {
    font-size: 14px;
    font-weight: bold;
    color: #40539f;
    text-align: center;
    padding: 8px;
}

/* キャラクター選択 */
.character-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

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

.character-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1;
}

.character-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 10px;
    padding: 20px;
    max-width: 960px;
    max-height: 80vh;
    overflow-y: auto;
    width: 90%;
    z-index: 2;
}

.character-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #252a42;
    padding-bottom: 10px;
}

.character-modal-title {
    font-size: 20px;
    color: #252a42;
    margin: 0;
}

.character-modal-close {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #424d71;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.character-modal-close:hover {
    color: #252a42;
}

.character-modal-body {
    color: #252a42;
    line-height: 1.8;
    padding: 0 8px 8px 8px;
    overflow-y: auto;
    flex: 1;
}

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

/* モーダル内のキャラクターオプション */
.character-option {
    width: 100%;
    height: 100%;
    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: #d5cdc7;
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0,0,0, 0.5);
}

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

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

/* ツールチップ */
.character-option-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px;
    font-size: 12px;
    text-align: center;
    font-weight: bold;
    opacity: 1;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 10;
    line-height: 1.25;
}

.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: #d5cdc7;
    border-radius: 5px;
    border: 2px solid #f1f1f1;
}

.character-modal-body::-webkit-scrollbar-thumb:hover {
    background: #635b58;
}

/* 小さい画面用の調整 */
@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: 12px;
    flex-wrap: wrap;
    flex: 1;
    align-items: flex-start;
    justify-content: 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: 4px;
    padding: 4px;
    background: white;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.75);
    box-shadow: 2px 2px 4px rgba(0,0,0,0.6);
    position: relative; /* ツールチップの基準位置 */
    width: 111px; /* 固定幅（クリックのたびに表示崩れするの防止） */
    flex-shrink: 0;
}

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

.potential-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
    transition: all 0.3s;
}

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

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

.potential-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid rgba(64,64,64,0.5);
}

/* グレーアウト状態（取得済み用） */
.potential-image-wrapper.grayed-out::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 97%;
    background: rgba(32, 32, 32, 0.6);
    z-index: 1;
    pointer-events: none;
    border-radius: 4px;
}

/* グレーアウト状態（取得しない素質用） */
.potential-image-wrapper.grayed-out-unobtained::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(128, 128, 128, 0);
    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: 48px;
    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: fixed;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 245px; /* ゲーム画面意識の幅 */
    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: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* ツールチップの下表示分岐 */
.potential-tooltip.show-below {
    bottom: auto;
    top: calc(100% + 7px);
}

.potential-tooltip.show-below::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: rgba(0, 0, 0, 0.9);
}


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

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

.status-btn:hover {
    background: #f0f0f0;
    transform: scale(1.00);
}

.status-btn:active {
    transform: scale(0.95);
}

/* コア素質のステータスボタン（取得するしない） */
.status-btn.active {
    background: #4CAF50;
    color: white;
    border-color: rgba(37,42,66,0.5);
}

.status-btn.inactive {
    background: #f44336;
    color: white;
    border-color: rgba(37,42,66,0.5);
}

/* サブ素質のステータスボタン（レベル別色分け） */
.sub-status-btn {
    padding: 6px 8px;
    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: rgba(37,42,66,0.5);
}

.sub-status-btn.level1 {
    background: rgba(124,252,0,1);
    border-color: rgba(37,42,66,0.5);
    color: rgba(37,42,66,1);
}

.sub-status-btn.level2 {
    background: rgba(255,215,0,1);
    border-color: rgba(37,42,66,0.5);
    color: rgba(37,42,66,1);
}

.sub-status-btn.level6 {
    background: #ff9900;
    border-color: rgba(37,42,66,0.5);
    color: rgba(37,42,66,1);
}

.sub-status-btn:hover {
    opacity: 0.8;
    transform: scale(1.00);
}

.sub-status-btn:active {
    transform: scale(0.95);
}

/* プリセットエリア（下段配置） */
.presets-area {
    padding: 16px;
    background: #f0f0ff;
    border-radius: 10px;
    margin: 20px 0;
    max-width: 100%;
    box-sizing: border-box;
}

.presets-area h3 {
    color: #252a42;
    margin-bottom: 8px;
    font-size: 20px;
    border-bottom: 2px solid #252a42;
}

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

.preset-item {
    background: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.preset-thumbnail {
    position: relative;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #252a42 0%, #424d71 100%);
    border-radius: 4px;
    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;
}

/* レスポンシブ対応 */

/* タブレット */
@media (max-width: 1200px) {
    .main-content {
        padding: 12px;
    }
    
    .presets-area {
        width: 100%;
        border-left: none;
        border-top: 2px solid #e0e0e0;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 12px;
    }
    
    /* キャラクターエリア */
    .character-area {
        gap: 12px;
    }
    
    .character-select-button {
        width: 100px;
        height: 100px;
    }
    
    .character-label {
        width: 120px;
    }
    
    /* キャラクターセクションを縦並びに */
    .character-section {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
    
    .character-header {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }
    
    /* 素質カード */
    .potentials-container {
        gap: 8px;
        width: 100%;
        flex: none;
    }
    
    .potential-card {
        padding: 4px;
    }
    
    .potential-image-wrapper {
        width: 85px;
        height: 108px;
    }
    
    /* コントロール */
    .page-controls,
    .controls {
        padding: 12px;
        gap: 8px;
    }
    
    /* プリセット */
    .presets-list {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }
    
    .preset-item {
        padding: 8px;
    }
    
    .preset-thumbnail {
        width: 60px;
        height: 60px;
    }
    
    .btn-save,
    .btn-load {
        padding: 10px 10px;
        font-size: 13px;
        min-height: 40px;
    }
    
    /* モーダル */
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 12px 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-content h2 {
        font-size: 16px;
    }
}

/* スマートフォン */
@media (max-width: 480px) {
    .main-content {
        padding: 4px;
    }
    
    /* キャラクターセクション（キャラ選択＋素質カード） */
    .character-section {
        flex-direction: column;
        align-items: center;
        padding: 8px;
        gap: 8px;
    }
    
    /* キャラクターヘッダー（ラベル＋選択ボタン） */
    .character-header {
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: center;
        gap: 10px;
        width: 100%;
    }
    
    .character-select-button {
        width: 80px;
        height: 80px;
    }
    
    .character-label {
        width: 80px;
    }
    
    /* 素質カード - 1行3つ表示 */
    .potentials-container {
        justify-content: center;
        gap: 8px;
        width: 100%;
        flex: none;
    }
    
    .potential-card {
        width: 95px;
        padding: 4px;
        gap: 6px;
    }
    
    .potential-image-wrapper {
        width: 100%;
        height: 100%;
    }
    
    .potential-count {
        font-size: 14px;
        min-width: 18px;
        padding: 0 0px;
    }
    
    /* ステータスボタンの調整 */
    .potential-status {
        gap: 3px;
    }
    
    .status-btn,
    .sub-status-btn {
        padding: 6px 6px;
        font-size: 12px;
    }
    
    /* コントロール */
    .page-controls,
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .page-controls label,
    .controls label {
        justify-content: center;
        flex-wrap: nowrap;
        min-height: 44px;
    }
    
    .btn {
        width: 100%;
        min-height: 32px;
    }
    
    /* プリセット */
    .presets-list {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .preset-thumbnail {
        width: 48px;
        height: 48px;
    }
    
    .btn-save,
    .btn-load {
        padding: 6px 6px;
        font-size: 12px;
    }
}

/* 小型スマホ（iPhone SE等） */
@media (max-width: 374px) {
    .main-content {
        padding: 6px;
    }
    
    .character-select-button {
        width: 80px;
        height: 80px;
    }
    
    .character-label {
        width: 90px;
    }
    
    /* 素質カード - 小型スマホでも3列維持 */
    .potentials-container {
        gap: 4px;
    }
    
    .potential-card {
        width: calc((100% - 8px) / 3);
        min-width: 90px;
        padding: 3px;
        gap: 4px;
    }
    
    .potential-image-wrapper {
        width: 80px;
        height: 101px;
    }
    
    .status-btn,
    .sub-status-btn {
        padding: 3px 4px;
        font-size: 10px;
    }
    
    .presets-list {
        grid-template-columns: 1fr;
    }
    
    .preset-item {
        flex-direction: row;
    }
}

/* トグルボタン（hideUnobtained用） */
.toggle-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    font-weight: bold;
    color: #333;
}

.toggle-button:hover {
    background: #e0e0e0;
    border-color: #ccc;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.toggle-button.active {
    background: #008000;
    border-color: #008000;
    color: white;
}

.toggle-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s;
    background: white;
}

.toggle-button.active .toggle-checkbox {
    background: #008000;
    border-color: #008000;
}

.toggle-checkbox::after {
    content: '✓';
    font-size: 16px;
    color: white;
    display: none;
}

.toggle-button.active .toggle-checkbox::after {
    display: block;
}

.toggle-label {
    user-select: none;
}
