/* ========================================
   三国志战略版 — 全局样式
   ======================================== */

/* ---- Reset & Base ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0d1117;
    --bg-panel: rgba(13, 17, 23, 0.92);
    --bg-card: rgba(30, 40, 55, 0.95);
    --border: rgba(100, 120, 150, 0.25);
    --border-gold: rgba(201, 168, 76, 0.6);
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-gold: #c9a84c;
    --accent-red: #dc3545;
    --accent-blue: #4169e1;
    --accent-green: #228b22;
    --font-title: 'Ma Shan Zheng', 'Noto Serif SC', serif;
    --font-body: 'Noto Serif SC', 'Microsoft YaHei', sans-serif;
    --radius: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-dark);
    user-select: none;
    -webkit-user-select: none;
}

/* ---- Canvas ---- */
#gameCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: grab;
}

#gameCanvas:active {
    cursor: grabbing;
}

/* ---- UI 覆盖层 ---- */
#uiContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

#uiContainer > * {
    pointer-events: auto;
}

/* ========================================
   顶部信息栏
   ======================================== */
.hud-top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: linear-gradient(180deg, rgba(13, 17, 23, 0.95) 0%, rgba(13, 17, 23, 0.8) 100%);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-gold);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
}

.hud-faction-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hud-faction-name {
    font-family: var(--font-title);
    font-size: 22px;
    color: var(--text-gold);
    letter-spacing: 2px;
}

.hud-turn {
    font-size: 14px;
    color: var(--text-secondary);
    background: rgba(201, 168, 76, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-gold);
}

.hud-resources {
    display: flex;
    gap: 20px;
    align-items: center;
}

.resource {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
}

.resource.gold { color: #ffd700; }
.resource.food { color: #8bc34a; }
.resource.cities { color: #ff9800; }
.resource.generals { color: #90caf9; }

.btn-end-turn {
    background: linear-gradient(135deg, #c9a84c, #a08030);
    color: #1a1a2e;
    border: none;
    padding: 8px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 1px;
}

.btn-end-turn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(201, 168, 76, 0.4);
    background: linear-gradient(135deg, #dab85c, #b09040);
}

.btn-end-turn:active {
    transform: translateY(0);
}

/* ========================================
   右侧详情面板
   ======================================== */
.hud-side-panel {
    position: fixed;
    top: 70px;
    right: 16px;
    width: 300px;
    max-height: calc(100vh - 160px);
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.panel-placeholder {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.panel-header {
    padding: 16px;
    border-bottom: 2px solid var(--border-gold);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    font-family: var(--font-title);
    font-size: 20px;
    color: var(--text-gold);
}

.panel-faction {
    font-size: 13px;
    padding: 2px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
}

.coord-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.panel-body {
    padding: 16px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
}

.stat-row span:first-child {
    color: var(--text-secondary);
}

.panel-desc {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
    font-style: italic;
}

/* 武将属性网格 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 12px 0;
}

.stat-item {
    text-align: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: bold;
}

.stat-value.force { color: #f44336; }
.stat-value.intel { color: #2196f3; }
.stat-value.cmd   { color: #ff9800; }
.stat-value.pol   { color: #9c27b0; }
.stat-value.spd   { color: #4caf50; }

/* 武将血条 */
.general-hp-bar {
    position: relative;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 11px;
    overflow: hidden;
    margin-bottom: 12px;
}

.hp-fill {
    height: 100%;
    border-radius: 11px;
    transition: width 0.5s ease;
}

.hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* 技能标签 */
.general-skills {
    margin-top: 12px;
}

.general-skills h4 {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.skill-tag {
    display: inline-block;
    padding: 3px 10px;
    margin: 2px 4px 2px 0;
    font-size: 12px;
    background: linear-gradient(135deg, rgba(201, 168, 76, 0.2), rgba(201, 168, 76, 0.05));
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    color: var(--text-gold);
}

/* ========================================
   底部操作栏
   ======================================== */
.hud-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    min-width: 400px;
    max-width: 700px;
    max-height: 0;
    overflow: hidden;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: var(--shadow);
    transition: max-height 0.3s ease;
}

.hud-bottom-bar.show {
    max-height: 350px;
    overflow-y: auto;
}

.deploy-panel {
    padding: 16px;
}

.deploy-panel h3 {
    font-family: var(--font-title);
    font-size: 18px;
    color: var(--text-gold);
    margin-bottom: 12px;
}

.general-select-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.general-select-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.general-select-item:hover {
    background: rgba(201, 168, 76, 0.1);
    border-color: var(--border-gold);
}

.general-select-item input[type="checkbox"] {
    accent-color: var(--text-gold);
}

.general-select-name {
    flex: 1;
    font-weight: bold;
    font-size: 14px;
}

.general-select-stats {
    font-size: 12px;
    color: var(--text-secondary);
}

.deploy-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.btn-deploy, .btn-cancel {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-deploy {
    background: linear-gradient(135deg, #c9a84c, #a08030);
    color: #1a1a2e;
    font-weight: bold;
}

.btn-deploy:hover {
    box-shadow: 0 4px 12px rgba(201, 168, 76, 0.3);
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* ========================================
   战斗场景
   ======================================== */
.battle-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.battle-overlay.show {
    opacity: 1;
}

.battle-panel {
    width: 520px;
    max-height: 80vh;
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    box-shadow: 0 8px 48px rgba(201, 168, 76, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.battle-overlay.show .battle-panel {
    transform: scale(1);
}

.battle-header {
    padding: 20px;
    text-align: center;
    background: linear-gradient(135deg, rgba(201, 168, 76, 0.15), rgba(201, 168, 76, 0.05));
    border-bottom: 1px solid var(--border-gold);
}

.battle-header h2 {
    font-family: var(--font-title);
    font-size: 24px;
    color: var(--text-gold);
    margin-bottom: 8px;
}

.battle-matchup {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 16px;
}

.attacker-name { color: #f44336; font-weight: bold; }
.vs { color: var(--text-secondary); font-size: 14px; }
.defender-name { color: #2196f3; font-weight: bold; }

.battle-log {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    max-height: 350px;
}

.log-entry {
    padding: 4px 8px;
    margin: 2px 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
    border-left: 2px solid transparent;
}

.log-entry:nth-child(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.log-result {
    color: var(--text-gold) !important;
    font-weight: bold;
    font-size: 14px;
    border-left-color: var(--text-gold);
    margin-top: 8px;
    padding: 8px;
    background: rgba(201, 168, 76, 0.08) !important;
    border-radius: 4px;
}

.battle-result {
    text-align: center;
    padding: 16px;
    font-size: 20px;
    font-family: var(--font-title);
    letter-spacing: 2px;
}

.battle-result.victory {
    color: #4caf50;
    background: rgba(76, 175, 80, 0.08);
}

.battle-result.defeat {
    color: #f44336;
    background: rgba(244, 67, 54, 0.08);
}

.battle-close-btn {
    margin: 12px 20px 20px;
    padding: 10px;
    background: linear-gradient(135deg, #c9a84c, #a08030);
    color: #1a1a2e;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: bold;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s ease;
}

.battle-close-btn:hover {
    box-shadow: 0 4px 16px rgba(201, 168, 76, 0.4);
}

/* ========================================
   弹窗
   ======================================== */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.dialog-overlay.show {
    opacity: 1;
}

.dialog-box {
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    padding: 28px;
    min-width: 340px;
    max-width: 500px;
    box-shadow: var(--shadow);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.dialog-overlay.show .dialog-box {
    transform: scale(1);
}

.dialog-title {
    font-family: var(--font-title);
    font-size: 20px;
    color: var(--text-gold);
    margin-bottom: 12px;
}

.dialog-message {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-dialog {
    padding: 8px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-confirm {
    background: linear-gradient(135deg, #c9a84c, #a08030);
    color: #1a1a2e;
    font-weight: bold;
}

.btn-confirm:hover {
    box-shadow: 0 2px 12px rgba(201, 168, 76, 0.3);
}

.btn-dialog.btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* 势力选择弹窗 */
.faction-dialog {
    max-width: 700px;
    min-width: 600px;
}

.faction-dialog .dialog-title {
    text-align: center;
    font-size: 28px;
    margin-bottom: 20px;
}

.faction-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.faction-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.02);
}

.faction-card:hover {
    border-color: var(--text-gold);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(201, 168, 76, 0.2);
}

.faction-card-header {
    padding: 16px;
    text-align: center;
}

.faction-card-header h4 {
    font-family: var(--font-title);
    font-size: 28px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.faction-card-header span {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
}

.faction-card-desc {
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.faction-card-stats {
    display: flex;
    justify-content: space-around;
    padding: 10px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
}

/* ========================================
   Toast 消息
   ======================================== */
.toast-message {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    color: var(--text-gold);
    padding: 10px 28px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.toast-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ========================================
   滚动条美化
   ======================================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 76, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 168, 76, 0.5);
}
