/* 全体のスタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* スクロールバーのカスタマイズ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1f2731;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #2a3441;
    border-radius: 4px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a4451;
}

/* Firefox用のスクロールバー */
* {
    scrollbar-width: thin;
    scrollbar-color: #2a3441 #1f2731;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #0f1923;
    color: #ece8e1;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    display: grid;
    grid-template-rows: 1fr auto;
    min-height: 100vh;
    padding: 15px;
    gap: 0px;
}

/* メインコンテンツエリア */
.main-content {
    display: grid;
    grid-template-columns: minmax(250px, 300px) 1fr;
    gap: 15px;
    height: calc(100vh - 120px);
    align-items: start;
    overflow: hidden;
}

/* マップ選択エリア */
.map-selection {
    background-color: #1f2731;
    padding: 20px;
    border-radius: 8px;
    height: fit-content;
    width: 100%;
    position: sticky;
    top: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.map-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin: 15px 0;
    font-size: 16px;
}

.map-btn {
    background-color: #2a3441;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    opacity: 0.7;
}

.map-btn:hover {
    background-color: #3a4451;
    transform: translateY(-2px);
    opacity: 0.9;
}

.map-btn.active {
    background-color: #ff4655;
    box-shadow: 0 0 10px rgba(255, 70, 85, 0.5);
    opacity: 1;
}

/* サイド選択 */
.side-selection {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 30px;
}

.side-btn {
    flex: 1;
    background-color: #2a3441;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 20px;
}

.side-btn:hover {
    background-color: #3a4451;
    transform: translateY(-2px);
}

.side-btn.active {
    background-color: #ff4655;
    box-shadow: 0 0 10px rgba(255, 70, 85, 0.5);
}

/* マップ表示エリア */
.map-display {
    background-color: #1f2731;
    border-radius: 8px;
    padding: 10px;
    position: relative;
    width: 100%;
    height: 90%;
    overflow: hidden;
    cursor: grab;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 5px;
}

.map-container {
    position: relative;
    width: 100%;
    height: 100%;
    transform-origin: center;
    transition: transform 0.1s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.map-root {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.map-root svg {
    width: 100%;
    height: 100%;
    cursor: grab;
}

.map-root svg:active {
    cursor: grabbing;
}

.map-display img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

/* 位置マーカー */
.position-marker {
    position: absolute;
    width: 32px;
    height: 32px;
    background-color: #ff4655;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: move;
    z-index: 100;
}

/* エージェント選択エリア */
.agent-selection {
    background-color: #1f2731;
    padding: 10px;
    border-radius: 8px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    height: 100px;
    position: relative;
    margin-top: -50px;
}

.agent-buttons {
    display: flex;
    gap: 10px;
    padding: 5px 0;
    min-width: min-content;
    height: 100%;
}

.agent-btn {
    background-color: #2a3441;
    border: none;
    border-radius: 4px;
    padding: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 65px;
    height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.agent-btn:hover {
    background-color: #3a4451;
    transform: translateY(-2px);
}

.agent-btn.active {
    background-color: #ff4655;
    box-shadow: 0 0 10px rgba(255, 70, 85, 0.5);
}

.agent-btn img {
    width: 85%;
    height: 85%;
    object-fit: contain;
}

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

.modal-content {
    position: relative;
    background-color: #1f2731;
    margin: 5% auto;
    padding: 20px;
    width: min(900px, 92vw);
    max-width: 900px;
    height: min(85vh, 720px);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.close {
    position: absolute;
    right: 20px;
    top: 10px;
    font-size: 28px;
    cursor: pointer;
    color: #ece8e1;
}

/* ステップカウンター（モーダル右上） */
.step-counter {
    position: absolute;
    top: 14px;
    right: 60px;
    color: #8b978f;
    font-size: 14px;
}

.point-info {
    display: flex;
    gap: 50px;
    margin-bottom: 15px;
}

.point-info p {
    margin-top: 10px;
}

/* 画像スライダー */
.slider-container {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
    border-radius: 4px;
    background-color: #0f1923;
}

.slider-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.slider-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 15px;
}

.slider-btn {
    background-color: #ff4655;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.slider-btn:hover:not(:disabled) {
    background-color: #ff6b77;
}

.slider-btn:disabled {
    background-color: #2a3441;
    cursor: not-allowed;
}

.slider-counter {
    color: #ece8e1;
    font-size: 14px;
}

/* スキルアイコン表示エリア */
.skill-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    padding: 0 15px;
    padding-top: 30px;
    justify-content: center;
}

.skill-btn {
    background-color: #2a3441;
    border: none;
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.skill-btn:hover {
    background-color: #3a4451;
    transform: translateY(-2px);
}

.skill-btn.active {
    background-color: #ff4655;
    box-shadow: 0 0 10px rgba(255, 70, 85, 0.5);
}

.skill-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px;
}

/* アイコン画像が未用意のスキルはスキル名を表示する */
.skill-fallback {
    color: #d8dce3;
    font-size: 10px;
    line-height: 1.2;
    text-align: center;
    word-break: break-word;
    padding: 2px;
}

/* カテゴリ表示エリア */
.category-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    padding: 30px 15px;
    justify-content: center;
}

.category-btn {
    background-color: #2a3441;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
    white-space: nowrap;
}

.category-btn:hover {
    background-color: #3a4451;
    transform: translateY(-2px);
}

.category-btn.active,
.category-btn.selected {
    background-color: #ff4655;
    box-shadow: 0 0 10px rgba(255, 70, 85, 0.5);
}

/* 定点マーカー */
.point-marker {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

/* 判定は常に一定・透明 */
.point-hit {
    fill: transparent;
    stroke: transparent;
    pointer-events: all;
    vector-effect: non-scaling-stroke;
}

/* アイコンは見た目専用（判定に関与させない） */
.point-icon {
    pointer-events: none;
    transform-box: fill-box;
    transform-origin: center;
    transition: transform 120ms ease, filter 120ms ease;
}

/* hover 演出（サイズと影のみ、判定は変化しない） */
.point:hover .point-icon {
    transform: scale(1.06);
    filter: drop-shadow(0 0 4px rgba(255,70,85,.55));
}

.point-marker:hover {
    transform: translate(-50%, -50%) scale(1.2);
}

.point-skill-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    border-radius: 50%;
    background-color: #1f2731;
    padding: 2px;
    border: 1px solid #2a3441;
}

/* お気に入りボタン */
.favorite-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #2a3441;
    color: #ece8e1;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-top: 15px;
}

.favorite-btn:hover {
    background-color: #3a4451;
}

.favorite-btn.active {
    background-color: #ff4655;
}

.favorite-icon {
    color: #ff4655;
    font-size: 20px;
}

.favorite-btn.active .favorite-icon {
    color: #ece8e1;
}

/* フローティングボタン */
.floating-buttons {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.floating-btn {
    background-color: #2a3441;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.floating-btn:hover {
    background-color: #3a4451;
    transform: translateY(-2px);
}

/* お気に入り一覧 */
.favorites-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.favorite-item {
    background-color: #2a3441;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.favorite-item:hover {
    background-color: #3a4451;
}

.favorite-item h3 {
    margin-bottom: 8px;
    color: #ece8e1;
}

.favorite-item p {
    color: #8b978f;
    font-size: 14px;
}

.favorite-item .remove-favorite {
    color: #ff4655;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    margin-top: 8px;
    font-size: 14px;
}

.favorite-item .remove-favorite:hover {
    color: #ff6b77;
}

/* 新規定点追加フォーム */
.add-point-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    color: #ece8e1;
    font-size: 14px;
}

.form-group select,
.form-group input[type="text"],
.form-group textarea {
    background-color: #2a3441;
    color: #ece8e1;
    border: 1px solid #3a4451;
    border-radius: 4px;
    padding: 8px;
    font-size: 14px;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.image-upload {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.image-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.image-preview img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
}

.position-info {
    display: flex;
    gap: 20px;
    color: #ece8e1;
    font-size: 14px;
    margin: 5px 0;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.submit-btn,
.cancel-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.submit-btn {
    background-color: #ff4655;
    color: white;
}

.submit-btn:hover {
    background-color: #ff6b77;
}

.cancel-btn {
    background-color: #2a3441;
    color: #ece8e1;
}

.cancel-btn:hover {
    background-color: #3a4451;
}

/* 定点追加のステップ */
.add-point-step {
    margin-bottom: 20px;
    padding-bottom: 72px; /* 右下固定のナビ分の余白 */
    flex: 1;
    overflow: auto;
}

.step-navigation {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    position: absolute; /* 常にモーダル右下で固定 */
    right: 20px;
    bottom: 16px;
    padding: 0;
    z-index: 2;
}

.prev-step-btn,
.next-step-btn {
    background-color: #2a3441;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 16px;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.prev-step-btn:hover,
.next-step-btn:hover:not(:disabled) {
    background-color: #3a4451;
    transform: translateY(-2px);
}

.next-step-btn {
    background-color: #ff4655;
    margin-left: 10px;
}

.next-step-btn:hover:not(:disabled) {
    background-color: #ff6b77;
}

.next-step-btn:disabled {
    background-color: #1f2731;
    cursor: not-allowed;
    opacity: 0.5;
}

.agent-selection-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    margin-top: 15px;
    padding: 10px;
}

.agent-selection-grid .agent-btn {
    width: 100%;
    aspect-ratio: 1;
    padding: 5px;
    background-color: #2a3441;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.agent-selection-grid .agent-btn img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.agent-selection-grid .agent-btn span {
    font-size: 12px;
    color: #ece8e1;
}

.agent-selection-grid .agent-btn:hover {
    background-color: #3a4451;
    transform: translateY(-2px);
}

.agent-selection-grid .agent-btn.active {
    background-color: #ff4655;
    box-shadow: 0 0 10px rgba(255, 70, 85, 0.5);
}

.skill-selection {
    margin-top: 15px;
}

.skill-selection select {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    background-color: #2a3441;
    color: white;
    border: 1px solid #3a4451;
}

/* 位置調整コントロール */
.position-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-top: 10px;
    max-width: 120px;
}

.position-btn {
    background-color: #2a3441;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.position-btn:hover {
    background-color: #3a4451;
}

.position-btn[data-direction="up"] {
    grid-column: 2;
}

.position-btn[data-direction="down"] {
    grid-column: 2;
    grid-row: 3;
}

.position-btn[data-direction="left"] {
    grid-column: 1;
    grid-row: 2;
}

.position-btn[data-direction="right"] {
    grid-column: 3;
    grid-row: 2;
}

/* 画像プレビュー */
.image-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.image-preview img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
}

.image-preview .remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(255, 70, 85, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview .remove-image:hover {
    background-color: #ff4655;
}

/* フォームのエラー表示 */
.form-group input.error,
.form-group select.error,
.form-group textarea.error {
    border-color: #ff4655;
    box-shadow: 0 0 5px rgba(255, 70, 85, 0.5);
}

.form-group input.error:focus,
.form-group select.error:focus,
.form-group textarea.error:focus {
    outline: none;
    border-color: #ff4655;
    box-shadow: 0 0 8px rgba(255, 70, 85, 0.7);
}

.form-group .error-message {
    color: #ff4655;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.form-group input.error + .error-message,
.form-group select.error + .error-message,
.form-group textarea.error + .error-message {
    display: block;
}

/* レスポンシブ対応 */
@media screen and (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        height: auto;
    }

    .map-selection {
        position: relative;
        top: 0;
        max-height: none;
    }

    .map-buttons {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

    .agent-selection {
        height: 100px;
    }

    .agent-btn {
        width: 60px;
        height: 60px;
    }
}

@media screen and (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .main-content {
        gap: 10px;
    }

    .map-selection {
        padding: 15px;
    }

    .map-buttons {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        font-size: 14px;
    }

    .agent-selection {
        height: 90px;
    }

    .agent-btn {
        width: 50px;
        height: 50px;
    }
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    padding: 12px;
    place-content: center;
    justify-items: center;
    width: 100%;
}

.skill-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border: 1px solid #2a3441;
    border-radius: 6px;
    background: #1f2731;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 120px;
}

.skill-button:hover {
    background: #2a3441;
    transform: translateY(-2px);
}

.skill-button.selected {
    background: #3a4451;
    border-color: #4a5568;
}

.skill-button img {
    width: 64px;
    height: 64px;
    margin-bottom: 6px;
    background-color: #1f2731;
    border-radius: 4px;
    padding: 4px;
    border: 1px solid #2a3441;
}

.skill-button span {
    font-size: 12px;
    color: #e2e8f0;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* 定点追加モーダル内のマップ表示エリア */
#addPointModal .map-display {
    height: 50vh;
    max-height: 500px;
    margin: 10px 0;
    cursor: grab;
    overflow: hidden;
}

/* Step1: マップ選択の均等レイアウト（モーダル内） */
#step1 .map-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    padding: 10px 10px 0 10px;
    align-content: start;
    justify-items: stretch;
}

#step1 .map-btn {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#addPointModal .map-container {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: center;
    transition: transform 0.1s ease;
}

#addPointModal .map-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

#addPointModal .map-display:active {
    cursor: grabbing;
}
