/* ================= 英雄无敌 3D · 出品向样式 ================= */
:root {
  --gold: #ffd76b;
  --gold-dark: #c8a951;
  --gold-border: #6b5a2e;
  --panel-bg: rgba(20, 15, 8, .88);
  --panel-bg-light: rgba(20, 15, 8, .72);
  --text-hi: #ffe9b0;
  --text-mid: #b8a888;
  --text-dim: #9a8a68;
  --blue: #3b82f6;
  --red: #ef4444;
  --green: #4f9140;
  --purple: #b89aff;
  --danger: #a5443a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden; background: #0d0b08;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text-hi);
  user-select: none; -webkit-user-select: none;
}
h1, .cg-title, .load-title { font-family: "Ma Shan Zheng", "Noto Sans SC", serif; }
#game, #game canvas { position: fixed; inset: 0; touch-action: none; }
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.36) 100%);
}
.hidden { display: none !important; }

/* ---------- 通用按钮 ---------- */
.btn-gold {
  background: linear-gradient(180deg, #3a2f1a, #241c0e);
  border: 1px solid var(--gold-dark); color: var(--text-hi);
  padding: 7px 16px; border-radius: 6px; cursor: pointer;
  font-size: 14px; font-family: inherit; letter-spacing: 1px;
  transition: all .15s; white-space: nowrap;
}
.btn-gold:hover:not(:disabled) { background: linear-gradient(180deg, #54431f, #33270f); box-shadow: 0 0 10px rgba(200,169,81,.4); }
.btn-gold:disabled { opacity: .35; cursor: not-allowed; }
.btn-gold.big { font-size: 20px; padding: 12px 44px; }
.btn-danger { border-color: var(--danger); color: #ff9a8a; }
.btn-danger:hover:not(:disabled) { background: linear-gradient(180deg, #542a1f, #33170f); box-shadow: 0 0 10px rgba(165,68,58,.4); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.dot.gold { background: #d4af37; } .dot.wood { background: #8a6b3d; } .dot.ore { background: #9a9da1; }

/* 描金边角（用于面板） */
.ornate { position: relative; }
.ornate::before, .ornate::after {
  content: ''; position: absolute; width: 12px; height: 12px; pointer-events: none; z-index: 3;
  border-color: var(--gold); border-style: solid;
}
.ornate::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.ornate::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

/* ---------- 加载画面 ---------- */
#loading {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #241c0e, #0d0b08);
  transition: opacity .6s;
}
#loading.fade { opacity: 0; pointer-events: none; }
.load-inner { text-align: center; }
.load-title { font-size: 42px; letter-spacing: 8px; color: var(--gold); text-shadow: 0 0 24px rgba(255,215,107,.4); margin-bottom: 22px; }
.load-bar { width: 220px; height: 8px; margin: 0 auto; background: #241c0e; border: 1px solid var(--gold-border); border-radius: 4px; overflow: hidden; }
.load-fill { height: 100%; width: 30%; background: linear-gradient(90deg, var(--gold-dark), var(--gold)); border-radius: 4px; animation: loadSlide 1.1s ease-in-out infinite alternate; }
@keyframes loadSlide { from { margin-left: 0; width: 30%; } to { margin-left: 70%; width: 30%; } }
.load-tip { margin-top: 12px; font-size: 13px; color: var(--text-dim); letter-spacing: 2px; }

/* ---------- 顶部资源栏 ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 46px; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  background: linear-gradient(180deg, rgba(20,15,8,.94), rgba(20,15,8,.78));
  border-bottom: 1px solid var(--gold-border);
}
.tb-day { font-size: 16px; color: var(--gold); font-weight: 700; letter-spacing: 2px; flex-shrink: 0; }
.tb-res { display: flex; gap: 22px; font-size: 14px; }
.res b { color: var(--text-hi); margin-left: 3px; }
.res .inc { color: #7dcf6a; font-size: 11px; margin-left: 3px; font-weight: normal; }
.tb-right { display: flex; gap: 8px; flex-shrink: 0; }
.btn-icon { padding: 7px 12px; }

/* ---------- 英雄栏（地图模式，左下） ---------- */
#herobar {
  position: fixed; left: 12px; bottom: 12px; z-index: 20;
  background: var(--panel-bg); border: 1px solid var(--gold-border); border-radius: 10px;
  padding: 10px 14px; width: 360px; max-width: calc(100vw - 200px);
}
#hero-info { margin-bottom: 8px; }
.hero-name { font-size: 15px; color: var(--gold); font-weight: 700; }
.hero-stats { font-size: 12px; color: var(--text-mid); margin-top: 2px; }
.xp-bar { position: relative; height: 8px; margin-top: 5px; background: #241c0e; border: 1px solid var(--gold-border); border-radius: 4px; overflow: hidden; }
.xp-fill { height: 100%; background: linear-gradient(90deg, #7a5fc0, var(--purple)); transition: width .3s; }
.xp-bar span { position: absolute; inset: 0; text-align: center; font-size: 8px; line-height: 8px; color: var(--text-hi); text-shadow: 0 1px 1px #000; }
#army { display: flex; flex-wrap: wrap; gap: 6px; max-height: 52px; overflow: hidden; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(50,40,20,.8); border: 1px solid var(--gold-border); border-radius: 5px;
  padding: 3px 8px; font-size: 12px; color: #d8c8a0;
}
.chip b { color: var(--text-hi); }
#mp-bar { position: relative; height: 16px; margin-top: 8px; background: #241c0e; border: 1px solid var(--gold-border); border-radius: 8px; overflow: hidden; }
#mp-fill { height: 100%; background: linear-gradient(90deg, #3f8f4f, #6fbf5f); transition: width .3s; }
#mp-text { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; color: #e8f8e0; text-shadow: 0 1px 2px #000; }

/* ---------- 底部提示（地图模式） ---------- */
#hint {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 15;
  font-size: 12px; color: rgba(232,220,192,.7); background: var(--panel-bg-light);
  padding: 5px 14px; border-radius: 14px; pointer-events: none;
}

/* ---------- 小地图（地图模式，右下） ---------- */
#minimap {
  position: fixed; right: 12px; bottom: 12px; z-index: 20;
  border: 2px solid var(--gold-dark); border-radius: 8px; overflow: hidden;
  background: #14100a; box-shadow: 0 4px 16px rgba(0,0,0,.5);
  opacity: .94; cursor: pointer;
}
#minimap canvas { display: block; }

/* ---------- 战场栏（战斗模式，底部两行） ---------- */
#battlebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: linear-gradient(0deg, rgba(20,15,8,.96), rgba(20,15,8,.74));
  border-top: 1px solid var(--gold-border);
  padding: 6px 14px;
  display: flex; flex-direction: column; gap: 5px;
}
.bb-top { display: flex; align-items: center; gap: 12px; }
.bb-bottom { display: flex; align-items: center; gap: 8px; justify-content: center; }
#round-ind { font-size: 14px; color: var(--gold); font-weight: 700; letter-spacing: 1px; white-space: nowrap; flex-shrink: 0; }
#queue { display: flex; gap: 4px; flex-wrap: nowrap; overflow-x: auto; flex: 1 1 auto; }
#queue::-webkit-scrollbar { height: 0; }
.q-chip { font-size: 11px; padding: 2px 7px; border-width: 2px; white-space: nowrap; }
.q-chip b { margin-left: 3px; }
.q-active { background: rgba(200,169,81,.35); box-shadow: 0 0 8px rgba(200,169,81,.5); }
#active-info { font-size: 13px; flex-shrink: 0; max-width: 320px; }
.ai-line { display: block; font-size: 11px; color: var(--text-mid); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-actions { display: flex; gap: 6px; }
#battle-hint { display: none; }

/* ---------- 战斗日志（战斗模式，右侧） ---------- */
#battle-log {
  position: fixed; right: 12px; top: 56px; z-index: 19;
  width: 250px; max-height: 40vh; overflow-y: auto;
  background: var(--panel-bg); border: 1px solid var(--gold-border); border-radius: 8px;
  padding: 8px 10px; font-size: 11.5px; line-height: 1.6;
}
#battle-log::-webkit-scrollbar { width: 5px; }
#battle-log::-webkit-scrollbar-thumb { background: var(--gold-border); border-radius: 3px; }
.log-line { color: #c8b890; border-bottom: 1px solid rgba(107,90,46,.2); padding: 1px 0; }
.log-line.ally { color: #9fc8f8; } .log-line.enemy { color: #ff9a8a; }
.log-line.spell { color: #d8a8ff; } .log-line.morale { color: var(--gold); }
.log-line.round { color: var(--text-dim); text-align: center; }

/* ---------- 回合横幅 ---------- */
#turn-banner {
  position: fixed; top: 32%; left: 50%; transform: translate(-50%, -50%) scale(.4);
  z-index: 42; pointer-events: none; opacity: 0;
  font-size: 44px; font-weight: 700; letter-spacing: 10px; color: var(--gold);
  text-shadow: 0 0 26px rgba(255,215,107,.7), 0 4px 8px #000;
}
#turn-banner.tb-anim { animation: bannerIn 1.5s ease-out both; }
#turn-banner.start { color: var(--text-hi); }
@keyframes bannerIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  30% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -56%) scale(1); }
}

/* ---------- 提示气泡 ---------- */
#toasts { position: fixed; top: 54px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(20,15,8,.92); border: 1px solid var(--gold-border); border-radius: 6px;
  padding: 7px 18px; font-size: 14px; color: var(--text-hi);
  animation: toastIn .25s ease-out, toastOut .4s ease-in 2.2s forwards;
}
.toast.good { border-color: var(--green); color: #b8e8a8; }
.toast.warn { border-color: var(--danger); color: #ff9a8a; }
.toast.round { border-color: #3f6f9e; color: #9fc8f8; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- 飘字 ---------- */
#floaters { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.floater {
  position: absolute; transform: translate(-50%, -50%);
  font-size: 22px; font-weight: 700; color: #ff6b5a; text-shadow: 0 2px 4px #000;
  animation: floatUp 1s ease-out forwards;
}
.floater.kill { font-size: 15px; color: #ffb09a; }
.floater.buff { color: #7db3ff; font-size: 17px; }
.floater.heal { color: #7dff6a; }
@keyframes floatUp { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -46px; } }

/* ---------- 战场单位标签 ---------- */
#labels { position: fixed; inset: 0; z-index: 25; pointer-events: none; }
.stk-label {
  position: absolute; left: 0; top: 0; min-width: 26px; text-align: center;
  font-size: 13px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
  background: rgba(15,12,6,.85); border: 1px solid; text-shadow: 0 1px 2px #000;
}
.stk-label.ally { border-color: var(--blue); color: #9fc8f8; }
.stk-label.enemy { border-color: var(--red); color: #ff9a8a; }

/* ---------- 伤害预估提示 ---------- */
#tooltip {
  position: fixed; z-index: 45; pointer-events: none;
  background: rgba(15,12,6,.94); border: 1px solid var(--gold-dark); border-radius: 6px;
  padding: 6px 10px; font-size: 12px; line-height: 1.5; color: var(--text-hi);
  transform: translate(16px, -100%);
}

/* ---------- 模态框 ---------- */
#modal { position: fixed; inset: 0; z-index: 50; background: rgba(5,4,2,.74); display: flex; align-items: center; justify-content: center; }
#modal-box {
  background: linear-gradient(180deg, #241c0e, #171208);
  border: 2px solid var(--gold-dark); border-radius: 12px; padding: 22px 26px;
  max-width: 860px; max-height: 86vh; overflow-y: auto;
  box-shadow: 0 0 40px rgba(200,169,81,.25);
}
.modal-title { font-size: 22px; color: var(--gold); text-align: center; letter-spacing: 4px; margin-bottom: 6px; font-weight: 700; }
.modal-res { text-align: center; font-size: 13px; color: var(--text-mid); margin-bottom: 6px; }
.modal-army { text-align: center; font-size: 12px; color: #9fc8f8; margin-bottom: 14px; }
.modal-btns { display: flex; justify-content: center; gap: 12px; margin-top: 16px; }

/* 招募卡片 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.card { background: rgba(50,40,20,.5); border: 1px solid var(--gold-border); border-radius: 8px; padding: 10px; }
.card-up { border-color: #d4af37; background: rgba(80,62,20,.4); }
.card-title { font-size: 15px; color: var(--text-hi); font-weight: 700; margin-bottom: 5px; }
.card-title small { color: var(--text-dim); font-weight: normal; }
.card-stats { font-size: 11px; color: var(--text-mid); line-height: 1.5; }
.card-cost { font-size: 12px; color: #d4af37; margin: 6px 0; }
.card-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.card-btns button {
  flex: 1; min-width: 34px; padding: 4px 2px; font-size: 12px; cursor: pointer;
  background: #33270f; color: var(--text-hi); border: 1px solid #8a6f35; border-radius: 4px; font-family: inherit;
}
.card-btns button:hover:not(:disabled) { background: #54431f; }
.card-btns button:disabled { opacity: .3; cursor: not-allowed; }

/* 兵营升级 */
.barracks {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: rgba(90,70,30,.35); border: 1px dashed var(--gold-dark); border-radius: 8px;
  padding: 8px 14px; margin-bottom: 12px; font-size: 13px; color: var(--text-hi);
}
.barracks.done { justify-content: center; border-style: solid; color: var(--gold); }
.sec-title { text-align: center; font-size: 12px; color: var(--text-dim); margin: 4px 0 10px; letter-spacing: 3px; }

/* 结算 */
.end-title { font-size: 34px; letter-spacing: 12px; font-weight: 700; }
.end-title.win { color: var(--gold); text-shadow: 0 0 20px rgba(255,215,107,.6); }
.end-title.lose { color: var(--danger); }
.end-stats { text-align: center; font-size: 15px; line-height: 1.9; color: #d8c8a0; margin-top: 8px; }

/* ---------- 魔法书（居中弹层） ---------- */
#spell-menu {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 46;
  width: min(320px, 92vw); max-height: 80vh; overflow-y: auto;
  background: linear-gradient(180deg, #241c0e, #171208);
  border: 2px solid var(--gold-dark); border-radius: 10px; padding: 12px;
  box-shadow: 0 0 30px rgba(200,169,81,.35);
}
#spell-menu::-webkit-scrollbar { width: 5px; }
#spell-menu::-webkit-scrollbar-thumb { background: var(--gold-border); border-radius: 3px; }
.spell-title { text-align: center; color: var(--gold); font-size: 15px; margin-bottom: 10px; letter-spacing: 2px; }
.spell-item { background: rgba(50,40,20,.5); border: 1px solid var(--gold-border); border-radius: 6px; padding: 8px 10px; margin-bottom: 7px; cursor: pointer; transition: all .12s; }
.spell-item:hover:not(.disabled) { border-color: var(--gold); background: rgba(80,62,28,.6); transform: translateX(3px); }
.spell-item.disabled { opacity: .4; cursor: not-allowed; }
.sp-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--text-hi); }
.sp-cost { color: #9fc8f8; font-size: 12px; }
.sp-desc { font-size: 11px; color: var(--text-mid); margin-top: 3px; line-height: 1.4; }

/* ---------- 技能选择 ---------- */
.skill-cards { display: flex; gap: 14px; justify-content: center; }
.skill-card {
  width: 220px; padding: 18px 16px; cursor: pointer; text-align: center;
  background: rgba(50,40,20,.6); border: 2px solid var(--gold-border); border-radius: 10px;
  transition: all .15s;
}
.skill-card:hover { border-color: var(--gold); transform: translateY(-3px); box-shadow: 0 6px 18px rgba(200,169,81,.35); }
.skill-name { font-size: 17px; color: var(--gold); font-weight: 700; margin-bottom: 8px; }
.skill-name small { color: var(--text-dim); font-weight: normal; font-size: 12px; }
.skill-desc { font-size: 13px; color: #c8b890; line-height: 1.6; }
.sp-tip { color: var(--purple); font-size: 11px; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .5; } to { opacity: 1; } }

/* ---------- 设置面板 ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 4px; border-bottom: 1px solid rgba(107,90,46,.3); font-size: 15px; color: var(--text-hi); min-width: 320px; }
.set-q { display: flex; gap: 8px; }
.q-on { background: linear-gradient(180deg, #6b5424, #463512); box-shadow: 0 0 10px rgba(200,169,81,.5); border-color: var(--gold); }

/* ---------- 胜利 CG ---------- */
#modal-box:has(#cg-canvas) { position: relative; overflow: hidden; min-width: 480px; }
#cg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cg-content { position: relative; z-index: 2; text-align: center; padding: 20px 10px; }
.cg-title {
  font-size: 56px; letter-spacing: 18px; color: var(--gold);
  text-shadow: 0 0 30px rgba(255,215,107,.8), 0 4px 10px #000;
  animation: cgIn .8s cubic-bezier(.2,1.6,.4,1) both, cgGlow 1.6s 1s ease-in-out infinite alternate;
}
@keyframes cgIn { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes cgGlow { from { text-shadow: 0 0 20px rgba(255,215,107,.6), 0 4px 10px #000; } to { text-shadow: 0 0 44px rgba(255,215,107,1), 0 4px 10px #000; } }
.cg-sub { font-size: 16px; color: var(--text-hi); margin: 14px 0 10px; }
.cg-stats { font-size: 14px; line-height: 2; color: #c8b890; }
.cg-stats b { color: var(--gold); }
.cg-skills { color: var(--purple); font-size: 13px; }

/* ---------- 开始画面 ---------- */
#start-screen {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(30,24,12,.55), rgba(8,6,3,.92));
}
.start-box { text-align: center; max-width: 560px; padding: 30px; }
.start-box h1 { font-size: 54px; letter-spacing: 10px; color: var(--gold); text-shadow: 0 0 30px rgba(255,215,107,.5), 0 4px 8px #000; margin-bottom: 6px; }
.start-box h1 span { color: #7db3ff; }
.start-box .sub { font-size: 15px; color: var(--text-mid); letter-spacing: 3px; margin-bottom: 22px; }
.start-help { font-size: 14px; line-height: 1.9; color: #d8c8a0; margin-bottom: 26px; }
.start-help b { color: #ff9a8a; }
.start-help .keys { font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.start-btns { display: flex; gap: 14px; justify-content: center; }

/* ---------- 移动端适配 ---------- */
@media (max-width: 820px) {
  #topbar { height: 40px; padding: 0 8px; }
  .tb-day { font-size: 12px; letter-spacing: 0; }
  .tb-res { gap: 8px; font-size: 11px; }
  .res .inc { display: none; }
  .btn-gold { padding: 5px 9px; font-size: 12px; }
  .btn-gold.big { font-size: 16px; padding: 10px 28px; }
  #herobar { width: auto; max-width: 58vw; padding: 7px 9px; left: 6px; bottom: 6px; }
  .hero-name { font-size: 13px; }
  .hero-stats { font-size: 10px; }
  .chip { font-size: 10px; padding: 2px 5px; }
  #minimap { right: 6px; bottom: 6px; transform: scale(.68); transform-origin: bottom right; }
  #battle-log { display: none !important; }
  #battlebar { padding: 4px 8px; }
  .bb-top { gap: 6px; }
  #round-ind { font-size: 11px; }
  #active-info { font-size: 11px; max-width: 40vw; }
  .ai-line { font-size: 9px; }
  .b-actions { gap: 4px; }
  #hint { display: none !important; }
  .start-box h1 { font-size: 36px; letter-spacing: 6px; }
  .start-help { font-size: 13px; }
  #modal-box { max-width: 94vw; padding: 14px 12px; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
  .skill-cards { flex-direction: column; align-items: center; }
  .cg-title { font-size: 38px; letter-spacing: 10px; }
  #turn-banner { font-size: 30px; letter-spacing: 6px; }
  .floater { font-size: 17px; }
  #toasts { top: 46px; }
  .toast { font-size: 12px; padding: 5px 12px; }
}
