:root {
    /* カラーパレット */
    --bg-color: #040714;
    --panel-bg: rgba(11, 17, 36, 0.75);
    --panel-bg-solid: rgba(11, 17, 36, 0.95);
    --border-color: rgba(245, 158, 11, 0.25);
    --border-hover: rgba(245, 158, 11, 0.6);
    --text-color: #f8fafc;
    --text-muted: #94a3b8;

    --accent-venus: #fbbf24;      /* 金星の金・イエローゴールド */
    --accent-ground: #38bdf8;     /* 地上・夕暮れのブルー */
    --accent-space: #ec4899;      /* 宇宙・マゼンタ・ローズ */
    --accent-sun: #f59e0b;        /* 太陽のアンバーオレンジ */
    --accent-reticle: #10b981;    /* 望遠鏡HUDの蛍光グリーン/シアン */

    --glow-venus: rgba(251, 191, 36, 0.35);
    --glow-ground: rgba(56, 189, 248, 0.25);
    --glow-space: rgba(236, 72, 153, 0.25);

    /* タイポグラフィ */
    --font-family: 'Noto Sans JP', sans-serif;
    --font-display: 'Orbitron', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* トランジション */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* リセット */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 15% 15%, rgba(245, 158, 11, 0.12) 0px, transparent 50%),
        radial-gradient(at 85% 85%, rgba(236, 72, 153, 0.1) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(56, 189, 248, 0.05) 0px, transparent 60%),
        linear-gradient(180deg, #02040b 0%, #080d21 100%);
    color: var(--text-color);
    font-family: var(--font-family);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 16px 24px 40px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ヘッダー */
header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 18px;
    position: relative;
}

.header-left {
    justify-self: start;
}

.header-right {
    justify-self: end;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 8px 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all var(--transition-fast);
}

.back-link:hover {
    color: #ffffff;
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--accent-venus);
}

.header-center {
    text-align: center;
}

h1 {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 3.8vw, 2.2rem);
    font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #ffffff, #fde68a, #f59e0b, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 16px rgba(245, 158, 11, 0.35));
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 0.5px;
}

/* メインレイアウト */
.main-layout {
    display: flex;
    flex-direction: column;
    gap: 18px;
    flex: 1;
}

/* 2画面 3D ビューポート */
.dual-viewport-container {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 18px;
    width: 100%;
}

.viewport-box {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.55);
    position: relative;
    transition: border-color var(--transition-normal);
}

.viewport-box:hover {
    border-color: var(--border-hover);
}

.viewport-header {
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
}

.view-tag {
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.ground-tag {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-ground);
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.space-tag {
    background: rgba(236, 72, 153, 0.15);
    color: var(--accent-space);
    border: 1px solid rgba(236, 72, 153, 0.35);
}

.direction-indicator,
.space-legend {
    color: var(--text-muted);
    font-size: 0.78rem;
    display: flex;
    gap: 10px;
}

.legend-earth { color: #38bdf8; font-weight: 600; }
.legend-sun { color: #fbbf24; font-weight: 600; }
.legend-venus { color: #f472b6; font-weight: 600; }

.canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #02040a;
    overflow: hidden;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* 地上ビュー 方角ラベル */
.compass-label {
    position: absolute;
    bottom: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.65);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    pointer-events: none;
    user-select: none;
    z-index: 5;
}

.compass-sw { left: 10px; color: #93c5fd; }
.compass-w { left: 50%; transform: translateX(-50%); color: #fde047; }
.compass-nw { right: 10px; color: #fca5a5; }

/* 肉眼注記バッジ */
.naked-eye-callout {
    position: absolute;
    bottom: 38px;
    left: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: #fde68a;
    font-size: 0.75rem;
    pointer-events: none;
    user-select: none;
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease;
    z-index: 5;
}

/* 望遠鏡 HUD 丸窓（シンプル版） */
.telescope-hud-container {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 130px;
    z-index: 10;
    pointer-events: none;
    user-select: none;
}

.telescope-lens-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: radial-gradient(circle at center, #020612 0%, #000000 85%);
    border: 2px solid rgba(16, 185, 129, 0.6);
    box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.95), 0 0 8px rgba(16, 185, 129, 0.2);
    overflow: hidden;
}

#telescope-canvas {
    width: 100%;
    height: 100%;
    display: block;
    transition: filter 0.3s ease, opacity 0.3s ease;
}

/* 太陽裏・観測不能時のグレーアウトオーバーレイ */
.telescope-disabled-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(30, 41, 59, 0.78);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.telescope-disabled-overlay .disabled-icon {
    font-size: 1.1rem;
    color: #ef4444;
    font-weight: bold;
    line-height: 1;
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

.telescope-disabled-overlay .disabled-text {
    font-size: 0.65rem;
    color: #cbd5e1;
    text-align: center;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* 観測不能状態の適用スタイル */
.telescope-hud-container.is-occluded .telescope-lens-frame {
    border-color: rgba(148, 163, 184, 0.4);
    box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.95), 0 0 6px rgba(100, 116, 139, 0.3);
}

.telescope-hud-container.is-occluded #telescope-canvas {
    filter: grayscale(100%) brightness(0.35);
    opacity: 0.3;
}

.telescope-hud-container.is-occluded .telescope-disabled-overlay {
    opacity: 1;
}

.telescope-hud-container.is-occluded .hud-caption {
    color: rgba(148, 163, 184, 0.7);
}

/* 丸窓下のキャプション（視直径 / 輝面比） */
.hud-caption {
    text-align: center;
    margin-top: 4px;
    font-size: 0.68rem;
    font-family: var(--font-mono);
    color: rgba(52, 211, 153, 0.85);
    transition: color 0.3s ease;
}


/* 宇宙ビュー HUD */
.space-hud {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
    z-index: 5;
}

.space-label {
    background: rgba(15, 23, 42, 0.7);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
}

.venus-dist-label {
    color: #f472b6;
    border: 1px solid rgba(244, 114, 182, 0.45);
}

/* コントロールセクション */
.controls-section {
    width: 100%;
}

.slider-control-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 18px 24px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.slider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.slider-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.slider-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-color);
    letter-spacing: 0.5px;
}

.play-btn {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fde68a;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition-fast);
}

.play-btn:hover {
    background: rgba(245, 158, 11, 0.3);
    border-color: var(--accent-venus);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.phase-display-badge {
    font-family: var(--font-display), var(--font-family);
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.5);
    color: #fbbf24;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.92rem;
    font-weight: 700;
    box-shadow: 0 0 14px rgba(251, 191, 36, 0.2);
}

/* スライダー本体 */
.slider-wrapper {
    position: relative;
    width: 100%;
    padding: 8px 0 22px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    background: linear-gradient(90deg, #f59e0b 0%, #ec4899 50%, #38bdf8 100%);
    border-radius: 6px;
    outline: none;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6), 0 0 8px rgba(245, 158, 11, 0.25);
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #fbbf24 60%, #b45309 100%);
    border: 2px solid #ffffff;
    box-shadow: 0 0 14px rgba(251, 191, 36, 0.8), 0 2px 6px rgba(0, 0, 0, 0.6);
    cursor: grab;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 20px rgba(251, 191, 36, 1), 0 2px 8px rgba(0, 0, 0, 0.7);
}

input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.25);
}

.slider-ticks {
    position: relative;
    width: 100%;
    height: 24px;
    margin-top: 8px;
}

.tick {
    position: absolute;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--transition-fast);
}

.tick:hover {
    color: var(--accent-venus);
}

/* クイックジャンプボタン */
.quick-buttons-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 12px;
}

.quick-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-family);
    transition: all var(--transition-fast);
}

.quick-btn:hover {
    background: rgba(245, 158, 11, 0.15);
    color: #ffffff;
    border-color: rgba(245, 158, 11, 0.4);
    transform: translateY(-1px);
}

.quick-btn.active {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.3) 0%, rgba(236, 72, 153, 0.3) 100%);
    border-color: var(--accent-venus);
    color: #ffffff;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.35);
}

/* リアルタイム天体データグリッド */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    width: 100%;
}

.metric-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.metric-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-value-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.metric-value {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 800;
    color: #fde68a;
    letter-spacing: 0.5px;
}

.metric-unit {
    font-size: 0.82rem;
    color: var(--accent-venus);
    font-weight: 600;
}

.metric-sub {
    font-size: 0.72rem;
    color: #94a3b8;
    font-family: var(--font-mono);
}

/* 解説セクション */
.explanation-section {
    width: 100%;
}

.explanation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.info-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 10px;
}

.card-icon {
    font-size: 1.3rem;
}

.info-card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
}

.info-card-body {
    font-size: 0.9rem;
    line-height: 1.65;
    color: #cbd5e1;
}

.info-card-body p {
    margin-bottom: 8px;
}

.info-card-body p:last-child {
    margin-bottom: 0;
}

.info-card-body strong {
    color: #ffffff;
}

.info-card-body .highlight-venus {
    color: #fde68a;
    font-weight: 700;
}

.info-card-body .highlight-key {
    color: #38bdf8;
    font-weight: 600;
}

/* フッター */
footer {
    text-align: center;
    padding: 24px 0 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* レスポンシブ (タブレット・スマホ) */
@media (max-width: 1024px) {
    .app-container {
        padding: 12px 16px 24px;
    }

    header {
        margin-bottom: 12px;
    }

    .main-layout {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }

    /* ビューポートコンテナの階層を解除し、各子要素の並び順を制御 */
    .dual-viewport-container {
        display: contents;
    }

    /* ① 地上視点ビュー */
    .ground-box {
        order: 1;
        width: 100%;
    }

    /* ② 操作コントロールエリア（地上視点と宇宙視点の中間に配置） */
    .controls-section {
        order: 2;
        width: 100%;
    }

    .slider-control-card {
        padding: 14px 18px;
        gap: 10px;
    }

    .slider-wrapper {
        padding: 6px 0 18px;
    }

    /* ③ 宇宙視点ビュー */
    .space-box {
        order: 3;
        width: 100%;
    }

    /* ④ リアルタイム天体データ */
    .metrics-grid {
        order: 4;
        width: 100%;
        grid-template-columns: repeat(2, 1fr);
    }

    /* ⑤ 解説パネル */
    .explanation-section {
        order: 5;
        width: 100%;
    }

    .explanation-grid {
        grid-template-columns: 1fr;
    }

    .canvas-wrapper {
        aspect-ratio: 16 / 9;
    }
}

@media (max-width: 640px) {
    .telescope-hud-container {
        width: 170px;
        padding: 6px 8px;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .slider-ticks .tick:nth-child(2) {
        display: none;
    }

    .quick-btn {
        padding: 5px 10px;
        font-size: 0.72rem;
    }
}
