/* OukaStrategy ダークテーマ(docs/02 8章の承認済みパレット) */

:root {
    --bg-deepest: #0d1015;
    --bg-base: #12151c;
    --panel: #161a22;
    --panel-alt: #1b2029;
    --border: #2a3140;
    --text: #d7dbe2;
    --text-weak: #8b93a3;
    --accent: #c9a227;
    --accent-bright: #e0c05a;
    --west: #3f7ca3;
    --east: #a1483f;
    --good: #5a9a5f;
    --river: #4a7fb5;
    --cell-size: 30px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg-deepest);
    color: var(--text);
    font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
    font-size: 14px;
}

#app, .game-root {
    height: 100%;
}

.text-west { color: #7db3d6; font-weight: bold; }
.text-east { color: #d08a80; font-weight: bold; }
.text-weak { color: var(--text-weak); }

/* ---- レイアウト(上部バー/左右パネル/中央マップ/下部コマンド) ---- */

.game-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-base);
}

.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 14px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.app-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--accent-bright);
}

.phase-tag {
    margin-left: 8px;
    font-size: 11px;
    font-weight: normal;
    color: var(--text-weak);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 6px;
}

.top-item {
    white-space: nowrap;
}

.tick-time {
    color: var(--text-weak);
    font-variant-numeric: tabular-nums;
}

.speed-controls {
    display: flex;
    gap: 4px;
}

.speed-button {
    background: var(--panel-alt);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 2px 10px;
    cursor: pointer;
}

.speed-button:hover {
    border-color: var(--accent);
}

.speed-button.active {
    background: var(--accent);
    color: var(--bg-deepest);
    font-weight: bold;
}

.middle-row {
    display: flex;
    flex: 1;
    min-height: 0;
}

.side-panel {
    width: 240px;
    padding: 10px;
    background: var(--panel);
    overflow-y: auto;
    flex-shrink: 0;
}

.left-panel { border-right: 1px solid var(--border); }
.right-panel { border-left: 1px solid var(--border); }

.side-panel h2 {
    font-size: 13px;
    color: var(--accent-bright);
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
    margin: 12px 0 8px;
}

.side-panel h2:first-child { margin-top: 0; }

.summary-line, .detail-line {
    margin: 4px 0;
    line-height: 1.5;
}

.division-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin: 2px 0;
    padding: 4px 6px;
    background: var(--panel-alt);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    text-align: left;
    font-size: 12px;
}

.division-row.selected {
    border-color: var(--accent-bright);
}

/* ---- マップ ---- */

.map-area {
    flex: 1;
    overflow: auto;
    padding: 12px;
    background: var(--bg-deepest);
}

.map-grid {
    display: grid;
    gap: 1px;
    width: max-content;
    background: var(--border);
    border: 1px solid var(--border);
}

.map-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-cell:hover {
    outline: 1px solid var(--accent);
    outline-offset: -1px;
    z-index: 2;
}

.owner-west { background: #24405a; }
.owner-east { background: #4d2a26; }

/* 地形による明度差(支配色の上に重ねる) */
.terrain-hills { box-shadow: inset 0 0 0 100px rgba(255, 255, 255, 0.05); }
.terrain-mountains { box-shadow: inset 0 0 0 100px rgba(0, 0, 0, 0.35); }
.terrain-forest { box-shadow: inset 0 0 0 100px rgba(60, 120, 60, 0.25); }
.terrain-marsh { box-shadow: inset 0 0 0 100px rgba(60, 110, 110, 0.25); }
.terrain-desert { box-shadow: inset 0 0 0 100px rgba(180, 160, 90, 0.18); }
.terrain-urban { box-shadow: inset 0 0 0 100px rgba(200, 200, 220, 0.16); }
.terrain-coast { box-shadow: inset 0 0 0 100px rgba(90, 140, 190, 0.15); }
.terrain-sea { background: #101c2c; cursor: not-allowed; }

.terrain-glyph {
    font-size: 10px;
    color: rgba(215, 219, 226, 0.55);
    pointer-events: none;
    user-select: none;
}

.cell-selected {
    outline: 2px solid var(--accent-bright);
    outline-offset: -2px;
    z-index: 3;
}

.cell-target {
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
    z-index: 3;
}

.division-markers {
    position: absolute;
    inset: 1px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 1px;
    pointer-events: none;
}

.division-marker {
    width: 12px;
    height: 12px;
    font-size: 9px;
    line-height: 12px;
    text-align: center;
    color: #fff;
    border-radius: 2px;
    user-select: none;
}

.marker-west { background: var(--west); }
.marker-east { background: var(--east); }
.marker-selected { outline: 1px solid var(--accent-bright); }
.marker-locked { opacity: 0.55; }

.hub-glyph {
    position: absolute;
    top: -1px;
    left: 1px;
    font-size: 11px;
    color: var(--accent-bright);
    pointer-events: none;
    user-select: none;
    z-index: 1;
}

.text-accent { color: var(--accent-bright); }

.production-row {
    margin: 2px 0;
    padding: 4px 6px;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 3px;
    font-size: 12px;
}

.production-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.factory-controls {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.mini-button {
    background: var(--bg-deepest);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 3px;
    width: 20px;
    height: 20px;
    line-height: 1;
    cursor: pointer;
}

.mini-button:hover { border-color: var(--accent); }

.reserve-row { border-color: var(--good); }

/* ---- 下部コマンド ---- */

.bottom-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--panel);
    border-top: 1px solid var(--border);
}

.command-button {
    background: var(--panel-alt);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 4px 14px;
    cursor: pointer;
}

.command-button:hover:not(:disabled) {
    border-color: var(--accent);
}

.command-button:disabled {
    opacity: 0.4;
    cursor: default;
}

.message {
    color: var(--text-weak);
}

.save-controls {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

/* 軍団編成(チェック+行)と経由地表示 */
.division-line {
    display: flex;
    align-items: stretch;
    gap: 4px;
}

.division-line .division-row {
    flex: 1;
    min-width: 0;
}

.check-button {
    flex: 0 0 auto;
    background: var(--panel-alt);
    color: var(--text-weak);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0 6px;
    font-size: 12px;
    cursor: pointer;
}

.check-button.checked {
    color: var(--accent-bright);
    border-color: var(--accent);
}

.cell-waypoint {
    outline: 2px dotted var(--accent-bright);
    outline-offset: -2px;
}

/* セーブ読み込み・勝敗のモーダル(フェーズ5) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 10, 14, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.modal-box {
    background: var(--panel);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 18px 22px;
    min-width: 340px;
    max-width: 70vw;
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.6);
}

.modal-box h1 {
    margin: 0 0 10px;
    font-size: 26px;
}

.modal-box h2 {
    margin: 0 0 10px;
    color: var(--accent-bright);
    font-size: 15px;
}

.modal-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: flex-end;
}

.victory-box {
    text-align: center;
}

.victory-box .modal-buttons {
    justify-content: center;
}

.import-textarea {
    width: 480px;
    max-width: 60vw;
    height: 140px;
    background: var(--bg-deepest);
    color: inherit;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px;
    font-size: 11px;
    resize: vertical;
}

.org-bar {
    display: inline-block;
    width: 60px;
    height: 7px;
    background: var(--bg-deepest);
    border: 1px solid var(--border);
    border-radius: 2px;
    overflow: hidden;
    vertical-align: middle;
}

.org-bar.wide { width: 120px; margin-left: 6px; }

.org-fill {
    display: block;
    height: 100%;
    background: var(--good);
}

.loading-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: var(--text-weak);
    font-size: 16px;
}

/* ---- Blazor起動時のローディング表示(テンプレート由来) ---- */

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #2a3140;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #c9a227;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    color: #d7dbe2;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

#blazor-error-ui {
    background: #4d2a26;
    color: #d7dbe2;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.3);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
