/* ============================================
   PLATEAU-2D スタイルシート（UI改善版）
   ============================================ */

/* ------------------------------
   基本スタイル
   ------------------------------ */
   body { 
    margin: 0; 
    padding: 0; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f0f2f5;
}

/* ------------------------------
   レイアウトコンテナ
   ------------------------------ */
#container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ------------------------------
   地図エリア
   ------------------------------ */
#map { 
    flex: 1;
    min-height: 40vh; /* 2Dビューを大きくするため地図を縮小 */
}

/* ------------------------------
   2D投影ビューエリア（拡大）
   ------------------------------ */
#projection-view {
    height: 450px; /* 350px → 450px に拡大 */
    background: linear-gradient(to top, #d2e9f3, #ffffff 60%);
    border-top: 2px solid #b0c4de;
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: 0 -4px 8px rgba(0,0,0,0.05);
    cursor: pointer;
    /* ピクセルアート最適化 */
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
}

#projection-canvas {
    position: absolute;
    top: 0;
    left: 0;
    /* ピクセルパーフェクトレンダリング */
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
}

/* ------------------------------
   操作説明オーバーレイ（2Dビュー右上）
   ------------------------------ */
#controls-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.4;
    z-index: 15;
    max-width: 250px;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

#controls-overlay .title {
    font-weight: bold;
    margin-bottom: 8px;
    color: #FFD700;
    border-bottom: 1px solid rgba(255,255,255,0.3);
    padding-bottom: 4px;
}

#controls-overlay .control-group {
    margin-bottom: 6px;
}

#controls-overlay .control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

#controls-overlay .key {
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 11px;
    min-width: 20px;
    text-align: center;
}

/* ------------------------------
   デリバリーアイテム対応表（2Dビュー左上）
   ------------------------------ */
#delivery-items-guide {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(255,255,255,0.9));
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    z-index: 15;
    min-width: 200px;
    backdrop-filter: blur(10px);
    box-shadow: 0 3px 12px rgba(0,0,0,0.15);
    border: 2px solid rgba(255,107,107,0.3);
    display: none; /* 初期状態で非表示 */
}

#delivery-items-guide .title {
    font-weight: bold;
    margin-bottom: 10px;
    color: #ff6b6b;
    text-align: center;
    border-bottom: 1px solid rgba(255,107,107,0.3);
    padding-bottom: 6px;
}

.delivery-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: rgba(255,107,107,0.1);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.delivery-item:hover {
    background: rgba(255,107,107,0.2);
    transform: scale(1.02);
}

.delivery-item .icon {
    font-size: 18px;
    margin-right: 8px;
}

.delivery-item .name {
    flex: 1;
    font-weight: 500;
    color: #333;
}

.delivery-item .controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.delivery-item .key-btn {
    background: #007cbf;
    color: white;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

.delivery-item .gamepad-btn {
    background: #4CAF50;
    color: white;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

/* ------------------------------
   情報パネル
   ------------------------------ */
#info-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    max-width: 300px;
    backdrop-filter: blur(10px);
}

#info-panel strong {
    color: #005a9e;
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
}

#info-panel .status {
    color: #555;
    line-height: 1.4;
}

/* ------------------------------
   地図マーカー
   ------------------------------ */

   .maplibregl-marker-start, 
.maplibregl-marker-goal {
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    white-space: nowrap;
}

.maplibregl-marker-start {
    background-color: #007cbf;
}

.maplibregl-marker-goal {
    background-color: #d32f2f;
}

.maplibregl-marker-start,
.maplibregl-marker-goal {
    animation: markerPulse 2s ease-in-out infinite;
}

@keyframes markerPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

/* プレイヤーマーカー */
.player-marker {
    animation: playerPulse 1.5s ease-in-out infinite;
}

/* プレイヤーマーカーのアニメーション */
@keyframes playerPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 5px 10px rgba(255, 107, 107, 0.5);
    }
}

/* ------------------------------
   スクロールバースタイル
   ------------------------------ */
#projection-view::-webkit-scrollbar {
    height: 8px;
}

#projection-view::-webkit-scrollbar-track {
    background: rgba(176, 196, 222, 0.3);
    border-radius: 4px;
}

#projection-view::-webkit-scrollbar-thumb {
    background: rgba(107, 122, 143, 0.6);
    border-radius: 4px;
}

#projection-view::-webkit-scrollbar-thumb:hover {
    background: rgba(107, 122, 143, 0.8);
}

/* ------------------------------
   レスポンシブデザイン
   ------------------------------ */
@media (max-width: 768px) {
    #container {
        flex-direction: column;
    }
    
    #map {
        min-height: 35vh;
    }
    
    #projection-view {
        height: 350px; /* モバイルでは少し小さく */
    }
    
    #info-panel {
        font-size: 12px;
        padding: 10px 14px;
    }
    
    #controls-overlay {
        font-size: 11px;
        padding: 10px 12px;
        max-width: 200px;
    }
    
    #delivery-items-guide {
        font-size: 12px;
        padding: 10px 12px;
        min-width: 180px;
    }
}

/* ------------------------------
   ローディングインジケーター
   ------------------------------ */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.loading-indicator.active {
    display: block;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 124, 191, 0.3);
    border-top: 4px solid #007cbf;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}