/* 基本スタイルとカラースキーム */
:root {
    /* SF感を意識したカラーパレット */
    --primary-dark: #1A2C3E; /* 濃いネイビー/チャコール */
    --primary-light: #00BFFF; /* 明るいスカイブルー (アクセント) */
    --accent-orange: #FFD700; /* ゴールドっぽいイエロー (アクセント) */
    --background-light: #F0F5F9; /* ごく薄いライトブルーグレー */
    --card-background: #FFFFFF;
    --text-color: #333333;
    --light-grey-border: #CED4DA; /* 明るいグレー */
    --medium-grey: #6C757D; /* 中間グレー */
    --soft-shadow: 0 8px 25px rgba(0, 0, 0, 0.15); /* 影を強調 */
    --transition-speed: 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94); /* よりSF的なイージング */
    /* HPバーの色 (グラデーション用) */
    --hp-low: #dc3545; /* 赤 */
    --hp-medium: #ffc107; /* 黄 */
    --hp-high: #28a745; /* 緑 */
    --hp-pulse-color: rgba(220, 53, 69, 0.6); /* 低HP時の脈動色 */
    /* SF演出用追加カラー */
    --neon-glow: #00EFFF; /* ネオンブルー */
    --neon-glow-strong: #00BFFF; /* より強いネオンブルー */
    --glitch-color1: #FF00FF; /* マゼンタ */
    --glitch-color2: #00FFFF; /* シアン */
    --grid-line-color: rgba(0, 191, 255, 0.08); /* グリッド線の色 */
    --loading-spinner-color: #00BFFF;
    /* X (Twitter) Blue for share buttons */
    --twitter-blue: #1DA1F2;
    --twitter-blue-shadow: rgba(29, 161, 242, 0.4);
    --twitter-blue-hover-shadow: rgba(29, 161, 242, 0.6);
    /* URL Copy Button Color */
    --copy-url-button-bg: #6c757d; /* Bootstrap secondary color */
    --copy-url-button-border: #6c757d;
    --copy-url-button-hover-bg: #5a6268;
    --copy-url-button-shadow: rgba(108, 117, 125, 0.4);
    --copy-url-button-hover-shadow: rgba(108, 117, 125, 0.6);
    --copy-success-bg: var(--hp-high); /* Green for success */
    --copy-success-border: var(--hp-high);
    --copy-success-shadow: rgba(40, 167, 69, 0.4);
}

/* ----- 基本スタイル ----- */
body {
    font-family: 'Noto Sans JP', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.7; /* 読みやすく */
    color: var(--text-color);
    max-width: 1200px;
    margin: 0 auto;
    padding: 25px; /* パディングを増やす */
    background: linear-gradient(135deg, var(--primary-dark) 0%, #102030 100%); /* 暗めのSF背景 */
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden; /* 横スクロール防止 */
    position: relative;
    min-height: 100vh; /* 最小高さを確保 */
    z-index: 1; /* グリッドやノイズの上にコンテンツを配置 */
    /* 背景アニメーションを継続 */
    background-size: 200% 200%;
    animation: backgroundShift 60s ease-in-out infinite alternate;
    will-change: background-position; /* will-changeを追加 */
}

@keyframes backgroundShift {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 100% 50%;
    }
}

/* 背景の微細なグリッドパターンとノイズ */
body::before, body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

body::before { /* グリッド */
    background-image: linear-gradient(to right, var(--grid-line-color) 1px, transparent 1px), linear-gradient(to bottom, var(--grid-line-color) 1px, transparent 1px);
    background-size: 50px 50px;
    opacity: 0.2;
    animation: gridPan 120s linear infinite;
    will-change: background-position; /* will-changeを追加 */
}

@keyframes gridPan {
    from {
        background-position: 0 0;
    }

    to {
        background-position: 5000px 5000px;
    }
    /* 非常にゆっくり移動 */
}

body::after { /* ノイズオーバレイ */
    /* base64エンコードされたSVGノイズ */
    background-image: url('data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 40 40%27%3E%3Cfilter id=%27h%27%3E%3CfeTurbulence type=%27fractalNoise%27 baseFrequency=%27.8 .8%27 numOctaves=%271%27 seed=%272%27/%3E%3C/filter%3E%3Crect width=%27100%25%27 height=%27100%25%27 fill=%27url(%23h)%27 opacity=%270.05%27/%3E%3C/svg%3E');
    background-size: 200px;
    opacity: 0.1;
}

h1 {
    font-family: 'Orbitron', sans-serif; /* SFフォント適用 */
    color: var(--card-background); /* 背景に合わせて白色に */
    text-align: center;
    margin-bottom: 40px;
    font-size: 3.2em; /* さらに大きく */
    font-weight: 700;
    letter-spacing: 3px; /* 文字間を広げる */
    text-shadow: 0 0 15px rgba(0, 191, 255, 0.6); /* 常にわずかに光る */
    position: relative;
    z-index: 10; /* 最前面に */
    display: inline-block; /* text-shadowアニメーションのため */
    padding: 5px 0;
}

/* ----- H1タイトル SF演出 (初期ロード時のみ) ----- */
.title-sf-effect {
    /* IMPROVEMENT 7: タイトルのグリッチエフェクト強化 */
    animation: neonGlowInitial 1.5s ease-in-out forwards, 
               glitchTextInitial 2s linear forwards,
               subtleGlitch 15s infinite alternate;
    will-change: transform, text-shadow, color; /* will-changeを追加 */
}

/* IMPROVEMENT 7: subtleGlitch keyframes */
@keyframes subtleGlitch {
  0%, 100% { transform: translate(0); }
  97% { transform: translate(1px, -1px); }
  98% { transform: translate(-1px, 1px); }
  99% { transform: translate(0.5px, -0.5px); }
}


@keyframes neonGlowInitial {
    0% {
        text-shadow: 0 0 5px var(--neon-glow), 0 0 10px var(--neon-glow), 0 0 20px var(--neon-glow), 0 0 40px rgba(0, 239, 255, 0.4);
        color: var(--primary-light); /* 初期は強く発光 */
    }

    100% {
        text-shadow: 0 0 15px rgba(0, 191, 255, 0.6); /* 落ち着いた輝きに */
        color: var(--card-background);
    }
}

@keyframes glitchTextInitial {
    0% {
        transform: translate(0);
        text-shadow: none;
    }

    5% {
        transform: translate(-2px, 2px);
        text-shadow: 2px 0 0 var(--glitch-color1);
    }

    10% {
        transform: translate(2px, -2px);
        text-shadow: -2px 0 0 var(--glitch-color2);
    }

    15% {
        transform: translate(-1px, 1px);
        text-shadow: 1px 0 0 var(--glitch-color1);
    }

    20% {
        transform: translate(1px, -1px);
        text-shadow: -1px 0 0 var(--glitch-color2);
    }

    21% {
        transform: translate(0);
        text-shadow: none;
    }

    70% {
        transform: translate(0);
        text-shadow: none;
    }

    75% {
        transform: translate(3px, -3px);
        text-shadow: -3px 0 0 var(--glitch-color2);
    }

    80% {
        transform: translate(-3px, 3px);
        text-shadow: 3px 0 0 var(--glitch-color1);
    }

    85% {
        transform: translate(2px, -2px);
        text-shadow: -2px 0 0 var(--glitch-color2);
    }

    90% {
        transform: translate(-2px, 2px);
        text-shadow: 2px 0 0 var(--glitch-color1);
    }

    91% {
        transform: translate(0);
        text-shadow: none;
    }

    100% {
        transform: translate(0);
        text-shadow: none;
    }
}

/* ----- 使い方ガイド（旧description）のスタイル ----- */
.usage-guide-container {
    background-color: var(--card-background);
    padding: 30px;
    margin-bottom: 50px;
    border-radius: 12px;
    box-shadow: var(--soft-shadow);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    position: relative;
    overflow: hidden; /* 背景アニメーション用 */
    border: 1px solid rgba(0, 191, 255, 0.2);
    will-change: transform, box-shadow; /* will-changeを追加 */
}

    .usage-guide-container:hover {
        transform: translateY(-8px); /* ホバー時の浮遊感を強調 */
        box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
        border-color: var(--primary-light);
    }

    .usage-guide-container h2 {
        color: var(--primary-dark);
        font-size: 2.2em;
        font-weight: 700;
        margin-top: 0;
        margin-bottom: 30px;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 15px;
        text-shadow: 1px 1px 5px rgba(0,0,0,0.15);
        position: relative;
        z-index: 1;
    }

    .usage-guide-container .guide-intro {
        font-size: 1.15em;
        color: #555;
        margin-bottom: 35px;
        text-align: center;
        line-height: 1.8;
        position: relative;
        z-index: 1;
        max-width: 70ch;
        margin-left: auto;
        margin-right: auto;
    }

/* ----- アコーディオンのスタイル ----- */
.accordion {
    border: 1px solid var(--primary-light); /* SF感のあるボーダー */
    border-radius: 10px;
    overflow: hidden;
    background-color: #F8FCFF;
    box-shadow: inset 0 0 15px rgba(0, 191, 255, 0.1);
    will-change: opacity, visibility, backdrop-filter; /* will-changeを追加 */
}

.accordion-item {
    border-bottom: 1px solid rgba(0, 191, 255, 0.1);
}

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

.accordion-header {
    background-color: var(--background-light);
    color: var(--primary-dark);
    padding: 18px 25px; /* パディングを増やす */
    width: 100%;
    text-align: left;
    border: none;
    outline: none;
    cursor: crosshair; /* SFカーソル */
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.2em; /* さらに大きく */
    font-weight: 700;
    transition: all var(--transition-speed), transform 0.1s ease-out; /* IMPROVEMENT 10: :activeでtransformを使うのでallにし、transform専用の短いtransitionを追加 */
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    will-change: background-color, color, box-shadow, transform; /* will-changeを追加, transform追加 for active state */
}

    /* IMPROVEMENT 10: インタラクティブな要素のフィードバック強化 */
    .accordion-header:active {
      transform: scale(0.98);
    }

    .accordion-header::before { /* ホバー・アクティブ時の光るボーダー */
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 10px;
        box-shadow: 0 0 0 0px var(--neon-glow-strong);
        transition: box-shadow 0.3s ease-out;
        z-index: -1;
        will-change: box-shadow; /* will-changeを追加 */
    }

    .accordion-header:hover {
        background-color: #E6EEF4;
        color: var(--primary-light);
        box-shadow: inset 0 0 15px rgba(0, 191, 255, 0.2);
    }

        .accordion-header:hover::before {
            box-shadow: 0 0 15px 3px var(--neon-glow-strong);
        }

    .accordion-header.active {
        background-color: var(--primary-light);
        color: var(--card-background);
        box-shadow: inset 0 0 25px rgba(0, 191, 255, 0.5);
    }

        .accordion-header.active::before {
            box-shadow: 0 0 20px 5px var(--neon-glow-strong);
        }

    .accordion-header span {
        display: flex;
        align-items: center;
        gap: 15px;
    }

    .accordion-header i:first-child {
        font-size: 1.4em;
        color: var(--accent-orange);
        transition: color var(--transition-speed);
    }

    .accordion-header.active i:first-child {
        color: var(--card-background);
    }

.accordion-icon { /*共用アイコンスタイル*/
    font-size: 1.1em;
    transition: transform var(--transition-speed);
    will-change: transform; /* will-changeを追加 */
}

.accordion-header.active .accordion-icon {
    transform: rotate(180deg) scale(1.1); /* わずかに拡大 */
}

.accordion-content {
    background-color: var(--card-background);
    padding: 0 25px;
    max-height: 0;
    overflow: hidden;
    /* IMPROVEMENT 3: アコーディオンの開閉アニメーション改善 */
    transition: 
      max-height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
      opacity 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
      transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
      padding 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); /* paddingもイージング適用 */
    color: #555;
    font-size: 1.05em;
    opacity: 0;
    transform: scaleY(0.8); /* 初期状態で縮小 */
    transform-origin: top;
    will-change: max-height, padding, opacity, transform; /* will-changeを追加 */
}

    .accordion-content.show {
        /* IMPROVEMENT 3: アコーディオンの開閉アニメーション改善 */
        max-height: 1000px; /* 十分な高さに設定 (提案通り1000pxに) */
        padding: 25px;
        opacity: 1;
        transform: scaleY(1); /* 表示時に元のサイズに */
    }

    .accordion-content p {
        max-width: 70ch; /* 読みやすい行長に制限 */
        margin: 0 auto 12px; /* 中央揃えにして上下マージン */
        line-height: 1.9; /* 行の高さを少し広げて読みやすく */
        transform: scaleY(1.03);
        transform-origin: top center; /* スケール原点を設定 */
    }

        .accordion-content p:last-child {
            margin-bottom: 0;
        }

    .accordion-content .formula {
        background-color: #F0F8FF;
        border-left: 6px solid var(--accent-orange);
        padding: 15px 20px;
        margin: 20px auto; /* 中央揃えに */
        max-width: 650px; /* 計算式ブロックの最大幅も制限 */
        border-radius: 8px;
        font-size: 1.2em;
        font-weight: 700;
        color: var(--primary-dark);
        text-align: center;
        box-shadow: 0 4px 10px rgba(0,0,0,0.12);
        font-family: 'Rajdhani', sans-serif; /* SFフォント適用 */
    }

    .accordion-content .tip {
        font-style: italic;
        color: var(--medium-grey);
        font-size: 0.98em;
        display: flex;
        align-items: flex-start;
        gap: 12px;
        margin-top: 25px;
        background-color: #FDFCDC;
        border-radius: 8px;
        padding: 12px 18px;
        border: 1px solid #FFECB3;
        box-shadow: 0 3px 8px rgba(0,0,0,0.1);
        max-width: 70ch;
        margin-left: auto;
        margin-right: auto;
    }

/* ----- 検索・フィルタリング・ソート ----- */
.controls-container {
    display: flex;
    flex-direction: column;
    margin-bottom: 50px;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-radius: 10px;
    margin-top: 20px; /* 追加: 検索欄の上のスペース */
    margin-bottom: 20px; /* 追加: 検索欄の下のスペース */
}

.search-icon {
    position: absolute;
    left: 20px; /* パディングに合わせて調整 */
    color: var(--primary-light);
    font-size: 1.3em;
    pointer-events: none;
    text-shadow: 0 0 8px rgba(0, 191, 255, 0.6);
    will-change: transform, opacity, text-shadow; /* will-changeを追加 */
}

#characterSearch {
    width: 100%;
    padding: 16px 20px 16px 60px; /* アイコン分のスペースを確保 */
    border: 2px solid var(--light-grey-border); /* ボーダーを太く */
    border-radius: 10px;
    font-size: 1.1em;
    background-color: var(--card-background);
    box-sizing: border-box;
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.08); /* 通常時のshadow */
    will-change: border-color, box-shadow; /* will-changeを追加 */
}

    #characterSearch:focus {
        border-color: var(--primary-light);
        outline: none;
    }
/* 検索結果なしメッセージ */
.no-results-message {
    text-align: center;
    color: #E74C3C;
    font-size: 1.3em;
    padding: 30px;
    opacity: 0; /* 初期非表示 */
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
    will-change: transform, opacity, text-shadow; /* will-changeを追加 */
}

@keyframes glitchDisplay {
    0% {
        transform: translate(0);
        opacity: 0;
    }

    10% {
        transform: translate(-2px, 2px);
        text-shadow: 2px 0 0 var(--glitch-color1);
        opacity: 1;
    }

    20% {
        transform: translate(2px, -2px);
        text-shadow: -2px 0 0 var(--glitch-color2);
    }

    30% {
        transform: translate(-1px, 1px);
        text-shadow: 1px 0 0 var(--glitch-color1);
    }

    40% {
        transform: translate(1px, -1px);
        text-shadow: -1px 0 0 var(--glitch-color2);
        opacity: 1;
    }

    50% {
        transform: translate(0);
        text-shadow: none;
        opacity: 1;
    }

    100% {
        transform: translate(0);
        text-shadow: none;
        opacity: 1;
    }
}

.filter-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: flex-start;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-start;
}

.filter-label {
    font-weight: bold;
    white-space: nowrap;
    color: var(--card-background);
    font-size: 1.05em;
    display: flex;
    align-items: center;
    gap: 10px;
}

    .filter-label i {
        color: var(--accent-orange);
        font-size: 1.2em;
        animation: bounceIcon 1.5s ease-in-out infinite alternate;
        will-change: transform; /* will-changeを追加 */
    }

    .filter-label:nth-of-type(2) i {
        animation-delay: 0.15s; /* アイコンのバウンスに遅延 */
    }

@keyframes bounceIcon {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.filter-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-button {
    background-color: var(--light-grey-border);
    border: 2px solid var(--light-grey-border);
    padding: 12px 20px; /* パディングを増やす */
    border-radius: 30px; /* 角丸を大きく */
    cursor: crosshair; /* SFカーソル */
    transition: all var(--transition-speed);
    font-size: 1em;
    color: var(--text-color);
    white-space: nowrap;
    min-width: 80px; /* 最小幅を確保 */
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.12); /* 影を強調 */
    position: relative;
    overflow: hidden;
    will-change: transform, background-color, box-shadow, color; /* will-changeを追加 */
}

    .filter-button i { /* 動的に追加されるアイコンのスタイル */
        margin-left: 8px; /* テキストとアイコンの間隔 */
        font-size: 0.9em; /* テキストに合わせたサイズ */
        color: var(--text-color); /* デフォルト色 */
        transition: color 0.3s ease;
    }

    .filter-button.active i {
        color: var(--card-background); /* アクティブ時の色 */
    }

    .filter-button::after { /* 波紋エフェクト */
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 5px;
        height: 5px;
        background: rgba(255, 255, 255, 0.6);
        border-radius: 50%;
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
        transition: transform 0.6s ease-out, opacity 0.6s ease-out;
        z-index: 1;
        will-change: transform, opacity; /* will-changeを追加 */
    }

    .filter-button:active::after {
        transform: translate(-50%, -50%) scale(20);
        opacity: 1;
        transition: 0s; /* クリック時に即時表示 */
    }

    .filter-button::before { /* 光沢アニメーション */
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
        transform: skewX(-20deg);
        transition: all 0.5s ease;
        z-index: 1;
        will-change: transform, left;
    }

    .filter-button:hover::before {
        left: 100%;
    }

    .filter-button.active {
        background-color: var(--primary-light);
        color: var(--card-background);
        box-shadow: 0 5px 15px rgba(0, 191, 255, 0.5); /* アクティブ時の影を強調 */
        border-color: var(--primary-light);
        font-weight: bold;
        background-image: linear-gradient(45deg, rgba(0, 191, 255, 0.8) 0%, rgba(0, 150, 200, 0.8) 100%);
        background-size: 200% 200%;
        animation: activeButtonGlow 4s ease-in-out infinite alternate;
        will-change: background-position, box-shadow; /* will-changeを追加 */
    }

@keyframes activeButtonGlow {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 100% 50%;
    }
}

.filter-button:hover:not(.active) {
    background-color: #E6EEF4;
    transform: translateY(-5px); /* 浮遊感を強調 */
    box-shadow: 0 6px 18px rgba(0,0,0,0.2);
    border-color: var(--medium-grey);
}

.filter-button.active:hover {
    background-color: #008DCC;
    transform: translateY(-5px);
}

/* IMPROVEMENT 10: インタラクティブな要素のフィードバック強化 (filter-button:active の更新) */
.filter-button:active {
    transform: translateY(3px) scale(0.98);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2) inset;
}


/* ----- キャラクターグリッドとカード ----- */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); /* さらに大きく */
    gap: 35px; /* 間隔を広げる */
    margin-top: 50px;
}

.character-card {
    background-color: var(--card-background);
    border-radius: 15px; /* 角丸を大きく */
    box-shadow: var(--soft-shadow);
    overflow: hidden; /* ::afterがはみ出ないように */
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed), filter var(--transition-speed); /* filterのtransition追加 */
    position: relative;
    border: 2px solid rgba(0, 191, 255, 0.1);
    background-image: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(240,245,249,0.9)); /* 薄いグラデーション */
    will-change: transform, box-shadow, opacity, filter; /* will-changeを追加, filter追加 */
}

    .character-card::before { /* ボーダーに沿って光るエフェクト */
        content: '';
        position: absolute;
        top: -2px;
        left: -2px;
        right: -2px;
        bottom: -2px;
        border-radius: 15px;
        background: linear-gradient(45deg, var(--neon-glow-strong) 0%, transparent 50%, var(--neon-glow-strong) 100%);
        background-size: 400% 400%;
        z-index: -1;
        opacity: 0.2; /* 常時薄く発光 */
        animation: cardBorderFlow 8s linear infinite;
        will-change: background-position, opacity; /* will-changeを追加 */
    }

    .character-card:hover::before {
        opacity: 0.8; /* ホバーで強く発光 */
    }

@keyframes cardBorderFlow {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 100% 50%;
    }
}

/* IMPROVEMENT 1: カードホバー時の高級感あるエフェクト強化 */
.character-card:hover {
  transform: translateY(-15px) scale(1.02) rotateZ(1deg);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
  border-color: var(--primary-light);
  filter: drop-shadow(0 0 15px rgba(0, 191, 255, 0.6));
}

/* IMPROVEMENT 1: カードホバー時の光のストリーク効果 */
.character-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1), 
    transparent
  );
  transition: all 0.8s cubic-bezier(0.19, 1, 0.22, 1);
  transform: skewX(-25deg);
  z-index: 0; /* コンテンツの下、背景の上。::before(-1) < ::after(0) < content(1) */
  pointer-events: none; 
}

.character-card:hover::after {
  left: 100%;
}


.character-header {
    background-color: var(--primary-dark);
    color: var(--card-background);
    padding: 18px 30px; /* パディングを増やす */
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    font-size: 1.2em;
    font-family: 'Rajdhani', sans-serif; /* SFフォント適用 */
    position: relative; /* z-indexを有効にするため */
    z-index: 1; /* ::after より手前に来るように */
}

.character-cost {
    background-color: var(--accent-orange);
    color: var(--primary-dark);
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 0.95em;
    font-weight: 700;
    box-shadow: inset 0 0 8px rgba(255, 215, 0, 0.4);
}

.character-body {
    padding: 30px; /* パディングを増やす */
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative; /* z-indexを有効にするため */
    z-index: 1; /* ::after より手前に来るように */
}

.character-image {
    width: 120px; /* さらに大きく */
    height: 120px;
    background-color: #F0F5F9;
    border-radius: 50%;
    margin: 0 auto 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 60px;
    color: #7F8C8D;
    font-weight: 700;
    border: 4px solid var(--primary-light); /* ボーダーを太く */
    box-shadow: 0 0 0 4px rgba(0, 191, 255, 0.3), inset 0 0 12px rgba(0,0,0,0.18);
    overflow: hidden;
    transition: all var(--transition-speed);
    will-change: transform, box-shadow; /* will-changeを追加 */
}

    .character-image:hover {
        transform: scale(1.1) rotateZ(5deg); /* より強調された拡大と回転 */
        box-shadow: 0 0 0 6px rgba(0, 191, 255, 0.6), inset 0 0 15px rgba(0,0,0,0.25);
    }

    .character-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 50%;
        display: block; /* default, overridden by JS if image fails/not present */
    }

    .character-image span.initial {
        width: 100%;
        height: 100%;
        display: flex; /* Initially flex to show, JS will hide if img loads */
        justify-content: center;
        align-items: center;
        font-size: 60px;
        color: #7F8C8D;
        font-weight: 700;
        font-family: 'Orbitron', sans-serif;
    }

.character-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 1.1em;
    padding: 10px 0;
    border-bottom: 1px solid var(--light-grey-border);
    font-weight: 500;
}

.character-hp {
    font-family: 'Rajdhani', sans-serif; /* SFフォント適用 */
    font-weight: 700;
    color: #E74C3C;
    font-size: 1.3em; /* さらに大きく */
    cursor: crosshair; /* SFカーソル */
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
    text-shadow: 0 0 5px rgba(231, 76, 60, 0.3);
    will-change: color, text-shadow, transform; /* will-changeを追加 */
}

    .character-hp:hover {
        color: var(--primary-light);
        text-shadow: 0 0 12px rgba(0, 191, 255, 0.7); /* ホバー時のグロー */
    }

    .character-hp:active {
        transform: translateY(2px) scale(0.96);
        color: #C0392B;
    }
    .character-hp.animating {
        animation: hpNumberPop 0.8s ease-out forwards;
        will-change: transform;
    }

@keyframes hpNumberPop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}


/* ----- HPバーのスタイル ----- */
.hp-bar-container {
    width: 100%;
    height: 12px; /* さらに太く */
    background-color: #E0E0E0;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 5px;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.2);
    position: relative;
    border: 1px solid rgba(0,0,0,0.1);
}

/* IMPROVEMENT 2: HPバーのグラデーションと光沢効果の強化 */
.hp-bar-fill {
    height: 100%;
    background: linear-gradient(
      to right,
      var(--hp-low) 0%,
      var(--hp-medium) 50%,
      var(--hp-high) 100%
    ), 
    linear-gradient(
      90deg,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, 0.5) 50%,
      rgba(255, 255, 255, 0) 100%
    );
    background-size: 100% 100%, 200% 100%;
    background-repeat: no-repeat;
    transform-origin: left;
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    animation: hpShine 2.5s linear infinite; /* アニメーション名変更 */
    will-change: transform, background-position;
}

/* IMPROVEMENT 2: @keyframes hpShine (既存のhpShineBackgroundを置き換え) */
@keyframes hpShine {
  0% { background-position: 0% 0%, -100% 0%; }
  100% { background-position: 0% 0%, 100% 0%; }
}

.hp-bar-low-pulse {
    animation: hpPulse 1.2s ease-in-out infinite alternate;
    box-shadow: 0 0 15px 5px var(--hp-pulse-color);
    will-change: box-shadow;
}

@keyframes hpPulse {
    0% {
        box-shadow: 0 0 10px 3px var(--hp-pulse-color);
    }

    100% {
        box-shadow: 0 0 20px 8px var(--hp-pulse-color);
    }
}

/* ----- HP割合表示のスタイル (新しく追加) ----- */
.hp-percentage-display {
    text-align: center;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.2em; /* 割合の文字サイズ */
    font-weight: 700;
    color: var(--primary-light);
    margin-top: 5px;
    margin-bottom: 20px; /* 下のテーブルとの間隔 */
    text-shadow: 0 0 8px rgba(0, 191, 255, 0.5);
    position: relative;
    z-index: 2;
    pointer-events: none;
    opacity: 0; /* 初期非表示 */
    transition: opacity 0.3s ease; /* フェードイン/アウト */
}

    .hp-percentage-display.show {
        opacity: 1;
    }

/* ----- テーブルスタイル ----- */
.cost-table {
    width: 100%;
    border-collapse: separate; /* border-radiusのために */
    border-spacing: 0;
    margin-top: 20px;
    font-size: 1em;
    border-radius: 8px;
    overflow: hidden; /* 角丸対応 */
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

    .cost-table th, .cost-table td {
        padding: 15px 8px;
        text-align: center;
        font-size: 0.95em;
    }

    .cost-table th {
        background-color: var(--primary-light);
        color: var(--card-background);
        font-weight: 700;
        border-bottom: 1px solid rgba(255,255,255,0.4);
        white-space: nowrap;
        font-family: 'Rajdhani', sans-serif; /* SFフォント適用 */
    }

        .cost-table th:first-child {
            border-top-left-radius: 8px;
        }

        .cost-table th:last-child {
            border-top-right-radius: 8px;
        }

    .cost-table td {
        border-top: 1px solid var(--light-grey-border);
        color: var(--text-color);
        cursor: crosshair; /* SFカーソル */
        transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
        position: relative;
        background-color: var(--card-background);
        will-change: background-color, color, box-shadow, transform; /* will-changeを追加 */
    }

    .cost-table tr:nth-child(even) td {
        background-color: #F8FCFF;
    }

    .cost-table td:hover {
        background-color: #EBF7FF;
        color: var(--primary-dark);
        box-shadow: inset 0 0 10px rgba(0, 191, 255, 0.3); /* ホバー時の内側の影を強調 */
        transform: translateY(-2px); /* わずかに浮遊 */
    }

    .cost-table td.active-hp-display {
        background-color: #D3EEFF;
        font-weight: bold;
        color: var(--hp-low);
        box-shadow: inset 0 0 15px rgba(0, 191, 255, 0.4);
        border: 1px solid var(--primary-light);
        transform: translateY(0);
        animation: cellFlash 0.3s ease-out;
    }
@keyframes cellFlash {
    0% {
        background-color: #D3EEFF;
        box-shadow: inset 0 0 30px rgba(0, 191, 255, 0.8), 0 0 20px 5px rgba(0, 191, 255, 0.8);
    }

    100% {
        background-color: #D3EEFF;
        box-shadow: inset 0 0 20px rgba(0, 191, 255, 0.6), 0 0 10px 3px rgba(0, 191, 255, 0.5);
    }
}

.cost-table tr:last-child td:first-child {
    border-bottom-left-radius: 8px;
}

.cost-table tr:last-child td:last-child {
    border-bottom-right-radius: 8px;
}

/* ----- ローディングインジケーターのスタイル ----- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 44, 62, 0.8); /* primary-darkの半透明 */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-backdrop-filter: blur(5px); /* Safari対応 */
    backdrop-filter: blur(5px); /* 背景をぼかす */
    will-change: opacity, visibility, backdrop-filter; /* will-changeを追加 */
}

    .loading-overlay.active {
        opacity: 1;
        visibility: visible;
    }

/* IMPROVEMENT 5: ローディングスピナーの未来感アップグレード */
.loading-spinner {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 255, 255, 0.1); 
    border-top: 3px solid var(--loading-spinner-color); 
    border-radius: 50%;
    animation: spin 1s linear infinite; 
    position: relative;
    box-shadow: 0 0 20px var(--loading-spinner-color); 
    will-change: transform, box-shadow;
}

/* IMPROVEMENT 5: ::before のスタイル変更 */
.loading-spinner::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border: 2px solid transparent;
    border-top: 2px solid var(--neon-glow);
    border-radius: 50%;
    animation: spin 1.5s linear infinite reverse; 
    opacity: 0.7;
}

/* IMPROVEMENT 5: ::after の新規追加 */
.loading-spinner::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: var(--neon-glow);
    border-radius: 50%;
    box-shadow: 
      0 0 10px var(--neon-glow),
      0 0 20px var(--neon-glow);
}


@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ----- フッターのスタイル ----- */
footer {
    text-align: center;
    margin-top: 80px; /* マージンを増やす */
    padding: 30px 0;
    border-top: 1px solid rgba(0, 191, 255, 0.2);
    color: var(--medium-grey);
    font-size: 0.95em; /* 少し大きく */
    letter-spacing: 1px;
    opacity: 0.7;
    background-color: rgba(0,0,0,0.1); /* 半透明の背景 */
    position: relative;
    z-index: 1;
}

    footer a {
        color: var(--medium-grey);
        text-decoration: none;
        transition: color var(--transition-speed);
    }

        footer a:hover {
            color: var(--primary-light);
            text-shadow: 0 0 8px rgba(0, 191, 255, 0.5);
        }

/* ----- 新規追加: 再出撃シミュレーションセクション ----- */
.simulation-container {
    background-color: var(--card-background);
    padding: 30px;
    margin-bottom: 50px;
    border-radius: 12px;
    box-shadow: var(--soft-shadow);
    border: 1px solid rgba(0, 191, 255, 0.2);
    position: relative;
    overflow: hidden;
    will-change: transform, box-shadow;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

    .simulation-container:hover {
        transform: translateY(-8px);
        box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
        border-color: var(--primary-light);
    }

    .simulation-container h2 {
        color: var(--primary-dark);
        font-size: 2.2em;
        font-weight: 700;
        margin-top: 0;
        margin-bottom: 30px;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 15px;
        text-shadow: 1px 1px 5px rgba(0,0,0,0.15);
        position: relative;
        z-index: 1;
    }

    .simulation-container .guide-intro {
        font-size: 1.15em;
        color: #555;
        margin-bottom: 35px;
        text-align: center;
        line-height: 1.8;
        max-width: 70ch;
        margin-left: auto;
        margin-right: auto;
    }

.character-select-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
}

.select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 250px;
}

    .select-wrapper label {
        font-weight: bold;
        color: var(--primary-dark);
        font-size: 1.1em;
        display: flex;
        align-items: center;
        gap: 10px;
    }

        .select-wrapper label i {
            color: var(--accent-orange);
            font-size: 1.2em;
        }

.select-dropdown {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--light-grey-border);
    border-radius: 8px;
    background-color: var(--background-light);
    font-size: 1em;
    color: var(--text-color);
    -webkit-appearance: none; /* Safari対応 */
    -moz-appearance: none; /* Firefox対応 */
    appearance: none; /* デフォルトの矢印を非表示 */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%236C757D' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); /* カスタム矢印 */
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 18px;
    cursor: pointer;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.08);
    will-change: border-color, box-shadow;
}

    .select-dropdown:focus {
        border-color: var(--primary-light);
        outline: none;
        box-shadow: 0 0 0 3px rgba(0, 191, 255, 0.3);
    }

/* Make number input fields look like select-dropdown */
input[type="number"].select-dropdown {
    -moz-appearance: textfield; /* Firefox */
}
input[type="number"].select-dropdown::-webkit-outer-spin-button,
input[type="number"].select-dropdown::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}


.team-cost-display {
    text-align: center;
    margin-bottom: 30px;
    padding: 15px 20px;
    background-color: #F0F8FF;
    border-radius: 10px;
    border: 1px solid var(--primary-light);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    will-change: transform, box-shadow;
    transition: all 0.3s ease;
}

    .team-cost-display:hover {
        transform: scale(1.01);
        box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    }

    .team-cost-display .cost-label {
        font-size: 1.2em;
        font-weight: 700;
        color: var(--primary-dark);
        display: flex;
        align-items: center;
        gap: 8px;
    }

        .team-cost-display .cost-label i {
            color: var(--neon-glow-strong);
            font-size: 1.3em;
        }

    .team-cost-display .cost-value {
        font-family: 'Orbitron', sans-serif;
        font-size: 2.2em;
        font-weight: 700;
        color: var(--primary-light);
        text-shadow: 0 0 10px rgba(0, 191, 255, 0.7);
        letter-spacing: 1px;
        transition: text-shadow 0.3s ease;
    }

.selected-characters-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 25px;
    margin-top: 30px;
    margin-bottom: 40px;
    min-height: 180px; /* ある程度の高さを確保 */
    align-items: center; /* 垂直方向中央揃え */
}

.mini-character-card {
    background-color: #F8FCFF;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    padding: 15px;
    text-align: center;
    width: 180px; /* ミニカードの固定幅 */
    border: 1px solid var(--light-grey-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0; /* 初期非表示 */
    transform: translateY(20px); /* アニメーション用 */
    transition: all 0.3s ease;
    will-change: opacity, transform;
}

    .mini-character-card.active {
        opacity: 1;
        transform: translateY(0);
    }

    .mini-character-card .char-name {
        font-weight: 700;
        color: var(--primary-dark);
        font-size: 1.1em;
        margin-bottom: 8px;
        font-family: 'Rajdhani', sans-serif;
    }

    .mini-character-card .char-image {
        width: 80px;
        height: 80px;
        border-radius: 50%;
        border: 3px solid var(--accent-orange);
        overflow: hidden;
        margin-bottom: 10px;
        box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.3), inset 0 0 8px rgba(0,0,0,0.1);
        will-change: transform, box-shadow;
        transition: all 0.3s ease;
    }

        .mini-character-card .char-image:hover {
            transform: scale(1.05) rotateZ(3deg);
            box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.5), inset 0 0 10px rgba(0,0,0,0.15);
        }

        .mini-character-card .char-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 50%;
            display: block;
        }

        .mini-character-card .char-image span.initial {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 100%;
            font-size: 36px;
            color: #7F8C8D;
            background-color: #F0F5F9;
            font-family: 'Orbitron', sans-serif;
        }

    .mini-character-card .char-cost {
        font-weight: 700;
        color: var(--primary-light);
        font-family: 'Rajdhani', sans-serif;
        font-size: 0.95em;
        background-color: rgba(0, 191, 255, 0.1);
        padding: 4px 10px;
        border-radius: 15px;
        border: 1px solid rgba(0, 191, 255, 0.3);
    }

.simulation-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

    .simulation-input-group label {
        font-weight: bold;
        color: var(--primary-dark);
        font-size: 1.1em;
        display: flex;
        align-items: center;
        gap: 10px;
    }

        .simulation-input-group label i {
            color: var(--accent-orange);
            font-size: 1.2em;
        }
/* Awakening specific input groups */
.awakening-simulation-area .simulation-input-group {
    max-width: none; /* Allow full width within its container */
    margin-bottom: 15px;
}

.awakening-additional-options { /* Container for new checkbox groups */
    display: flex;
    flex-direction: column; /* Default to vertical stacking */
    gap: 10px;
    text-align: left;
    max-width: 450px; /* Control width of this section */
    margin: 15px auto; /* Center the section */
}

.awakening-additional-options .checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.awakening-additional-options .checkbox-group label {
    font-weight: normal;
    font-size: 1em;
    margin-bottom: 0;
    margin-left: 5px; /* Space between icon/checkbox and text */
}
.awakening-additional-options .checkbox-group input[type="checkbox"] {
    margin-right: 0; /* Remove default margin if icon is present */
    transform: scale(1.2);
    cursor: pointer;
}
 .awakening-additional-options .checkbox-group > i {
    color: var(--accent-orange);
    font-size: 1.2em;
    width: 20px; /* Ensure icon has some width */
    text-align: center;
}

.awakening-additional-options .select-dropdown-container {
     margin-left: 30px; /* Indent dropdown if it's under a checkbox with icon */
     margin-top: 5px;
     display: none;
}


/* Responsive layout for awakening options */
@media (min-width: 768px) { /* Apply for wider screens */
    .awakening-additional-options {
        flex-direction: row; /* Stack horizontally */
        flex-wrap: wrap; /* Allow wrapping if not enough space */
        justify-content: space-around; /* Distribute space */
        align-items: flex-start;
        gap: 20px; /* Adjust gap for horizontal layout */
        max-width: none; /* Allow to use more width */
    }
    .awakening-additional-options .simulation-input-group.checkbox-group {
        /* Adjust width for horizontal items if needed, e.g., flex-basis */
         min-width: 200px; /* Example minimum width */
    }
    .awakening-additional-options .select-dropdown-container {
        width: 100%; /* Make dropdown take full width of its parent group if needed */
        margin-left: 0; /* Reset indent if it's part of a horizontal group */
    }
     /* If a checkbox group has a dropdown, make them stack vertically even in horizontal layout */
    .awakening-additional-options .simulation-input-group.has-dropdown {
        display: flex;
        flex-direction: column;
        align-items: flex-start; /* Align checkbox and dropdown to the left */
    }
    .awakening-additional-options .simulation-input-group.has-dropdown .select-dropdown-container {
         margin-left: 30px; /* Re-apply indent for dropdown */
    }
}



.simulation-buttons { /* Container for simulation execution buttons AND share button groups */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px; /* Reduced from 40px to make space for share group if needed */
}

.simulation-button { /* This is a base class for simulation and share buttons */
    color: var(--card-background);
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1.1em;
    font-weight: 700;
    cursor: crosshair;
    transition: all var(--transition-speed);
    position: relative;
    overflow: hidden;
    will-change: transform, background-color, box-shadow, text-shadow;
    display: flex; /* For icon alignment */
    align-items: center;
    justify-content: center;
    gap: 10px; /* Space between icon and text */
}

/* Specific styles for primary simulation buttons */
#simulatePlayerRedeploy, #simulatePartnerRedeploy {
    background-color: var(--primary-light);
    border: 2px solid var(--primary-light);
    box-shadow: 0 5px 15px rgba(0, 191, 255, 0.5);
}
#simulatePlayerRedeploy:hover, #simulatePartnerRedeploy:hover {
    background: linear-gradient(45deg, rgba(0, 191, 255, 0.9), rgba(0, 150, 200, 0.9));
    transform: translateY(-5px) scale(1.01);
    box-shadow: 0 8px 20px rgba(0, 191, 255, 0.7), 0 0 15px rgba(0, 239, 255, 0.5);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.simulation-button:active { /* General active state for all sim/share buttons */
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 2px 5px rgba(0,0,0,0.08) !important; /* Ensure active shadow overrides others */
}

.simulation-button::before { /* Gloss effect for all sim/share buttons */
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: skewX(-20deg);
    transition: all 0.5s ease;
    z-index: 1;
    will-change: transform, left;
}
.simulation-button:hover::before {
    left: 100%;
}


.simulation-results {
    background-color: #F8FCFF;
    padding: 30px;
    border-radius: 12px;
    box-shadow: inset 0 0 15px rgba(255, 215, 0, 0.1);
    text-align: center;
    opacity: 0; /* 初期非表示 */
    transform: translateY(20px);
    will-change: opacity, transform;
    pointer-events: none; /* デフォルトでクリック不可に */
    margin-bottom: 0; /* Removed margin, share buttons group will handle spacing */
}

    .simulation-results.active {
        pointer-events: auto; /* 表示時にクリック可能に */
        animation: fadeInScale 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    }

    @keyframes fadeInScale {
      0% {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
      }
      100% {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }

    .simulation-results h3 {
        color: var(--primary-dark);
        font-size: 2em;
        font-weight: 700;
        margin-top: 0;
        margin-bottom: 25px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        text-shadow: 1px 1px 5px rgba(0,0,0,0.1);
    }

        .simulation-results h3 i {
            color: var(--primary-light);
            font-size: 1.2em;
        }

.result-display-area {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px 20px;
    margin-bottom: 25px;
    text-align: left;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.redeploy-char-info {
    display: flex;
    flex-direction: column;
    background-color: #E6EEF4;
    padding: 12px 18px;
    border-radius: 8px;
    border: 1px solid rgba(0, 191, 255, 0.1);
    box-shadow: inset 0 1px 5px rgba(0,0,0,0.05);
    transition: background-color 0.3s ease;
    will-change: background-color;
}

    .redeploy-char-info:hover {
        background-color: #DDEBF6;
    }

    .redeploy-char-info .info-label {
        font-weight: bold;
        color: var(--medium-grey);
        font-size: 0.9em;
        margin-bottom: 5px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .redeploy-char-info .info-value {
        font-family: 'Rajdhani', sans-serif;
        font-size: 1.4em;
        font-weight: 700;
        color: var(--primary-dark);
        text-shadow: 1px 1px 2px rgba(0,0,0,0.05);
    }
/* 特定の強調表示 */
#redeployCalculatedHp.low-hp-value {
    color: var(--hp-low);
    text-shadow: 0 0 8px rgba(220, 53, 69, 0.5);
    animation: hpNumberPop 0.8s ease-out forwards;
}
/* 新規追加: 99%以下の赤い文字表示用クラス */
#redeployCalculatedHp.red-value {
    color: var(--hp-low); /* hp-lowは赤色 */
    text-shadow: 0 0 8px rgba(220, 53, 69, 0.5); /* 赤い影 */
    animation: none; /* low-hp-valueのanimationが競合しないように */
}

.simulation-hp-bar { /* シミュレーション結果のHPバー */
    width: 80%; /* 幅を調整 */
    max-width: 600px; /* 最大幅 */
    margin: 25px auto 10px; /* 中央揃えとマージン */
    border: 2px solid var(--primary-light); /* 強調 */
    box-shadow: 0 0 15px rgba(0, 191, 255, 0.5);
    height: 16px; /* 太く */
}

.simulation-hp-percentage { /* シミュレーション結果の割合表示 */
    font-size: 1.5em; /* 大きく */
    margin-top: 10px; /* 上のバーとの間隔 */
    color: var(--primary-dark); /* 暗い色 */
    text-shadow: none; /* デフォルトの影を解除 */
    font-family: 'Orbitron', sans-serif; /* SFフォント */
    font-weight: 700;
}

.simulation-note {
    color: var(--medium-grey);
    font-size: 0.9em;
    margin-top: 20px;
}

/* ----- 新規追加: 合計耐久力表示エリア ----- */
.total-hp-display-area {
    margin-top: 40px;
    padding: 30px;
    border-top: 1px dashed var(--light-grey-border);
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    will-change: opacity, transform;
    background-color: #F8FCFF;
    border-radius: 12px;
    border: 1px solid var(--accent-orange);
    box-shadow: inset 0 0 15px rgba(255, 215, 0, 0.1);
}

    .total-hp-display-area.active {
        opacity: 1;
        transform: translateY(0);
    }

    .total-hp-display-area h3 {
        color: var(--accent-orange);
        font-size: 1.8em;
        margin-bottom: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        text-shadow: 1px 1px 5px rgba(0,0,0,0.1);
    }

        .total-hp-display-area h3 i {
            color: var(--accent-orange);
        }

.total-hp-summary {
    font-size: 1.05em;
    color: #666;
    margin-bottom: 25px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

    .total-hp-summary .cost-value-small {
        font-family: 'Orbitron', sans-serif;
        font-size: 1.2em;
        font-weight: 700;
        color: var(--primary-light);
        text-shadow: 0 0 5px rgba(0, 191, 255, 0.5);
        margin-left: 5px;
        margin-right: 5px;
    }

.total-hp-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
    margin-bottom: 25px;
    text-align: left;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}
@media (max-width: 1200px) {
     .total-hp-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 920px) {
    .total-hp-grid {
        grid-template-columns: repeat(2, 1fr);
         max-width: 700px;
    }
}
@media (max-width: 650px) {
    .total-hp-grid {
        grid-template-columns: 1fr;
        max-width: 400px;
    }
}


.total-hp-scenario {
    background-color: #E6EEF4;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid rgba(0, 191, 255, 0.1);
    box-shadow: inset 0 1px 5px rgba(0,0,0,0.05);
    margin-bottom: 0;
    text-align: center;
    display: flex;
    flex-direction: column;
}

    .total-hp-scenario h4 {
        color: var(--primary-dark);
        font-size: 1.3em;
        font-weight: 700;
        margin-top: 0;
        margin-bottom: 15px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }

        .total-hp-scenario h4 i {
            color: var(--accent-orange);
        }

    .total-hp-scenario .redeploy-char-info {
        background-color: #F0F8FF;
        margin-bottom: 10px;
        flex-shrink: 0;
    }

        .total-hp-scenario .redeploy-char-info:last-of-type {
            margin-bottom: 0;
        }
    /* NEW: Total HP Accordion Styles */
    .total-hp-accordion-header {
        background-color: transparent;
        border: none;
        border-bottom: 1px dashed rgba(0,0,0,0.1);
        padding: 10px 0 8px 0;
        width: 100%;
        text-align: left;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 15px;
        margin-bottom: 0;
        outline: none;
        transition: background-color 0.3s ease;
    }
    .total-hp-accordion-header:hover {
        background-color: rgba(0, 191, 255, 0.05);
    }
    .total-hp-accordion-title {
        color: var(--primary-dark);
        font-size: 1.1em;
        font-weight: 600;
    }
    .total-hp-accordion-header .accordion-icon {
        font-size: 1em;
        color: var(--primary-dark);
    }

    .total-hp-accordion-content {
        list-style: none;
        font-size: 0.95em;
        color: var(--text-color);
        text-align: left;
        overflow-y: auto;
        max-height: 0; /* Closed by default */
        border-style: solid;
        border-color: var(--light-grey-border);
        border-width: 0px; /* Closed by default */
        border-radius: 5px;
        background-color: var(--card-background);
        scrollbar-width: thin;
        scrollbar-color: var(--primary-light) #f1f1f1;
        opacity: 0; /* Closed by default */
        padding: 0; /* Closed by default */
        margin: 0; /* Closed by default */
        transition: max-height 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                    opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                    padding 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                    margin-top 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
                    /* border-width 0.4s ease; */ /* 問題の可能性があった行をコメントアウトまたは削除 */
    }
    .total-hp-accordion-content.show {
        max-height: 300px;
        opacity: 1;
        padding: 8px;
        margin-top: 10px;
        border-width: 1px;
    }

    .total-hp-accordion-content::-webkit-scrollbar { width: 10px; }
    .total-hp-accordion-content::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
    .total-hp-accordion-content::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 10px; }
    .total-hp-accordion-content::-webkit-scrollbar-thumb:hover { background: #008DCC; }

    .total-hp-accordion-content li {
        background-color: var(--card-background);
        padding: 6px 10px;
        border-radius: 5px;
        margin-bottom: 5px;
        border: 1px solid var(--light-grey-border);
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
        white-space: normal;
        word-break: break-word;
    }
    .total-hp-accordion-content li:last-child {
        margin-bottom: 0;
    }
    .total-hp-accordion-content li:hover {
        transform: translateX(5px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    }

    .total-hp-scenario .info-label {
        font-size: 0.85em;
    }

    .total-hp-scenario .info-value {
        font-size: 1.3em;
    }

@media (max-width: 480px) {
    .total-hp-display-area h3 {
        font-size: 1.4em;
    }
    .total-hp-summary {
        font-size: 0.95em;
    }
    .total-hp-scenario h4 {
        font-size: 1.2em;
    }
    .total-hp-scenario .info-value {
        font-size: 1.1em;
    }
}

/* NEW Awakening Simulation Area Styles */
.awakening-simulation-area {
    display: none; /* Initially hidden */
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed var(--light-grey-border);
}
.simulation-results.active .awakening-simulation-area {
    display: block; /* Show when results are active */
}

.awakening-possible {
    color: var(--hp-high) !important; /* Greenish color, !important to override other styles */
    text-shadow: 0 0 8px rgba(40, 167, 69, 0.5) !important;
    font-weight: bold;
}
.awakening-not-possible {
    color: var(--hp-low) !important; /* Reddish color, !important to override other styles */
    text-shadow: 0 0 8px rgba(220, 53, 69, 0.5) !important;
    font-weight: bold;
}
.awakening-simulation-area .simulation-input-group label {
     margin-bottom: 8px;
}
.awakening-additional-options .simulation-input-group {
    margin-bottom: 10px; /* Reduced margin for checkbox groups */
}
.awakening-additional-options .select-dropdown-container {
    margin-left: 25px; /* Indent dropdown under checkbox */
    margin-top: 5px;
    display: none;
}
.awakening-additional-options .checkbox-group {
    align-items: center; /* Vertically align checkbox and label */
}
.awakening-additional-options .checkbox-group label {
    font-weight: normal; /* Less emphasis for checkbox label */
    margin-left: 5px;
}

/* ★ここからサブアコーディオン用のスタイル追加★ */
.sub-accordion-container {
    margin-top: 25px; /* 上の要素との間隔 */
    margin-bottom: 25px;
    border: 1px dashed var(--light-grey-border); /* 親より軽いボーダー */
    border-radius: 8px;
    background-color: #F8FCFF; /* 親より少し明るい背景色 */
    box-shadow: inset 0 0 8px rgba(0, 191, 255, 0.05); /* 親より軽い影 */
}

    .sub-accordion-container .accordion-item {
        border-bottom: 1px dashed rgba(0, 191, 255, 0.08); /* 親より軽いボーダー */
    }
        .sub-accordion-container .accordion-item:last-child {
            border-bottom: none;
        }

.sub-accordion-header {
    background-color: #EBF7FF; /* 親より明るい背景色 */
    padding: 12px 20px; /* 親より少し小さいパディング */
    font-size: 1.05em; /* 親より少し小さいフォントサイズ */
    font-weight: 600;
    color: var(--primary-dark);
    text-shadow: none;
}

    .sub-accordion-header:hover {
        background-color: #D3EEFF;
        color: var(--primary-light);
        box-shadow: inset 0 0 10px rgba(0, 191, 255, 0.1);
        border-color: rgba(0, 191, 255, 0.2);
    }
        .sub-accordion-header:hover::before {
            box-shadow: 0 0 8px 2px rgba(0, 191, 255, 0.4);
        }

    .sub-accordion-header.active {
        background-color: var(--primary-light); /* 親と同じアクティブカラー */
        color: var(--card-background);
        box-shadow: inset 0 0 15px rgba(0, 191, 255, 0.4);
    }
        .sub-accordion-header.active::before {
            box-shadow: 0 0 12px 3px var(--neon-glow-strong);
        }

    .sub-accordion-header span {
        gap: 10px; /* アイコンとテキストの間隔を調整 */
    }

    .sub-accordion-header i:first-child {
        font-size: 1.2em; /* 親より少し小さいアイコンサイズ */
        color: var(--accent-orange); /* 親と同じアイコン色 */
    }
        .sub-accordion-header.active i:first-child {
            color: var(--card-background);
        }

.sub-accordion-content {
    padding: 0 20px; /* 親より少し小さいパディング */
    font-size: 0.95em; /* 親より少し小さいフォントサイズ */
    /* transition: max-height 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), padding 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), margin-top 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), border-width 0.4s ease; */ /* この行全体をコメントアウトまたは削除 */
}
    .sub-accordion-content.show {
        padding: 20px; /* 開いた時のパディング */
        max-height: 3000px; /* サブアコーディオンの最大高さ (デバッグ前の値に戻す) */
        /* overflow: visible !important; */ /* デバッグ用スタイルを削除 */
        /* background-color: lime !important; */ /* デバッグ用スタイルを削除 */
        /* border: 5px solid red !important; */ /* デバッグ用スタイルを削除 */
        /* z-index: 9999 !important; */ /* デバッグ用スタイルを削除 */
    }

    /* 以下が新規/変更されたスタイル */

    .sub-accordion-content p {
        /* max-widthやtransformは個別の要素で制御するため、ここで汎用的なpタグのスタイルを調整 */
        max-width: none;
        margin: 0 0 12px; /* セクション外のpタグとの兼ね合いで調整 */
        line-height: 1.8;
        transform: none; /* 親のscaleY(1.03)をリセット */
        transform-origin: top;
    }

    .sub-accordion-content .gauge-section {
        margin-bottom: 25px; /* 各ゲージ計算セクション間のスペース */
        padding-bottom: 15px;
        border-bottom: 1px dotted var(--light-grey-border); /* セクションの区切り線 */
    }
    .sub-accordion-content .gauge-section:last-of-type {
        border-bottom: none; /* 最後のセクションには区切り線なし */
        margin-bottom: 0;
        padding-bottom: 0;
    }

    .sub-accordion-content .gauge-section h5 {
        color: var(--primary-dark);
        font-size: 1.2em; /* サブセクション見出しのサイズ */
        font-weight: 700;
        margin-top: 0;
        margin-bottom: 15px;
        display: flex;
        align-items: center;
        gap: 10px;
        text-shadow: 1px 1px 3px rgba(0,0,0,0.08);
    }
    .sub-accordion-content .gauge-section h5 i {
        color: var(--primary-light); /* 見出しアイコンの色 */
        font-size: 1.1em;
    }

    .sub-accordion-content .gauge-section ul {
        margin: 10px 0 0 0; /* リストの上マージン調整 */
        padding-left: 25px;
        list-style-type: disc;
        color: #555;
    }
    .sub-accordion-content .gauge-section ul li {
        margin-bottom: 8px;
        line-height: 1.6;
    }

    .sub-accordion-content .formula.small-formula {
        padding: 10px 15px;
        margin: 15px 0; /* セクション内での上下マージンに調整 */
        font-size: 1.1em;
        max-width: 100%; /* 親要素の幅いっぱいに広げる */
        border-left: 4px solid var(--accent-orange);
    }
    .sub-accordion-content .tip {
        margin: 15px 0; /* セクション内での上下マージンに調整 */
        font-size: 0.9em;
        padding: 8px 15px;
        border-radius: 6px;
        max-width: 100%; /* 親要素の幅いっぱいに広げる */
    }

    /* 注意点セクションの特別なスタイル */
    .sub-accordion-content .tip.additional-note-block {
        background-color: #F8E6EC; /* 警告色の背景 */
        border: 1px solid #E7B3C4; /* 警告色のボーダー */
        box-shadow: 0 3px 8px rgba(0,0,0,0.1);
        padding: 15px 20px;
        border-radius: 8px;
        margin-top: 25px; /* 上の要素との間隔を確保 */
        display: flex; /* アイコンとテキストを横並びにするため */
        align-items: flex-start; /* 上揃え */
        gap: 15px; /* アイコンとテキストの間隔 */
        max-width: 100%; /* 親の幅に合わせる */
        color: #8B0000; /* 注意点を強調するテキスト色 */
    }
    .sub-accordion-content .tip.additional-note-block i {
        font-size: 1.6em; /* アイコンを大きく */
        color: #DC3545; /* アイコンの色 */
        flex-shrink: 0; /* アイコンが縮まないように */
    }
    .sub-accordion-content .tip.additional-note-block h4 {
        color: #8B0000; /* 注意点見出しの色 */
        font-size: 1.1em;
        font-weight: 700;
        margin-top: 0;
        margin-bottom: 10px;
    }
    .sub-accordion-content .tip.additional-note-block ul {
        margin: 0;
        padding-left: 20px;
        list-style-type: disc;
        color: #8B0000; /* リスト項目の色 */
    }
    .sub-accordion-content .tip.additional-note-block ul li {
        margin-bottom: 5px;
        line-height: 1.5;
    }
    .sub-accordion-content .tip.additional-note-block ul li:last-child {
        margin-bottom: 0;
    }
    .sub-accordion-content .tip.additional-note-block p {
        margin-top: 10px;
        margin-bottom: 0;
        color: #8B0000;
    }
/* ★ここまでサブアコーディオン用のスタイル追加★ */

/* Share Button Styles */
.share-buttons-group { /* Container for share buttons */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px; /* Space between buttons */
}

.simulation-results .share-buttons-group {
    margin-top: 25px; /* Spacing after awakening results */
    margin-bottom: 0; /* No bottom margin from group, result div handles padding */
}

.total-hp-display-area .share-buttons-group {
    margin-top: 30px;  /* Spacing after total HP grid */
    margin-bottom: 10px; /* Spacing before end of total HP area */
}


/* Styles for the X (Twitter) share button */
.share-button#shareRedeployResultBtn,
.share-button#shareTotalHpResultBtn {
    background-color: var(--twitter-blue) !important;
    border: 2px solid var(--twitter-blue) !important;
    box-shadow: 0 5px 15px var(--twitter-blue-shadow) !important;
}
.share-button#shareRedeployResultBtn:hover,
.share-button#shareTotalHpResultBtn:hover {
    background: linear-gradient(45deg, #1a91da, #1f9cf0) !important;
    box-shadow: 0 8px 20px var(--twitter-blue-hover-shadow), 0 0 15px var(--twitter-blue-hover-shadow) !important;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.7) !important;
}

/* Styles for the URL copy button */
.copy-url-button {
    background-color: var(--copy-url-button-bg) !important;
    border: 2px solid var(--copy-url-button-border) !important;
    box-shadow: 0 5px 15px var(--copy-url-button-shadow) !important;
}

.copy-url-button:hover {
    background: var(--copy-url-button-hover-bg) !important;
    box-shadow: 0 8px 20px var(--copy-url-button-hover-shadow), 0 0 15px var(--copy-url-button-hover-shadow) !important;
}
.copy-url-button:disabled { /* Style for when URL is copied (success feedback) */
    background-color: var(--copy-success-bg) !important;
    border-color: var(--copy-success-border) !important;
    box-shadow: 0 5px 15px var(--copy-success-shadow) !important;
    cursor: default !important;
    opacity: 1 !important;
}
.copy-url-button:disabled:hover { /* Keep success style on hover when disabled */
    background-color: var(--copy-success-bg) !important;
    box-shadow: 0 5px 15px var(--copy-success-shadow) !important;
}

.simulation-button i { /* General icon style within any .simulation-button (share or primary) */
     font-size: 1.2em;
}


/* IMPROVEMENT 9: カスタムスクロールバー */
::-webkit-scrollbar {
  width: 8px;
  background: rgba(26, 44, 62, 0.3); /* 背景色に合わせたスクロールバートラック */
}

::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 4px;
  border: 1px solid rgba(0, 191, 255, 0.5); 
}
::-webkit-scrollbar-thumb:hover { 
    background: var(--neon-glow-strong);
    box-shadow: 0 0 5px var(--neon-glow-strong);
}


/* IMPROVEMENT 8: レスポンシブデザインの改善 */
@media (max-width: 768px) {
  .character-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px; 
  }
  
  .filter-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px; 
  }

  .filter-buttons {
      justify-content: flex-start;
  }

  h1 {
      font-size: 2.5em; 
  }
  .usage-guide-container h2, .simulation-container h2 {
      font-size: 1.8em; 
  }
  .character-header {
      padding: 15px 20px;
      font-size: 1.1em;
  }
  .character-body {
      padding: 20px;
  }
  .character-image {
      width: 100px;
      height: 100px;
      font-size: 50px;
  }
  .simulation-buttons { 
      flex-direction: column; 
      align-items: center;
  }
  .simulation-button { /* This includes all buttons that use this base class */
      width: 80%;
      max-width: 300px; 
  }
  .total-hp-grid {
    grid-template-columns: 1fr; /* 768px以下では1列に */
  }
  .awakening-additional-options { 
      flex-direction: column;
      align-items: flex-start;
  }
  .awakening-additional-options .simulation-input-group.checkbox-group {
      min-width: auto; 
  }
   .awakening-additional-options .simulation-input-group.has-dropdown .select-dropdown-container {
         margin-left: 20px; 
    }
}

@media (max-width: 480px) {
    body {
        padding: 15px;
    }
    h1 {
        font-size: 2em;
    }
     .usage-guide-container h2, .simulation-container h2 {
      font-size: 1.5em;
    }
    .character-grid {
        grid-template-columns: 1fr; /* 1列表示 */
        gap: 25px;
    }
    .character-card:hover { /* スマホではホバーエフェクトを控えめに */
        transform: translateY(-5px) scale(1.01);
        filter: drop-shadow(0 0 10px rgba(0, 191, 255, 0.4));
    }

    .filter-buttons .filter-button {
        padding: 10px 15px;
        font-size: 0.9em;
    }
    .search-container {
        margin-bottom: 15px;
    }
    .filter-container {
        gap: 20px;
    }
    #characterSearch {
        padding: 12px 15px 12px 50px;
        font-size: 1em;
    }
    .search-icon {
        font-size: 1.1em;
        left: 15px;
    }
    /* Ensure share buttons in groups also take up more width on small screens */
    .share-buttons-group .simulation-button { 
        width: 90%;
        max-width: 320px;
    }
}

/* ----- 新規追加: メインセクション用アコーディオンのスタイル ----- */
.main-section-accordion {
    margin-bottom: 30px; /* 各メインセクション間のマージン */
    border: 1px solid rgba(0, 191, 255, 0.3); /* 通常のアコーディオンより少し目立つボーダー */
    border-radius: 12px;
    overflow: hidden;
    background-color: var(--card-background);
    box-shadow: var(--soft-shadow);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.main-section-accordion:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-color: var(--primary-light);
}

.main-section-accordion-header {
    background-color: #EBF7FF; /* 通常のヘッダーより少し明るく */
    padding: 20px 30px; /* パディングを広めに */
    font-size: 1.5em; /* フォントサイズを大きく */
    font-weight: 700;
    color: var(--primary-dark);
    cursor: pointer; /* カーソルをポインターに */
}

.main-section-accordion-header:hover {
    background-color: #D3EEFF;
    color: var(--primary-light);
}

.main-section-accordion-header.active {
    background-color: var(--primary-light);
    color: var(--card-background);
}

.main-section-accordion-header .accordion-icon {
    font-size: 1em; /* アイコンサイズ調整 */
}

.main-section-accordion-content {
    background-color: var(--card-background);
    padding: 0; /* コンテンツ内の simulation-container や total-hp-display-area が自身のパディングを持つため */
    max-height: none; /* 初期表示で開いている場合は制限なし */
    opacity: 1;
    transform: scaleY(1);
    /* 開閉アニメーションは既存の .accordion-content と同様にJSで制御 */
}

.main-section-accordion-content.show {
    padding: 0; /* showクラスでも同様 */
    max-height: 6000px; /* 親アコーディオンの最大高さ (デバッグ前の値に戻す) */
    /* overflow: visible !important; */ /* デバッグ用スタイルを削除 */
}

/* simulation-container と total-hp-display-area のマージンとボーダーを調整 */
.main-section-accordion-content .simulation-container,
.main-section-accordion-content .total-hp-display-area {
    margin-bottom: 0; /* アコーディオンコンテントが最後のマージンを持つため不要に */
    border: none; /* アコーディオン自体がボーダーを持つため不要に */
    box-shadow: none; /* アコーディオン自体が影を持つため不要に */
    border-radius: 0; /* 親のアコーディオンの角丸に合わせる */
}

.main-section-accordion-content .simulation-container:hover,
.main-section-accordion-content .total-hp-display-area:hover {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    transform: translateY(-3px);
}

/* ===== NEW STYLES FOR DETAILS IN USAGE GUIDE ===== */
.accordion-content details[open] {
    overflow: visible; /* detailsが開いたときに内容が隠れないように */
    padding-bottom: 10px; /* 内容の下に少し余白を追加 */
}

.accordion-content details[open] summary {
    margin-bottom: 10px; /* summaryと内容の間に余白を追加 */
}

/* 
  .accordion-content はデフォルトで overflow: hidden; のままです。
  .accordion-content.show の時に overflow: visible; にすることで、
  展開された <details> の内容が表示されるようにします。
  特に .usage-guide-container 内のアコーディオンに適用します。
*/
.usage-guide-container .accordion-content.show {
    overflow: visible !important; /* Ensure content isn't clipped when details open */
}

.guide-details { /* detailsタグ自体へのスタイル */
    background-color: #f8f9fa; /* 少し明るい背景色 */
    border: 1px solid #dee2e6;
    border-radius: .25rem; /* 4px */
    padding: 1rem; /* 15px or 16px depending on root font-size */
    margin-top: 1rem;
    color: var(--text-color); 
}

.guide-details summary {
    font-weight: bold;
    cursor: pointer;
    color: var(--primary-dark);
    padding: 0.5rem 0; /* summaryにも少しパディング */
    position: relative; /* For custom marker or pseudo-elements if needed */
}

.guide-details summary:hover {
    color: var(--primary-light);
}

/* 
  デフォルトのdetailsマーカー（通常は三角形）はブラウザによってスタイル制御が難しい場合があります。
  もしマーカーの色も変えたい場合は、list-style: none; にしてカスタムアイコンを擬似要素で追加するなどの対応も考えられます。
  ここでは、summaryのテキスト色に連動することを期待します。
  もしマーカーの色が追従しない場合、 .guide-details summary::marker { color: var(--primary-dark); } などを試します。
*/
.guide-details summary::marker {
    color: var(--primary-dark); /* Trying to style the marker */
}
.guide-details summary:hover::marker {
    color: var(--primary-light); /* Trying to style the marker on hover */
}


.usage-guide-container .accordion-item .accordion-content details p,
.usage-guide-container .accordion-item .accordion-content details ul {
    margin-bottom: 0.75rem; /* details内の段落やリストの下に余白 */
    color: var(--text-color);
    font-size: 0.95em; /* 少し小さくして本文と区別 */
    line-height: 1.6;
}

.usage-guide-container .accordion-item .accordion-content details ul {
    padding-left: 20px; /* list items indent */
    list-style-type: disc; /* Ensure list style is visible */
}
.usage-guide-container .accordion-item .accordion-content details ul li {
    margin-bottom: 0.5rem; /* Space between list items */
}


.usage-guide-container .accordion-item .accordion-content details p:last-child,
.usage-guide-container .accordion-item .accordion-content details ul:last-child {
    margin-bottom: 0; /* Last element in details has no bottom margin */
}

/* ===== NEW STYLES FOR DETAILS IN USAGE GUIDE (REVISED ATTEMPT 2) ===== */
.usage-guide-container .accordion-item .accordion-content.show {
    /* Attempt to remove max-height constraint to see if content appears */
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;  /* Crucial for <details> content */
    /* opacity and transform are handled by the general .accordion-content.show */
    /* Padding might still be needed if removed by other rules */
    padding-top: 25px !important; /* Ensure padding is applied from .accordion-content.show */
    padding-bottom: 25px !important; /* Ensure padding is applied from .accordion-content.show */
}

/* Resetting styles on the parent accordion content that might conflict */
/* This selector targets the accordion content within the usage guide specifically */
.usage-guide-container > .accordion > .accordion-item > .accordion-content {
    /* Try to reset transform and opacity if they are causing issues with details visibility */
    /* transform: none !important; */ /* Might break opening animation, test carefully */
    /* opacity: 1 !important; */     /* Might break opening animation, test carefully */
}

.usage-guide-container > .accordion > .accordion-item > .accordion-content.show {
    /* Re-apply desired open state for this specific accordion, overriding general ones if needed */
    max-height: none !important; /* Let content define height */
    height: auto !important;
    opacity: 1 !important;
    transform: scaleY(1) !important;
    overflow: visible !important;
    padding: 25px !important; /* Original padding for .accordion-content.show */
}

/* Ensure the details element itself is not being clipped or limited */
.guide-details {
    max-height: none !important; /* Remove any potential max-height limit */
    overflow: visible !important; /* Ensure its own content is visible */
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: .25rem;
    padding: 1rem;
    margin-top: 1rem;
    color: var(--text-color);
}

.guide-details[open] {
    /* Styles for when details is open */
    /* overflow: visible; /* Already set by the rule above */
}

.guide-details summary {
    font-weight: bold;
    cursor: pointer;
    color: var(--primary-dark);
    padding: 0.5rem 0;
    position: relative;
}
.guide-details summary:hover {
    color: var(--primary-light);
}
.guide-details summary::marker {
    color: var(--primary-dark);
}
.guide-details summary:hover::marker {
    color: var(--primary-light);
}

.usage-guide-container .accordion-item .accordion-content details p,
.usage-guide-container .accordion-item .accordion-content details ul {
    margin-bottom: 0.75rem;
    color: var(--text-color);
    font-size: 0.95em;
    line-height: 1.6;
}

.usage-guide-container .accordion-item .accordion-content details ul {
    padding-left: 20px;
    list-style-type: disc;
}
.usage-guide-container .accordion-item .accordion-content details ul li {
    margin-bottom: 0.5rem;
}

.usage-guide-container .accordion-item .accordion-content details p:last-child,
.usage-guide-container .accordion-item .accordion-content details ul:last-child {
    margin-bottom: 0;
}

@keyframes card-entry {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* OCR Modal Styles */
.ocr-modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ocr-modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 1200px;
    border-radius: 15px;
    position: relative;
    background: linear-gradient(135deg, #1f2937, #111827);
    color: #f3f4f6;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

.ocr-modal-content .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0; /* Adjusted for modal */
}

/* Header */
.ocr-modal-content header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.ocr-modal-content header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.ocr-modal-content header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Upload section */
.ocr-modal-content .upload-section {
    margin-bottom: 30px;
}

.ocr-modal-content .upload-area {
    border: 3px dashed #fff;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

.ocr-modal-content .upload-area:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #ffd700;
}

.ocr-modal-content .upload-area.dragover {
    background: rgba(255, 215, 0, 0.2);
    border-color: #ffd700;
}

.ocr-modal-content .upload-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 20px;
    stroke-width: 2;
}

.ocr-modal-content .upload-content p {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.ocr-modal-content .file-info {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Image section */
.ocr-modal-content .image-section {
    background: #1f2937; /* Darker background */
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.ocr-modal-content .image-container {
    position: relative;
    margin-bottom: 20px;
    border-radius: 10px;
    overflow: hidden;
    background: #111827; /* Even darker for canvas parent */
}

.ocr-modal-content #imageCanvas {
    max-width: 100%;
    height: auto;
    display: block;
}

.ocr-modal-content .region-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.ocr-modal-content .region {
    position: absolute;
    border: 3px solid;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(2px);
    pointer-events: auto;
    cursor: move;
}

.ocr-modal-content .resizer {
    position: absolute;
    width: 10px;
    height: 10px;
    background: transparent;
    border: 2px solid #fff;
    z-index: 10;
}

.ocr-modal-content .resizer.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.ocr-modal-content .resizer.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.ocr-modal-content .resizer.se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.ocr-modal-content .resizer.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }

.ocr-modal-content .durability-region {
    border-color: #ff6b35; /* Orange */
}

.ocr-modal-content .awakening-region {
    border-color: #4ecdc4; /* Teal */
}

.ocr-modal-content .region-label {
    position: absolute;
    top: -25px;
    left: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
}

/* Controls */
.ocr-modal-content .controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.ocr-modal-content .btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ocr-modal-content .btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.ocr-modal-content .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.ocr-modal-content .btn-secondary {
    background: #6c757d;
    color: white;
}

.ocr-modal-content .btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.ocr-modal-content .btn:disabled {
    background-color: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Results section */
.ocr-modal-content .results-section {
    background: #1f2937;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.ocr-modal-content .result-card h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.4em;
    color: #cbd5e0;
    border-bottom: 2px solid #4a5568;
    padding-bottom: 10px;
}

.ocr-modal-content .result-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.ocr-modal-content .result-item-header {
    border-bottom: 1px solid #4a5568;
    padding-bottom: 8px;
    margin-top: 15px;
}

.ocr-modal-content .result-item-header h4 {
    margin: 0;
    color: #e2e8f0;
    font-size: 1.2em;
}

.ocr-modal-content .result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #2d3748;
    padding: 15px;
    border-radius: 6px;
}

.ocr-modal-content .result-item label {
    font-weight: 600;
    color: #cbd5e0;
    min-width: 80px;
}

.ocr-modal-content .result-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #9f7aea;
    min-width: 60px;
}

.ocr-modal-content .confidence {
    font-size: 0.9rem;
    color: #9ca3af;
    margin-left: auto;
}

.ocr-modal-content .preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background-color: #2d3748;
    padding: 15px;
    border-radius: 6px;
    margin-top: 5px;
}

.ocr-modal-content .preview-container canvas {
    border: 1px solid #4a5568;
    background-color: #1a202c;
    border-radius: 4px;
}

.ocr-modal-content .preview-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-size: 0.9em;
    width: 100%;
}

.ocr-modal-content .preview-controls label {
    color: #a0aec0;
}

.ocr-modal-content .preview-controls input[type="range"] {
    width: 100px;
}

/* Progress section */
.ocr-modal-content .progress-section {
    margin-top: 20px;
    text-align: center;
}

.ocr-modal-content .progress-bar {
    width: 100%;
    height: 8px;
    background: #4a5568;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.ocr-modal-content .progress-fill {
    height: 100%;
    background: linear-gradient(45deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

.ocr-modal-content #progressText {
    color: #cbd5e0;
    font-weight: 500;
}

.ocr-modal-content .ocr-actions {
    text-align: center;
    margin-top: 20px;
}


/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.upload-button {
    color: #ffffff !important; /* 文字色を白に */
    background-color: var(--primary-light) !important; /* 背景色をアクセントカラーに */
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

.upload-button:hover {
    background-color: var(--neon-glow-strong) !important;
    transform: translateY(-2px);
}

.ocr-warning {
    font-size: 0.8em;
    color: var(--medium-grey);
    margin-top: 10px;
    text-align: center;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

.ocr-instructions-box {
    margin: 20px auto;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.2);
    border-left: 4px solid var(--primary-light);
    border-radius: 4px;
    max-width: 90%;
    color: var(--background-light);
}

.ocr-instructions-box h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.ocr-instructions-box ol {
    margin: 0;
    padding-left: 20px;
    font-size: 0.9em;
    line-height: 1.6;
}

.ocr-instructions-box ol li {
    margin-bottom: 5px;
}

.ocr-instructions-box ol li:last-child {
    margin-bottom: 0;
}

.ocr-modal-content .results-section {
    padding: 20px;
    margin-top: 20px;
}