/* ============================================================
   乱世基业 · UI 样式
   设计方向：「残卷 · 烽火」—— 竖屏如一卷泛黄军阵残卷。
   宣纸暖褐为底，朱砂为印，金箔为题，书法立题，衬线记数。
   签名手法：HUD=卷边匾额+朱印角标；圆盘=兵符令牌；面板=军令奏折。
   ============================================================ */

:root {
  /* —— 残卷色板 —— */
  --bg:         #16110b;   /* 卷外墨夜 */
  --bg-2:       #221a10;
  --paper:      #2c2114;   /* 奏折暖褐 */
  --paper-2:    #3a2c1a;
  --paper-edge: #5a4326;
  --ink:        #efe2c6;   /* 米白墨字 */
  --ink-soft:   #cbb68d;
  --ink-mute:   #8c7a58;
  --gold:       #ecca72;   /* 金箔题字 */
  --gold-deep:  #a9802f;
  --gold-glow:  rgba(236,202,114,.55);
  --verm:       #c8402e;   /* 朱砂 */
  --verm-glow:  #ef5a3c;
  --verm-deep:  #7e2418;
  --ink-line:   #43331f;

  /* 兵种色（提饱和，暗底上立得住） */
  --blue:   #7fb2dd;
  --green:  #7fc79f;
  --red:    #e06a64;
  --cav:    #e6b85c;
  --purple: #b494ec;

  /* —— 字体 —— */
  --brush: 'Ma Shan Zheng', 'KaiTi', cursive;          /* 书法立题 */
  --serif: 'Noto Serif SC', 'Songti SC', 'SimSun', serif; /* 衬线记数/正文 */

  /* —— 尺寸 —— */
  --hud-h: 56px;
  --bottom-h: 38px;
  --radius: 6px;
}

* { margin:0; padding:0; box-sizing:border-box; }

html, body {
  width:100%; height:100%;
  overflow:hidden;
  display:flex; align-items:center; justify-content:center;
  /* 卷外：墨夜中一点烛火暖光，烘托画框 */
  background:
    radial-gradient(120% 90% at 50% 38%, #2a2014 0%, #16110b 55%, #0c0905 100%);
  font-family: var(--serif);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* 画框：裱金边 + 外烛影，像挂起来的残卷 */
#game-root {
  position: relative;
  width: 100%; height: auto;
  aspect-ratio: 480 / 854;
  max-height: 100%;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(236,202,114,.28),
    0 0 0 4px #1c150c,
    0 0 0 5px rgba(169,128,47,.5),
    0 18px 60px rgba(0,0,0,.7),
    0 0 90px rgba(200,120,40,.10);
}

#game-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: block;
}

/* ============================================================
   顶部 HUD —— 卷边匾额
   ============================================================ */
#hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--hud-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top, 0);
  background:
    linear-gradient(180deg, rgba(34,26,16,.96) 0%, rgba(34,26,16,.78) 60%, rgba(34,26,16,0) 100%);
  border-bottom: 1px solid rgba(236,202,114,.30);
  box-shadow: 0 6px 18px rgba(0,0,0,.45), inset 0 -1px 0 rgba(126,36,24,.4);
  z-index: 100;
  font-size: 13px;
  pointer-events: none;
}
#hud-top > * { pointer-events: auto; }
/* 匾额两端朱印角标 */
#hud-top::before, #hud-top::after {
  content:''; position:absolute; top:8px; width:7px; height:7px;
  background: var(--verm);
  box-shadow: 0 0 6px var(--verm-glow);
  pointer-events:none;
}
#hud-top::before { left:6px; }
#hud-top::after  { right:6px; }

/* 资源令牌：emoji+数字 框成盖印小牌 */
.hud-left { display:flex; gap:8px; }
#hud-gold, #hud-order {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .3px;
  padding: 3px 10px 3px 8px;
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(0,0,0,.42), rgba(0,0,0,.22));
  border: 1px solid var(--gold-deep);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 1px 3px rgba(0,0,0,.4);
}
#hud-gold  { color: var(--gold);  text-shadow: 0 0 7px var(--gold-glow); border-color: var(--gold-deep); }
#hud-order { color: var(--purple); text-shadow: 0 0 7px rgba(180,148,236,.5); border-color: #6a5290; }

.hud-center {
  display:flex; flex-direction:column; align-items:center; gap:3px;
  flex: 1; margin: 0 10px;
}
#hud-wave-bar {
  width: 100%; height: 6px;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(236,202,114,.25);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.6);
}
#hud-wave-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold) 60%, #fff3cf);
  box-shadow: 0 0 8px var(--gold-glow);
  border-radius: 3px;
  transition: width 0.3s;
}
#hud-wave-text {
  font-family: var(--brush);
  font-size: 15px;
  color: var(--gold);
  letter-spacing: 1px;
  text-shadow: 0 1px 0 #000, 0 0 8px var(--gold-glow);
}

.hud-right { display:flex; align-items:center; gap:7px; }
#hud-base-hp {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--verm-glow);
  text-shadow: 0 0 8px rgba(239,90,60,.55);
  padding: 3px 9px;
  border: 1px solid var(--verm-deep);
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(126,36,24,.35), rgba(0,0,0,.2));
}
/* 圆形朱印/金环按钮 */
#btn-pause, #btn-ach, #btn-rebirth {
  background: radial-gradient(circle at 35% 30%, rgba(90,70,40,.7), rgba(28,21,12,.85));
  border: 1px solid var(--gold-deep);
  color: var(--ink);
  border-radius: 50%;
  width: 32px; height: 32px; font-size: 15px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 2px 5px rgba(0,0,0,.5);
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
#btn-pause:active, #btn-ach:active, #btn-rebirth:active {
  transform: scale(.92);
  border-color: var(--verm-glow);
  box-shadow: 0 0 12px rgba(239,90,60,.6), inset 0 0 8px rgba(239,90,60,.3);
}

/* ============================================================
   底部信息条 —— 卷尾题跋
   ============================================================ */
#hud-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-h);
  padding-bottom: env(safe-area-inset-bottom, 0);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 14px; padding-right: 14px;
  background: linear-gradient(0deg, rgba(34,26,16,.96) 0%, rgba(34,26,16,.7) 60%, rgba(34,26,16,0) 100%);
  border-top: 1px solid rgba(236,202,114,.22);
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: .3px;
  color: var(--ink-soft);
  z-index: 100;
  pointer-events: none;
}
#countdown-timer { color: var(--gold); font-weight:700; text-shadow:0 0 6px var(--gold-glow); }

/* ============================================================
   章节横幅 —— 书法题卷
   ============================================================ */
#chapter-banner {
  position: absolute;
  top: 64px; left: 0; right: 0;
  text-align: center;
  font-family: var(--brush);
  font-size: 40px;
  color: var(--gold);
  letter-spacing: 6px;
  /* 多层阴影模拟朱墨描边 + 金光 */
  text-shadow:
    0 0 1px var(--verm-deep), 1px 1px 0 var(--verm-deep), -1px 1px 0 var(--verm-deep),
    0 2px 14px rgba(236,202,114,.55), 0 0 26px rgba(200,64,46,.35);
  z-index: 90;
  animation: bannerIn 1.5s cubic-bezier(.2,.8,.2,1) forwards;
  pointer-events: none;
}
#chapter-banner::before, #chapter-banner::after {
  content:''; position:absolute; top:50%; width:64px; height:1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
#chapter-banner::before { left: 14%; }
#chapter-banner::after  { right: 14%; }
@keyframes bannerIn {
  0%   { opacity:0; transform:translateY(-22px) scale(.92); filter:blur(6px); }
  22%  { opacity:1; transform:translateY(0) scale(1); filter:blur(0); }
  78%  { opacity:1; }
  100% { opacity:0; transform:translateY(-12px) scale(1.02); filter:blur(2px); }
}

/* ============================================================
   Boss 横幅 —— 朱旗压境
   ============================================================ */
#boss-banner {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 60px;
  display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(180deg, rgba(126,36,24,.95) 0%, rgba(126,36,24,.55) 65%, rgba(126,36,24,0) 100%);
  border-bottom: 1px solid rgba(236,202,114,.4);
  box-shadow: 0 6px 22px rgba(126,36,24,.5);
  z-index: 95;
  animation: bossSlide 0.5s ease-out;
  pointer-events: none;
}
#boss-name {
  font-family: var(--brush);
  font-size: 30px;
  letter-spacing: 4px;
  color: #fff4e6;
  text-shadow: 0 0 14px var(--verm-glow), 0 2px 0 var(--verm-deep), 0 0 30px rgba(239,90,60,.6);
}
#boss-name::before { content:'⚔ '; color: var(--gold); }
#boss-name::after  { content:' ⚔'; color: var(--gold); }
@keyframes bossSlide {
  from { transform:translateY(-100%); }
  to   { transform:translateY(0); }
}

/* ============================================================
   圆盘菜单 —— 兵符令牌
   ============================================================ */
#radial-menu {
  position: absolute;
  z-index: 110;
  pointer-events: auto;
}
.radial-ring {
  pointer-events: none;
  position: relative;
  width: 180px; height: 180px;
}
.radial-item {
  pointer-events: auto;
  position: absolute;
  width: 54px; height: 54px;
  border-radius: 14px;            /* 兵符：圆角方印 */
  /* 暖褐令牌底 + 顶部高光 */
  background:
    radial-gradient(circle at 38% 26%, rgba(120,96,56,.55), rgba(30,22,12,.95) 72%);
  /* border-color 由 JS inline 设为兵种色 → 兵符环 */
  border: 2px solid var(--gold-deep);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 21px;
  color: var(--ink);
  cursor: pointer;
  /* 外金环 + 内兵种色辉光（box-shadow 不被 inline border 影响） */
  box-shadow:
    0 0 0 1px rgba(0,0,0,.5),
    0 0 10px rgba(236,202,114,.30),
    inset 0 1px 0 rgba(255,240,200,.18),
    inset 0 -3px 6px rgba(0,0,0,.5),
    0 4px 10px rgba(0,0,0,.55);
  transition: transform 0.14s, box-shadow 0.14s;
}
.radial-item::before {           /* 令牌顶部半月高光 */
  content:''; position:absolute; top:3px; left:18%; right:18%; height:38%;
  background: linear-gradient(180deg, rgba(255,245,210,.22), transparent);
  border-radius: 50%;
  pointer-events:none;
}
.radial-item:active {
  transform: scale(1.14) rotate(-2deg);
  box-shadow:
    0 0 0 1px rgba(0,0,0,.5),
    0 0 16px var(--gold-glow),
    0 0 22px rgba(239,90,60,.4),
    inset 0 0 10px rgba(239,90,60,.35);
}
.radial-item .r-label {
  font-family: var(--serif);
  font-size: 8px;
  color: var(--ink-soft);
  margin-top: 1px;
  white-space: nowrap;
  text-shadow: 0 1px 1px #000;
}
.radial-item.disabled {
  opacity: 0.32;
  pointer-events: none;
  filter: grayscale(.5);
}

/* ============================================================
   面板 —— 军令奏折
   ============================================================ */
.panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 100% at 50% 40%, rgba(10,7,4,.78), rgba(6,4,2,.92));
  backdrop-filter: blur(2px);
  z-index: 200;
}
.panel-inner {
  position: relative;
  width: 88%;
  max-width: 380px;
  /* 做旧暖褐宣纸 */
  background:
    linear-gradient(180deg, #34281700, #1c140a55),
    repeating-linear-gradient(0deg, rgba(0,0,0,.05) 0 2px, transparent 2px 4px),
    linear-gradient(160deg, #3a2c1a, #2a2013 60%, #241a0f);
  border: 1px solid var(--gold-deep);
  border-radius: 4px;
  padding: 26px 22px 22px;
  text-align: center;
  /* 外朱 + 内金 双层边 */
  box-shadow:
    0 0 0 3px rgba(126,36,24,.55),
    0 0 0 4px rgba(236,202,114,.35),
    inset 0 0 28px rgba(0,0,0,.5),
    0 20px 50px rgba(0,0,0,.6);
}
/* 奏折四角朱印 */
.panel-inner::before, .panel-inner::after {
  content:''; position:absolute; width:16px; height:16px;
  border: 2px solid var(--verm);
  pointer-events:none;
  box-shadow: 0 0 6px rgba(239,90,60,.4);
}
.panel-inner::before { top:6px; left:6px; border-right:none; border-bottom:none; }
.panel-inner::after  { bottom:6px; right:6px; border-left:none; border-top:none; }
.panel-inner h2 {
  font-family: var(--brush);
  font-size: 30px;
  letter-spacing: 3px;
  color: var(--gold);
  margin-bottom: 6px;
  text-shadow: 0 2px 0 var(--verm-deep), 0 0 14px var(--gold-glow);
}
/* 标题下朱批金线 */
.panel-inner h2::after {
  content:''; display:block; width:70%; height:2px; margin:8px auto 14px;
  background: linear-gradient(90deg, transparent, var(--verm), var(--gold), var(--verm), transparent);
}
#report-body, #rebirth-body {
  text-align: left;
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.85;
  color: var(--ink);
  margin-bottom: 20px;
  max-height: 300px;
  overflow-y: auto;
}
#report-body p, #rebirth-body p { text-shadow: 0 1px 1px rgba(0,0,0,.5); }
#report-body b, #rebirth-body b { color: var(--gold); }

/* 金箔主按钮 */
.btn-primary {
  display: inline-block;
  padding: 11px 30px;
  font-family: var(--brush);
  font-size: 19px;
  letter-spacing: 2px;
  color: #2a1c08;
  background: linear-gradient(180deg, #f6dd92, var(--gold) 45%, var(--gold-deep));
  border: 1px solid #7a5a1c;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), inset 0 -2px 4px rgba(120,80,20,.5), 0 4px 12px rgba(0,0,0,.5);
  text-shadow: 0 1px 0 rgba(255,245,200,.5);
  transition: transform .1s, filter .1s;
}
.btn-primary:active { transform: translateY(1px); filter: brightness(.9); }
.btn-secondary {
  display: inline-block;
  padding: 10px 26px;
  font-family: var(--serif);
  color: var(--ink-soft);
  font-size: 14px;
  background: transparent;
  border: 1px solid var(--verm-deep);
  border-radius: var(--radius);
  cursor: pointer;
  margin-left: 10px;
  transition: border-color .12s, color .12s;
}
.btn-secondary:active { border-color: var(--verm-glow); color: var(--ink); }

/* ============================================================
   新手引导 —— 朱批提示
   ============================================================ */
#tutorial-hint {
  position: absolute;
  z-index: 105;
  background: linear-gradient(180deg, rgba(126,36,24,.32), rgba(40,28,16,.6));
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 9px 16px;
  font-family: var(--brush);
  font-size: 17px;
  letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 0 0 8px var(--gold-glow);
  box-shadow: 0 0 14px rgba(236,202,114,.25), inset 0 0 10px rgba(0,0,0,.3);
  animation: hintPulse 1.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes hintPulse {
  0%,100% { opacity:.72; transform:scale(1); }
  50%     { opacity:1;   transform:scale(1.05); }
}

/* ============================================================
   暂停遮罩 —— 封卷
   ============================================================ */
#pause-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 45%, rgba(20,14,8,.55), rgba(8,5,3,.82));
  z-index: 150;
  pointer-events: none;
}
#pause-overlay span {
  font-family: var(--brush);
  font-size: 52px;
  letter-spacing: 8px;
  color: var(--gold);
  text-shadow: 0 3px 0 var(--verm-deep), 0 0 24px var(--gold-glow);
}
#pause-overlay small {
  font-family: var(--serif);
  color: var(--ink-soft);
  margin-top: 10px;
  letter-spacing: 1px;
}

/* ============================================================
   成就弹出 —— 金榜题名
   ============================================================ */
#achievement-toast {
  position: absolute;
  top: 72px; left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #3a2c1a, #241a0f);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 12px 22px;
  font-family: var(--brush);
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold-glow);
  box-shadow: 0 0 0 2px rgba(126,36,24,.5), 0 8px 24px rgba(0,0,0,.55);
  z-index: 180;
  animation: toastIn 0.45s cubic-bezier(.2,1.4,.4,1);
  pointer-events: none;
}
@keyframes toastIn {
  from { opacity:0; transform:translateX(-50%) translateY(-22px) scale(.85); }
  to   { opacity:1; transform:translateX(-50%) translateY(0) scale(1); }
}

/* 全屏特效层（武将降临等，DOM 由 animations.js 注入） */
#fullscreen-fx {
  position: absolute;
  inset: 0;
  z-index: 190;
  pointer-events: none;
}

/* 成就列表 */
#ach-body {
  text-align:left; font-family:var(--serif); font-size:13px; line-height:2;
  max-height:52vh; overflow-y:auto; margin-bottom:16px; color:var(--ink);
}
#ach-body p { margin: 1px 0; text-shadow:0 1px 1px rgba(0,0,0,.5); }

/* 滚动条（奏折内） */
#report-body::-webkit-scrollbar, #rebirth-body::-webkit-scrollbar, #ach-body::-webkit-scrollbar { width:6px; }
#report-body::-webkit-scrollbar-thumb, #rebirth-body::-webkit-scrollbar-thumb, #ach-body::-webkit-scrollbar-thumb {
  background: var(--gold-deep); border-radius:3px;
}

/* ============================================================
   技能栏 —— 军令虎符（底部一排）
   ============================================================ */
#skill-bar {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(var(--bottom-h) + 8px);
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 0 10px;
  z-index: 105;
  pointer-events: none;
}
.skill-btn {
  pointer-events: auto;
  position: relative;
  width: 58px; height: 62px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 38% 24%, rgba(120,96,56,.5), rgba(26,19,10,.95) 72%);
  border: 1.5px solid var(--gold-deep);
  color: var(--ink);
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  box-shadow:
    0 0 0 1px rgba(0,0,0,.5),
    0 0 10px rgba(236,202,114,.22),
    inset 0 1px 0 rgba(255,240,200,.16),
    inset 0 -3px 6px rgba(0,0,0,.5),
    0 4px 10px rgba(0,0,0,.5);
  transition: transform .12s, box-shadow .12s, border-color .12s;
  overflow: hidden;
}
.skill-btn::before {
  content:''; position:absolute; top:3px; left:20%; right:20%; height:34%;
  background: linear-gradient(180deg, rgba(255,245,210,.2), transparent);
  border-radius: 50%; pointer-events:none;
}
.skill-btn:active {
  transform: scale(.93);
  border-color: var(--verm-glow);
  box-shadow: 0 0 14px rgba(239,90,60,.5), inset 0 0 8px rgba(239,90,60,.3);
}
.sk-icon { font-size: 22px; line-height: 1; filter: drop-shadow(0 1px 2px #000); }
.sk-name { font-family: var(--brush); font-size: 12px; color: var(--gold); margin-top: 2px; letter-spacing: 1px; }
.sk-cost {
  position: absolute; top: 3px; right: 4px;
  font-family: var(--serif); font-size: 9px; font-weight: 700;
  color: #2a1c08; background: var(--gold);
  border-radius: 7px; padding: 0 4px; line-height: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.sk-cost::before { content:'📜'; font-size: 8px; margin-right: 1px; }
.sk-cd {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-weight: 900; font-size: 20px;
  color: #fff; text-shadow: 0 1px 3px #000;
  background: rgba(10,7,4,.62);
  opacity: 0; pointer-events: none;
}
.skill-btn.cooling .sk-cd { opacity: 1; }
.skill-btn.cooling { filter: grayscale(.4) brightness(.8); }
.skill-btn.noorder { filter: grayscale(.7) brightness(.55); }
.skill-btn.noorder .sk-cost { background: #6a5a3a; color: #2a2010; }

/* 落雷瞄准提示 */
#aim-hint {
  position: absolute;
  top: 64px; left: 50%; transform: translateX(-50%);
  font-family: var(--brush); font-size: 18px; letter-spacing: 1px;
  color: #bfe3ff; text-shadow: 0 0 10px rgba(120,200,255,.7);
  background: linear-gradient(180deg, rgba(20,40,60,.6), rgba(10,20,30,.4));
  border: 1px solid rgba(120,200,255,.5);
  border-radius: 8px; padding: 7px 16px;
  z-index: 106; pointer-events: none;
  animation: hintPulse 1s ease-in-out infinite;
}

/* ---------- 工具类 ---------- */
.hidden { display: none !important; }

/* ---------- 桌面：裱框 ---------- */
@media (min-width: 481px) {
  #game-root {
    border-radius: 2px;
  }
}

/* ---------- 无障碍：尊重减少动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
