/* =================================================================
 * Dynamic Vision Test Styles (Final Polish & Dark Mode Fix)
 * =================================================================
 */

/* --- コントローラー (十字キー) --- */
.d-pad-grid {
    display: grid;
    grid-template-columns: 64px 64px 64px;
    grid-template-rows: 64px 64px 64px;
    gap: 8px;
}

.dir-btn {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border-radius: 50% !important;
    transition: all 0.1s;
}

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

/* --- ゲームステージ --- */
#game-card {
    border: none;
}

#dynamic-stage {
    background-color: #212529;
    overflow: hidden;
    cursor: crosshair;
    transition: background-color 0.5s;
}

/* 移動ターゲット */
#moving-target {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
    will-change: transform, top, left;
    z-index: 2;
}

#moving-target svg {
    width: 60%;
    height: 60%;
    fill: #000;
}

/* --- 悪天候モード (Bad Weather) --- */
#dynamic-stage.weather-bad {
    background-color: #343a40;
    background-image:
        repeating-linear-gradient(45deg,
            rgba(255, 255, 255, 0.03),
            rgba(255, 255, 255, 0.03) 1px,
            transparent 1px,
            transparent 10px);
}

/* 悪天候時のターゲット */
#dynamic-stage.weather-bad #moving-target {
    background-color: #6c757d;
    /* 背景をグレーに */
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.1);
    filter: blur(1px);
    /* ぼかし */
    opacity: 0.8;
}

#dynamic-stage.weather-bad #moving-target svg path {
    fill: #212529;
    /* Cの黒い部分を薄く */
}

/* 切れ目を隠すための矩形(rect)の色も背景に合わせる */
#dynamic-stage.weather-bad #moving-target svg rect {
    fill: #6c757d;
}

/* ユーティリティ */
.drop-shadow {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* =================================================================
 * ダークモード対応 & 視認性修正
 * =================================================================
 */

/* --- 背景色の調整 --- */

/* ライトモード (デフォルト) の明示 */
.bg-light,
.card.bg-light {
    background-color: #f8f9fa;
    color: #212529;
}

.bg-white {
    background-color: #ffffff;
    color: #212529;
}

/* ダークモード時の上書き (強制的に暗くする) */
[data-bs-theme="dark"] .bg-light,
[data-bs-theme="dark"] .card.bg-light {
    background-color: #212529 !important;
    /* Dark Gray */
    border-color: #495057 !important;
    color: #e0e0e0 !important;
}

[data-bs-theme="dark"] .bg-white {
    background-color: #343a40 !important;
    /* Slightly lighter Dark Gray */
    border-color: #495057 !important;
    color: #e0e0e0 !important;
}

/* --- テキスト色の調整 --- */
/* ダークモード時、明るい背景用クラスの中にある文字を白くする */
[data-bs-theme="dark"] .bg-light h3,
[data-bs-theme="dark"] .bg-light h5,
[data-bs-theme="dark"] .bg-light h6,
[data-bs-theme="dark"] .bg-light p,
[data-bs-theme="dark"] .bg-light .text-dark,
[data-bs-theme="dark"] .bg-light strong,
[data-bs-theme="dark"] .bg-white h3,
[data-bs-theme="dark"] .bg-white h6,
[data-bs-theme="dark"] .bg-white p,
[data-bs-theme="dark"] .bg-white .text-dark,
[data-bs-theme="dark"] .bg-white strong {
    color: #e0e0e0 !important;
}

[data-bs-theme="dark"] .bg-light .text-muted,
[data-bs-theme="dark"] .bg-white .text-muted {
    color: #adb5bd !important;
}

/* --- テーブルの調整 --- */
[data-bs-theme="dark"] .table {
    --bs-table-color: #e0e0e0;
    --bs-table-bg: transparent;
    border-color: #444;
}

[data-bs-theme="dark"] .table thead th {
    background-color: #333;
    color: #fff;
}

/* --- ボタンの調整 --- */
[data-bs-theme="dark"] .dir-btn.btn-outline-dark {
    color: #e0e0e0;
    border-color: #6c757d;
}

[data-bs-theme="dark"] .dir-btn.btn-outline-dark:hover,
[data-bs-theme="dark"] .dir-btn.btn-outline-dark:active {
    background-color: #495057;
    color: #fff;
    border-color: #f8f9fa;
}

/* --- その他 --- */
[data-bs-theme="dark"] #speed-display {
    color: #ffc107 !important;
}

/* --- 関連ツールリンク (Footer) --- */
.vision-tool-card {
    transition: all 0.2s ease;
}

.vision-tool-card:hover {
    border-color: var(--bs-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
    z-index: 1;
}

/* レスポンシブ調整 */
@media (max-width: 576px) {
    .d-pad-grid {
        grid-template-columns: 50px 50px 50px;
        grid-template-rows: 50px 50px 50px;
        gap: 6px;
    }

    .dir-btn {
        font-size: 1.2rem;
    }

    #game-card .card-body {
        height: 240px !important;
    }

    #moving-target {
        width: 60px !important;
        height: 60px !important;
    }
}