/* 素質シミュレーター */

: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;
    touch-action: manipulation; /* ダブルタップでのズームを無効化 */
}

.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; /* グレーアウトの上 */
    pointer-events: none; /* クリック判定なし */
}

/* レベル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; /* グレーアウトの上 */
    pointer-events: none; /* クリック判定なし */
}

.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: rgba(66,77,113,1);
    border-radius: 10px;
    margin: 20px 0;
    max-width: 100%;
    box-sizing: border-box;
}

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

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

.preset-item {
    background: rgba(32, 32, 128, 0.4);
    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: visible; /* ラベルをはみ出させるために変更 */
    flex-shrink: 0;
}

.preset-icon {
    position: relative;
    z-index: 1; /* ラベルより後ろに配置 */
    width: 100%;
    height: 100%;
    border-radius: 4px; /* サムネイルの角丸に合わせる */
    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;
}

/* hideUnobtained用の色設定（緑） */
#hideUnobtained.active {
    background: #008000;
    border-color: #008000;
}

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

/* reorderMode用の色設定（オレンジ） */
#reorderMode.active {
    background: #ff8c00;
    border-color: #ff8c00;
}

#reorderMode.active .toggle-checkbox {
    background: #ff8c00;
    border-color: #ff8c00;
}

.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-checkbox::after {
    content: '✓';
    font-size: 16px;
    color: white;
    display: none;
}

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

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

/* ラベル選択ボタン */
.label-select-btn.active {
    border-color: #40539f !important;
    box-shadow: 0 0 4px rgba(64, 83, 159, 0.5);
}

.label-select-btn:hover {
    border-color: #7d8cb8;
}

/* プリセットのラベル画像 */
.preset-label {
    position: absolute;
    bottom: -12px;
    right: -10px;
    width: 48px;
    height: 48px;
    z-index: 10;   /* キャラアイコンより前 */
}


/* 選択していないラベルボタンをグレースケール */
.label-select-btn:not(.active) {
    filter: grayscale(100%);
    opacity: 0.5;
}

.label-select-btn:not(.active):hover {
    filter: grayscale(25%);
    opacity: 0.8;
}

/* プリセット名入力欄 */
#preset-name-input-inline {
    font-size: 14px;
    min-height: 20px;
    vertical-align: middle;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    padding: 2px 4px;
}

/* 編集ボタン */
#preset-name-edit-btn {
    padding: 5px 12px;
    font-size: 14px;
    width: auto !important;
    min-width: auto !important;
}

/* スマートフォン用レスポンシブ対応 */
@media screen and (max-width: 768px) {
    /* ラベル選択ボタン（プリセット名の上） */
    .label-select-btn {
        width: 48px !important;
        height: 48px !important;
    }
    
    /* noneボタンの✕サイズ */
    .label-select-btn[data-label="none"] span {
        font-size: 32px !important;
    }
    
    /* プリセットのラベル画像 */
    .preset-label {
        width: 32px !important;
        height: 32px !important;
        bottom: -8px !important;
        right: -8px !important;
    }
}

/* ボタンの色設定 */
/* カウントリセット */
#resetCount {
    background: #00bfff;
    border-color: #00bfff;
    color: white;
}

#resetCount:hover {
    background: #00b0d7;
    border-color: #00b0d7;
}

/* 並び順リセット */
#resetOrder {
    background: #9370db;
    border-color: #9370db;
    color: white;
}

#resetOrder:hover {
    background: #7b5ec0;
    border-color: #7b5ec0;
}

#autoAssign:hover {
    background: #43a864;
    border-color: #43a864;
}

/* disabledスタイルは共通の白 */
#autoAssign.btn-disabled {
    background: #cccccc;
    border-color: #cccccc;
    color: #666666;
    cursor: not-allowed;
    opacity: 0.6;
}

#autoAssign.btn-disabled:hover {
    background: #cccccc;
    border-color: #cccccc;
    transform: none;
    box-shadow: none;
}

/* さらに小さい画面（360px以下）用 */
@media screen and (max-width: 360px) {
    /* ラベル選択ボタン（プリセット名の上） */
    .label-select-btn {
        width: 20px !important;
        height: 20px !important;
    }
    
    /* noneボタンのテキストサイズ調整 */
    .label-select-btn[data-label="none"] span {
        font-size: 8px !important;
    }
    
    /* プリセットサムネイルのラベル画像 */
    .preset-label {
        width: 24px !important;
        height: 24px !important;
        bottom: -6px !important;
        right: -6px !important;
    }
}

/* 「取得しない素質を非表示」有効時、コア素質下のボタンを押せなくする */
body.hide-unobtained-active .potential-card[data-type="core"] .status-btn {
    cursor: not-allowed !important;
    opacity: 0.6;
}

body.hide-unobtained-active .potential-card[data-type="core"] .status-btn:hover {
    opacity: 0.6 !important;
}

/* スマートフォン用のレイアウト調整 */
@media screen and (max-width: 768px) {
    /* プリセット名コンテナ */
    
    /* プリセット名表示エリア */
    #preset-name-display-area {
        flex-wrap: wrap !important;
        gap: 4px !important;
    }
    
    /* ラベルセレクターの後に改行 */
    #label-selector {
        width: 100% !important;
        justify-content: center !important;
        margin-bottom: 4px;
    }
    
    /* プリセット名:ラベルの後に改行 */
    #preset-name-display-area > span[data-i18n="labels.presetName"] {
        width: 100% !important;
        text-align: center !important;
        font-size: 12px !important;
        margin-bottom: 2px;
    }
    
    /* プリセット名入力欄 */
    #preset-name-input-inline {
        width: 100% !important;
        max-width: 200px !important;
        font-size: 16px !important;
        word-wrap: break-word !important;
        white-space: pre-wrap !important;
        text-align: center !important;
        min-height: 24px;
        padding: 4px 8px !important;
        line-height: 1.4 !important;
        touch-action: manipulation;
    }
    
    /* 編集ボタン */
    #preset-name-edit-btn {
        font-size: 12px !important;
        padding: 4px 8px !important;
        width: auto !important;
        min-width: auto !important;
        touch-action: manipulation;
    }
    
    /* 編集ボタンのテキストを非表示にしてアイコンのみ表示 */
    #preset-name-edit-btn::before {
        content: '✎';
    }
    #preset-name-edit-btn {
        font-size: 0 !important;
        padding: 6px 10px !important;
        width: auto !important;
    }
    #preset-name-edit-btn::before {
        font-size: 16px !important;
    }
}

@media screen and (max-width: 360px) {
    #preset-name-display-area {
        gap: 2px !important;
    }
    
    #preset-name-display-area > span[data-i18n="labels.presetName"] {
        font-size: 11px !important;
    }
    
    #preset-name-input-inline {
        max-width: 150px !important;
        font-size: 16px !important;
    }
    
    #preset-name-edit-btn {
        font-size: 11px !important;
        padding: 3px 6px !important;
    }
}

/* 並べ替えモード用 */

/* ドラッグ中のカーソル */
body.reorder-mode-active .potential-card {
    cursor: move;
    cursor: grab;
    transition: all 0.2s ease;
}

body.reorder-mode-active .potential-card:active {
    cursor: grabbing;
}

/* ホバー（ツールチップ）無効化 */
body.reorder-mode-active .potential-image-wrapper:hover {
    transform: none;
}

body.reorder-mode-active .potential-image-wrapper:active {
    transform: none;
}

/* 普段のクリックアクションを無効化 */
body.reorder-mode-active .potential-image-wrapper {
    pointer-events: none;
}

body.reorder-mode-active .status-btn,
body.reorder-mode-active .sub-status-btn {
    pointer-events: none;
    opacity: 0.5;
}

/* スマートフォン・タブレットでスクショボタンを非表示 */
@media (max-width: 768px) {
    #screenshot {
        display: none !important;
    }
}

/* 並べ替えモードのドラッグ */

/* ドラッグ中カードの予測地点（半透明） */
.sortable-ghost {
    opacity: 0.3;
}

/* 選択されたカード（長押し中） */
.sortable-chosen {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0);
}

/* ドラッグ中の元カード（透明） */
.sortable-fallback {
    opacity: 0 !important;
    box-shadow: 0 0px 0px rgba(0, 0, 0, 0);
    z-index: 99999;
    pointer-events: none;
}

/* タッチデバイス用：選択防止 */
body.reorder-mode-active .potential-card {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
