* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    line-height: 1.6;
}

#app {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

header {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 2rem;
}

header h1 {
    font-size: 1.4rem;
    color: #ffd700;
}

#loading-status {
    color: #88ff88;
    font-size: 0.9rem;
    min-width: 400px;
    text-align: right;
    white-space: nowrap;
}

/* ナビゲーション */
.navigation {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid #333;
}

/* ナビゲーション行（1行分） */
.nav-row {
    display: flex;
    gap: 20px;
}

/* ナビゲーショングループ */
.nav-group {
    display: flex;
    gap: 20px;
}

/* フロアタブ */
.floor-tabs {
    display: flex;
    gap: 4px;
    flex: 1;
}

.floor-tab {
    padding: 6px 12px;
    background-color: #2a2a2a;
    color: #888;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}

.floor-tab:hover {
    background-color: #333;
    color: #aaa;
}

.floor-tab.active {
    background-color: #444;
    color: #ffd700;
    font-weight: bold;
}

.floor-tab.building-mode {
    background-color: #2a3a2a;
}

.floor-tab.building-mode.active {
    background-color: #3a5a3a;
    color: #88ff88;
}

.floor-tab.route-mode {
    background-color: #2a2a3a;
}

.floor-tab.route-mode.active {
    background-color: #3a4a5a;
    color: #88ccff;
}

/* ビュータブ */
.view-tabs {
    display: flex;
    gap: 4px;
}

.view-tab {
    padding: 6px 12px;
    background-color: #2a2a2a;
    color: #888;
    border: 1px solid #444;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.85rem;
}

.view-tab:hover {
    background-color: #333;
    color: #aaa;
}

.view-tab.active {
    background-color: #4a4a5a;
    color: #88ccff;
    border-color: #6688aa;
    font-weight: bold;
}

/* メインコンテンツ */
main {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

#canvas-container {
    background-color: #222;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 0;
    min-height: 700px;
    /* 適切な高さに調整 */
    max-width: 100%;
    /* 横スクロール防止 */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* スクロールバー非表示 */
    position: relative;
    /* オーバーレイボタンの配置基準 */
}

/* 編集モード時のオーバーレイボタン */
.edit-overlay-button {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    background-color: #4a3a2a;
    color: #ffd700;
    border: 2px solid #ffd700;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    z-index: 10;
}

.edit-overlay-button:hover {
    background-color: #5a4a3a;
    border-color: #ffdd44;
}

#iso-canvas {
    display: block;
    cursor: pointer;
    max-width: 100%;
    /* Canvas自体も横幅制限 */
    height: auto;
}

/* マップリストパネル（右） */
#map-list-panel {
    background-color: #222;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 12px;
    height: fit-content;
    max-height: 700px;
    display: flex;
    flex-direction: column;
}

/* マップリストナビゲーション */
.map-list-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #444;
    flex-shrink: 0;
}

.map-nav-btn {
    flex: 1;
    padding: 4px 6px;
    background-color: #2a2a2a;
    color: #aaa;
    border: 1px solid #444;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.map-nav-btn:hover:not(:disabled) {
    background-color: #333;
    color: #ffd700;
    border-color: #666;
}

.map-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#map-list {
    font-size: 0.85rem;
    line-height: 1.8;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.map-list-item {
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 3px;
    user-select: text;
}

.map-list-item:hover {
    background-color: #2a2a2a;
}

.map-list-item.current {
    background-color: #4a2a2a;
    color: #ffaa88;
    font-weight: bold;
}

.map-list-item.prev-route {
    color: #FFA500;
    font-style: italic;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #444;
}

.map-list-item.prev-route:hover {
    background-color: #3a2a1a;
    color: #FFD700;
}

.map-list-item.next-route {
    color: #00CED1;
    font-style: italic;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #444;
}

.map-list-item.next-route:hover {
    background-color: #1a3a3a;
    color: #00FFFF;
}

/* 情報パネル（下部） */
#info-panel {
    background-color: #222;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 20px;
    margin-top: 20px;
}

#info-panel h2 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: #ffd700;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
}

#info-content {
    font-size: 0.9rem;
    margin-bottom: 20px;
}

#info-content p {
    margin-bottom: 10px;
}

#info-content .info-section {
    margin-bottom: 15px;
}

#info-content .info-label {
    font-weight: bold;
    color: #aaa;
    margin-bottom: 5px;
}

/* 凡例 */
.legend {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #333;
}

.legend h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: #ffd700;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.legend-box {
    width: 20px;
    height: 20px;
    border: 2px solid #555;
    display: inline-block;
}

.legend-box.current {
    border-color: #d66666;
    border-width: 4px;
    background-color: rgba(196, 68, 68, 0.5);
}

.legend-box.accessible {
    border-color: #66cc66;
    border-width: 3px;
    background-color: rgba(74, 74, 74, 0.3);
    /* グレーの背景 */
}

.legend-box.locked {
    border-color: #666;
    background-color: rgba(100, 100, 100, 0.3);
    opacity: 0.5;
}

.legend-box.yellow {
    background-color: #9a8650;
}

.legend-box.green {
    background-color: #5a7a5a;
}

/* 右側コントロール */
.right-controls {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

/* 接続表示コントロール */
.connection-controls {
    display: flex;
    gap: 4px;
}

.connection-tab {
    padding: 6px 12px;
    background-color: #2a2a2a;
    color: #888;
    border: 1px solid #444;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.85rem;
}

.connection-tab:hover {
    background-color: #333;
    color: #aaa;
}

.connection-tab.active {
    background-color: #3a4a3a;
    color: #88ff88;
    border-color: #66aa66;
    font-weight: bold;
}

/* テクスチャモード切り替え */
.texture-controls {
    display: flex;
    gap: 4px;
}

.texture-tab {
    padding: 6px 12px;
    background-color: #2a2a2a;
    color: #888;
    border: 1px solid #444;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.85rem;
}

.texture-tab:hover {
    background-color: #333;
    color: #aaa;
}

.texture-tab.active {
    background-color: #4a3a4a;
    color: #ff88ff;
    border-color: #aa66aa;
    font-weight: bold;
}

/* 曲線アルゴリズム切り替え */
.curve-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.curve-label {
    font-size: 0.75rem;
    color: #888;
    padding: 0 8px;
    user-select: none;
}

.curve-tab {
    padding: 6px 12px;
    background-color: #2a2a2a;
    color: #888;
    border: 1px solid #444;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.85rem;
}

.curve-tab:hover {
    background-color: #333;
    color: #aaa;
}

.curve-tab.active {
    background-color: #3a3a4a;
    color: #ffcc88;
    border-color: #aa8866;
    font-weight: bold;
}

/* 右側ボタン共通スタイル */
.right-controls .edit-button,
.right-controls .scale-toggle-btn {
    padding: 4px 8px;
    background-color: #2a2a2a;
    color: #888;
    border: 1px solid #444;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.75rem;
}

.right-controls .edit-button:hover,
.right-controls .scale-toggle-btn:hover {
    background-color: #333;
    color: #aaa;
}

.right-controls .edit-button.active {
    background-color: #4a3a2a;
    color: #ffaa88;
    border-color: #aa6644;
}

.right-controls .scale-toggle-btn.active {
    background-color: #4a4a3a;
    color: #ffdd88;
    border-color: #aaaa66;
    font-weight: bold;
}

/* 縮尺コントロール */
.scale-controls {
    display: flex;
    gap: 20px;
    padding: 12px 15px;
    background-color: #2a2a2a;
    border: 1px solid #333;
    border-radius: 4px;
    margin-bottom: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.scale-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scale-control-group label {
    color: #aaa;
    font-size: 0.9rem;
    min-width: 90px;
}

.scale-control-group input[type="range"] {
    width: 120px;
    height: 6px;
    background: #444;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.scale-control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #88aaff;
    border-radius: 50%;
    cursor: pointer;
}

.scale-control-group input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #88aaff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.scale-control-group input[type="number"] {
    width: 60px;
    padding: 4px 6px;
    background-color: #1a1a1a;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 3px;
    font-size: 0.9rem;
}

.scale-control-group .scale-unit {
    color: #888;
    font-size: 0.9rem;
    min-width: 30px;
}

.scale-reset-btn {
    padding: 6px 12px;
    background-color: #3a3a4a;
    color: #aaa;
    border: 1px solid #555;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.scale-reset-btn:hover {
    background-color: #4a4a5a;
    color: #fff;
}

/* 編集ボタン（.right-controls以外で使用される場合のデフォルト） */
.edit-button {
    padding: 6px 12px;
    background-color: #2a2a2a;
    color: #888;
    border: 1px solid #444;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.85rem;
}

.edit-button:hover {
    background-color: #333;
    color: #aaa;
}

.edit-button.active {
    background-color: #4a3a2a;
    color: #ffaa88;
    border-color: #aa6644;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
    background-color: #222;
    margin: 5% auto;
    padding: 0;
    border: 2px solid #ffd700;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #444;
}

.modal-header h2 {
    margin: 0;
    color: #ffd700;
    font-size: 1.3rem;
}

.close-button {
    background: none;
    border: none;
    color: #888;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 30px;
}

.close-button:hover {
    color: #ffd700;
}

#export-textarea {
    width: calc(100% - 40px);
    height: 400px;
    background-color: #1a1a1a;
    color: #88ff88;
    border: 1px solid #444;
    border-radius: 3px;
    padding: 15px;
    margin: 20px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    resize: none;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #444;
    text-align: right;
}

/* 編集モード時のカーソル */
#main-canvas.edit-mode {
    cursor: move;
}

#main-canvas.edit-mode.dragging {
    cursor: grabbing;
}

/* テクスチャプレビュー */
#texture-preview {
    margin-top: 15px;
    padding: 15px;
    background-color: #2a2a2a;
    border-radius: 5px;
    border: 1px solid #3a3a3a;
}

#texture-preview h3 {
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 10px;
}

#texture-image {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 300px;
    border-radius: 3px;
    border: 2px solid #4a4a4a;
    background-color: #1a1a1a;
    image-rendering: auto;
    object-fit: contain;
}

/* マップ情報レイアウト（左右配置、ボスありの場合は3ペイン） */
.map-info-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.map-info-layout.with-boss {
    display: grid;
    grid-template-columns: 200px 1fr 200px;
    gap: 20px;
}

.map-info-image {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
    background-color: #2a2a2a;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: auto;
}

.map-preview-placeholder {
    color: #666;
    font-size: 0.9rem;
    text-align: center;
    padding: 10px;
}

.map-info-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    justify-content: space-between;
}

.map-info-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 8px;
}

.map-info-row {
    font-size: 0.95rem;
    line-height: 1.4;
}

.map-info-row .label {
    color: #888;
    font-weight: 500;
    display: inline-block;
    min-width: 80px;
}

.map-info-ids {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #333;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.map-info-id {
    font-size: 0.85rem;
    color: #aaa;
}

.map-info-id .label {
    color: #666;
    font-weight: 500;
    display: inline-block;
    min-width: 70px;
}

.map-info-id code {
    background-color: #2a2a2a;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #7ec699;
}

/* ボス画像エリア（右側ペイン） */
.map-info-boss-image {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
    background-color: rgba(255, 221, 0, 0.1);
    border: 2px solid #ffdd00;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.boss-preview-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: auto;
}

/* レスポンシブ */
@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }

    #canvas-container {
        min-height: 600px;
    }

    .map-info-layout {
        flex-direction: column;
    }

    .map-info-image {
        width: 100%;
        height: 250px;
    }
}

/* フッター */
#footer {
    margin-top: 20px;
    padding: 20px 30px;
    background-color: #2a2a2a;
    border-radius: 4px;
    border-top: 1px solid #444;
    font-size: 0.85rem;
    line-height: 1.8;
}

#footer p {
    margin: 5px 0;
    color: #aaa;
}

#footer hr {
    margin: 15px 0;
    border: none;
    border-top: 1px solid #444;
}

#footer ul {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
}

#footer ul li {
    padding: 3px 0;
    color: #aaa;
}

#footer ul li::before {
    content: "• ";
    color: #666;
    margin-right: 8px;
}

#footer a {
    color: #6ab0de;
    text-decoration: none;
    transition: color 0.2s;
}

#footer a:hover {
    color: #8fc9ec;
    text-decoration: underline;
}