/* ==========================================
   GeoDetective - スタイルシート
   ========================================== */

:root {
    /* カラーパレット */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-panel: rgba(30, 30, 50, 0.85);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --border-color: rgba(255, 255, 255, 0.1);

    /* サイズ */
    --header-height: 60px;
    --panel-width: 360px;
    --border-radius: 12px;
    --border-radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

/* ==========================================
   ヘッダー
   ========================================== */

#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
}

#header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#score-display {
    font-size: 1.25rem;
    font-weight: 600;
}

#current-score {
    color: var(--accent-success);
    font-size: 1.5rem;
}

#timer-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 20px;
}

#timer-label {
    font-size: 0.9rem;
    color: #888;
}

#timer-display {
    font-size: 1.25rem;
    font-weight: 600;
    background: #f0f0ff;
    border: 2px solid var(--accent-primary);
    border-radius: 8px;
    padding: 6px 12px;
    width: 80px;
    text-align: center;
}

#remaining-time {
    color: #6366f1;
    font-size: 1.5rem;
    font-weight: 700;
}

#timer-display.warning {
    background: #fee2e2;
    border-color: #ef4444;
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ==========================================
   メインレイアウト
   ========================================== */

#main {
    display: flex;
    height: 100vh;
    padding-top: var(--header-height);
}

#map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* タイムラインサイドバー（地図上にオーバーレイ） */
#timeline-sidebar {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    background: rgba(26, 26, 46, 0.85);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 500;
    transform: translateX(100%);
}

#timeline-sidebar.expanded {
    transform: translateX(0);
}

#timeline-sidebar .timeline-toggle {
    position: absolute;
    left: -40px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 60px;
    background: rgba(26, 26, 46, 0.85);
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    z-index: 10;
}

#timeline-sidebar .timeline-toggle:hover {
    background: var(--accent-primary);
}

#timeline-sidebar .timeline-content-wrapper {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

#timeline-sidebar.collapsed .timeline-content-wrapper {
    opacity: 0;
    pointer-events: none;
}

#timeline-sidebar h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* 回答ボタン（フローティング） */
.btn-submit-floating {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    padding: 16px 32px;
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #10b981, #34d399);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
    transition: all 0.2s ease;
}

.btn-submit-floating:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(16, 185, 129, 0.5);
}

.btn-submit-floating:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #6b7280;
    box-shadow: none;
}

/* ==========================================
   サイドパネル
   ========================================== */

#side-panel {
    width: var(--panel-width);
    background: var(--bg-secondary);
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    z-index: 600;
}

.panel {
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 16px;
}

.panel h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ==========================================
   ボタン
   ========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn.loading {
    cursor: wait;
    opacity: 0.7;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.7;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 0.7;
    }
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
}

/* 難易度セレクター */
.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0;
}

.difficulty-selector label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.difficulty-selector select {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.difficulty-selector select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.difficulty-selector select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.info-link {
    display: block;
    font-size: 0.8rem;
    color: var(--accent-secondary);
    text-decoration: none;
    margin-bottom: 8px;
}

.info-link:hover {
    text-decoration: underline;
}

.btn-query {
    width: 100%;
    margin-top: 8px;
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-secondary);
    border: 1px solid var(--accent-primary);
}

.btn-query:hover:not(:disabled) {
    background: rgba(99, 102, 241, 0.3);
}

.btn-query.active {
    background: var(--accent-primary);
    color: white;
}

/* ==========================================
   クエリアイテム
   ========================================== */

.query-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.query-item:last-child {
    border-bottom: none;
}

.query-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.query-name {
    font-weight: 600;
    flex: 1;
}

.query-cost {
    font-size: 0.75rem;
    color: var(--accent-warning);
    background: rgba(245, 158, 11, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
}

.query-limit {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.query-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.query-inputs {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.query-inputs select,
.query-inputs input {
    flex: 1;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
}

.query-inputs input[type="number"] {
    width: 80px;
    flex: none;
}

.query-inputs span {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* スライダー */
.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-container input[type="range"] {
    flex: 1;
    height: 20px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    outline: none;
    border: none;
}

.slider-container input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    margin-top: -6px;
}

.slider-container input[type="range"]::-moz-range-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

.slider-container span {
    min-width: 60px;
    text-align: right;
    font-weight: 600;
}

/* ==========================================
   タイムライン
   ========================================== */

.timeline-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    background: rgba(30, 30, 50, 0.9);
    border-radius: 0;
    border-left: 3px solid var(--accent-primary);
}

.timeline-item .timeline-type {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-secondary);
    margin-bottom: 4px;
}

.timeline-item .timeline-result {
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.timeline-item.visible-true {
    border-left-color: var(--accent-success);
}

.timeline-item.visible-false {
    border-left-color: var(--accent-danger);
}

/* ==========================================
   モーダル
   ========================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 24px;
    min-width: 320px;
    max-width: 480px;
}

.modal-content h3 {
    font-size: 1.25rem;
    margin-bottom: 16px;
}

#modal-body {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

#modal-body .result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-success);
    display: block;
    margin: 8px 0;
}

/* ==========================================
   結果パネル
   ========================================== */

#result-content {
    text-align: center;
}

.result-score {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-success), #34d399);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-distance {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin: 8px 0;
}

.result-breakdown {
    text-align: left;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.result-breakdown dt {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.result-breakdown dd {
    font-weight: 600;
    margin-bottom: 8px;
}

/* ==========================================
   ゲームメッセージ
   ========================================== */

#game-message {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* ==========================================
   レスポンシブ
   ========================================== */

@media (max-width: 768px) {
    #side-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        max-height: 50vh;
        border-radius: var(--border-radius) var(--border-radius) 0 0;
        z-index: 1000;
    }

    #map-container {
        height: calc(100vh - var(--header-height));
    }
}

/* ==========================================
   Leaflet カスタム
   ========================================== */

.leaflet-container {
    background: #ffffff;
}

.leaflet-control-zoom a {
    background: var(--bg-panel) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-secondary) !important;
}