/* ============ 斩妖幸存者 · 水墨修仙 UI ============ */
:root {
  --cream: #f4eede;          /* 宣纸底（与画布同色） */
  --mint: #5e8c6a;           /* 玉 */
  --mint-dark: #3f6b4a;
  --pink: #c2543f;           /* 朱砂 */
  --pink-deep: #a03328;
  --blue: #7a92a0;           /* 青墨 */
  --yellow: #d8b44a;         /* 金 */
  --orange: #b5722f;         /* 赭 */
  --purple: #6f6390;         /* 紫墨 */
  --ink: #3d4448;            /* 浓墨 */
  --ink-light: #6e7a80;      /* 淡墨 */
  --white: #ffffff;
  --shadow: 0 6px 0 rgba(var(--ink-rgb), .16);
  --font: 'KaiTi', 'STKaiti', 'Kaiti SC', 'DFKai-SB', 'Microsoft YaHei', serif;

  /* 水墨辅助色板（换装后值；变量名沿用糖果期，含义见注释） */
  --ink-rgb: 61, 68, 72;            /* 浓墨阴影基色 */
  --white-rgb: 255, 255, 255;       /* 白色半透明罩层 */
  --veil-rgb: 240, 234, 216;        /* 弹层背景的宣纸罩 */
  --pink-deep-rgb: 160, 51, 40;     /* boss 名字光晕（朱砂） */
  --coral-rgb: 201, 150, 46;        /* boss 横幅光晕（金） */
  --paper-card: #faf6ea;            /* 面板宣纸卡底 */
  --card-line: rgba(61, 68, 72, .18); /* 面板墨线描边 */
  --blue-light: #9fb4c0;            /* 经验条渐变亮头（青墨） */
  --pink-light: #c2543f;            /* 血条/大按钮渐变亮头（朱砂） */
  --coral: #8f3129;                 /* boss 血条渐变深头 */
  --orange-deep: #a87d24;           /* 连杀胶囊渐变深头 */
  --pink-shadow: #7c2a20;           /* 大按钮硬阴影 */
  --sky: #7a92a0;                   /* 小按钮渐变亮头（青墨） */
  --blue-deep: #55707e;             /* 小按钮渐变深头 */
  --blue-shadow: #3f5560;           /* 小按钮硬阴影 */
  --dash-warm: #c9bfa4;             /* 虚线描边（茶色墨线） */
  --dash-light: #d8cfb4;            /* 虚线分隔 */
  --gray-warm: #a89a80;             /* 弱化文字 */
  --tag-new-bg: #dcead8;            /* 升级卡"新"标签底（淡玉） */
  --tag-up-bg: #f2ddd5;             /* 升级卡"升级"标签底（淡朱砂） */
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--cream);
  font-family: var(--font);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ============ HUD ============ */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#xpWrap {
  /* 悬浮圆角胶囊：与血量/击杀数等 HUD 元素同一套视觉语言，
     不再全宽贴死屏幕上沿（那样像系统横幅，Lv 徽章也顶死左上角没呼吸感） */
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 10px; right: 10px;
  height: 26px;
  background: rgba(var(--white-rgb), .82);
  border: 2px solid rgba(var(--ink-rgb), .08);
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(var(--ink-rgb), .1), 0 6px 16px rgba(var(--ink-rgb), .08);
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px;
}
#lvBadge {
  background: var(--pink); color: var(--white);   /* 朱砂印章感 */
  font-weight: bold; font-size: 12.5px;
  padding: 2px 11px; border-radius: 999px;
  box-shadow: 0 2px 0 rgba(var(--ink-rgb), .2);
  white-space: nowrap;
}
#barsWrap { flex: 1; display: flex; flex-direction: column; gap: 3px; }
#xpBar { width: 100%; height: 12px; background: rgba(var(--ink-rgb), .14); border-radius: 999px; overflow: hidden; }
#xpFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--blue-light), var(--mint), var(--yellow));
  border-radius: 999px;
  transition: width .18s ease-out;
}
/* 奥义充能条：贴在经验条正下方（同胶囊不分家，任何断点都不新增布局） */
#ultBar { width: 100%; height: 6px; background: rgba(var(--ink-rgb), .1); border-radius: 999px; overflow: hidden; }
#ultFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--blue-light), var(--purple));
  border-radius: 999px;
  transition: width .2s ease-out;
}
#ultBar.ready #ultFill {
  background: linear-gradient(90deg, var(--yellow), var(--orange));
  animation: ultBreath 1.1s ease-in-out infinite;
}
@keyframes ultBreath { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.6); } }

#statRow {
  position: absolute; top: calc(46px + env(safe-area-inset-top, 0px)); left: 10px; right: 10px;
  display: flex; align-items: flex-start; gap: 10px;
}
#hpWrap { display: flex; align-items: center; gap: 5px; }
#hpWrap .ico { font-size: 18px; filter: drop-shadow(0 2px 0 rgba(var(--ink-rgb), .15)); }
#hpBar { width: clamp(110px, 22vw, 190px); height: 18px; background: rgba(var(--white-rgb), .8); border-radius: 999px; overflow: hidden; box-shadow: inset 0 2px 4px rgba(var(--ink-rgb), .18); }
#hpFill { height: 100%; width: 100%; background: linear-gradient(180deg, var(--pink-light), var(--pink-deep)); border-radius: 999px; transition: width .15s; }
#hpText { font-size: 13px; font-weight: bold; color: var(--ink-light); }

/* 计时器脱离弹性流、绝对居中：flex:1 只能在"剩余空间"里居中，
   左边血量+击杀占宽后中心会整体右偏（宽屏偏 100px+） */
#timer {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  text-align: center; white-space: nowrap;
  font-size: clamp(22px, 4.5vw, 32px);
  font-weight: bold; color: var(--ink);
  text-shadow: 0 2px 0 var(--white), 0 4px 0 rgba(var(--ink-rgb), .15);
  letter-spacing: 2px;
}

#killWrap {
  display: flex; align-items: center; gap: 5px;
  background: rgba(var(--white-rgb), .85); border-radius: 999px;
  padding: 4px 14px; font-weight: bold; font-size: 16px;
  box-shadow: var(--shadow);
}
#killWrap .ico { font-size: 16px; }

#topBtns { position: absolute; top: calc(46px + env(safe-area-inset-top, 0px)); right: calc(10px + env(safe-area-inset-right, 0px)); display: flex; gap: 8px; }
.roundBtn {
  pointer-events: auto;
  width: 44px; height: 44px; border-radius: 50%;
  border: none; background: rgba(var(--white-rgb), .9);
  font-size: 19px; cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .1s;
}
.roundBtn:active { transform: scale(.88); }

#comboBox {
  position: absolute; top: 88px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(180deg, var(--orange), var(--orange-deep));
  color: var(--white); font-weight: bold; font-size: 20px;
  padding: 6px 22px; border-radius: 999px;
  box-shadow: 0 4px 0 rgba(var(--ink-rgb), .2);
  animation: comboPop .25s ease-out;
}
@keyframes comboPop { 0% { transform: translateX(-50%) scale(.5); } 70% { transform: translateX(-50%) scale(1.18); } 100% { transform: translateX(-50%) scale(1); } }

/* 奥义释放钮：右下角大圆钮，未满灰、满了金光呼吸 */
#ultBtn {
  pointer-events: auto;
  position: absolute;
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 66px; height: 66px; border-radius: 50%;
  border: 3px solid rgba(var(--ink-rgb), .22);
  background: rgba(var(--white-rgb), .55);
  color: var(--ink-light); font-family: var(--font);
  font-size: 17px; font-weight: bold; letter-spacing: 3px;
  cursor: pointer; box-shadow: var(--shadow);
  transition: transform .1s, background .25s, color .25s;
}
#ultBtn:disabled { cursor: default; }
#ultBtn.ready {
  background: linear-gradient(180deg, #e8c96a, var(--orange-deep));
  color: var(--white);
  border-color: rgba(var(--white-rgb), .75);
  animation: ultBtnBreath 1.1s ease-in-out infinite;
}
#ultBtn:active { transform: scale(.88); }
@keyframes ultBtnBreath { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.09); } }

#bossWrap {
  position: absolute; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  width: min(72vw, 460px); text-align: center;
}
#bossName {
  color: var(--white); font-weight: bold; font-size: 16px;
  text-shadow: 0 2px 0 rgba(var(--ink-rgb), .4), 0 0 12px rgba(var(--pink-deep-rgb), .8);
  margin-bottom: 5px;
}
#bossBar { height: 16px; background: rgba(var(--ink-rgb), .35); border-radius: 999px; overflow: hidden; border: 2px solid rgba(var(--white-rgb), .6); }
#bossFill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--coral), var(--pink)); transition: width .15s; }

/* ============ 虚拟摇杆 ============ */
#joyBase {
  position: fixed; z-index: 20; width: 110px; height: 110px;
  border-radius: 50%;
  background: rgba(var(--white-rgb), .35);
  border: 3px solid rgba(var(--white-rgb), .7);
  pointer-events: none;
  transform: translate(-50%, -50%);
}
#joyStick {
  position: absolute; left: 50%; top: 50%;
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(var(--white-rgb), .9);
  box-shadow: 0 3px 8px rgba(var(--ink-rgb), .25);
  transform: translate(-50%, -50%);
}

/* ============ 弹层通用 ============ */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(var(--veil-rgb), .55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 14px;
}
.panel {
  background: var(--paper-card);
  border: 2px solid var(--card-line);
  border-radius: 28px;
  padding: 26px 28px;
  box-shadow: 0 10px 0 rgba(var(--ink-rgb), .14), 0 24px 60px rgba(var(--ink-rgb), .22);
  text-align: center;
  max-width: 94vw;
  max-height: 92vh;
  overflow-y: auto;
  touch-action: pan-y;   /* html/body 是 none，不放开这里触屏上弹层滚不动 */
  animation: panelIn .38s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes panelIn { from { transform: scale(.7) translateY(30px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }

/* ============ 主菜单 ============ */
.menuPanel { width: min(480px, 94vw); }
.titleWrap { margin-bottom: 10px; }
.gameTitle { font-size: clamp(38px, 9vw, 54px); letter-spacing: 4px; }
.gameTitle span { display: inline-block; animation: bounce 1.6s ease-in-out infinite; text-shadow: 0 4px 0 rgba(var(--ink-rgb), .15); }
.gameTitle span:nth-child(1) { color: var(--pink); animation-delay: 0s; }
.gameTitle span:nth-child(2) { color: var(--mint); animation-delay: .12s; }
.gameTitle span:nth-child(3) { color: var(--blue); animation-delay: .24s; }
.gameTitle span:nth-child(4) { color: var(--orange); animation-delay: .36s; }
.gameTitle span:nth-child(5) { color: var(--purple); animation-delay: .48s; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.subtitle { color: var(--ink-light); font-size: 15px; letter-spacing: 5px; margin-top: 2px; }
.tagline { color: var(--ink-light); font-size: 14px; line-height: 1.8; margin: 12px 0 16px; }
.tagline b { color: var(--pink-deep); }

#recordChips { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.recordChip {
  background: var(--cream); border: 2px dashed var(--dash-warm);
  border-radius: 999px; padding: 5px 14px;
  font-size: 13px; color: var(--ink-light); font-weight: bold;
}

.bigBtn {
  display: block; width: 100%;
  border: none; cursor: pointer;
  background: linear-gradient(180deg, var(--pink-light), var(--pink-deep));
  color: var(--white); font-family: var(--font);
  font-size: 22px; font-weight: bold; letter-spacing: 4px;
  padding: 15px 0; border-radius: 999px;
  box-shadow: 0 6px 0 var(--pink-shadow);
  transition: transform .08s, box-shadow .08s;
  animation: breathe 2.2s ease-in-out infinite;
}
.bigBtn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--pink-shadow); }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }

.helpBox {
  margin-top: 18px; text-align: left;
  background: var(--cream); border-radius: 18px;
  padding: 13px 17px; font-size: 13.5px; line-height: 2;
  color: var(--ink-light);
}
.helpTitle { font-weight: bold; color: var(--ink); font-size: 14.5px; }
.credit { margin-top: 13px; font-size: 11.5px; color: var(--gray-warm); letter-spacing: 1px; }

/* ============ 升级卡片 ============ */
.levelupPanel { width: min(760px, 96vw); }
.luTitle { font-size: clamp(21px, 4.6vw, 28px); font-weight: bold; margin-bottom: 16px; }
#cardRow { display: flex; gap: 13px; justify-content: center; flex-wrap: wrap; }
.card {
  position: relative;
  width: 190px; cursor: pointer;
  background: var(--cream);
  border: 3px solid transparent;
  border-radius: 22px; padding: 15px 13px 14px;
  text-align: center;
  transition: transform .13s cubic-bezier(.34,1.56,.64,1), border-color .13s, box-shadow .13s;
  animation: cardIn .4s cubic-bezier(.34, 1.56, .64, 1) backwards;
}
/* 绝学顿悟卡：暖金宣纸 + 金边，全场唯一有资格"发光"的卡 */
.card.evo { background: linear-gradient(160deg, #faf3dd, #f3e3bb); border-color: rgba(201, 150, 46, .55); }
.card.evo:hover, .card.evo:active { border-color: var(--yellow); box-shadow: 0 10px 26px rgba(168, 125, 36, .35); }
.cardTag.evo { background: linear-gradient(180deg, var(--yellow), var(--orange-deep)); color: var(--white); }
.evoSeal {
  position: absolute; top: 10px; right: 10px;
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--pink); color: var(--white);
  font-size: 15px; font-weight: bold; line-height: 26px; text-align: center;
  transform: rotate(8deg);
  box-shadow: 0 2px 0 rgba(var(--ink-rgb), .2);
}
.card:nth-child(1) { animation-delay: .05s; } .card:nth-child(2) { animation-delay: .13s; } .card:nth-child(3) { animation-delay: .21s; }
@keyframes cardIn { from { transform: translateY(46px) scale(.6); opacity: 0; } }
.card:hover, .card:active { transform: translateY(-7px) scale(1.04); border-color: var(--cardColor, var(--pink)); box-shadow: 0 10px 24px rgba(var(--ink-rgb), .2); background: var(--white); }
.cardIcon { width: 68px; height: 68px; margin: 0 auto 7px; display: block; }
.cardName { font-weight: bold; font-size: 16.5px; margin-bottom: 2px; }
.cardTag { font-size: 11px; font-weight: bold; padding: 2px 10px; border-radius: 999px; display: inline-block; margin-bottom: 7px; }
.cardTag.new { background: var(--tag-new-bg); color: var(--mint-dark); }
.cardTag.up { background: var(--tag-up-bg); color: var(--pink-deep); }
.cardTag.relic { background: #e3e9d8; color: #5a6b3f; }
.cardLvPips { display: flex; justify-content: center; gap: 4px; margin-bottom: 8px; }
.pip { width: 13px; height: 7px; border-radius: 4px; background: rgba(var(--ink-rgb), .15); }
.pip.on { background: var(--cardColor, var(--pink)); }
.cardDesc { font-size: 12.5px; color: var(--ink-light); line-height: 1.65; min-height: 42px; }
.cardDesc b { color: var(--cardColor, var(--pink-deep)); }
.luBtns { margin-top: 17px; display: flex; gap: 11px; justify-content: center; flex-wrap: wrap; }

/* 配装一览条 */
#buildStrip {
  display: flex; justify-content: center; align-items: center;
  gap: 7px; flex-wrap: wrap;
  margin-top: 15px; padding-top: 12px;
  border-top: 2px dashed var(--dash-light);
}
.stripLabel { font-size: 12px; color: var(--gray-warm); font-weight: bold; margin-right: 3px; }
.stripItem { position: relative; width: 34px; height: 34px; }
.stripItem canvas { width: 30px; height: 30px; background: var(--cream); border-radius: 9px; }
.stripLv {
  position: absolute; right: -5px; bottom: -5px;
  color: var(--white); font-size: 9.5px; font-weight: bold;
  padding: 1px 5px; border-radius: 999px;
  box-shadow: 0 1px 0 rgba(var(--ink-rgb), .25);
}

.smallBtn {
  border: none; cursor: pointer; font-family: var(--font);
  background: linear-gradient(180deg, var(--sky), var(--blue-deep));
  color: var(--white); font-size: 15px; font-weight: bold;
  padding: 10px 24px; border-radius: 999px;
  box-shadow: 0 4px 0 var(--blue-shadow);
  transition: transform .08s, box-shadow .08s;
}
.smallBtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--blue-shadow); }
.smallBtn:disabled { filter: grayscale(.6); opacity: .55; cursor: default; }
.smallBtn.ghost { background: var(--cream); color: var(--ink-light); box-shadow: 0 4px 0 rgba(var(--ink-rgb), .14); }

/* ============ 暂停 & 结算 ============ */
.pausePanel, .resultPanel { width: min(420px, 92vw); }
#pauseStats { margin-bottom: 18px; }
#resultTitle { font-size: clamp(26px, 6vw, 34px); font-weight: bold; }
#resultTitle.win { color: var(--mint-dark); }
#resultTitle.lose { color: var(--pink-deep); }
#resultEmoji { font-size: 58px; margin: 8px 0 14px; animation: bounce 1.4s ease-in-out infinite; display: inline-block; }
#resultStats { margin-bottom: 20px; }
.statRow { display: flex; justify-content: space-between; padding: 9px 6px; border-bottom: 2px dashed var(--dash-light); font-size: 15px; color: var(--ink-light); }
.statRow b { color: var(--ink); font-size: 17px; }
.statRow .newRecord { color: var(--pink-deep); font-size: 12px; margin-left: 6px; animation: recordPop .4s ease-out; }
/* 不能复用 comboPop：它带 translateX(-50%)，用在行内徽章上会横向闪跳 */
@keyframes recordPop { 0% { transform: scale(.5); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
.resultPanel .smallBtn, .pausePanel .smallBtn { margin-top: 12px; }
.resultPanel .bigBtn, .pausePanel .bigBtn { margin-top: 6px; }
#pauseStats .statRow:last-child, #resultStats .statRow:last-child { border-bottom: none; }
/* 谢幕落款：呼应"战场即画卷"——每一局都是一幅画 */
.sealLine {
  margin-top: 10px; font-size: 12.5px; color: var(--gray-warm);
  letter-spacing: 1px;
}

/* ============ BOSS 横幅 & toast ============ */
#bossBanner {
  position: fixed; top: 34%; left: 0; right: 0; z-index: 40;
  text-align: center; font-size: clamp(26px, 6.5vw, 44px);
  font-weight: bold; color: var(--white); letter-spacing: 6px;
  text-shadow: 0 0 18px rgba(var(--coral-rgb), .9), 0 3px 0 rgba(var(--ink-rgb), .35);
  pointer-events: none;
  animation: bannerIn 2.6s ease-out forwards;
}
@keyframes bannerIn {
  0% { transform: scale(2.6); opacity: 0; }
  14% { transform: scale(1); opacity: 1; }
  80% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

#toast {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%);
  z-index: 40; background: rgba(var(--ink-rgb), .88); color: var(--white);
  font-size: 14.5px; font-weight: bold;
  padding: 9px 22px; border-radius: 999px; pointer-events: none;
  animation: toastIn 2s ease-out forwards;
  white-space: nowrap;
}
@keyframes toastIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(16px); }
  12% { opacity: 1; transform: translateX(-50%) translateY(0); }
  82% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* 窄屏适配：断点取 760px——计时器绝对居中后，621~700px 区间仍会压到
   左侧血量/击杀胶囊，两行布局需要覆盖到这个横屏区间 */
@media (max-width: 760px) {
  .panel { padding: 20px 16px; border-radius: 22px; }
  #cardRow { flex-direction: row; gap: 8px; }
  .card { width: calc(33% - 6px); min-width: 104px; padding: 11px 7px; }
  .cardIcon { width: 50px; height: 50px; }
  .cardDesc { font-size: 11px; min-height: 54px; }
  .cardName { font-size: 14px; }
  #statRow { gap: 6px; }
  /* 手机竖屏改两行：第一行 计时器(居中)+按钮(右)，第二行 血量+击杀。
     窄屏上左侧行内容会和居中的计时器重叠，分行后互不打架 */
  #timer { top: -44px; font-size: 22px; }
  #statRow { top: calc(88px + env(safe-area-inset-top, 0px)); }
  #topBtns { top: calc(44px + env(safe-area-inset-top, 0px)); }
  #comboBox { top: calc(124px + env(safe-area-inset-top, 0px)); }
  .roundBtn { width: 40px; height: 40px; font-size: 17px; }
  #ultBtn { width: 58px; height: 58px; font-size: 15px; right: 10px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 380px) {
  /* 保持换行：nowrap + min-width 会在 320px 档手机上把第三张卡挤出屏幕 */
  .card { min-width: 96px; }
}
