@font-face {
    font-family: 'KanjyukuGothic';
    src: url('/KanjyukuGothic.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

html,
body {
    font-family: 'KanjyukuGothic', 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif;
}

/* ポケモンカードスタイル */
.pokemon-card-fight {
    transition: all 0.2s ease;
    cursor: pointer;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.pokemon-card-fight:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.pokemon-card-fight.selected {
    background: linear-gradient(135deg, rgba(239, 246, 255, 0.6) 0%, rgba(219, 234, 254, 0.6) 100%);
    border-color: #3b82f6;
    border-width: 2px;
}

.pokemon-card-fight.selected:hover {
    background: linear-gradient(135deg, rgba(239, 246, 255, 0.8) 0%, rgba(219, 234, 254, 0.8) 100%);
}

/* 選択されたポケモンアイコン */
.opponent-pokemon-icon {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 6px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: 80px;
    width: 80px;
    flex-shrink: 0;
}

.opponent-pokemon-icon:hover {
    border-color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.2);
}

.opponent-pokemon-icon.selected {
    border-color: #3b82f6;
    background: #eff6ff;
}

/* 選出状態のポケモンアイコン（薄い黄色） */
.opponent-pokemon-icon.selected-pokemon {
    background: #fef9c3;
    border-color: #facc15;
}

.opponent-pokemon-icon.selected-pokemon:hover {
    background: #fef08a;
    border-color: #eab308;
}

.opponent-pokemon-icon img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin-bottom: 6px;
}

/* 右上のチェックボタン */
.opponent-pokemon-icon .select-pokemon-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 2px solid rgba(156, 163, 175, 0.8);
    border-radius: 4px;
    background: rgba(156, 163, 175, 0.8);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.7rem;
    z-index: 10;
}

.opponent-pokemon-icon .select-pokemon-btn:hover {
    background: rgba(107, 114, 128, 0.9);
    transform: scale(1.1);
}

.opponent-pokemon-icon .select-pokemon-btn:active {
    transform: scale(0.95);
}

.opponent-pokemon-icon .select-pokemon-btn.selected {
    background: rgba(34, 197, 94, 0.9);
    border-color: rgba(34, 197, 94, 0.9);
}

.opponent-pokemon-icon .select-pokemon-btn.selected:hover {
    background: rgba(22, 163, 74, 0.9);
}

.opponent-pokemon-icon .select-pokemon-btn:disabled {
    background: transparent;
    border-color: rgba(209, 213, 219, 0.8);
    color: rgba(209, 213, 219, 0.8);
    cursor: not-allowed;
    opacity: 0.6;
}

.opponent-pokemon-icon .select-pokemon-btn:disabled:hover {
    transform: none;
    background: transparent;
    border-color: rgba(209, 213, 219, 0.8);
    color: rgba(209, 213, 219, 0.8);
}

/* 下部の削除ボタン */
.opponent-pokemon-icon .remove-pokemon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #9ca3af;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.7rem;
}

.opponent-pokemon-icon .remove-pokemon-btn:hover:not(:disabled) {
    background: #6b7280;
    transform: scale(1.1);
}

.opponent-pokemon-icon .remove-pokemon-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.opponent-pokemon-icon .remove-pokemon-btn:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.5;
}

.opponent-pokemon-icon .remove-pokemon-btn:disabled:hover {
    transform: none;
    background: #d1d5db;
}

/* ポケモン詳細情報スタイル */
.pokemon-detail-card {
    background: white;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #e5e7eb;
}

.detail-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f3f4f6;
}

.detail-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.detail-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 8px;
}

.detail-value {
    font-size: 0.95rem;
    color: #1f2937;
}

/* バトルデータ詳細スタイル（detail.jsと同じスタイル） */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .stat-card {
        padding: 10px;
    }

    .stat-title {
        font-size: 0.95rem;
        margin-bottom: 6px;
        padding-bottom: 5px;
    }

    .stat-item {
        padding: 5px 0;
    }

    .stat-name {
        font-size: 0.8rem;
    }

    .stat-value {
        font-size: 0.85rem;
    }
}

/* タブレット幅でも2列を維持 */
@media (min-width: 641px) and (max-width: 900px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
}

@media (max-width: 420px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    min-width: 0; /* グリッド内でのはみ出し防止 */
}

.stat-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid #667eea;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f8f9fa;
    gap: 8px;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-name,
.stat-value {
    min-width: 0;
    word-break: break-word;
}

/* 円グラフ用コンテナ */
.chart-container {
    position: relative;
    height: 180px;
    margin: 10px 0 8px 0;
}

.stat-name {
    font-size: 0.85rem;
    color: #495057;
}

.stat-value {
    font-weight: 600;
    color: #667eea;
    font-size: 0.9rem;
}

.pokemon-detail-header {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.pokemon-detail-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    background: #f9fafb;
    border-radius: 12px;
    padding: 10px;
    margin: 0 auto 12px auto;
    display: block;
    border: 2px solid #e5e7eb;
}

.pokemon-detail-name {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 10px;
    color: #1f2937;
}

.pokemon-types {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.pokemon-detail-rank {
    background: #f3f4f6;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 1.05rem;
    margin-bottom: 8px;
    color: #374151;
    font-weight: 600;
    display: inline-block;
}

.pokemon-detail-rank i {
    color: #f59e0b;
}

.pokemon-detail-season {
    font-size: 0.95rem;
    color: #6b7280;
    font-weight: 500;
}

.pokemon-detail-season i {
    color: #667eea;
}

.list-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.list-content.show {
    max-height: 1000px;
    overflow: visible;
}

/* タイプバッジスタイル */
.type-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.type-badge.type-normal { background: #A8A878; }
.type-badge.type-fire { background: #F08030; }
.type-badge.type-water { background: #6890F0; }
.type-badge.type-electric { background: #F8D030; }
.type-badge.type-grass { background: #78C850; }
.type-badge.type-ice { background: #98D8D8; }
.type-badge.type-fighting { background: #C03028; }
.type-badge.type-poison { background: #A040A0; }
.type-badge.type-ground { background: #E0C068; }
.type-badge.type-flying { background: #A890F0; }
.type-badge.type-psychic { background: #F85888; }
.type-badge.type-bug { background: #A8B820; }
.type-badge.type-rock { background: #B8A038; }
.type-badge.type-ghost { background: #705898; }
.type-badge.type-dragon { background: #7038F8; }
.type-badge.type-dark { background: #705848; }
.type-badge.type-steel { background: #B8B8D0; }
.type-badge.type-fairy { background: #EE99AC; }
.type-badge.type-stellar {
    background: linear-gradient(45deg, #E53E3E, #DD6B20, #D69E2E, #38A169, #319795, #3182CE, #553C9A, #805AD5);
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

/* ツールチップスタイル */
.ability-tooltip {
    cursor: pointer;
    position: relative;
}

.ability-tooltip:hover::after {
    content: attr(data-tooltip);
    position: fixed;
    background-color: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: pre-wrap;
    z-index: 99999;
    max-width: 300px;
    pointer-events: none;
}

.item-tooltip {
    position: relative;
    cursor: pointer;
}

.item-tooltip .tooltip-text {
    visibility: hidden;
    position: fixed;
    background-color: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    z-index: 99999;
    max-width: 300px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.item-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* 折りたたみボタンスタイル */
.toggle-panel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #6b7280;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.toggle-panel-btn:hover {
    background: #4b5563;
    transform: scale(1.1);
}

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

/* メインコンテナのスタイル */
.battle-main-container {
    display: flex;
    flex-direction: column;
}

/* 折りたたみ時のバトルデータ領域（デスクトップ・SP共通） */
#collapsedBattleData {
    display: none;
}

#collapsedBattleData:not(.hidden) {
    display: block !important;
    margin-bottom: 0.25rem !important;
}

/* 左パネルの自動折りたたみ演出 */
.battle-left-panel {
    position: relative;
}

.battle-left-panel.auto-collapse-effect {
    pointer-events: none;
    animation: battle-left-panel-auto-collapse 0.38s ease forwards;
}

@keyframes battle-left-panel-auto-collapse {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-32px);
    }
}

/* デスクトップ表示時の詳細情報 */
@media (min-width: 769px) {
    .battle-detail-section {
        margin-top: 1rem;
    }

    /* デスクトップでも折りたたみ機能を有効化 */
    .battle-left-panel.hidden-sp {
        display: none !important;
    }

    .battle-right-panel.expanded-sp {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
    }

    /* デスクトップ表示時：「バトルデータからポケモンを選択してください」の文字サイズを「相手てもち」タイトルと同じサイズに */
    #opponentPartyMessage {
        font-size: 1.125rem !important;
        font-weight: 600 !important;
    }

    /* デスクトップ表示時：相手てもちエリアの上側パディングを増やしてhover効果で見切れないようにする */
    #opponentParty {
        padding-top: 0.75rem !important;
        overflow: visible !important;
    }

    #opponentPartyGrid {
        overflow: visible !important;
    }

    /* デスクトップ表示時：バトルデータリストのコンテナにスクロールを追加（4行分） */
    .battle-left-panel {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
    }

    .battle-left-panel > div:first-of-type {
        flex-shrink: 0 !important;
    }

    .battle-left-panel #pokemonList {
        flex: 1 !important;
        min-height: 0 !important;
    }

    .battle-pokemon-list-container {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        /* 4行分の高さ（ポケモンカードの高さ約140px × 4行 + gap × 3） */
        max-height: calc(4 * 140px + 3 * 0.5rem) !important;
        height: calc(4 * 140px + 3 * 0.5rem) !important;
    }

    /* デスクトップ表示時：ポケモンカードのサイズを適切に設定 */
    .battle-pokemon-list .pokemon-card-fight {
        padding: 0.75rem 0.5rem !important;
        min-height: 140px !important;
    }

    .battle-pokemon-list .pokemon-card-fight > div {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.5rem !important;
        height: 100% !important;
        justify-content: flex-start !important;
    }

    .battle-pokemon-list .pokemon-card-fight img {
        width: 56px !important;
        height: 56px !important;
        max-width: 100% !important;
        object-fit: contain !important;
        flex-shrink: 0 !important;
    }

    .battle-pokemon-list .pokemon-card-fight .font-semibold {
        font-size: 0.875rem !important;
        line-height: 1.4 !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        text-align: center !important;
        width: 100% !important;
    }

    .battle-pokemon-list .pokemon-card-fight .rounded-full {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.5rem !important;
        min-width: 32px !important;
        flex-shrink: 0 !important;
    }
}

/* SP版対応 */
@media (max-width: 768px) {
    /* SP表示時のみボタンを表示 */
    .sp-only {
        display: flex !important;
    }

    /* 非表示クラスが付いている場合は非表示 */
    .sp-only.hidden {
        display: none !important;
    }

    /* 折りたたみボタンをSP表示時に確実に表示 */
    .toggle-panel-btn.sp-only {
        display: flex !important;
    }

    .toggle-panel-btn.sp-only.hidden {
        display: none !important;
    }

    /* メインコンテナのパディングを小さく */
    .container {
        padding-left: 0.3rem !important;
        padding-right: 0.3rem !important;
        padding-top: 0.2rem !important;
        padding-bottom: 0.2rem !important;
    }

    /* バトル形式・シーズン選択セクションのパディングを小さく */
    .container > div:first-of-type {
        padding: 0.3rem !important;
    }

    /* 検索セクションのパディングを小さく */
    .container > div:nth-of-type(2) {
        padding: 0.25rem !important;
    }

    /* メインコンテンツのレイアウトを横並びに */
    .battle-main-layout {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.25rem !important;
        position: relative;
    }

    /* 左側パネルと右側パネルを同じサイズに固定 */
    .battle-left-panel {
        grid-column: 1 / 2 !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        flex-shrink: 0 !important;
        flex-grow: 0 !important;
        box-sizing: border-box !important;
        padding: 0.3rem !important;
    }

    .battle-right-panel {
        grid-column: 2 / 3 !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        flex-shrink: 0 !important;
        flex-grow: 0 !important;
        box-sizing: border-box !important;
        padding: 0.3rem !important;
    }

    /* 左側パネルを隠す */
    .battle-left-panel.hidden-sp {
        display: none !important;
    }

    /* 右側パネルを拡張 */
    .battle-right-panel.expanded-sp {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
    }

    /* 左側のポケモンリストを2列に固定、空白を最小化 */
    .battle-pokemon-list {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.25rem !important;
    }

    /* バトルデータリストのコンテナにスクロールを追加 */
    .battle-pokemon-list-container {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        /* 相手てもちの6体選出時の高さに合わせる（ポケモンタイル90px × 6 + gap×5 + パディング） */
        height: calc(6 * 90px + 5 * 4px + 2rem) !important;
        max-height: calc(6 * 90px + 5 * 4px + 2rem) !important;
    }

    /* 左側パネルの高さを調整（相手てもちと同じ高さに） */
    .battle-left-panel {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
    }

    .battle-left-panel > div:first-of-type {
        flex-shrink: 0 !important;
    }

    .battle-left-panel #pokemonList {
        flex: 1 !important;
        min-height: 0 !important;
    }

    /* バトルデータのカードサイズを調整（見える程度に最小限） */
    .battle-pokemon-list .pokemon-card-fight {
        padding: 0.375rem 0.25rem !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: visible !important;
        min-height: 90px !important;
    }

    .battle-pokemon-list .pokemon-card-fight > div {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.25rem !important;
        height: 100% !important;
    }

    .battle-pokemon-list .pokemon-card-fight img {
        width: 2.5rem !important;
        height: 2.5rem !important;
        max-width: 100% !important;
        object-fit: contain !important;
        flex-shrink: 0 !important;
    }

    .battle-pokemon-list .pokemon-card-fight .font-semibold {
        font-size: 0.55rem !important;
        line-height: 1.2 !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        text-align: center !important;
        width: 100% !important;
    }

    .battle-pokemon-list .pokemon-card-fight .rounded-full {
        font-size: 0.6rem !important;
        padding: 0.125rem 0.375rem !important;
        min-width: 24px !important;
        flex-shrink: 0 !important;
    }

    /* もっと見るボタンを小さく */
    #loadMoreBtn {
        padding: 0.5rem 1rem !important;
        font-size: 0.75rem !important;
    }

    #loadMoreBtn i {
        font-size: 0.625rem !important;
    }

    /* SP表示時：折りたたみ時のバトルデータ領域のタイトルと展開ボタンを縦並びに */
    #collapsedBattleData > div > div {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }

    #collapsedBattleData > div > div > div:last-child {
        width: 100% !important;
        justify-content: flex-start !important;
    }

    /* 折りたたみ時のバトルデータ領域（SP表示時のみ小さく） */
    #collapsedBattleData > div {
        padding: 0.25rem !important;
    }

    #collapsedBattleData h3 {
        font-size: 0.75rem !important;
        margin-bottom: 0 !important;
    }

    #collapsedBattleData h3 i {
        font-size: 0.625rem !important;
    }

    #collapsedBattleData .toggle-panel-btn {
        width: 24px !important;
        height: 24px !important;
        font-size: 0.625rem !important;
    }

    /* 左側のタイトルを小さく */
    .battle-left-panel h3 {
        font-size: 0.875rem !important;
        margin-bottom: 0.5rem !important;
    }

    .battle-left-panel h3 i {
        font-size: 0.75rem !important;
    }

    /* SP表示時：バトルデータのタイトルと折りたたみボタンを縦並びに */
    .battle-left-panel > div:first-of-type {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .battle-left-panel > div:first-of-type > div:last-child {
        width: 100% !important;
        justify-content: flex-start !important;
    }

    /* 右側のタイトルを小さく */
    .battle-right-panel h3 {
        font-size: 0.875rem !important;
        margin-bottom: 0.25rem !important;
    }

    .battle-right-panel h3 i {
        font-size: 0.75rem !important;
    }

    /* SP表示時：相手てもちのタイトルとリセットボタンを縦並びに */
    .battle-right-panel > div:nth-of-type(2) {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .battle-right-panel > div:nth-of-type(2) button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* 相手手持ちポケモンアイコンを小さく */
    .opponent-pokemon-icon {
        min-width: 56px;
        width: 56px;
        padding: 6px 3px;
    }

    .opponent-pokemon-icon img {
        width: 40px;
        height: 40px;
    }

    .opponent-pokemon-icon .select-pokemon-btn,
    .opponent-pokemon-icon .remove-pokemon-btn {
        width: 18px;
        height: 18px;
        font-size: 0.55rem;
    }

    .opponent-pokemon-icon .select-pokemon-btn {
        top: 2px;
        right: 2px;
    }

    /* 相手手持ちエリアの高さ調整（6匹全て表示できるように） */
    #opponentParty {
        min-height: auto !important;
        max-height: none !important;
        padding: 0.5rem !important;
    }

    /* 通常時：縦一列表示 */
    #opponentPartyGrid {
        gap: 0.25rem !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        overflow-x: visible !important;
        overflow-y: visible !important;
        max-height: none !important;
    }

    /* 相手手持ちポケモンアイコンをSP表示時に縦一列に */
    #opponentPartyGrid .opponent-pokemon-icon {
        width: 100% !important;
        min-width: 100% !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0.375rem !important;
        margin-bottom: 0 !important;
        min-height: 50px !important;
        height: 50px !important;
        gap: 0.5rem !important;
    }

    #opponentPartyGrid .opponent-pokemon-icon img {
        width: 40px !important;
        height: 40px !important;
        margin-bottom: 0 !important;
        margin-right: 0 !important;
        flex-shrink: 0 !important;
        order: 2 !important;
    }

    #opponentPartyGrid .opponent-pokemon-icon .select-pokemon-btn {
        position: static !important;
        order: 1 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 4px !important;
        border: 2px solid rgba(156, 163, 175, 0.8) !important;
        flex-shrink: 0 !important;
    }

    #opponentPartyGrid .opponent-pokemon-icon .select-pokemon-btn.selected {
        border-color: rgba(34, 197, 94, 0.9) !important;
    }

    #opponentPartyGrid .opponent-pokemon-icon .remove-pokemon-btn {
        margin-left: 0 !important;
        order: 3 !important;
        flex-shrink: 0 !important;
    }

    /* 折りたたみ後：2行×3列のグリッドレイアウト */
    .battle-right-panel.expanded-sp #opponentParty {
        display: flex !important;
        flex-direction: column !important;
    }

    .battle-right-panel.expanded-sp #opponentPartyMessage {
        flex-shrink: 0 !important;
        margin-bottom: 0.5rem !important;
    }

    .battle-right-panel.expanded-sp #opponentPartyGrid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        grid-template-rows: repeat(2, 1fr) !important;
        gap: 0.375rem !important;
        flex: 1 !important;
        min-height: 0 !important;
        overflow-x: visible !important;
        overflow-y: visible !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
    }

    .battle-right-panel.expanded-sp #opponentPartyGrid .opponent-pokemon-icon {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0.25rem 0.25rem !important;
        margin-bottom: 0 !important;
        height: auto !important;
        min-height: 0 !important;
        gap: 0.25rem !important;
    }

    .battle-right-panel.expanded-sp #opponentPartyGrid .opponent-pokemon-icon img {
        width: 40px !important;
        height: 40px !important;
        margin-bottom: 0 !important;
        margin-right: 0 !important;
        flex-shrink: 0 !important;
        order: 2 !important;
    }

    .battle-right-panel.expanded-sp #opponentPartyGrid .opponent-pokemon-icon .select-pokemon-btn {
        position: static !important;
        order: 1 !important;
        margin: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 20px !important;
        height: 20px !important;
        font-size: 0.65rem !important;
        border-radius: 3px !important;
        border: 2px solid rgba(156, 163, 175, 0.8) !important;
        flex-shrink: 0 !important;
    }

    .battle-right-panel.expanded-sp #opponentPartyGrid .opponent-pokemon-icon .select-pokemon-btn.selected {
        border-color: rgba(34, 197, 94, 0.9) !important;
    }

    .battle-right-panel.expanded-sp #opponentPartyGrid .opponent-pokemon-icon .remove-pokemon-btn {
        margin-top: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        order: 3 !important;
        width: 20px !important;
        height: 20px !important;
        font-size: 0.65rem !important;
        position: static !important;
        flex-shrink: 0 !important;
    }

    /* 詳細情報セクションを下に表示 */
    .battle-detail-section {
        margin-top: 0.5rem !important;
        width: 100% !important;
        grid-column: 1 / -1 !important;
    }

    .battle-detail-section.hidden {
        display: none !important;
    }

    /* 詳細情報のタイトル */
    .battle-detail-section h4 {
        font-size: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    /* 詳細情報のコンテンツ */
    .battle-detail-section #pokemonDetailContent {
        padding: 1rem !important;
        font-size: 0.875rem !important;
    }


    .pokemon-card-fight img {
        width: 2.5rem !important;
        height: 2.5rem !important;
    }

    .pokemon-card-fight .font-semibold {
        font-size: 0.625rem !important;
    }

    /* もっと見るボタンを小さく */
    #loadMoreBtn {
        padding: 0.5rem 1rem !important;
        font-size: 0.75rem !important;
    }

    #remainingCountBattle {
        font-size: 0.625rem !important;
        padding: 0.125rem 0.375rem !important;
    }
}

/* SP版ヘッダー対応 */
@media (max-width: 768px) {
    /* ヘッダーのタイトル非表示 */
    header h1 {
        display: none !important;
    }

    /* ヘッダーの説明文非表示 */
    header p {
        display: none !important;
    }

    /* ヘッダーのボタンテキストサイズ調整 */
    header a.inline-block {
        font-size: 0.75rem !important;
        padding: 0.375rem 0.5rem !important;
    }

    /* ヘッダーのパディング調整 */
    header .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    /* ヘッダーのアイコンサイズ調整 */
    header .w-10 {
        width: 2rem !important;
        height: 2rem !important;
    }

    header .w-12 {
        width: 2.5rem !important;
        height: 2.5rem !important;
    }
}

