/* ニチモン適性診断 ゲーム用スタイルシート */

:root {
    --bg-dark: #09090e;
    --bg-surface: rgba(18, 18, 28, 0.75);
    --border-neon: rgba(99, 102, 241, 0.3);
    --primary-neon: #6366f1;
    --secondary-neon: #a855f7;
    --warning-neon: #fbbf24;
    --success-neon: #10b981;
    --danger-neon: #ef4444;
    --text-neon: #e0e0ff;
    --text-muted: #8b8ba7;
    --font-cyber: 'Orbitron', 'Noto Sans JP', sans-serif;
}

body.diagnosis-page {
    background: var(--bg-dark);
    color: var(--text-neon);
    font-family: var(--font-cyber);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.08) 0%, transparent 40%);
}

.diag-container {
    max-width: 780px;
    width: 100%;
    margin: 0 auto;
    padding: 0.5rem 1rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 145px); /* PCポータルの下部余白に対応するため引き算を130pxから145pxに拡大 */
    min-height: 0;
    overflow: hidden;
}

/* ヘッダー・ヒーロー */
.diag-hero {
    text-align: center;
    margin-bottom: 0.75rem; /* 余白を2remから0.75remに大幅に圧縮 */
}

.diag-hero h1 {
    font-size: 1.8rem; /* 2.2remから1.8remに少しコンパクト化 */
    font-weight: 900;
    margin: 0.25rem 0;
    background: linear-gradient(135deg, #6366f1, #a855f7, #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(99, 102, 241, 0.2);
    letter-spacing: 2px;
}

.diag-hero p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

/* グラスモーフィズムカード共通 */
.diag-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-neon);
    border-radius: 1.5rem;
    padding: 1.5rem 1.75rem; /* 縦パディングを2.5rem→1.5remに縮小 */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(99, 102, 241, 0.05);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    
    /* 縦幅フィット用のFlex子要素設定 */
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-bottom: 0.5rem;
}

.diag-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-neon), var(--secondary-neon));
}

/* タブナビゲーション */
.diag-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem; /* 1.5remから1remへ縮小 */
}

.tab-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    padding: 0.6rem 1.5rem;
    border-radius: 2rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    transition: all 0.25s ease;
}

.tab-btn:hover {
    color: var(--text-neon);
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.05);
}

.tab-btn.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary-neon), var(--secondary-neon));
    border-color: transparent;
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

/* 診断セクションの制御 */
.diag-tab {
    flex: 1;
    display: none;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden; /* 横スクロールバー防止 */
    padding-right: 0.25rem;
}

.diag-sub-section {
    flex: 1;
    display: none;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden; /* 横スクロールバー防止 */
}

.diag-tab.active, .diag-sub-section.active {
    display: flex;
    animation: fadeIn 0.4s ease forwards;
}

/* 名前入力フォーム */
.form-group {
    margin-bottom: 1.25rem; /* 2remから1.25remに縮小 */
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem; /* 0.75remから0.5remに縮小 */
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-cyber {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1.5px solid rgba(99, 102, 241, 0.2);
    border-radius: 0.75rem;
    padding: 0.8rem 1.1rem; /* 縦パディングを1rem→0.8rem、横を1.2rem→1.1remに縮小 */
    font-size: 1.05rem; /* 1.1remから少しコンパクトに */
    color: #fff;
    font-family: inherit;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.input-cyber:focus {
    outline: none;
    border-color: var(--primary-neon);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3), inset 0 0 10px rgba(99, 102, 241, 0.1);
}

/* トグルスイッチ */
.mode-toggle-container {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.2rem 1.2rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1.25rem; /* 下マージンを2rem→1.25remに縮小 */
}

.mode-toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 0;
}

.mode-toggle-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
}

.mode-info {
    text-align: left;
}

.mode-title {
    font-size: 0.95rem;
    font-weight: 700;
}

.mode-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--success-neon);
    border-color: transparent;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

input:checked + .slider:before {
    transform: translateX(24px);
    background-color: #fff;
    box-shadow: 0 0 10px #fff;
}

/* ボタン */
.btn-cyber {
    background: linear-gradient(135deg, var(--primary-neon), var(--secondary-neon));
    border: none;
    color: #fff;
    font-weight: 700;
    padding: 1.1rem 2.5rem;
    border-radius: 2rem;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-cyber:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5), 0 0 15px rgba(168, 85, 247, 0.3);
}

.btn-cyber:active {
    transform: translateY(-1px);
}

/* 質問エリアの進行バー */
.progress-bar-container {
    background: rgba(255, 255, 255, 0.05);
    height: 6px;
    border-radius: 3px;
    margin-bottom: 1.5rem; /* 2.5remから1.5remへ縮小 */
    overflow: hidden;
}

.progress-fill {
    background: linear-gradient(90deg, var(--primary-neon), var(--secondary-neon));
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.question-counter {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: -1.25rem; /* -2remから-1.25remへ縮小 */
    margin-bottom: 0.75rem; /* 1.5remから0.75remへ縮小 */
    font-weight: 700;
}

/* 質問カード */
.question-title {
    font-size: 1.2rem; /* 1.25remから1.2remへ縮小 */
    line-height: 1.6;
    margin-bottom: 1.25rem; /* 2remから1.25remへ縮小 */
    text-align: left;
    color: #fff;
    font-weight: 800;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* 1remから0.75remへ縮小 */
    overflow: hidden; /* ホバー時の右シフトによる横スクロールバー防止 */
}

.option-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 1rem;
    padding: 0.9rem 1.2rem; /* 1.2rem 1.5remから0.9rem 1.2remへ縮小 */
    text-align: left;
    color: var(--text-neon);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.option-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: transparent;
    transition: background-color 0.25s ease;
}

@media (hover: hover) {
    .option-btn:hover {
        background: rgba(99, 102, 241, 0.04);
        border-color: rgba(99, 102, 241, 0.3);
        color: #fff;
        transform: translateX(4px);
    }
    .option-btn:hover::before {
        background: var(--primary-neon);
    }
}

/* ローディング・演出アニメーション */
.loading-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 0;
}

.scanner-box {
    position: relative;
    width: 140px;
    height: 140px;
    border: 2px dashed rgba(99, 102, 241, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    animation: rotate 10s linear infinite;
}

.scanner-inner {
    width: 100px;
    height: 100px;
    border: 3px solid var(--secondary-neon);
    border-radius: 50%;
    background: rgba(168, 85, 247, 0.05);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.2);
    position: relative;
}

.scanner-line {
    position: absolute;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, #fbbf24, transparent);
    top: 50%;
    animation: scan 2s ease-in-out infinite;
    box-shadow: 0 0 10px #fbbf24;
}

.loading-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--warning-neon);
    letter-spacing: 1.5px;
    margin-bottom: 0.5rem;
}

.loading-subtext {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* 診断結果画面 */
.result-header {
    text-align: center;
    margin-bottom: 1rem; /* 2.5remから1remへ縮小 */
}

.result-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.result-monster-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 0.25rem; /* 0.5remから0.25remへ縮小 */
}

.result-emoji {
    font-size: 3rem; /* 4remから3remへ縮小 */
    margin-bottom: 0.5rem; /* 1remから0.5remへ縮小 */
    animation: bounce 2s infinite ease-in-out;
}

.result-name {
    font-size: 1.6rem; /* 2remから1.6remへ縮小 */
    font-weight: 900;
    color: #fff;
    margin-bottom: 0.25rem; /* 0.5remから0.25remへ縮小 */
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.rarity-tag {
    font-size: 0.75rem;
    font-weight: 900;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    letter-spacing: 1px;
}

.rarity-tag.N { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #fff; }
.rarity-tag.R { background: rgba(16,185,129,0.15); border: 1px solid var(--success-neon); color: var(--success-neon); }
.rarity-tag.SR { background: rgba(168,85,247,0.15); border: 1px solid var(--secondary-neon); color: var(--secondary-neon); }
.rarity-tag.UR { background: rgba(251,191,36,0.15); border: 1px solid var(--warning-neon); color: var(--warning-neon); box-shadow: 0 0 10px rgba(251,191,36,0.3); }

/* 結果レイアウト (2カラム) */
.result-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 1.5rem; /* 2.5remから1.5remへ縮小 */
    align-items: center;
    margin-bottom: 1.25rem; /* 2.5remから1.25remへ縮小 */
}

.result-chart-area {
    width: 100%;
    display: flex;
    justify-content: center;
}

.result-chart-wrapper {
    position: relative;
    width: 220px; /* 250pxから220pxへ縮小して縦幅を節約 */
    height: 220px;
}

.result-description-area {
    text-align: left;
}

.result-description-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--primary-neon);
    margin-bottom: 0.5rem; /* 0.75remから0.5remへ縮小 */
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
    padding-bottom: 0.25rem; /* 0.5remから0.25remへ縮小 */
}

.result-desc {
    font-size: 0.9rem; /* 0.95remから0.9remへ */
    line-height: 1.7; /* 1.8から1.7へ */
    color: var(--text-neon);
    background: rgba(0,0,0,0.2);
    padding: 0.85rem 1rem; /* 1.25remから0.85rem 1remへ縮小 */
    border-radius: 1rem;
    border: 1px solid rgba(255,255,255,0.03);
}

/* 特典/ログイン誘導セクション */
.reward-notice {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.05), rgba(99, 102, 241, 0.05));
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: 1rem;
    padding: 0.75rem 1rem; /* 1.25remから0.75rem 1remへ縮小 */
    margin-bottom: 1.25rem; /* 2remから1.25remへ縮小 */
    text-align: center;
    font-size: 0.85rem;
}

/* シェア＆操作ボタン */
.result-actions {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.btn-share-x {
    background: #000;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: none;
}

.btn-share-x:hover {
    background: #111;
    border-color: #fff;
    box-shadow: 0 0 15px rgba(255,255,255,0.15);
}

/* 図鑑タブ */
.book-stats {
    display: flex;
    justify-content: space-between;
    background: rgba(0,0,0,0.2);
    padding: 1rem 1.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(255,255,255,0.03);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 1rem;
}

.book-item {
    background: rgba(255,255,255,0.02);
    border: 1.5px solid rgba(255,255,255,0.06);
    border-radius: 1rem;
    padding: 1.25rem 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.book-item.locked {
    opacity: 0.4;
    filter: grayscale(1);
}

.book-item.unlocked:hover {
    transform: translateY(-5px);
    border-color: var(--primary-neon);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.2);
}

.book-item-emoji {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
}

.book-item-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-neon);
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-item-rarity {
    font-size: 0.6rem;
    font-weight: 900;
    margin-top: 0.25rem;
    padding: 0.05rem 0.4rem;
    border-radius: 0.2rem;
}

/* 履歴タブ */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.history-item {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: rgba(255,255,255,0.04);
}

.history-left {
    text-align: left;
}

.history-player-name {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.history-monster-info {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-right {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* スクロールバーのカスタマイズ */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.4);
}

/* モーダル表示 */
.diag-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.diag-modal.active {
    display: flex;
    animation: fadeIn 0.3s ease forwards;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-neon);
    border-radius: 1.5rem;
    max-width: 500px;
    width: 100%;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    position: relative;
    animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#modal-ach-title, #m-detail-title {
    color: #fff;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #white;
}

/* アニメーションキーフレーム */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes scan {
    0%, 100% { top: 10%; }
    50% { top: 90%; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* メディアクエリ（スマートフォン対応） */
@media (max-width: 768px) {
    .result-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .diag-card {
        padding: 1.5rem 1rem;
    }
    
    .diag-hero h1 {
        font-size: 1.8rem;
    }
    
    .btn-cyber {
        width: 100%;
        justify-content: center;
    }
}

/* リアルタイムスコアパネル */
.realtime-score-container {
    display: flex;
    justify-content: space-around;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.realtime-meter {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 80px;
}

.meter-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.meter-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.3rem;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.meter-fill {
    height: 100%;
    width: 0%;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px currentColor;
}

.meter-fill.lazy { background-color: #6366f1; color: rgba(99, 102, 241, 0.5); }
.meter-fill.chaos { background-color: #ec4899; color: rgba(236, 72, 153, 0.5); }
.meter-fill.waste { background-color: #fbbf24; color: rgba(251, 191, 36, 0.5); }
.meter-fill.sensitive { background-color: #10b981; color: rgba(16, 185, 129, 0.5); }

.meter-val {
    font-size: 0.85rem;
    font-weight: 900;
    color: #fff;
}

/* 獲得スコアの数値表示 (結果画面) */
.scores-detail-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 1rem;
    padding: 0.85rem 1rem; /* 1.25remから0.85rem 1remへ縮小 */
    margin-top: 1rem; /* 1.5remから1remへ縮小 */
    margin-bottom: 1rem; /* 1.5remから1remへ縮小 */
}

.scores-detail-title {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--warning-neon);
    margin-bottom: 0.5rem; /* 0.75remから0.5remへ縮小 */
    text-align: center;
    letter-spacing: 1px;
}

.scores-detail-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.score-detail-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1.5px solid rgba(255, 255, 255, 0.05);
    border-radius: 0.75rem;
    padding: 0.5rem 0.75rem; /* 0.75remから0.5rem 0.75remへ縮小 */
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.score-detail-item span {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
}

.score-detail-item strong {
    font-size: 1.15rem;
    font-weight: 900;
    color: #fff;
}

@media (max-width: 600px) {
    .scores-detail-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- AdSense 広告のレイアウトと非表示制御 --- */
.diag-ad-wrapper {
    width: 100%;
    min-width: 250px;
    min-height: 90px;
    max-height: 100px;
    margin: 0.25rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
}

.diag-ad-wrapper ins.adsbygoogle {
    display: inline-block !important;
    width: 100% !important;
    height: 90px !important;
}

/* 診断中（#question-section）およびスキャン中（#loading-section）がアクティブな時は、
   親要素である .diag-card の兄弟要素である #diag-ad-container を完全に非表示にして表示領域を最大化 */
.diag-card:has(#question-section.active) ~ #diag-ad-container,
.diag-card:has(#loading-section.active) ~ #diag-ad-container {
    display: none !important;
}

/* ポータルへ戻るボタンのスタイル */
.diag-back-link-area {
    text-align: center;
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.btn-cyber-back {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.75rem;
    padding: 0.4rem 1.2rem;
    color: var(--text-muted);
    border-radius: 2rem;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
}

.btn-cyber-back:hover {
    color: #fff;
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.05);
}

/* --- スマホ向けの極限レスポンシブ最適化 --- */
@media (max-width: 600px) {
    .diag-hero {
        display: none !important; /* スマホでは巨大ロゴを非表示にして縦スペースを最優先 */
    }
    
    .diag-container {
        padding: 0.25rem 0.5rem;
        height: calc(100dvh - 125px); /* ヘッダー・フッターに完璧フィット */
    }
    
    .diag-card {
        padding: 1rem 0.85rem; /* 余白を最小化 */
        border-radius: 1rem;
    }
    
    .diag-tabs {
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }
    
    .tab-btn {
        padding: 0.4rem 0.85rem;
        font-size: 0.75rem;
    }
    
    /* 質問カードのスマホ圧縮 */
    .question-title {
        font-size: 1.05rem;
        line-height: 1.5;
        margin-bottom: 1.25rem;
    }
    
    .option-btn {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
        border-radius: 0.75rem;
    }
    
    .options-list {
        gap: 0.6rem;
    }
    
    .progress-bar-container {
        margin-bottom: 1.25rem;
    }
    
    .question-counter {
        margin-top: -1rem;
        margin-bottom: 0.5rem;
    }
    
    /* リアルタイムスコアメーターのスマホ圧縮 */
    .realtime-score-container {
        padding: 0.4rem 0.5rem !important;
        margin-bottom: 0.85rem !important;
        gap: 0.4rem !important;
    }
    
    .realtime-meter {
        flex-direction: column;
        align-items: center;
        gap: 0.1rem !important;
    }
    
    .realtime-meter .meter-label {
        font-size: 0.65rem !important;
        width: auto !important;
        line-height: 1;
    }
    
    .realtime-meter .meter-bar {
        height: 3px !important;
        width: 50px !important;
    }
    
    .realtime-meter .meter-val {
        font-size: 0.75rem !important;
        line-height: 1;
    }
    
    /* 診断結果画面のスマホ最適化 */
    .result-header {
        margin-bottom: 1.5rem;
    }
    
    .result-emoji {
        font-size: 3rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .result-name {
        font-size: 1.5rem !important;
    }
    
    .result-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .result-chart-wrapper {
        max-width: 180px;
        margin: 0 auto;
    }
    
    .result-desc {
        font-size: 0.85rem !important;
        line-height: 1.6 !important;
    }
    
    .scores-detail-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }
    
    .score-detail-item {
        padding: 0.5rem !important;
    }
    
    .score-detail-item strong {
        font-size: 1rem !important;
    }
    
    .result-actions {
        flex-direction: column;
        gap: 0.5rem !important;
    }
    
    .result-actions .btn-cyber {
        width: 100%;
        padding: 0.75rem 1.5rem !important;
        font-size: 0.85rem !important;
        justify-content: center;
    }
    
    /* モンスター図鑑・履歴のスマホ調整 */
    .book-stats {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }
    
    .book-grid {
        gap: 0.6rem;
    }

    .book-item-name {
        white-space: normal;
        font-size: 0.65rem;
        line-height: 1.2;
        word-break: break-all;
        height: 2.4em;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ==========================================================================
   ライトテーマ (Light Theme) 上書き設定
   ポータル側のhtmlに .light-theme クラスが付与された場合に適用されます
   ========================================================================== */
html.light-theme {
    /* 配色変数の上書き */
    --bg-dark: #f0f2f5;
    --bg-surface: rgba(255, 255, 255, 0.85);
    --border-neon: rgba(99, 102, 241, 0.25);
    --primary-neon: #4f46e5;
    --secondary-neon: #7c3aed;
    --warning-neon: #d97706;
    --success-neon: #059669;
    --danger-neon: #dc2626;
    --text-neon: #1f2937;
    --text-muted: #4b5563;
}

html.light-theme body.diagnosis-page {
    /* ライトテーマに馴染む薄いグラデーション */
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.04) 0%, transparent 40%);
}

/* カードの陰影を優しく */
html.light-theme .diag-card {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08), 0 0 20px rgba(99, 102, 241, 0.03);
}

/* タブボタン */
html.light-theme .tab-btn {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.08);
}
html.light-theme .tab-btn:hover {
    color: var(--text-neon);
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.03);
}
html.light-theme .tab-btn.active {
    color: var(--primary-neon) !important;
    background: rgba(79, 70, 229, 0.08) !important;
    border-color: var(--primary-neon) !important;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.12) !important;
    font-weight: 800;
}

/* 入力フォーム */
html.light-theme .input-cyber {
    background: rgba(255, 255, 255, 0.9);
    border: 1.5px solid rgba(99, 102, 241, 0.25);
    color: #1f2937;
}
html.light-theme .input-cyber::placeholder {
    color: #9ca3af;
}
html.light-theme .input-cyber:focus {
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.15), inset 0 0 5px rgba(99, 102, 241, 0.05);
}

/* トグルスイッチ周辺 */
html.light-theme .mode-toggle-container {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(0, 0, 0, 0.06);
}
html.light-theme .mode-toggle-divider {
    background: rgba(0, 0, 0, 0.06);
}
html.light-theme .slider {
    background-color: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.12);
}
html.light-theme .slider:before {
    background-color: #9ca3af;
}
html.light-theme input:checked + .slider {
    background-color: var(--success-neon);
    border-color: transparent;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}
html.light-theme input:checked + .slider:before {
    background-color: #fff;
    box-shadow: 0 0 8px #fff;
}

/* 質問タイトル */
html.light-theme .question-title {
    color: #1f2937;
}

/* 選択肢ボタン */
html.light-theme .option-btn {
    background: rgba(0, 0, 0, 0.01);
    border: 1.5px solid rgba(0, 0, 0, 0.06);
    color: var(--text-neon);
}
@media (hover: hover) {
    html.light-theme .option-btn:hover {
        background: rgba(99, 102, 241, 0.03);
        border-color: rgba(99, 102, 241, 0.4);
        color: #000;
    }
}

/* リアルタイムスコアパネル */
html.light-theme .realtime-score-container {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.05);
}
html.light-theme .meter-bar {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.02);
}
html.light-theme .meter-val {
    color: #1f2937;
}

/* 診断結果画面 */
html.light-theme .result-name {
    color: #1f2937;
    text-shadow: none;
}
html.light-theme .result-desc {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.05);
}
html.light-theme .scores-detail-container {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.05);
}
html.light-theme .score-detail-item {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.05);
}
html.light-theme .score-detail-item strong {
    color: #1f2937;
}

/* 図鑑 */
html.light-theme .book-stats {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.05);
}
html.light-theme .book-item {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(0, 0, 0, 0.05);
}
html.light-theme .book-item.locked {
    opacity: 0.5;
}
html.light-theme .book-item-name {
    color: var(--text-neon);
}
html.light-theme .book-item.locked .book-item-name {
    color: var(--text-muted);
}

/* 履歴 */
html.light-theme .history-item {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(0, 0, 0, 0.05);
}
html.light-theme .history-item:hover {
    background: rgba(255, 255, 255, 0.8);
}
html.light-theme .history-monster-info {
    color: #1f2937;
}

/* モーダル */
html.light-theme .modal-content {
    background: #fff;
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 15px 45px rgba(0,0,0,0.15);
}
html.light-theme #modal-ach-title,
html.light-theme #m-detail-title {
    color: #1f2937;
}
html.light-theme #m-detail-desc {
    background: rgba(0, 0, 0, 0.03);
    color: #1f2937;
}
html.light-theme .modal-close:hover {
    color: #000;
}

/* 広告コンテナ */
html.light-theme .diag-ad-wrapper {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.05);
}

/* モンスター画像表示スタイル */
.result-monster-image-wrapper {
    margin: 0.8rem auto 0;
    width: 130px;
    height: 130px;
    border-radius: 1.25rem;
    overflow: hidden;
    border: 2px solid var(--border-neon);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-monster-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.monster-detail-image-wrapper {
    margin: 0 auto 1.25rem;
    width: 160px;
    height: 160px;
    border-radius: 1.5rem;
    overflow: hidden;
    border: 2px solid var(--border-neon);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.25);
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.monster-detail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ライトテーマでの調整 */
html.light-theme .result-monster-image-wrapper,
html.light-theme .monster-detail-image-wrapper {
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* 巨大絵文字デコレーション */
.monster-detail-emoji-wrapper {
    width: 100px;
    height: 100px;
    margin: 0 auto 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border: 2px dashed var(--border-neon);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.1);
}

.monster-detail-emoji-wrapper.large-emoji {
    font-size: 3.5rem;
    animation: pulseGlow 3s infinite alternate;
}

.result-monster-emoji-wrapper {
    width: 90px;
    height: 90px;
    margin: 0.8rem auto 0;
    background: rgba(255, 255, 255, 0.03);
    border: 2px dashed var(--border-neon);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
    animation: pulseGlow 3s infinite alternate;
}

@keyframes pulseGlow {
    from {
        box-shadow: 0 0 10px rgba(99, 102, 241, 0.1);
        border-color: rgba(99, 102, 241, 0.2);
    }
    to {
        box-shadow: 0 0 25px rgba(99, 102, 241, 0.35);
        border-color: var(--primary-neon);
    }
}

/* ライトテーマでの絵文字デコレーション調整 */
html.light-theme .monster-detail-emoji-wrapper,
html.light-theme .result-monster-emoji-wrapper {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

