/**
 * Fantasy RTS - Scene Styles
 * シーン管理用のUI/UXスタイル
 */

/* ============================================
   共通スタイル
   ============================================ */

:root {
    --ui-scale: 1;
    --ui-safe-top: env(safe-area-inset-top, 0px);
    --ui-safe-right: env(safe-area-inset-right, 0px);
    --ui-safe-bottom: env(safe-area-inset-bottom, 0px);
    --ui-safe-left: env(safe-area-inset-left, 0px);
}

.scene-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    pointer-events: auto;
}

.panel-bg {
    background: linear-gradient(135deg, rgba(20, 30, 50, 0.95), rgba(10, 15, 30, 0.98));
    border: 2px solid rgba(100, 150, 220, 0.5);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    padding: 32px;
    max-width: 800px;
    margin: 5% auto;
}

h1,
h2,
h3 {
    color: #e8f0ff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 16px;
}

/* ボタン */
.btn-primary,
.btn-secondary,
.title-btn {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 16px;
    padding: 12px 32px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.btn-primary {
    background: linear-gradient(135deg, #4a7cff, #2a5cdf);
    color: white;
    box-shadow: 0 4px 12px rgba(74, 124, 255, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5a8cff, #3a6cef);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(74, 124, 255, 0.5);
}

.btn-secondary {
    background: linear-gradient(135deg, #555, #333);
    color: #ddd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #666, #444);
    transform: translateY(-2px);
}

.button-row {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 24px;
}

/* ============================================
   タイトル画面
   ============================================ */

.title-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg,
            rgba(10, 15, 30, 0.9) 0%,
            rgba(20, 40, 80, 0.85) 50%,
            rgba(10, 20, 40, 0.95) 100%);
}

.title-bg {
    text-align: center;
}

.title-text {
    font-size: 72px;
    font-weight: 700;
    color: #fff;
    text-shadow:
        0 0 20px rgba(100, 150, 255, 0.8),
        0 4px 8px rgba(0, 0, 0, 0.8),
        0 8px 16px rgba(0, 30, 100, 0.5);
    margin-bottom: 48px;
    letter-spacing: 8px;
    animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {

    0%,
    100% {
        text-shadow: 0 0 20px rgba(100, 150, 255, 0.8), 0 4px 8px rgba(0, 0, 0, 0.8);
    }

    50% {
        text-shadow: 0 0 40px rgba(120, 180, 255, 1), 0 4px 8px rgba(0, 0, 0, 0.8);
    }
}

.title-menu {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.title-btn {
    width: 280px;
    font-size: 20px;
    padding: 16px 40px;
    background: linear-gradient(135deg, rgba(40, 60, 100, 0.9), rgba(20, 40, 80, 0.95));
    color: #e0e8ff;
    border: 1px solid rgba(100, 150, 220, 0.6);
}

.title-btn:hover {
    background: linear-gradient(135deg, rgba(60, 90, 140, 0.95), rgba(40, 70, 120, 0.95));
    border-color: rgba(140, 180, 255, 0.8);
    transform: scale(1.05);
}

.version-text {
    color: rgba(200, 210, 230, 0.6);
    font-size: 14px;
    margin-top: 48px;
}

/* ============================================
   マップ選択画面
   ============================================ */

.map-select-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 15, 25, 0.9);
}

.map-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.map-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(30, 40, 60, 0.8);
    border: 2px solid rgba(80, 100, 140, 0.4);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.map-item:hover {
    background: rgba(40, 55, 85, 0.9);
    border-color: rgba(100, 150, 220, 0.6);
}

.map-item.selected {
    background: rgba(50, 80, 130, 0.9);
    border-color: #4a7cff;
    box-shadow: 0 0 16px rgba(74, 124, 255, 0.4);
}

.map-stage-order {
    flex: 0 0 48px;
    height: 48px;
    border-radius: 8px;
    background: rgba(10, 16, 28, 0.85);
    border: 1px solid rgba(120, 160, 220, 0.45);
    color: #ffd700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 15px;
}

.map-thumb {
    width: 120px;
    height: 80px;
    background: linear-gradient(135deg, #2a4070, #1a2a50);
    border-radius: 8px;
}

.map-info h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
}

.map-info p {
    margin: 0;
    color: rgba(180, 190, 210, 0.8);
    font-size: 14px;
}

.map-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}

.stage-select-status,
.stage-file-name {
    font-size: 12px;
    color: rgba(210, 220, 240, 0.72);
}

.map-item.free-select .stage-select-status {
    color: #9fd3ff;
}

.map-item.unlocked .stage-select-status {
    color: #9fda9f;
}

/* タブスタイル */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.tab-btn {
    padding: 10px 24px;
    font-size: 14px;
    background: rgba(40, 50, 70, 0.8);
    border: 1px solid rgba(100, 150, 220, 0.4);
    color: #aaa;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Noto Sans JP', sans-serif;
}

.tab-btn:hover {
    background: rgba(50, 70, 100, 0.9);
    color: #ddd;
}

.tab-btn.active {
    background: linear-gradient(135deg, #4a7cff, #2a5cdf);
    color: white;
    border-color: #4a7cff;
}

/* ============================================
   編成画面（新レイアウト v6: 3カラム）
   ============================================ */

.organization-screen {
    display: flex;
    flex-direction: column;
    background: url('../assets/images/bg_organization.jpg') no-repeat center center;
    background-size: cover;
    background-color: #111;
    padding: 0;
    overflow: hidden;
}

.org-container-v6 {
    display: flex;
    width: 100%;
    height: 100%;
    padding: 15px 25px;
    box-sizing: border-box;
    gap: 15px;
}

/* --- 左カラム: 所有リスト --- */
.org-col-left {
    flex: 0 0 35%;
    /* 幅調整 */
    background: rgba(10, 15, 25, 0.92);
    border: 1px solid rgba(80, 100, 140, 0.5);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

/* --- 中央カラム: 操作 --- */
.org-col-center {
    flex: 0 0 60px;
    /* 狭めでOK */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.btn-remove-deploy {
    width: 50px;
    height: 80px;
    background: linear-gradient(135deg, #555, #333);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #ddd;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-remove-deploy:hover:not(:disabled) {
    background: linear-gradient(135deg, #666, #444);
    border-color: #fff;
    transform: translateX(-2px);
}

.btn-remove-deploy:disabled {
    opacity: 0.3;
    cursor: default;
}

/* --- 右カラム: 出撃詳細 --- */
.org-col-right {
    flex: 1;
    /* 残り全部 */
    background: rgba(16, 24, 40, 0.95);
    border: 1px solid rgba(100, 150, 220, 0.4);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

/* コンポーネント共通ヘッダー */
.panel-header {
    background: linear-gradient(90deg, rgba(26, 42, 64, 0.9), rgba(16, 21, 32, 0.9));
    border-bottom: 1px solid rgba(58, 92, 143, 0.5);
    padding: 12px 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-title {
    font-size: 16px;
    color: #e0e8ff;
    font-weight: bold;
}

/* 左カラム：カードリスト */
.org-unit-list.card-view {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    align-content: start;
}

/* カードスタイル (共通) */
.org-unit-card {
    background: linear-gradient(180deg, rgba(40, 50, 70, 0.7), rgba(30, 40, 60, 0.8));
    border: 1px solid rgba(136, 170, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.org-unit-card:hover {
    background: rgba(50, 65, 90, 0.9);
    border-color: #8af;
}

.org-unit-card.selected {
    border-color: #4f8;
    /* 左選択は緑 */
    box-shadow: 0 0 8px rgba(74, 255, 128, 0.3);
}

.org-unit-card.deployed {
    background: rgba(20, 40, 30, 0.8);
    opacity: 0.6;
    /* 出撃中は薄く */
}

.org-unit-card.deployed.selected {
    opacity: 1;
}

.card-content {
    padding: 8px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.badg-type {
    font-size: 10px;
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    border: 1px solid #555;
}

.badg-status {
    font-size: 9px;
    color: #4f8;
    font-weight: bold;
}

.card-name {
    font-size: 13px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 4px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.card-meta {
    font-size: 11px;
    color: #aaa;
}

.card-equipment-icons,
.d-equipment-icons {
    display: flex;
    gap: 3px;
    margin-top: 4px;
    height: 18px;
    align-items: center;
}

.equipment-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background-repeat: no-repeat;
    background-color: #f8f8f2;
    border: 1px solid rgba(190, 205, 235, 0.35);
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.25);
    color: #89a;
    font-size: 11px;
    overflow: hidden;
}

.equipment-icon.mini {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    box-shadow: none;
}

.equipment-icon.large {
    width: 72px;
    height: 72px;
    border-radius: 8px;
}

.equipment-icon.empty {
    background-image: none;
    background-color: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.16);
    color: #667;
}


/* --- 右カラム詳細 --- */
.org-right-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: linear-gradient(90deg, rgba(30, 40, 60, 0.9), rgba(20, 30, 50, 0.9));
    border-bottom: 1px solid rgba(100, 150, 220, 0.3);
    flex-shrink: 0;
}

.cost-area {
    display: flex;
    flex-direction: column;
}

.cost-area label {
    font-size: 10px;
    color: #aaa;
    letter-spacing: 1px;
}

.cost-area span {
    font-size: 24px;
    font-weight: bold;
    font-family: 'Consolas', monospace;
    color: #fff;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn-sub-action {
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #4a7cff;
    color: #cde;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
}

.btn-sub-action:hover:not(:disabled) {
    background: #4a7cff;
    color: white;
}

.btn-sub-action:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: #555;
}

/* 出撃部隊詳細リスト */
.deployed-detail-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
}

.empty-state {
    text-align: center;
    margin-top: 50px;
    color: #666;
    font-size: 14px;
}

/* リスト行 */
.deployed-row {
    display: flex;
    background: rgba(40, 50, 70, 0.6);
    border: 1px solid rgba(100, 150, 220, 0.2);
    border-radius: 6px;
    margin-bottom: 8px;
    height: 64px;
    overflow: hidden;
    transition: all 0.2s;
    cursor: pointer;
}

.deployed-row:hover {
    background: rgba(50, 65, 90, 0.7);
    border-color: #8af;
}

.deployed-row.selected {
    background: linear-gradient(90deg, rgba(40, 60, 100, 0.8), rgba(30, 50, 90, 0.8));
    border: 1px solid #4a7cff;
    box-shadow: 0 0 12px rgba(74, 124, 255, 0.2);
}

/* 行左：シンボル＆情報 */
.d-row-left {
    flex: 0 0 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 10px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    background: rgba(0, 0, 0, 0.2);
}

.d-symbol {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 32px;
    opacity: 0.2;
    pointer-events: none;
}

.d-name {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 1;
}

.d-lv {
    font-size: 11px;
    color: #aaa;
    z-index: 1;
}

.d-equipment-icons {
    margin-top: 2px;
    z-index: 1;
}

.d-count-ctrl {
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 2;
    /* クリックできるように */
}

.btn-mini {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #555;
    background: #222;
    color: #ddd;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.btn-mini:hover {
    border-color: #888;
    background: #333;
}

.d-count-ctrl .val {
    font-size: 14px;
    font-weight: bold;
    width: 20px;
    text-align: center;
}

/* 行右：スプライト列 */
.d-row-right {
    flex: 1;
    display: flex;
    align-items: center;
    overflow: hidden;
    /* はみ出しは隠す or スクロール */
    padding-left: 10px;
    white-space: nowrap;
}

.unit-sprite-line {
    display: flex;
    align-items: center;
    /* gap: -5px; 重ねて密集感を出す */
    margin-left: 10px;
}

/* 小さいスプライトセル */
.unit-sprite-cell-small {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    image-rendering: pixelated;
    background-repeat: no-repeat;
    background-size: 700% 400%;
    /* 7x4 */
    animation: sprite-anim-ready-small 0.8s steps(1) infinite alternate;
    margin-right: -4px;
    /* 少し重ねる */
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}

@keyframes sprite-anim-ready-small {
    0% {
        background-position: 16.666% 0%;
    }

    100% {
        background-position: 33.333% 0%;
    }
}


/* フッター */
.org-right-footer {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    /* 右寄せ */
    gap: 15px;
    padding: 0 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(10, 15, 25, 0.5);
    flex-shrink: 0;
}

.btn-xl {
    padding: 10px 40px;
    font-size: 16px;
}

/* ============================================
   装備購入・装備変更
   ============================================ */

.equipment-screen {
    background: rgba(5, 8, 14, 0.96);
    padding: 24px;
    overflow: hidden;
}

.equipment-screen-shell {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: rgba(16, 24, 40, 0.95);
    border: 1px solid rgba(100, 150, 220, 0.4);
    border-radius: 8px;
    overflow: hidden;
}

.equipment-screen-header {
    height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    background: linear-gradient(90deg, rgba(30, 40, 60, 0.92), rgba(20, 30, 50, 0.92));
    border-bottom: 1px solid rgba(100, 150, 220, 0.3);
    flex-shrink: 0;
}

.equipment-screen-header h2 {
    margin: 0 0 6px 0;
    color: #f2f6ff;
    font-size: 24px;
}

.equipment-screen-header p {
    margin: 0;
    color: #d9b45f;
    font-size: 13px;
    letter-spacing: 0;
}

.equipment-screen-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.equipment-screen-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 300px 1fr;
}

.equipment-roster-panel {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.22);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.equipment-panel-title {
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    color: #dfe8ff;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.equipment-roster-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px;
    display: grid;
    gap: 8px;
    align-content: start;
}

.equipment-roster-item {
    width: 100%;
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 10px;
    align-items: center;
    min-height: 74px;
    padding: 9px;
    text-align: left;
    color: inherit;
    background: rgba(38, 48, 68, 0.72);
    border: 1px solid rgba(132, 168, 230, 0.2);
    border-radius: 6px;
    cursor: pointer;
}

.equipment-roster-item.active,
.equipment-roster-item:hover {
    border-color: #6fa0ff;
    background: rgba(54, 82, 132, 0.82);
}

.equipment-roster-marker {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 6px;
    font-size: 22px;
}

.equipment-roster-main strong {
    display: block;
    color: #fff;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.equipment-roster-main span {
    display: block;
    margin-top: 3px;
    color: #99aaca;
    font-size: 12px;
}

.equipment-detail-panel {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.equipment-unit-summary {
    min-height: 90px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.equipment-unit-summary h3 {
    margin: 0 0 4px 0;
    color: #fff;
    font-size: 22px;
}

.equipment-unit-summary p {
    margin: 0;
    color: #9eb0d0;
    font-size: 13px;
}

.equipment-total-bonus {
    min-width: 240px;
}

.equipment-total-bonus label {
    display: block;
    margin-bottom: 8px;
    color: #96a8c4;
    font-size: 12px;
}

.equipment-current-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) 1fr;
    gap: 14px;
    padding: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.equipment-slot-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.equipment-screen-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
    gap: 8px;
    align-content: start;
}

.equipment-screen-stat {
    min-height: 56px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 3px 8px;
    align-items: center;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
}

.equipment-screen-stat span {
    color: #96a8c4;
    font-size: 11px;
}

.equipment-screen-stat strong {
    grid-column: 1;
    color: #fff;
    font-size: 20px;
    line-height: 1;
}

.equipment-screen-stat em {
    grid-column: 2;
    grid-row: 1 / 3;
    color: #8fdca8;
    font-style: normal;
    font-size: 12px;
}

.equipment-screen-choice {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.equipment-shop-screen {
    background: rgba(5, 8, 14, 0.96);
    padding: 24px;
    overflow: hidden;
}

.equipment-shop-shell {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: rgba(16, 24, 40, 0.95);
    border: 1px solid rgba(100, 150, 220, 0.4);
    border-radius: 8px;
    overflow: hidden;
}

.equipment-shop-header {
    height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    background: linear-gradient(90deg, rgba(30, 40, 60, 0.92), rgba(20, 30, 50, 0.92));
    border-bottom: 1px solid rgba(100, 150, 220, 0.3);
}

.equipment-shop-header h2 {
    margin: 0 0 6px 0;
    color: #f2f6ff;
    font-size: 24px;
}

.equipment-shop-header p {
    margin: 0;
    color: #d9b45f;
    font-size: 13px;
    letter-spacing: 0;
}

.equipment-shop-tabs {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.18);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.equipment-shop-tab {
    padding: 8px 14px;
    background: rgba(20, 28, 44, 0.9);
    border: 1px solid rgba(120, 150, 210, 0.28);
    color: #cde;
    border-radius: 4px;
    cursor: pointer;
}

.equipment-shop-tab.active,
.equipment-shop-tab:hover {
    background: #385f9d;
    border-color: #7fa7ff;
    color: #fff;
}

.equipment-shop-grid {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    align-content: start;
}

.equipment-shop-card {
    display: grid;
    grid-template-columns: 76px 1fr;
    grid-template-rows: 1fr auto;
    gap: 10px;
    min-height: 150px;
    background: rgba(38, 48, 68, 0.74);
    border: 1px solid rgba(132, 168, 230, 0.2);
    border-radius: 8px;
    padding: 12px;
}

.equipment-shop-info h3 {
    margin: 0 0 6px 0;
    color: #fff;
    font-size: 16px;
}

.equipment-shop-info p {
    margin: 0 0 8px 0;
    color: #aeb9cf;
    font-size: 12px;
    line-height: 1.45;
}

.equipment-shop-stats,
.equipment-choice-stats,
.equipment-stat-lines {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.equipment-shop-stats span,
.equipment-choice-stats span,
.equipment-stat-lines span {
    padding: 2px 6px;
    background: rgba(74, 124, 255, 0.16);
    border: 1px solid rgba(115, 160, 255, 0.26);
    border-radius: 4px;
    color: #dbe7ff;
    font-size: 11px;
}

.equipment-shop-owned {
    margin-top: 8px;
    color: #8fa1c2;
    font-size: 12px;
}

.equipment-buy-btn {
    grid-column: 1 / -1;
    justify-self: end;
    min-width: 96px;
}

.equipment-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.62);
    pointer-events: auto;
}

.equipment-modal {
    width: min(900px, calc(100vw - 48px));
    height: min(620px, calc(100vh - 48px));
    display: flex;
    flex-direction: column;
    background: rgba(14, 22, 36, 0.98);
    border: 1px solid rgba(122, 165, 238, 0.48);
    border-radius: 8px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.equipment-modal-header {
    height: 70px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    background: linear-gradient(90deg, rgba(32, 44, 66, 0.96), rgba(18, 26, 42, 0.96));
    border-bottom: 1px solid rgba(100, 150, 220, 0.32);
}

.equipment-modal-title {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
}

.equipment-modal-sub {
    margin-top: 4px;
    color: #9eb0d0;
    font-size: 12px;
}

.equipment-close-btn {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.25);
    color: #e8edf8;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.equipment-modal-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.equipment-slot-panel {
    min-width: 0;
    padding: 14px;
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    overflow-y: auto;
}

.equipment-slot-btn {
    width: 100%;
    min-height: 68px;
    display: grid;
    grid-template-columns: 44px 1fr;
    grid-template-rows: auto auto;
    column-gap: 10px;
    align-items: center;
    text-align: left;
    margin-bottom: 8px;
    padding: 8px;
    background: rgba(36, 46, 66, 0.74);
    border: 1px solid rgba(120, 150, 210, 0.22);
    border-radius: 6px;
    color: #cbd6ea;
    cursor: pointer;
}

.equipment-slot-btn .equipment-icon {
    grid-row: 1 / 3;
}

.equipment-slot-btn span {
    font-size: 12px;
    color: #91a5c8;
}

.equipment-slot-btn strong {
    min-width: 0;
    color: #fff;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.equipment-slot-btn.active,
.equipment-slot-btn:hover {
    border-color: #6fa0ff;
    background: rgba(54, 82, 132, 0.82);
}

.equipment-bonus-box {
    margin-top: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
}

.equipment-bonus-box label {
    display: block;
    margin-bottom: 8px;
    color: #96a8c4;
    font-size: 12px;
}

.equipment-choice-panel {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.equipment-choice-header {
    height: 62px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.equipment-choice-header span {
    display: block;
    color: #91a5c8;
    font-size: 12px;
}

.equipment-choice-header strong {
    color: #fff;
}

.btn-secondary.compact {
    padding: 7px 12px;
}

.equipment-choice-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: grid;
    gap: 10px;
    align-content: start;
}

.equipment-choice-card {
    width: 100%;
    display: grid;
    grid-template-columns: 44px 1fr 72px;
    gap: 10px;
    align-items: center;
    min-height: 74px;
    padding: 10px;
    background: rgba(38, 48, 68, 0.72);
    border: 1px solid rgba(132, 168, 230, 0.2);
    border-radius: 6px;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.equipment-choice-card.active {
    border-color: #72e09c;
    background: rgba(42, 84, 64, 0.72);
}

.equipment-choice-card:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.equipment-choice-name {
    color: #fff;
    font-weight: 700;
    margin-bottom: 3px;
}

.equipment-choice-desc {
    color: #9eacc3;
    font-size: 12px;
    margin-bottom: 6px;
}

.equipment-choice-stock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    color: #91a5c8;
    font-size: 11px;
}

.equipment-empty {
    padding: 28px;
    color: #8b99b1;
    text-align: center;
    border: 1px dashed rgba(255, 255, 255, 0.16);
    border-radius: 6px;
}

@media (max-width: 760px) {
    .equipment-screen-body {
        grid-template-columns: 1fr;
    }

    .equipment-roster-panel {
        max-height: 220px;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .equipment-current-layout {
        grid-template-columns: 1fr;
    }

    .equipment-modal-body {
        grid-template-columns: 1fr;
    }

    .equipment-slot-panel {
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        max-height: 220px;
    }
}


/* ============================================
   配置画面
   ============================================ */

.deployment-screen {
    background: transparent;
    pointer-events: none;
}

.deploy-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px;
    pointer-events: auto;
}

.deploy-panel {
    background: linear-gradient(135deg, rgba(20, 30, 50, 0.95), rgba(10, 15, 30, 0.98));
    border: 2px solid rgba(100, 150, 220, 0.5);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================
   リザルト画面（横長レイアウト）
   ============================================ */

.result-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 10, 20, 0.95);
}

.result-layout {
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    background: linear-gradient(135deg, rgba(20, 30, 50, 0.98), rgba(10, 15, 30, 0.98));
    border: 2px solid rgba(100, 150, 220, 0.5);
    border-radius: 16px;
    overflow: hidden;
}

.result-header {
    padding: 20px 24px;
    text-align: center;
}

.result-header.victory {
    background: linear-gradient(90deg, rgba(40, 80, 40, 0.8), rgba(60, 120, 60, 0.6), rgba(40, 80, 40, 0.8));
    border-bottom: 2px solid rgba(100, 200, 100, 0.5);
}

.result-header.defeat {
    background: linear-gradient(90deg, rgba(80, 40, 40, 0.8), rgba(120, 60, 60, 0.6), rgba(80, 40, 40, 0.8));
    border-bottom: 2px solid rgba(200, 100, 100, 0.5);
}

.result-header .result-title {
    font-size: 36px;
    margin: 0;
}

.result-header.victory .result-title {
    color: #8f8;
    text-shadow: 0 0 16px rgba(100, 255, 100, 0.6);
}

.result-header.defeat .result-title {
    color: #f88;
    text-shadow: 0 0 16px rgba(255, 100, 100, 0.6);
}

.result-content {
    display: flex;
    gap: 16px;
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.result-section {
    flex: 1;
    background: rgba(20, 30, 50, 0.6);
    border: 1px solid rgba(80, 100, 140, 0.4);
    border-radius: 10px;
    padding: 12px;
}

.result-section h3 {
    font-size: 14px;
    color: #8af;
    margin: 0 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(100, 150, 220, 0.3);
}

.result-stats-grid {
    display: flex;
    gap: 12px;
}

.stat-box {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: bold;
    color: #fff;
}

.stat-label {
    font-size: 12px;
    color: #888;
}

.exp-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.exp-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    font-size: 13px;
    color: #ddd;
}

.exp-row.level-up {
    background: linear-gradient(90deg, rgba(80, 120, 80, 0.4), rgba(60, 100, 60, 0.2));
    border-left: 3px solid #8f8;
}

.level-badge {
    color: #8f8;
    font-weight: bold;
}

.loot-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.loot-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    font-size: 13px;
}

.loot-item.gold {
    background: linear-gradient(135deg, rgba(100, 80, 20, 0.5), rgba(60, 50, 10, 0.5));
    border: 1px solid rgba(200, 180, 100, 0.5);
    color: #fd0;
}

.loot-item.rare {
    background: linear-gradient(135deg, rgba(60, 40, 100, 0.5), rgba(40, 20, 80, 0.5));
    border: 1px solid rgba(150, 100, 200, 0.5);
    color: #c8f;
}

.loot-icon {
    font-size: 18px;
}

.result-footer {
    padding: 12px 24px;
    text-align: center;
    border-top: 1px solid rgba(100, 150, 220, 0.3);
}

/* ============================================
   配置画面追加スタイル
   ============================================ */

.deploy-sidebar {
    position: absolute;
    left: 20px;
    top: 100px;
    width: 220px;
    background: linear-gradient(135deg, rgba(20, 30, 50, 0.95), rgba(10, 15, 30, 0.98));
    padding: 16px;
    pointer-events: auto;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    z-index: 50;
}

.deploy-sidebar h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #8af;
}

.deploy-unit-list {
    max-height: 400px;
    overflow-y: auto;
}

.deploy-unit-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(30, 40, 60, 0.6);
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 13px;
    color: #ddd;
}

.deploy-unit-item.placed {
    background: rgba(40, 80, 60, 0.7);
    border-left: 3px solid #4a8;
}

.place-status {
    margin-left: auto;
    font-size: 11px;
    color: #888;
}

.full-width {
    width: 100%;
    margin-top: 12px;
}

.deploy-info {
    margin: 16px 0;
    font-size: 16px;
    color: #aaa;
}

.deploy-info strong {
    color: #4a7cff;
    font-size: 20px;
}

/* 戦闘開始確認ダイアログ（同ウィンドウ内） */
.deploy-confirm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    pointer-events: auto;
}

.deploy-confirm-dialog {
    background: linear-gradient(135deg, rgba(20, 30, 50, 0.98), rgba(10, 15, 30, 0.98));
    border: 2px solid rgba(100, 150, 220, 0.6);
    border-radius: 12px;
    padding: 32px 48px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7), 0 0 20px rgba(74, 124, 255, 0.15);
    min-width: 280px;
}

.deploy-confirm-message {
    font-size: 18px;
    color: #e0e8ff;
    margin: 0 0 24px 0;
    font-weight: bold;
}

.deploy-confirm-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.deploy-confirm-buttons .btn-primary,
.deploy-confirm-buttons .btn-secondary {
    min-width: 100px;
    padding: 10px 24px;
    font-size: 15px;
}

/* マップ選択の追加スタイル */
.map-item.completed {
    border-color: rgba(100, 200, 100, 0.5);
}

.map-item.completed h3 {
    color: #8f8;
}

.difficulty {
    color: #ffd700;
    font-size: 12px;
}

.turn-limit {
    color: #f88;
    font-size: 12px;
}

.stage-preview {
    margin-top: 16px;
    padding: 12px;
    background: rgba(20, 30, 50, 0.6);
    border-radius: 8px;
}

/* ============================================
   バトル画面のアクションボタン
   ============================================ */

#action-btn {
    position: absolute;
    bottom: 30px;
    right: 30px;
    font-size: 22px;
    padding: 15px 50px;
    background: #8b0000;
    color: white;
    border: 1px solid #ff4500;
    cursor: pointer;
    pointer-events: auto;
    font-family: serif;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    transition: 0.2s;
    z-index: 100;
}

#action-btn:hover {
    background: #a00000;
    letter-spacing: 2px;
}

#action-btn:active {
    transform: translateY(2px);
}

/* コンテキストメニュー */
#context-menu {
    position: absolute;
    display: none;
    flex-direction: column;
    gap: 1px;
    background: #fff;
    padding: 2px;
    pointer-events: auto;
    z-index: 200;
}

#context-menu .ctx-btn {
    padding: 8px 16px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    cursor: pointer;
    font-size: 14px;
}

#context-menu .ctx-btn:hover {
    background: #ddd;
}

/* スピードコントロール */
#speed-control {
    position: absolute;
    top: 30px;
    right: 30px;
    display: flex;
    flex-direction: row;
    gap: 5px;
    pointer-events: auto;
    z-index: 90;
}

.speed-btn {
    padding: 8px 12px;
    background: rgba(40, 40, 60, 0.9);
    color: #ddd;
    border: 1px solid #666;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.speed-btn:hover {
    background: rgba(60, 60, 80, 0.9);
}

.speed-btn.active {
    background: linear-gradient(135deg, #4a7cff, #2a5cdf);
    color: white;
    border-color: #4a7cff;
}

.preview-enemies {
    font-size: 13px;
    color: #ddd;
    margin-top: 8px;
}

/* ============================================
   会話イベントレイヤー
   ============================================ */
#conversation-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#conversation-layer.active {
    pointer-events: auto;
    /* イベント中のみタップをブロック＆受容 */
    background: rgba(0, 0, 0, 0.3);
    /* 暗転効果 */
}

.dialogue-box {
    position: absolute;
    width: 80%;
    left: 10%;
    background: rgba(10, 15, 25, 0.95);
    border: 2px solid #8af;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8), inset 0 0 15px rgba(100, 150, 255, 0.2);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease-out;
    pointer-events: none;
}

.dialogue-box.top {
    top: 50px;
}

.dialogue-box.bottom {
    bottom: 50px;
    transform: translateY(-20px);
}

.dialogue-box.show {
    opacity: 1;
    transform: translateY(0);
}

.dialogue-box.narration {
    border-color: #d8c08a;
    background: rgba(22, 18, 14, 0.94);
}

.dialogue-box.narration .dialogue-content {
    justify-content: center;
}

.dialogue-box.narration .dialogue-speaker {
    display: none;
}

.dialogue-box.narration .dialogue-text {
    text-align: center;
    color: #f3e3c0;
}

.dialogue-box.system {
    border-color: #b7c7d9;
    background: rgba(18, 24, 30, 0.94);
}

.dialogue-box.shout {
    border-color: #e08a45;
}

.dialogue-box.emotion-angry {
    border-color: #d8664b;
}

.dialogue-box.emotion-worried {
    border-color: #b9b05f;
}

.dialogue-content {
    display: flex;
    gap: 20px;
    align-items: center;
}

.dialogue-speaker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 100px;
}

.speaker-img {
    width: clamp(80px, 15vw, 150px);
    height: clamp(80px, 15vw, 150px);
    border-radius: 5px;
    border: 2px solid #555;
    background: #222;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.speaker-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}


.speaker-img span {
    font-size: clamp(36px, 7vw, 70px);
    color: #666;
    font-family: serif;
}

.speaker-name {
    font-size: clamp(16px, 3vw, 24px);
    font-weight: bold;
    color: #ffd700;
    text-shadow: 1px 1px 2px #000;
    font-family: serif;
    text-align: center;
}

.dialogue-text {
    flex: 1;
    color: #fff;
    font-size: clamp(16px, 3.5vw, 26px);
    line-height: 1.6;
    text-shadow: 1px 1px 2px #000;
    font-family: serif;
    max-height: 7.6em;
    overflow: hidden;
}

.click-prompt {
    position: absolute;
    bottom: 20px;
    right: 30px;
    color: #fff;
    font-size: 14px;
    animation: blink-prompt 1.5s infinite;
    display: none;
}

#conversation-layer.active .click-prompt {
    display: block;
}

@keyframes blink-prompt {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

/* ============================================
   ResultScene — EXP/LvUP Cards
   ============================================ */

.result-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    color: #e8f0ff;
    padding: 20px;
}

.result-header {
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.result-unit-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    max-width: 900px;
    margin-bottom: 30px;
}

.result-unit-card {
    background: linear-gradient(135deg, rgba(30,40,60,0.95), rgba(20,25,40,0.98));
    border: 1px solid rgba(100,150,220,0.4);
    border-radius: 10px;
    padding: 12px 16px;
    min-width: 140px;
    text-align: center;
    position: relative;
}

.result-unit-card .unit-name {
    font-size: 16px;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 6px;
}

.result-unit-card .unit-level {
    font-size: 14px;
    color: #aac;
}

.result-unit-card .unit-exp {
    font-size: 13px;
    color: #8fa;
    margin-top: 4px;
}

.result-unit-card .lvup-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ffd700;
    color: #333;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 8px;
    animation: lvup-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes lvup-pulse {
    from { transform: scale(1); opacity: 0.9; }
    to { transform: scale(1.15); opacity: 1; }
}

.result-unit-card .stat-change {
    font-size: 11px;
    color: #8cf;
    margin-top: 2px;
}

/* ============================================
   EventScene — 戦闘中会話と同じUIを使用
   ============================================ */

.event-screen {
    background: rgba(0, 0, 0, 0.4);
}

/* ============================================
   WorldMapScene
   ============================================ */

.world-map-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    padding: 22px;
    background: radial-gradient(circle at 50% 20%, rgba(58, 44, 27, 0.5), rgba(8, 9, 12, 0.88));
    overflow: auto;
}

.world-map-header {
    text-align: center;
    color: #f4e4c3;
}

.world-map-title {
    font-size: clamp(24px, 3vw, 36px);
    color: #f6e7c5;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    font-family: serif;
}

.world-map-subtitle {
    margin-top: 4px;
    font-size: 13px;
    color: rgba(246, 231, 197, 0.76);
}

.world-map-layout {
    display: grid;
    grid-template-columns: minmax(640px, 1120px) minmax(240px, 300px);
    gap: 16px;
    width: min(1460px, calc(100vw - 44px));
    align-items: stretch;
}

.world-map-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 520px;
    border: 2px solid rgba(84, 51, 23, 0.8);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    background: #2b2117;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.world-map-viewport.dragging {
    cursor: grabbing;
}

.world-map-canvas {
    position: absolute;
    inset: 0;
    transform-origin: 0 0;
    will-change: transform;
}

.world-map-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.world-map-routes,
.world-map-node-layer {
    position: absolute;
    inset: 0;
}

.world-map-routes {
    pointer-events: none;
}

.world-map-routes path {
    fill: none;
    stroke: rgba(80, 37, 17, 0.58);
    stroke-width: 0.45;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 1.5 1.15;
    vector-effect: non-scaling-stroke;
    animation: world-map-route-pulse 3.6s ease-in-out infinite;
}

@keyframes world-map-route-pulse {
    0%,
    100% {
        opacity: 0.34;
    }

    50% {
        opacity: 0.82;
    }
}

.stage-node {
    position: absolute;
    width: 22px;
    height: 22px;
    min-height: 0;
    transform: translate(-50%, -50%);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: default;
    transition: transform 0.16s, box-shadow 0.16s, opacity 0.16s;
    pointer-events: auto;
    font-family: serif;
}

.stage-node.selectable {
    cursor: pointer;
}

.stage-node.available {
    opacity: 1;
}

.stage-node.selectable:hover {
    transform: translate(-50%, -50%) scale(1.22);
    z-index: 8;
}

.stage-node.completed {
    opacity: 0.95;
}

.stage-node.locked {
    opacity: 0.48;
}

.stage-node.planned {
    opacity: 0.56;
}

.stage-node.selected {
    transform: translate(-50%, -50%) scale(1.35);
    z-index: 10;
}

.stage-node.selected::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid rgba(255, 229, 137, 0.74);
    animation: world-map-selected-pulse 1.6s ease-in-out infinite;
}

@keyframes world-map-selected-pulse {
    0%,
    100% {
        transform: scale(0.88);
        opacity: 0.35;
    }

    50% {
        transform: scale(1.15);
        opacity: 1;
    }
}

.node-marker {
    display: block;
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: rgba(57, 42, 24, 0.9);
    border: 2px solid rgba(219, 184, 115, 0.95);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.55), 0 0 9px rgba(245, 203, 108, 0.25);
}

.stage-node.available .node-marker {
    border-color: #f1cf64;
    background: rgba(86, 60, 22, 0.96);
    box-shadow: 0 0 0 2px rgba(255, 217, 112, 0.18), 0 0 14px rgba(255, 222, 111, 0.58);
}

.stage-node.available .node-marker::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: #ffe081;
}

.stage-node.completed .node-marker {
    border-color: #a6d073;
    background: rgba(50, 80, 42, 0.96);
}

.stage-node.completed .node-marker::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 48%;
    width: 5px;
    height: 8px;
    border-right: 2px solid #e9ffd2;
    border-bottom: 2px solid #e9ffd2;
    transform: translate(-50%, -50%) rotate(45deg);
}

.stage-node.locked .node-marker,
.stage-node.planned .node-marker {
    inset: 5px;
    border-width: 1px;
    border-color: rgba(127, 101, 65, 0.8);
    background: rgba(35, 29, 24, 0.82);
    box-shadow: none;
}

.world-map-viewport.zoomed-out .stage-node {
    width: 14px;
    height: 14px;
}

.world-map-viewport.zoomed-out .stage-node.selected::before {
    inset: -5px;
}

.node-label {
    position: absolute;
    left: 25px;
    top: 50%;
    display: flex;
    align-items: center;
    gap: 5px;
    max-width: 176px;
    padding: 4px 7px;
    border-radius: 7px;
    border: 1px solid rgba(66, 39, 16, 0.66);
    background: rgba(23, 16, 9, 0.72);
    color: #ffe7b4;
    line-height: 1.15;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.86);
    transform: translateY(-50%) translateX(-4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.16s, transform 0.16s, visibility 0.16s;
    box-shadow: 0 2px 9px rgba(0, 0, 0, 0.32);
    pointer-events: none;
}

.stage-node.available .node-label,
.stage-node.selected .node-label,
.stage-node:hover .node-label,
.stage-node:focus-visible .node-label {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%);
}

.stage-node .node-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
    font-weight: bold;
}

.stage-node.selected .node-name,
.stage-node.available .node-name {
    max-width: 110px;
}

.node-state-icon {
    flex: 0 0 auto;
    position: relative;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255, 218, 112, 0.92);
    box-shadow: 0 0 10px rgba(255, 218, 112, 0.36);
}

.node-state-icon::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 5px;
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 7px solid #3b2509;
}

.stage-node.available .node-label {
    border-color: rgba(255, 218, 112, 0.86);
    background: rgba(40, 25, 9, 0.86);
    box-shadow: 0 0 16px rgba(255, 210, 93, 0.3), 0 2px 9px rgba(0, 0, 0, 0.34);
}

.stage-node.locked .node-label,
.stage-node.planned .node-label {
    color: rgba(245, 223, 183, 0.72);
    background: rgba(21, 17, 13, 0.58);
}

.world-map-viewport.zoomed-out .node-label {
    display: none !important;
}

.world-map-zoom-controls {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 20;
    display: flex;
    gap: 6px;
    pointer-events: auto;
}

.world-map-zoom-controls button {
    width: 34px;
    height: 34px;
    border-radius: 7px;
    border: 1px solid rgba(218, 180, 108, 0.55);
    background: rgba(20, 15, 11, 0.72);
    color: #ffe4a8;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.world-map-zoom-controls button:hover {
    background: rgba(56, 39, 21, 0.84);
}

.world-map-info {
    min-height: 100%;
    padding: 18px;
    border: 1px solid rgba(172, 130, 72, 0.52);
    border-radius: 8px;
    background: rgba(22, 17, 13, 0.78);
    color: #f4e3c0;
    box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.28);
    font-family: serif;
}

.world-map-info-kicker {
    color: rgba(237, 199, 129, 0.85);
    font-size: 12px;
}

.world-map-info-title {
    margin-top: 8px;
    font-size: 23px;
    color: #ffe4a8;
}

.world-map-info-place {
    margin-top: 6px;
    font-size: 14px;
    color: rgba(255, 244, 216, 0.78);
}

.world-map-info-description {
    margin: 14px 0 0;
    font-size: 14px;
    line-height: 1.65;
    color: rgba(255, 248, 232, 0.9);
}

.world-map-buttons {
    margin-top: 0;
    display: flex;
    gap: 12px;
}

/* ============================================
   解像度連動UIスケール
   ============================================ */

.scene-ui,
.scene-ui * {
    box-sizing: border-box;
}

.title-bg {
    transform: scale(var(--ui-scale));
    transform-origin: center;
}

#top-bar {
    top: max(6px, calc(10px * var(--ui-scale)));
    transform: translateX(-50%) scale(var(--ui-scale));
    transform-origin: top center;
}

#unit-list {
    top: max(46px, calc(70px * var(--ui-scale)));
    left: max(8px, calc(20px * var(--ui-scale)));
    max-height: calc((100vh - 80px) / var(--ui-scale));
    transform: scale(var(--ui-scale));
    transform-origin: top left;
}

#context-menu {
    transform: scale(var(--ui-scale));
    transform-origin: top left;
}

#formation-panel {
    right: max(8px, calc(30px * var(--ui-scale)));
    top: max(54px, calc(100px * var(--ui-scale)));
    transform: scale(var(--ui-scale));
    transform-origin: top right;
}

#speed-control {
    top: max(6px, calc(30px * var(--ui-scale)));
    right: max(6px, calc(30px * var(--ui-scale)));
    transform: scale(var(--ui-scale));
    transform-origin: top right;
}

#bgm-toggle,
.speed-btn {
    min-width: 45px;
    padding: 8px 12px;
    background: rgba(40, 40, 60, 0.9);
    color: #ddd;
    border: 1px solid #666;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

#bgm-toggle.active,
.speed-btn.active {
    background: linear-gradient(135deg, #4a7cff, #2a5cdf);
    color: white;
    border-color: #4a7cff;
}

#action-btn {
    bottom: calc(max(8px, calc(30px * var(--ui-scale))) + var(--ui-safe-bottom)) !important;
    right: calc(max(8px, calc(30px * var(--ui-scale))) + var(--ui-safe-right)) !important;
    font-size: calc(22px * var(--ui-scale)) !important;
    padding: calc(15px * var(--ui-scale)) calc(50px * var(--ui-scale)) !important;
}

:root.ui-compact .panel-bg {
    max-width: min(800px, calc((100vw - 24px) / var(--ui-scale)));
    max-height: calc((100vh - 24px) / var(--ui-scale));
    margin: 12px auto;
    overflow-y: auto;
    transform: scale(var(--ui-scale));
    transform-origin: center;
}

:root.ui-compact .map-list {
    max-height: min(400px, calc((100vh - 230px) / var(--ui-scale)));
}

:root.ui-compact .org-container-v6,
:root.ui-compact .equipment-screen-shell,
:root.ui-compact .equipment-shop-shell {
    width: calc(100% / var(--ui-scale));
    height: calc(100% / var(--ui-scale));
    transform: scale(var(--ui-scale));
    transform-origin: top left;
}

:root.ui-compact .organization-screen,
:root.ui-compact .equipment-screen,
:root.ui-compact .equipment-shop-screen {
    overflow: hidden;
}

:root.ui-compact .equipment-screen,
:root.ui-compact .equipment-shop-screen {
    padding: max(8px, calc(24px * var(--ui-scale)));
}

:root.ui-compact .deploy-sidebar {
    left: max(8px, calc(20px * var(--ui-scale)));
    top: max(54px, calc(100px * var(--ui-scale)));
    max-height: calc((100vh - 80px) / var(--ui-scale));
    transform: scale(var(--ui-scale));
    transform-origin: top left;
}

:root.ui-compact .deploy-overlay {
    padding: max(8px, calc(24px * var(--ui-scale)));
    padding-bottom: calc(max(8px, calc(24px * var(--ui-scale))) + var(--ui-safe-bottom));
}

:root.ui-compact .deploy-panel,
:root.ui-compact .deploy-confirm-dialog {
    transform: scale(var(--ui-scale));
    transform-origin: center bottom;
}

:root.ui-compact .equipment-modal {
    width: min(900px, calc((100vw - 24px) / var(--ui-scale)));
    height: min(620px, calc((100vh - 24px) / var(--ui-scale)));
    transform: scale(var(--ui-scale));
    transform-origin: center;
}

:root.ui-compact .result-screen {
    padding: max(8px, calc(20px * var(--ui-scale)));
}

:root.ui-compact .result-screen > .result-header,
:root.ui-compact .result-screen > .result-unit-grid,
:root.ui-compact .result-screen > .btn-primary {
    transform: scale(var(--ui-scale));
    transform-origin: center;
}

:root.ui-compact .world-map-screen {
    padding: max(8px, calc(18px * var(--ui-scale)));
}

@media (max-width: 1100px) {
    .world-map-layout {
        grid-template-columns: 1fr;
        width: min(100%, calc(100vw - 28px));
    }

    .world-map-viewport {
        min-height: 0;
    }

    .world-map-info {
        min-height: 0;
    }
}

@media (max-width: 760px) {
    .stage-node {
        width: 18px;
        height: 18px;
    }
}

:root.ui-phone .dialogue-box {
    width: 92%;
    left: 4%;
    padding: max(8px, calc(15px * var(--ui-scale)));
}

:root.ui-phone .dialogue-content {
    gap: max(8px, calc(20px * var(--ui-scale)));
}

:root.ui-phone .speaker-img {
    width: calc(110px * var(--ui-scale));
    height: calc(110px * var(--ui-scale));
}

:root.ui-phone .speaker-name {
    font-size: calc(22px * var(--ui-scale));
}

:root.ui-phone .dialogue-text {
    font-size: calc(22px * var(--ui-scale));
}

@media (orientation: portrait) and (max-width: 760px) {
    #unit-list {
        width: min(280px, calc((100vw - 16px) / var(--ui-scale)));
    }

    #top-bar {
        max-width: calc((100vw - 16px) / var(--ui-scale));
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px 18px;
    }

    :root.ui-compact .org-container-v6 {
        gap: 10px;
        padding: 10px;
    }

    :root.ui-compact .org-col-left {
        flex-basis: 38%;
    }

    :root.ui-compact .org-col-center {
        flex-basis: 48px;
    }
}

