:root {
  --gold: #e8a33d; --gold-dim: #c08a3a; --bg: #eef3e6; --panel: rgba(255,255,255,0.86);
  --text: #4a4030; --enemy: #e8624d;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: var(--bg); }
body { font-family: "PingFang SC", "Microsoft YaHei", "Comic Sans MS", "Baloo", sans-serif; color: var(--text); -webkit-tap-highlight-color: transparent; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
/* 所有按钮/可点击元素文字不可被选中（移动端点击不会误选文字） */
button, .btn, .btnd, .join button, .hud { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
#map { display: block; width: 100vw; height: 100vh; background: radial-gradient(ellipse at 50% 40%, #f6f9ee 0%, var(--bg) 75%); -webkit-user-select: none; user-select: none; touch-action: manipulation; }

.hud { position: fixed; inset: 0; pointer-events: none; }
.hud .top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 12px 60px; background: linear-gradient(180deg, rgba(8,10,14,0.9), transparent); }
.title { font-size: 20px; letter-spacing: 3px; color: var(--gold); }
.title .en { font-size: 12px; color: var(--gold-dim); }
.brand { font-size: 10px; letter-spacing: 3px; color: var(--gold-dim); margin-top: 2px; opacity: 0.8; }
.res { display: flex; gap: 14px; font-size: 13px; letter-spacing: 1px; }
.res .r { color: #9fb0c8; }
.res .r b { color: var(--gold); font-weight: 600; }

.tilePop { position: absolute; z-index: 40; display: none; background: var(--panel); border: 1px solid var(--gold-dim); border-radius: 8px; padding: 6px 8px; font-size: 10px; line-height: 1.45; width: -moz-fit-content; width: fit-content; max-width: min(92vw, 360px); max-height: 52vh; overflow-y: auto; pointer-events: auto; box-shadow: 0 8px 22px rgba(0,0,0,.4); }
.tilePop.show { display: block; }
.tilePop .popHead { color: var(--gold); font-size: 10px; letter-spacing: 1px; margin-bottom: 3px; border-bottom: 1px solid rgba(138,109,59,.3); padding-bottom: 3px; display: flex; align-items: center; justify-content: space-between; }
.tilePop .popClose { cursor: pointer; color: var(--gold-dim); font-size: 14px; line-height: 1; padding: 0 2px; }
.tilePop .popClose:active { color: var(--gold); }
.tilePop .btn { margin-top: 3px; display: inline-block; min-height: 0; font-size: 10px; line-height: 1.3; letter-spacing: 0.5px; border: 1px solid var(--gold-dim); color: var(--gold); background: transparent; padding: 2px 7px; border-radius: 6px; cursor: pointer; margin-right: 4px; margin-bottom: 2px; }
.tilePop .btn:active { background: rgba(138,109,59,0.2); }
.tilePop .btn.disabled { color: #6a6456; border-color: rgba(106,100,86,0.4); background: transparent; cursor: not-allowed; opacity: 0.55; pointer-events: none; }


.join { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(6,8,12,0.92); z-index: 10; }
.join .box { background: var(--panel); border: 1px solid var(--gold-dim); border-radius: 14px; padding: 28px 32px; text-align: center; }
.join .t { font-size: 22px; letter-spacing: 4px; color: var(--gold); margin-bottom: 18px; }
.join input { display: block; width: 220px; margin: 0 auto 14px; font-size: 14px; padding: 9px 12px; background: rgba(0,0,0,0.3); border: 1px solid var(--gold-dim); border-radius: 8px; color: var(--text); text-align: center; }
.join button { font-size: 14px; letter-spacing: 3px; border: 1px solid var(--gold-dim); background: linear-gradient(180deg, #a8842f, #8a6d1f); color: #1a1408; font-weight: bold; padding: 10px 36px; border-radius: 8px; cursor: pointer; }
.join .hint { margin-top: 16px; font-size: 11px; color: var(--gold-dim); letter-spacing: 1px; }

/* 左上角汉堡菜单按钮（CSS 三条横杠） */
.menuBtn { position: fixed; top: 14px; left: 14px; z-index: 30; width: 38px; height: 38px; border: 1px solid var(--gold-dim); border-radius: 8px; background: rgba(18,22,30,0.85); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; cursor: pointer; padding: 0; pointer-events: auto; -webkit-user-select: none; user-select: none; }
.menuBtn .bar { display: block; width: 18px; height: 2px; background: var(--gold); border-radius: 2px; transition: transform .2s, opacity .2s; }
.menuBtn:active { background: rgba(138,109,59,0.25); }
/* 展开态：三条杠变 X（可选视觉反馈） */
.menuBtn.open .bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menuBtn.open .bar:nth-child(2) { opacity: 0; }
.menuBtn.open .bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
/* 左侧抽屉菜单 */
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 220px; z-index: 29; background: rgba(14,18,26,0.97); border-right: 1px solid var(--gold-dim); padding: 64px 12px 12px; transform: translateX(-100%); transition: transform .22s ease; pointer-events: auto; box-shadow: 4px 0 24px rgba(0,0,0,0.5); -webkit-user-select: none; user-select: none; }
.drawer.open { transform: translateX(0); }
.drawerHead { color: var(--gold-dim); letter-spacing: 3px; font-size: 12px; margin-bottom: 10px; padding-left: 6px; }
.menuItem { display: block; padding: 12px 14px; margin-bottom: 6px; font-size: 14px; letter-spacing: 1px; color: var(--text); text-decoration: none; border: 1px solid rgba(138,109,59,0.3); border-radius: 8px; cursor: pointer; -webkit-user-select: none; user-select: none; }
.menuItem:hover, .menuItem:active { background: rgba(138,109,59,0.2); color: var(--gold); }
/* 抽屉遮罩：点击关闭 */
.drawerMask { position: fixed; inset: 0; z-index: 28; background: rgba(0,0,0,0.35); opacity: 0; visibility: hidden; transition: opacity .2s; pointer-events: auto; }
.drawerMask.open { opacity: 1; visibility: visible; }
.footer { position: fixed; bottom: 6px; left: 50%; transform: translateX(-50%); font-size: 10px; letter-spacing: 2px; color: var(--gold-dim); opacity: 0.7; z-index: 4; }

.battles { position: absolute; right: 16px; top: 64px; width: 230px; background: var(--panel); border: 1px solid var(--gold-dim); border-radius: 8px; padding: 6px 10px; font-size: 11px; line-height: 1.5; pointer-events: auto; cursor: default; }
.battles .bh { color: var(--gold); letter-spacing: 1px; margin-bottom: 2px; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
.battles .tri { font-size: 13px; font-weight: 600; color: var(--gold); letter-spacing: 1px; }
.battles .bempty { color: var(--gold-dim); }
.battles .brow { color: #9fb0c8; padding: 2px 0; border-top: 1px solid rgba(138,109,59,0.15); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.battles .brow.me { color: var(--gold); font-weight: 600; }
.battles .bmore { color: var(--gold-dim); font-size: 10px; margin-top: 3px; text-align: center; cursor: pointer; border-top: 1px dashed rgba(138,109,59,0.25); padding-top: 3px; }
.battles .bmore:active { color: var(--gold); }
/* 展开全部战报：窗口拉高可滚动 */
.battles.all { max-height: 60vh; overflow-y: auto; }
/* 收起成小图标，节省屏幕空间 */
.battles.collapsed { width: auto; max-height: none; padding: 4px 6px; cursor: pointer; overflow: visible; }
.battles .bicon { font-size: 20px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }

.btnd { display: inline-block; font-size: 12px; letter-spacing: 1px; border: 1px solid rgba(138,109,59,0.4); color: #6a6456; background: transparent; padding: 6px 12px; border-radius: 6px; margin-top: 8px; margin-right: 6px; cursor: not-allowed; opacity: 0.6; }
.res2 { display: block; margin-top: 8px; font-size: 12px; color: var(--gold-dim); letter-spacing: 1px; }
.shield { display: inline-block; margin-top: 8px; font-size: 12px; color: #6fd08c; border: 1px solid rgba(111,208,140,0.5); background: rgba(111,208,140,0.1); padding: 5px 10px; border-radius: 6px; }

.hero { display: block; font-size: 11px; color: #c8b6e0; padding: 2px 0; border-top: 1px solid rgba(138,109,59,0.15); }
.hero.here { color: #ff9a9a; font-weight: 600; }
.hero .btn { font-size: 10px; padding: 2px 6px; margin-left: 6px; }
.hf { display: block; font-size: 10px; color: #9a8a78; padding: 1px 0 4px 8px; }
/* 赛季历史面板 */
.sechist { margin-top: 8px; border-top: 1px solid rgba(138,109,59,0.2); padding-top: 6px; }
.sechist .shh { font-size: 11px; color: #e0c060; margin-bottom: 3px; }
.sechist .shrow { display: flex; font-size: 11px; padding: 1px 0; align-items: center; }
.sechist .shs { color: #9a8a78; width: 28px; flex: 0 0 28px; }
.sechist .shc { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sechist .shsc { color: #c8b6e0; margin-left: 6px; }
/* 赛季切换横幅 */
.season-banner {
  position: fixed; top: 18%; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: linear-gradient(135deg, rgba(60,40,20,0.96), rgba(40,25,55,0.96));
  border: 1px solid rgba(224,192,96,0.6); border-radius: 10px;
  color: #ffe9a8; font-size: 15px; font-weight: 600; padding: 14px 26px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5); z-index: 9999;
  opacity: 0; pointer-events: none; transition: opacity .4s, transform .4s;
  white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
.season-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* ===== 内政页（标签式） ===== */
.internal {
  position: fixed; inset: 0; z-index: 9000; display: none;
  background: rgba(20,14,8,0.55); backdrop-filter: blur(2px);
  align-items: center; justify-content: center;
}
.internal.show { display: flex; }
.internalBox {
  width: min(880px, 94vw); height: min(82vh, 720px);
  background: linear-gradient(160deg, #2a2018, #1c150f);
  border: 1px solid rgba(224,192,96,0.45); border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
  display: flex; flex-direction: column; overflow: hidden;
}
.internalHead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid rgba(224,192,96,0.3);
  background: rgba(224,192,96,0.08);
}
.internalTitle { font-size: 17px; font-weight: 700; color: #ffe9a8; }
.internalClose {
  background: transparent; border: none; color: #c0a878; font-size: 20px;
  cursor: pointer; line-height: 1; padding: 2px 8px; border-radius: 6px;
}
.internalClose:hover { background: rgba(255,255,255,0.08); color: #fff; }
.internalTabs {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 14px 0;
  border-bottom: 1px solid rgba(224,192,96,0.18);
}
.internalTab {
  padding: 7px 14px; font-size: 13px; color: #c0a878; cursor: pointer;
  border-radius: 8px 8px 0 0; border: 1px solid transparent; border-bottom: none;
  user-select: none;
}
.internalTab:hover { color: #ffe9a8; background: rgba(255,255,255,0.04); }
.internalTab.on {
  color: #1c150f; background: #e0c060; font-weight: 600;
  border-color: rgba(224,192,96,0.6);
}
.internalBody {
  flex: 1; overflow-y: auto; padding: 16px 18px; color: #e8dcc8; font-size: 13px; line-height: 1.7;
}
.internalBody h3 { color: #ffe9a8; font-size: 14px; margin: 4px 0 10px; border-left: 3px solid #e0c060; padding-left: 8px; }
.internalBody h4 { color: #d8c090; font-size: 13px; margin: 14px 0 6px; }
.internalBody .row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; align-items: center; }
.internalBody .kv { color: #c0a878; }
.internalBody .kv b { color: #ffe9a8; font-weight: 600; }
.card {
  background: rgba(255,255,255,0.04); border: 1px solid rgba(224,192,96,0.2);
  border-radius: 10px; padding: 10px 12px; margin: 8px 0;
}
.card .ct { color: #ffe9a8; font-weight: 600; margin-bottom: 4px; }
.card .cd { color: #b8a888; font-size: 12px; }
.ph {
  display: block; width: 100%; max-width: 240px; height: 96px; margin: 8px 0;
  background: repeating-linear-gradient(45deg, #3a3026, #3a3026 10px, #342a20 10px, #342a20 20px);
  border: 1px dashed rgba(224,192,96,0.35); border-radius: 8px;
  color: #8a7a60; font-size: 11px; display: flex; align-items: center; justify-content: center; text-align: center;
}
.internalBody .btn, .internalBody .bld, .internalBody .btnd {
  display: inline-block; cursor: pointer; border-radius: 6px; padding: 4px 10px; font-size: 12px; margin: 2px 4px 2px 0;
}
.internalBody .btn { background: #3a6ea5; color: #fff; border: 1px solid #4f86c6; }
.internalBody .btn:hover { background: #4f86c6; }
.internalBody .bld { background: #4a7a3a; color: #fff; border: 1px solid #5e9a4a; }
.internalBody .btnd { background: #554a3a; color: #9a8a70; border: 1px solid #6a5a44; cursor: not-allowed; }
.internalBody .morder { background: rgba(255,255,255,0.04); border: 1px solid rgba(138,109,59,0.3); border-radius: 6px; padding: 6px 10px; margin: 4px 0; font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.internalBody .morder .btn, .internalBody .morder .btnd { margin-left: auto; }
.internalBody select, .internalBody input[type="number"] { background: rgba(0,0,0,0.3); border: 1px solid var(--gold-dim); color: var(--text); border-radius: 6px; padding: 4px 6px; font-size: 13px; }

/* ===== 移动端适配（平板/手机，窄屏 ≤768px） ===== */
@media (max-width: 768px) {
  /* 顶部资源条：缩小、换行、让出左侧菜单键 */
  .hud .top { padding: 8px 10px 8px 52px; flex-wrap: wrap; gap: 4px; background: linear-gradient(180deg, rgba(8,10,14,0.95), rgba(8,10,14,0.4)); }
  .title { font-size: 14px; }
  .brand { font-size: 9px; }
  .res { gap: 8px; font-size: 11px; flex-wrap: wrap; }
  .res .r { white-space: nowrap; }

  /* 菜单按钮稍小，避免遮挡 */
  .menuBtn { top: 10px; left: 10px; width: 34px; height: 34px; }

  /* 战报在手机上放右上角，默认3行+更多，可收起成图标 */
  .battles { right: 8px; top: 52px; width: 200px; }
  .battles .bh { font-size: 11px; }
  .battles.collapsed { width: auto; max-height: none; }

  /* 选中操作浮窗：手机上底部居中,宽度随内容(不铺满) */
  .tilePop {
    left: 50%; transform: translateX(-50%); bottom: calc(8px + env(safe-area-inset-bottom)); top: auto; right: auto;
    width: -moz-fit-content; width: fit-content; max-width: 90vw;
    border-radius: 10px 10px 8px 8px; max-height: 46vh; overflow-y: auto;
    padding: 7px 9px; font-size: 10px; line-height: 1.45; box-shadow: 0 -6px 24px rgba(0,0,0,0.5);
  }
  .tilePop .btn { display: inline-block; min-height: 0; margin: 3px 4px 3px 0; padding: 3px 8px; font-size: 11px; line-height: 1.3; }

  /* 触摸热区：按钮/标签最小 40px 高，方便手指点 */
  .btn, .bld, .btnd, .internalTab, .menuBtn { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; }
  .internalTab { padding: 8px 14px; font-size: 13px; }

  /* 内政页：窄屏更贴近边缘，标签栏可横滑 */
  .internalBox { width: 96vw; height: 88vh; border-radius: 12px; }
  .internalTabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .internalTab { white-space: nowrap; flex: 0 0 auto; }
  .internalBody { padding: 12px 12px; font-size: 13px; }
  .internalBody .btn, .internalBody .bld, .internalBody .btnd { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px; margin: 3px 4px 3px 0; }
  .ph { max-width: 100%; height: 88px; }

  /* 抽屉菜单在手机上稍宽 */
  .drawer { width: 78vw; max-width: 280px; }

  /* 战报标题更小 */
  .battles .bh { font-size: 11px; }
}

/* 超小屏（手机竖屏 ≤480px）进一步收紧；资源改为最右侧竖列，不挤占顶部 */
@media (max-width: 480px) {
  .res {
    position: fixed; right: 0; top: 50px; bottom: auto;
    flex-direction: column; align-items: flex-end; gap: 2px;
    background: rgba(20,16,10,0.7); padding: 6px 8px; border-radius: 8px 0 0 8px;
    max-height: calc(100vh - 120px); overflow-y: auto; z-index: 25;
    font-size: 11px;
  }
  .res .r { white-space: nowrap; }
  .top { padding: 8px 10px 8px 48px; }
  .title { font-size: 13px; }
  .battles { width: 150px; }
  .internalBox { width: 100vw; height: 92vh; border-radius: 0; }
}

/* 主城内建筑列表（上下排列，每建筑一标签） */
.bldList { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.bldRow { border: 1px solid #4a3a20; border-radius: 6px; padding: 6px 8px; background: rgba(40,30,15,0.4); }
.bldName { color: #ffe9a8; font-weight: 600; font-size: 13px; }
.bldLv { color: #9fd8a0; font-weight: 400; margin-left: 4px; }
.bldReq { color: #c0a878; font-size: 11px; margin: 2px 0; }
.bldAct { margin-top: 3px; }
.bldAct .btn.off { opacity: 0.45; cursor: not-allowed; }

/* 建造页：左标签 + 右详情 */
.buildWrap { display: flex; gap: 10px; align-items: flex-start; }
.buildTabs { flex: 0 0 150px; display: flex; flex-direction: column; gap: 3px; border-right: 1px solid #3a2f1a; padding-right: 8px; }
.bldTab { padding: 5px 8px; border: 1px solid #3a2f1a; border-radius: 5px; color: #c0a878; cursor: pointer; font-size: 12px; }
.bldTab b { color: #9fd8a0; font-weight: 400; margin-left: 4px; }
.bldTab.on { border-color: #e0c060; background: rgba(60,50,20,0.6); color: #ffe9a8; }
.buildDetail { flex: 1; min-width: 0; }

/* 科技/建筑左侧分组小标题 */
.bldGroup { font-size: 11px; color: #8a7a52; padding: 6px 8px 2px; border-bottom: 1px dotted #3a2f1a; margin-bottom: 2px; }

/* 科技树图（左大类标签 + 右节点树） */
.techSvg { background: rgba(20,30,20,0.35); border:1px solid #2f3a2a; border-radius:6px; margin:4px 0; max-width:100%; }
.techSvg .edge { stroke:#546; stroke-width:1.5; fill:none; }
.techSvg .edge.done { stroke:#5a8f5a; }
.techSvg .edge.lock { stroke:#3a3a3a; }
.tnode { cursor:default; }
.tnode rect { fill:#1c241a; stroke:#4a5a3a; stroke-width:1.5; rx:6; }
.tnode text { fill:#cfe0c0; font-size:12px; }
.tnode .lv { fill:#9fd8a0; font-size:11px; }
.tnode .req { fill:#8a9a7a; font-size:10px; }
.tnode.avail rect { stroke:#6fcf6f; fill:#223018; cursor:pointer; }
.tnode.avail:hover rect { fill:#2c4018; }
.tnode.done rect { stroke:#5a8f5a; fill:#1a2c16; }
.tnode.done .ttl { fill:#bfe8bf; }
.tnode.lock rect { stroke:#555; fill:#1a1a1a; opacity:0.7; }
  .crossDep{ fill:#e8a33d; font-size:9px; }
.tnode.lock text { fill:#777; }

/* 科技树图 紧凑化(移动端友好) */
.techSvg { width:100%; height:auto; touch-action:manipulation; }
.tnode text { font-size:10px; }
.tnode .lv { font-size:9px; }
.tnode .req { font-size:8px; }
.tnode rect { rx:4; stroke-width:1.2; }
/* 窄屏: 左标签收窄, 详情占满 */
@media (max-width: 560px) {
  .buildTabs { flex: 0 0 104px; }
  .bldTab { font-size:11px; padding:4px 6px; }
  .bldGroup { font-size:10px; padding:5px 6px 1px; }
  .internalBox { width: 96vw; max-width: 96vw; }
  .techSvg { min-width: 280px; }
}
