/* —— 马皇的天下 · 中式宫廷风 —— */
:root {
  --底: #14110d;
  --底2: #1d1814;
  --卡: #261d15;
  --卡边: #5a4327;
  --金: #d6a64a;
  --金亮: #f3cf7a;
  --金深: #8a6a2c;
  --红: #b6342b;
  --红深: #7a1d18;
  --字: #f0e3c6;
  --字暗: #9a8a6b;
  --绿: #6bbf59;
  --蓝: #4aa3d6;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--底);
  color: var(--字);
  font-family: "PingFang SC", "Noto Serif SC", "STKaiti", "KaiTi", serif;
  overflow: hidden;
  user-select: none;
}
body {
  display: flex; flex-direction: column;
  max-width: 540px; margin: 0 auto;
  position: relative;
  background:
    radial-gradient(circle at 50% 30%, #2a1f15 0%, #14110d 70%),
    var(--底);
}

/* —— 顶部 HUD —— */
#顶栏 {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #1d1812 0%, #14110d 100%);
  border-bottom: 1px solid var(--卡边);
  position: relative; z-index: 5;
}
.主公 { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.头像 {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, #3a2a18, #1a1410);
  border: 2px solid var(--金);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 0 12px rgba(214,166,74,.35);
  position: relative;
}
.头像 img { width: 100%; height: 100%; object-fit: cover; display: none; }
.头像 img.有 { display: block; }
.占位字 {
  font-size: 24px; color: var(--金亮); font-weight: bold;
}
.头像 img.有 + .占位字 { display: none; }
.主公文字 .称号 { font-size: 13px; color: var(--金亮); font-weight: 600; }
.主公文字 .等级 { font-size: 11px; color: var(--字暗); margin-top: 2px; }

.资源条 {
  display: flex; flex: 1; gap: 6px; justify-content: flex-end;
  flex-wrap: wrap;
}
.资源 {
  display: flex; align-items: center; gap: 3px;
  background: rgba(0,0,0,.35);
  border: 1px solid var(--金深);
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--字);
  min-width: 64px;
}
.资源 .图 { font-size: 13px; }
.资源 .值 { color: var(--金亮); font-weight: 600; }
#存档按钮 {
  background: transparent; border: 1px solid var(--金深);
  color: var(--金); border-radius: 8px; padding: 4px 8px;
  font-size: 16px; cursor: pointer;
}

/* —— 主舞台 —— */
#舞台 {
  flex: 1; position: relative; overflow: hidden;
  background: #0e0a06;
}
#主画面 {
  position: absolute; inset: 0;
  z-index: 0;
}
#主画面 svg {
  display: block; width: 100%; height: 100%;
  transition: transform .4s cubic-bezier(.2,.7,.3,1);
  transform-origin: 50% 25%;
}
/* 面板弹出时主画面整体上移+缩小，确保马皇主体不被遮挡 */
body.面板开 #主画面 svg {
  transform: translateY(-22%) scale(.82);
}

/* —— 主画面动画 —— */
.月亮 {
  transform-origin: 320px 70px;
  animation: 月光呼吸 4s ease-in-out infinite;
}
@keyframes 月光呼吸 {
  0%,100% { opacity: .85; }
  50% { opacity: 1; filter: drop-shadow(0 0 8px #f3cf7a); }
}

.飞鸟 {
  animation: 飞过 14s linear infinite;
}
@keyframes 飞过 {
  0% { transform: translateX(0); opacity: 0; }
  10% { opacity: .8; }
  90% { opacity: .8; }
  100% { transform: translateX(440px); opacity: 0; }
}

.灯火 circle {
  animation: 灯闪 2s ease-in-out infinite;
}
.灯火 circle:nth-child(2) { animation-delay: .5s; }
.灯火 circle:nth-child(3) { animation-delay: 1s; }
.灯火 circle:nth-child(4) { animation-delay: 1.5s; }
@keyframes 灯闪 {
  0%,100% { opacity: .5; }
  50% { opacity: 1; }
}

.左灯 > g {
  transform-origin: 80px 280px;
  animation: 灯笼摆 3s ease-in-out infinite;
}
.右灯 > g {
  transform-origin: 320px 280px;
  animation: 灯笼摆 3s ease-in-out infinite;
  animation-delay: -1.5s;
}
@keyframes 灯笼摆 {
  0%,100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

.左旗 > g {
  transform-origin: 40px 380px;
  animation: 旗飘 2.4s ease-in-out infinite;
}
.右旗 > g {
  transform-origin: 360px 380px;
  animation: 旗飘 2.4s ease-in-out infinite;
  animation-delay: -1.2s;
}
@keyframes 旗飘 {
  0%,100% { transform: skewY(-3deg) scaleX(1); }
  50% { transform: skewY(3deg) scaleX(.95); }
}

.马皇光晕 {
  transform-origin: 200px 295px;
  animation: 光晕脉动 2.5s ease-in-out infinite;
}
@keyframes 光晕脉动 {
  0%,100% { opacity: .55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.15); }
}

.巡兵 {
  animation: 巡逻 10s linear infinite;
}
@keyframes 巡逻 {
  0% { transform: translateX(-20px); }
  45% { transform: translateX(440px); }
  46% { transform: translateX(440px) scaleX(-1); }
  95% { transform: translateX(-20px) scaleX(-1); }
  96% { transform: translateX(-20px); }
  100% { transform: translateX(-20px); }
}


/* 飘字 */
#飘字层 { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.飘字 {
  position: absolute; font-size: 14px; font-weight: 600;
  color: var(--金亮); text-shadow: 0 1px 2px #000;
  animation: 飘 1.4s ease-out forwards;
}
@keyframes 飘 {
  0% { opacity: 0; transform: translateY(0); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-40px); }
}

/* —— 底部导航 —— */
#底栏 {
  display: flex; background: #0d0a07;
  border-top: 1px solid var(--卡边);
  padding: 6px 4px env(safe-area-inset-bottom);
  z-index: 5;
}
#底栏 button {
  flex: 1; background: transparent; border: none;
  color: var(--字暗); font-size: 13px;
  padding: 8px 4px; cursor: pointer;
  font-family: inherit;
  border-radius: 8px;
}
#底栏 button.开启 {
  color: var(--金亮);
  background: rgba(214,166,74,.1);
  border: 1px solid var(--金深);
}

/* —— 面板（底部抽屉式，不挡主画面）—— */
.面板 {
  position: absolute; left: 0; right: 0;
  bottom: 56px;
  height: 55vh; max-height: 480px;
  background: linear-gradient(180deg, rgba(29,24,20,.96) 0%, rgba(20,17,13,.98) 100%);
  border-top: 2px solid var(--金);
  box-shadow: 0 -8px 20px rgba(0,0,0,.7);
  overflow-y: auto;
  padding: 12px 12px 16px;
  z-index: 6;
  transform: translateY(calc(100% + 56px));
  transition: transform .3s cubic-bezier(.2,.7,.3,1);
  border-radius: 14px 14px 0 0;
}
.面板.开 { transform: translateY(0); }
.面板::before {
  content: "";
  position: sticky; top: 0;
  display: block;
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--金深); margin: -4px auto 8px;
}
.面板 h2 {
  margin: 0 0 12px; font-size: 16px; color: var(--金亮);
  border-left: 3px solid var(--金); padding-left: 8px;
  font-weight: 600;
}
.卡 {
  background: var(--卡);
  border: 1px solid var(--卡边);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  display: flex; gap: 10px; align-items: center;
}
.卡 .图 {
  width: 44px; height: 44px; border-radius: 8px;
  background: linear-gradient(135deg, #3a2a18, #1a1410);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
  border: 1px solid var(--金深);
}
.卡 .主 { flex: 1; min-width: 0; }
.卡 .主 .名 { font-size: 14px; color: var(--金亮); font-weight: 600; }
.卡 .主 .描 { font-size: 11px; color: var(--字暗); margin-top: 3px; line-height: 1.4; }
.卡 .主 .进 {
  margin-top: 6px; height: 4px; background: #000;
  border-radius: 2px; overflow: hidden;
}
.卡 .主 .进 .条 { height: 100%; background: var(--金); transition: width .3s; }
.卡 .主 .耗 { font-size: 10px; color: var(--字暗); margin-top: 4px; }
.卡 .主 .耗 span { color: var(--金亮); }
.卡 .主 .耗 span.缺 { color: var(--红); }
.卡 button {
  background: linear-gradient(180deg, #c89339 0%, #8a6a2c 100%);
  border: 1px solid var(--金亮); color: #1a1208;
  font-family: inherit; font-weight: 600;
  padding: 6px 12px; border-radius: 6px;
  font-size: 12px; cursor: pointer;
  flex-shrink: 0;
}
.卡 button:disabled {
  background: #3a2e1c; color: #6a5a3a;
  border-color: #4a3a22; cursor: not-allowed;
}
.卡 button.红 {
  background: linear-gradient(180deg, #c33b30 0%, #7a1d18 100%);
  color: #fff; border-color: #e25a4e;
}

/* —— 弹层 —— */
.弹层 {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.弹层.隐 { display: none; }
.弹卡 {
  background: var(--卡); border: 2px solid var(--金);
  border-radius: 14px; padding: 18px;
  width: 80%; max-width: 360px;
  box-shadow: 0 0 30px rgba(214,166,74,.4);
}
.弹标题 {
  font-size: 16px; color: var(--金亮); font-weight: 600;
  text-align: center; margin-bottom: 10px;
}
.弹内容 {
  font-size: 13px; color: var(--字); line-height: 1.6;
  margin-bottom: 14px; max-height: 50vh; overflow-y: auto;
}
.弹按钮 { display: flex; gap: 8px; justify-content: flex-end; }
.弹按钮 button {
  font-family: inherit;
  padding: 6px 14px; border-radius: 6px; font-size: 13px;
  background: transparent; border: 1px solid var(--金深);
  color: var(--金); cursor: pointer;
}
.弹按钮 .主按钮 {
  background: linear-gradient(180deg, #c89339 0%, #8a6a2c 100%);
  color: #1a1208; border-color: var(--金亮); font-weight: 600;
}

/* 战报 */
.战报 {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 99; padding: 20px;
}
.战报.隐 { display: none; }
.战报内 {
  background: var(--卡); border: 2px solid var(--红);
  border-radius: 14px; padding: 18px;
  width: 90%; max-width: 380px;
  box-shadow: 0 0 30px rgba(182,52,43,.5);
}
.战报内 h3 {
  margin: 0 0 12px; text-align: center; font-size: 18px;
}
.战报内 h3.胜 { color: var(--金亮); }
.战报内 h3.败 { color: var(--红); }
.战报行 {
  font-size: 12px; color: var(--字暗); margin: 4px 0;
  padding-left: 8px; border-left: 2px solid var(--金深);
}
.战报内 button {
  margin-top: 12px; width: 100%;
  background: linear-gradient(180deg, #c89339 0%, #8a6a2c 100%);
  color: #1a1208; border: 1px solid var(--金亮);
  padding: 8px; border-radius: 8px; font-family: inherit;
  font-weight: 600; cursor: pointer;
}

/* 提示条 */
.提示条 {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: var(--金亮);
  border: 1px solid var(--金深); border-radius: 8px;
  padding: 6px 14px; font-size: 13px;
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
  z-index: 200;
  white-space: nowrap;
}
.提示条.显 { opacity: 1; }

/* 任务条目 */
.任务 {
  background: var(--卡); border: 1px solid var(--卡边);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
  display: flex; gap: 10px; align-items: center;
}
.任务 .主 { flex: 1; }
.任务 .主 .名 { font-size: 13px; color: var(--金亮); }
.任务 .主 .描 { font-size: 11px; color: var(--字暗); margin-top: 3px; }
.任务 .主 .奖 { font-size: 10px; color: var(--绿); margin-top: 4px; }
.任务.成 .主 .名::before { content: "✓ "; color: var(--绿); }
.任务.成 { opacity: .6; }
.任务 button {
  background: linear-gradient(180deg, #c89339 0%, #8a6a2c 100%);
  color: #1a1208; border: 1px solid var(--金亮);
  padding: 5px 12px; border-radius: 6px; font-size: 12px;
  font-family: inherit; font-weight: 600; cursor: pointer;
}
.任务 button:disabled {
  background: #3a2e1c; color: #6a5a3a;
  border-color: #4a3a22;
}

/* 滚动条 */
.面板::-webkit-scrollbar, .弹内容::-webkit-scrollbar { width: 4px; }
.面板::-webkit-scrollbar-thumb, .弹内容::-webkit-scrollbar-thumb {
  background: var(--金深); border-radius: 2px;
}
