:root {
  --ink: #2b2521;
  --paper: #fbf6e6;
  --paper-2: #fffdf2;
  --blue: #3f7df2;
  --red: #ee574c;
  --gold: #f6c445;
  --pencil: #5a5a66;
  --hand: "Hannotate SC", "HanziPen SC", "Wawati SC", "Xingkai SC", "YouYuan", "Comic Sans MS",
    "Chalkboard SE", "Marker Felt", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #14302a; }
body {
  font-family: var(--hand);
  color: var(--ink);
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}
.hidden { display: none !important; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
body[data-theme="easy"] #vignette { background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 42%, rgba(20,12,6,0.58) 100%); }
body[data-theme="normal"] #vignette { background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 42%, rgba(5,28,22,0.6) 100%); }
body[data-theme="hard"] #vignette { background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 36%, rgba(4,6,10,0.74) 100%); }
body[data-theme="hard"] .menu-card { background: #f8f0dd repeating-linear-gradient(transparent 0 30px, rgba(120,90,50,0.12) 30px 31px); }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.flabel {
  position: absolute; left: 0; top: 0; font-size: 20px; font-weight: 700; white-space: nowrap;
  text-shadow: 0 0 4px #fff, 0 0 10px #fff, 1px 1px 0 #fff;
  will-change: transform, opacity;
}
#selbox {
  position: fixed; display: none; z-index: 3; pointer-events: none;
  border: 2px dashed var(--blue); background: rgba(63,125,242,0.14);
}

/* ---------------- 便利贴 / 纸片 ---------------- */
.note {
  background: var(--paper-2) repeating-linear-gradient(transparent 0 24px, rgba(90,130,180,0.13) 24px 25px);
  border: 2px solid var(--ink);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  box-shadow: 3px 4px 0 rgba(43,37,33,0.25);
  padding: 5px 16px; font-size: 17px; white-space: nowrap;
}

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
/* 面板本身要挡住鼠标：否则点在卡片间隙、技能栏空白处会穿透到下面的战场，变成一条移动命令 */
#hud button, #hud .note, #skillbar, #cards, #hint, #placingTip, #toasts .toast, #sysbtns { pointer-events: auto; }

#topbar {
  position: absolute; top: 12px; left: 14px; right: 14px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.tl { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
#inkbox { display: flex; align-items: center; gap: 8px; transform: rotate(-1.5deg); }
#inkbox b { font-size: 27px; min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }
#income { color: #2f8f57; font-size: 15px; }
.ico { width: 20px; height: 20px; fill: var(--blue); stroke: var(--ink); stroke-width: 1.5; flex: none; }

#rankbox { display: flex; align-items: center; gap: 7px; padding: 2px 12px 2px 8px; font-size: 14px; transform: rotate(0.8deg); }
#rankbox svg g { stroke-width: 1.7; }
#rankName { font-weight: 700; font-size: 16px; }
.rprog { width: 64px; height: 8px; border: 1.5px solid var(--ink); border-radius: 4px; background: #f4eedd; overflow: hidden; }
.rprog i { display: block; height: 100%; background: linear-gradient(#ffe08a, var(--gold)); }

#versus { display: flex; align-items: center; gap: 14px; }
.basebar { display: flex; align-items: center; gap: 8px; }
.basebar .bar {
  width: 190px; height: 19px; border: 2px solid var(--ink); background: #f4eedd;
  border-radius: 9px 6px 10px 7px / 6px 10px 7px 9px; overflow: hidden;
  box-shadow: 2px 3px 0 rgba(43,37,33,0.22); transform: rotate(0.8deg);
}
.basebar.foe .bar { transform: rotate(-0.8deg); }
.basebar .bar { position: relative; }
.basebar .bar i { position: absolute; top: 0; bottom: 0; transition: width 0.25s, left 0.25s; }
#hpMe { left: 40%; width: 60%; background: linear-gradient(#7aa4ff, var(--blue)); }
#hpFoe { left: 40%; width: 60%; background: linear-gradient(#ff9a90, var(--red)); }
/* 外壳那段（石灰色）：外壳破了就消失，露出本体的整段 */
.basebar .bar i.shell { left: 0; width: 40%; background: repeating-linear-gradient(135deg, #cfc8b8 0 5px, #b9b2a2 5px 10px); border-right: 2px solid var(--ink); }
.basebar .bar.broken i.shell { width: 0; border-right-width: 0; }
.lbl {
  font-size: 14px; padding: 0 8px; background: var(--paper-2); border: 1.5px solid var(--ink);
  border-radius: 9px 4px 10px 5px / 5px 10px 4px 9px; box-shadow: 1.5px 2px 0 rgba(43,37,33,0.25);
}
.lbl.me { color: #2557b9; }
.lbl.foe { color: #b1342c; }
.lbl.soft { color: var(--pencil); font-size: 12.5px; padding: 0 6px; }
#timer { font-variant-numeric: tabular-nums; transform: rotate(-1deg); font-size: 16px; padding: 3px 12px; }
#timer.late { color: #b1342c; border-color: var(--red); animation: wiggle 1.3s ease-in-out infinite; }
#army { transform: rotate(1.2deg); font-size: 14px; padding: 5px 12px; }
#army b { font-size: 19px; }

#centerTop {
  position: absolute; top: 68px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(600px, 92vw); pointer-events: none;
}
.sticky {
  background: #fff3a8; color: var(--ink); padding: 9px 18px 9px 26px;
  font-size: 15.5px; line-height: 1.5; text-align: left;
  box-shadow: 3px 4px 0 rgba(43,37,33,0.22); transform: rotate(-0.6deg); position: relative;
  clip-path: polygon(0 3%, 4% 0, 100% 0, 100% 97%, 97% 100%, 0 100%);
}
.sticky::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: rgba(238,87,76,0.55); }
.sticky b { color: #2557b9; }
/* 提示便签放在左上角空白处，不挡敌方城堡 */
#hint { position: absolute; top: 108px; left: 14px; max-width: min(440px, 44vw); }
.pop { animation: pop 0.35s ease-out; }
/* 界面动画只用位移/缩放，不用透明度：即使运行环境把动画冻住，内容也不会停在“看不见”的状态 */
@keyframes pop { from { transform: rotate(-4deg) scale(0.7); } to { transform: rotate(-0.6deg) scale(1); } }

#toasts { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast {
  background: rgba(255,253,242,0.96); border: 2px solid var(--ink); padding: 3px 14px; font-size: 15px;
  border-radius: 12px 4px 14px 5px / 5px 14px 4px 12px;
  transform: translateY(-10px); transition: transform 0.25s ease-out;
  box-shadow: 2px 3px 0 rgba(43,37,33,0.2);
}
.toast.show { transform: none; }
.toast.hide { transform: translateY(-8px); }
.toast.warn, .toast.foe { border-color: var(--red); color: #b1342c; }
.toast.me { border-color: var(--blue); color: #2557b9; }

/* ---------------- 左下角：技能栏 + 卡片 ---------------- */
#bottomLeft { position: absolute; left: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

#skillbar {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  background: rgba(255,253,242,0.94); border: 2px solid var(--ink);
  border-radius: 14px 6px 16px 7px / 7px 16px 6px 14px;
  box-shadow: 3px 4px 0 rgba(43,37,33,0.22); transform: rotate(-0.4deg);
}
.vsep { width: 2px; height: 32px; background: rgba(43,37,33,0.22); margin: 0 2px; }

.skill {
  position: relative; width: 48px; height: 48px; padding: 0; cursor: pointer; overflow: hidden;
  border-radius: 50% 46% 52% 48% / 47% 52% 48% 53%; border: 2px solid var(--ink);
  background: #fff; display: grid; place-items: center; transition: transform 0.12s;
  font-family: var(--hand); color: var(--ink);
}
.skill img { width: 30px; height: 30px; pointer-events: none; }
.skill kbd {
  position: absolute; right: -1px; bottom: -1px; min-width: 17px; height: 17px; line-height: 15px; padding: 0 2px;
  font-size: 11px; font-weight: 700; font-family: var(--hand); background: var(--gold);
  border: 1.5px solid var(--ink); border-radius: 4px;
}
.skill .cd {
  position: absolute; left: 0; right: 0; top: 0; height: 0; pointer-events: none;
  background: rgba(43,37,33,0.62); color: #fff; font-size: 17px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.skill:hover { transform: scale(1.08); }
.skill.active { outline: 3px dashed var(--gold); outline-offset: 2px; }
.skill.off { filter: grayscale(0.7); opacity: 0.6; }
.skill.locked { filter: grayscale(1); opacity: 0.55; }
.skill.wide {
  width: auto; border-radius: 24px 12px 26px 13px / 13px 26px 12px 24px; padding: 0 12px 0 8px;
  display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700;
}
.skill.wide kbd { position: static; }
.skill.ready { background: var(--gold); animation: wiggle 1.3s ease-in-out infinite; }
@keyframes wiggle {
  0%, 100% { transform: rotate(-2deg) scale(1); }
  50% { transform: rotate(2deg) scale(1.07); }
}

.tech {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 0;
  min-width: 68px; padding: 3px 8px 4px; border: 2px solid var(--ink);
  border-radius: 12px 5px 14px 6px / 6px 14px 5px 12px; background: #fff;
  font-family: var(--hand); color: var(--ink); cursor: pointer; transition: transform 0.12s;
}
.tech img { width: 22px; height: 22px; }
.tech .tname { font-size: 12px; font-weight: 700; line-height: 1.2; }
.tech .tlv { font-size: 9px; line-height: 1; letter-spacing: 1px; color: #2557b9; }
.tech .tcost { font-size: 12px; font-weight: 700; line-height: 1.2; }
.tech:hover { transform: translateY(-2px); }
.tech.poor { opacity: 0.6; }
.tech.maxed { background: #e6f4e6; }

#cards { display: flex; gap: 9px; align-items: flex-end; }
.card {
  position: relative; width: 96px; height: 146px; padding: 0; overflow: hidden;
  background: var(--paper-2); border: 2.5px solid var(--ink); color: var(--ink); font-family: var(--hand);
  border-radius: 8px 16px 10px 18px / 16px 8px 18px 10px;
  box-shadow: 3px 5px 0 rgba(43,37,33,0.28); cursor: pointer;
  transform: rotate(var(--tilt, 0deg)); transition: transform 0.14s, box-shadow 0.14s, filter 0.2s;
}
.card:hover { transform: translateY(-8px) rotate(0deg); box-shadow: 4px 9px 0 rgba(43,37,33,0.28); }
.card:active { transform: translateY(-2px) scale(0.97); }
.card.active { outline: 3px dashed var(--blue); outline-offset: 3px; transform: translateY(-10px) rotate(0deg); }
.card.poor { filter: grayscale(0.85); opacity: 0.62; }
.card img { position: absolute; left: 50%; top: 3px; transform: translateX(-50%); height: 94px; max-width: 100%; object-fit: contain; }
.cname { position: absolute; left: 0; right: 0; top: 98px; text-align: center; font-size: 14.5px; font-weight: 700; }
.ccount {
  position: absolute; right: 7px; top: 5px; font-size: 12px; background: var(--paper);
  border: 1.5px solid var(--ink); border-radius: 50% 45% 50% 48%; padding: 0 6px;
}
.ccost { position: absolute; left: 0; right: 0; bottom: 6px; display: flex; justify-content: center; align-items: center; gap: 3px; font-size: 17px; font-weight: 700; }
.ccost svg { width: 13px; height: 13px; fill: var(--blue); }
.card kbd {
  position: absolute; left: 6px; top: 5px; width: 21px; height: 21px; line-height: 18px; text-align: center;
  font-family: var(--hand); font-size: 13px; font-weight: 700; background: var(--gold);
  border: 1.5px solid var(--ink); border-radius: 5px 3px 6px 4px; box-shadow: 1px 1.5px 0 rgba(43,37,33,0.35);
}
.cd {
  position: absolute; left: 0; right: 0; top: 0; height: 0; pointer-events: none;
  background: rgba(43,37,33,0.62); color: #fff; font-size: 32px; font-weight: 700;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4px;
}
/* 英雄卡片 */
.card.hero { width: 126px; background: #fff8d8; box-shadow: 3px 5px 0 rgba(150,110,0,0.35); --tilt: -1deg; }
.card.hero img { height: 98px; top: 2px; }
.card.hero .clevel {
  position: absolute; right: 6px; top: 5px; font-size: 12px; font-weight: 700; padding: 0 6px;
  background: var(--gold); border: 1.5px solid var(--ink); border-radius: 10px 4px 11px 5px;
}
.card.hero .chstate { position: absolute; left: 0; right: 0; bottom: 7px; text-align: center; font-size: 14px; font-weight: 700; color: #2557b9; }
.card.hero.onField { outline: 3px solid #ffd23a; outline-offset: 2px; }
.card.hero .cd { font-size: 24px; align-items: center; padding: 0; }

#placingTip {
  position: absolute; left: 18px; bottom: 242px; font-size: 14px; color: #fff;
  background: rgba(43,37,33,0.86); padding: 4px 12px; transform: rotate(-0.8deg);
  border-radius: 10px 4px 12px 5px / 5px 12px 4px 10px; max-width: 46vw;
}

#selpanel {
  position: absolute; right: 16px; bottom: 16px; padding: 9px 14px; transform: rotate(0.8deg);
  max-width: 300px; display: flex; flex-direction: column; gap: 7px; white-space: normal; font-size: 14px;
}
.selrow { display: flex; align-items: center; gap: 9px; }
.selrow img { height: 46px; width: auto; flex: none; }
.selrow b { font-size: 15px; }
.selrow span { display: block; opacity: 0.7; font-size: 12.5px; }
.hpbar { height: 7px; width: 150px; margin-top: 2px; border: 1.5px solid var(--ink); border-radius: 4px; background: #f4eedd; overflow: hidden; }
.hpbar i { display: block; height: 100%; background: #5fd068; }

#sysbtns { position: absolute; right: 14px; top: 64px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.sbtn {
  position: relative; width: 42px; height: 42px; display: grid; place-items: center;
  border: 2px solid var(--ink); background: var(--paper-2); color: var(--ink);
  font-family: var(--hand); font-size: 19px; font-weight: 700;
  border-radius: 50% 46% 52% 48% / 47% 52% 48% 53%;
  box-shadow: 2px 3px 0 rgba(43,37,33,0.25); cursor: pointer; transform: rotate(-2deg); transition: transform 0.12s;
}
.sbtn.wide { width: auto; padding: 0 13px; font-size: 14px; }
.sbtn:hover { transform: scale(1.08) rotate(0deg); }
.sbtn svg { width: 20px; height: 20px; fill: var(--ink); }
.sbtn .i-play { display: none; }
.sbtn.paused .i-pause { display: none; }
.sbtn.paused .i-play { display: block; fill: #2f8f57; }
.sbtn.off svg { fill: #b5ae9f; }
.sbtn.on { background: #5b6475; color: #fff; border-color: #2f3542; }
.sbtn.part { background: #d9dde6; }
.selrow em.tag { display: inline-block; margin-left: 6px; padding: 0 7px; border: 1.5px solid #5b6475; border-radius: 9px; font-style: normal; font-size: 12px; line-height: 18px; color: #3b4250; background: #e9ecf2; vertical-align: 2px; }
.selrow em.tag.part { opacity: 0.6; }
.sbtn.off::after { content: ""; position: absolute; width: 30px; height: 2.5px; background: var(--red); transform: rotate(-45deg); border-radius: 2px; }
#btnHero.hasPts { background: var(--gold); }
.hskills { display: contents; }

/* ---------------- 全屏遮罩 ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(24,15,8,0.42), rgba(24,15,8,0.82));
}
#minigame { z-index: 13; }
#filewarn { z-index: 19; }
.menu-card {
  position: relative; max-height: 94vh; overflow: auto;
  background: var(--paper-2) repeating-linear-gradient(transparent 0 30px, rgba(90,130,180,0.12) 30px 31px);
  border: 3px solid var(--ink); padding: 30px 46px 26px; text-align: center;
  border-radius: 18px 8px 22px 10px / 10px 22px 8px 18px;
  box-shadow: 8px 10px 0 rgba(0,0,0,0.35); transform: rotate(-0.6deg);
  width: min(94vw, 680px); animation: cardIn 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes cardIn { from { transform: rotate(-6deg) scale(0.88) translateY(24px); } to { transform: rotate(-0.6deg) scale(1); } }

.big-btn {
  font-family: var(--hand); font-size: 23px; font-weight: 700; padding: 9px 30px; cursor: pointer;
  border: 3px solid var(--ink); background: var(--blue); color: #fff;
  border-radius: 18px 6px 20px 8px / 8px 20px 6px 18px;
  box-shadow: 4px 5px 0 rgba(43,37,33,0.4); transition: transform 0.12s, box-shadow 0.12s;
}
.big-btn:hover { transform: translateY(-3px) rotate(-0.8deg); box-shadow: 5px 8px 0 rgba(43,37,33,0.4); }
.big-btn:active { transform: translateY(1px); box-shadow: 2px 2px 0 rgba(43,37,33,0.4); }
.big-btn.ghost { background: #fff; color: var(--ink); }
.keys { font-size: 13px; color: var(--pencil); margin: 8px 0 12px; line-height: 1.6; }

/* ---------------- 作业本：整页界面 ---------------- */
#book { background: radial-gradient(ellipse at center, rgba(24,15,8,0.5), rgba(24,15,8,0.86)); }
.sheet {
  width: min(1220px, 96vw); height: min(760px, 94vh);
  display: grid; grid-template-columns: 188px minmax(0, 1fr);
  background: var(--paper-2) repeating-linear-gradient(transparent 0 29px, rgba(90,130,180,0.13) 29px 30px);
  border: 3px solid var(--ink); border-radius: 22px 10px 26px 12px / 12px 26px 10px 22px;
  box-shadow: 10px 14px 0 rgba(0,0,0,0.38); transform: rotate(-0.25deg); overflow: hidden;
  animation: bookIn 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
/* 作业本的纸跟着难度换：方格草稿纸 / 横线作业本 / 牛皮作战图 */
body[data-theme="easy"] .sheet {
  background:
    repeating-linear-gradient(90deg, transparent 0 25px, rgba(86,124,168,0.16) 25px 26px),
    repeating-linear-gradient(transparent 0 25px, rgba(86,124,168,0.16) 25px 26px), var(--paper-2);
}
body[data-theme="hard"] .sheet { background: #f8f0dd repeating-linear-gradient(transparent 0 29px, rgba(120,90,50,0.16) 29px 30px); }
@keyframes bookIn { from { transform: rotate(-1.6deg) scale(0.94) translateY(18px); } to { transform: rotate(-0.25deg) scale(1); } }

.rail { display: flex; flex-direction: column; padding: 18px 0 14px; background: rgba(255,255,255,0.62); border-right: 2px dashed rgba(43,37,33,0.28); }
.rail-logo { padding: 2px 16px 14px 18px; font-size: 24px; font-weight: 700; white-space: nowrap; transform: rotate(-2deg); text-shadow: 2px 2px 0 #fff, 4px 4px 0 rgba(63,125,242,0.45); }
.rail-logo b { display: inline-block; margin-left: 4px; padding: 0 6px; font-size: 12px; line-height: 18px; background: var(--red); color: #fff; border: 2px solid var(--ink); border-radius: 6px 3px 7px 4px; transform: rotate(8deg) translateY(-5px); text-shadow: none; }
.rail-tabs { display: flex; flex-direction: column; gap: 3px; }
.tab {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px 8px 20px; font-family: var(--hand); font-size: 18px; font-weight: 700;
  color: var(--ink); text-align: left; background: transparent; border: 0; border-left: 6px solid transparent;
  cursor: pointer; transition: background 0.12s, transform 0.12s;
}
.tab:hover { background: rgba(246,196,69,0.28); }
.tab.on { background: var(--gold); border-left-color: var(--ink); }
.tab em { width: 11px; height: 11px; border-radius: 50%; background: var(--red); border: 1.5px solid var(--ink); }
.rail-foot { margin-top: auto; padding: 10px 14px 0; display: flex; flex-direction: column; gap: 8px; }
.rail-foot .big-btn { font-size: 17px; padding: 6px 10px; }
.ver { font-size: 11.5px; color: var(--pencil); text-align: center; }

.pages { overflow-x: hidden; overflow-y: auto; padding: 16px 30px 20px; }
.pg { display: none; animation: pgIn 0.25s ease-out; }
.pg.on { display: block; }
@keyframes pgIn { from { transform: translateX(14px); } to { transform: none; } }
.pg h2 { font-size: 30px; line-height: 1.15; }
.pg h3 { margin: 10px 0 6px; font-size: 18px; color: #2557b9; display: flex; align-items: baseline; gap: 10px; }
.pg h3 .hint { font-size: 12.5px; font-weight: 400; color: var(--pencil); }
.pg-title { margin-bottom: 10px; }
.note-line { margin: 6px 0 12px; font-size: 13.5px; color: var(--pencil); line-height: 1.6; }

/* 主页 */
.home { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: 28px; height: 100%; align-items: stretch; }
.home-main { display: flex; flex-direction: column; justify-content: center; padding: 6px 0; }
.kicker { font-size: 15px; color: var(--pencil); letter-spacing: 0.08em; }
.title {
  display: inline-block; align-self: flex-start; position: relative; font-size: clamp(48px, 6vw, 74px); line-height: 1.05; letter-spacing: 0.04em; font-weight: 700;
  text-shadow: 4px 4px 0 #fff, 7px 7px 0 rgba(63,125,242,0.55); transform: rotate(-1.5deg);
}
.badge3d {
  position: absolute; right: -14px; top: -10px; padding: 1px 12px; background: var(--red); color: #fff;
  font-size: 24px; font-weight: 700; border: 2.5px solid var(--ink);
  border-radius: 10px 4px 12px 5px / 5px 12px 4px 10px; transform: rotate(9deg);
  box-shadow: 2px 3px 0 rgba(43,37,33,0.35); text-shadow: none; letter-spacing: 0;
}
.lead { margin: 10px 0 16px; font-size: clamp(14px, 1.45vw, 17px); color: var(--pencil); line-height: 1.6; max-width: 540px; }
.block { padding: 10px 14px 12px; border: 2px dashed rgba(43,37,33,0.35); border-radius: 12px 5px 14px 6px / 6px 14px 5px 12px; background: rgba(255,255,255,0.6); }
.block-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; font-size: 14px; }
.block-h b { font-size: 18px; color: #2557b9; }
.block-h span { color: var(--pencil); font-size: 12.5px; }
.diff-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.map-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.map-card {
  display: grid; justify-items: center; gap: 1px; padding: 6px 4px 5px; cursor: pointer; color: var(--ink); font-family: var(--hand);
  background: var(--paper-2); border: 2px solid var(--ink); border-radius: 8px 12px 9px 13px / 12px 8px 13px 9px; transition: transform 0.12s;
}
.map-card svg { width: 100%; max-width: 92px; height: auto; }
.map-card b { font-size: 15px; white-space: nowrap; }
.map-card i { font-style: normal; font-size: 11px; color: var(--pencil); white-space: nowrap; }
.map-card:hover { transform: translateY(-2px); }
.map-card.on { background: var(--gold); transform: rotate(-1deg); box-shadow: 2px 3px 0 rgba(43,37,33,0.3); }
.map-card .dice { display: grid; place-items: center; width: 100%; max-width: 92px; aspect-ratio: 50 / 46; font-size: 34px; font-weight: 700; border: 2px dashed var(--pencil); border-radius: 8px; }
.diff-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 7px 12px 8px; font-family: var(--hand); text-align: left; color: var(--ink);
  background: #fff; border: 2px solid var(--ink); border-radius: 14px 5px 16px 6px / 6px 16px 5px 14px;
  cursor: pointer; transition: transform 0.12s, background 0.12s;
}
.diff-card:hover { transform: translateY(-2px); }
.diff-card.on { background: var(--gold); transform: rotate(-1deg); box-shadow: 2px 3px 0 rgba(43,37,33,0.3); }
.diff-card b { font-size: 19px; }
.diff-card em { font-style: normal; font-size: 12.5px; }
.diff-card i { font-style: normal; font-size: 11.5px; color: var(--pencil); }
.home-cta { display: flex; align-items: center; gap: 16px; margin-top: 18px; flex-wrap: wrap; }
.big-btn.start { font-size: 27px; padding: 11px 40px; }
.foe-note { font-size: 13px; color: var(--pencil); max-width: 250px; line-height: 1.45; }
.home-side { display: flex; flex-direction: column; gap: 12px; justify-content: center; }
.panel {
  display: flex; flex-direction: column; gap: 6px; padding: 10px 14px 12px; text-align: left; font-family: var(--hand); color: var(--ink);
  background: #fff; border: 2px solid var(--ink); border-radius: 14px 5px 16px 6px / 6px 16px 5px 14px;
  box-shadow: 3px 4px 0 rgba(43,37,33,0.22); cursor: pointer; transition: transform 0.12s, box-shadow 0.12s;
}
button.panel:hover { transform: translateY(-3px) rotate(-0.5deg); box-shadow: 4px 7px 0 rgba(43,37,33,0.22); }
.panel-h { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: #2557b9; font-weight: 700; }
.panel-h em { font-style: normal; font-size: 11.5px; color: var(--pencil); font-weight: 400; }
.panel-body { display: flex; align-items: center; gap: 12px; }
.panel-body img { height: 76px; max-width: 44%; object-fit: contain; flex: none; }
.panel-body svg { flex: none; }
.panel-body > span { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.panel-body b { font-size: 21px; }
.panel-body i { font-style: normal; font-size: 13px; color: var(--pencil); }
.panel-body em { font-style: normal; font-size: 12px; color: #2f8f57; margin-top: 3px; }
.panel.plain { cursor: default; box-shadow: none; background: transparent; border-style: dashed; }
.quick { flex-direction: row; gap: 8px; padding: 8px 10px; }
.quick button {
  flex: 1; display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-family: var(--hand); text-align: left; color: var(--ink);
  background: #fff; border: 2px solid var(--ink); border-radius: 12px 5px 14px 6px / 6px 14px 5px 12px; cursor: pointer;
}
.quick button:hover { background: var(--gold); }
.quick img { width: 30px; height: 30px; flex: none; }
.quick span { display: flex; flex-direction: column; line-height: 1.25; }
.quick b { font-size: 15px; }
.quick em { font-style: normal; font-size: 11px; color: var(--pencil); }

/* 英雄页 */
.roster { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; margin-bottom: 10px; }
.roster-card {
  position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr); grid-template-rows: auto auto auto; column-gap: 8px; align-items: center;
  padding: 5px 10px; font-family: var(--hand); text-align: left; color: var(--ink); background: #fff;
  border: 2px solid var(--ink); border-radius: 14px 5px 16px 6px / 6px 16px 5px 14px; cursor: pointer; transition: transform 0.12s, background 0.12s;
}
.roster-card img { grid-row: 1 / 4; height: 58px; }
.roster-card b { font-size: 17px; align-self: end; white-space: nowrap; }
.roster-card span { font-size: 11.5px; color: var(--pencil); white-space: nowrap; }
.roster-card em { font-style: normal; font-size: 11px; color: var(--pencil); align-self: start; }
.roster-card:hover { transform: translateY(-2px); }
.roster-card.on { background: #fff6c9; box-shadow: 0 0 0 3px var(--gold); }
.roster-card .tag {
  position: absolute; right: 6px; top: 5px; padding: 0 6px; font-size: 10.5px; font-style: normal; font-weight: 700; color: #2557b9;
  background: #dfe9ff; border: 1.5px solid var(--ink); border-radius: 8px 3px 9px 4px;
}
.hero-detail { display: grid; grid-template-columns: minmax(270px, 0.9fr) minmax(0, 1.25fr); gap: 22px; align-items: start; }
.hd-left { padding: 12px 16px 14px; background: rgba(255,255,255,0.7); border: 2px dashed rgba(43,37,33,0.35); border-radius: 14px 6px 16px 7px / 7px 16px 6px 14px; overflow: hidden; }
.hd-portrait { float: right; height: 146px; margin: -6px -8px 4px 10px; }
.hd-left h2 { font-size: 30px; line-height: 1.1; }
.hd-left h2 small { display: block; font-size: 15px; color: var(--pencil); font-weight: 400; }
.hd-role { font-size: 14px; color: #2557b9; font-weight: 700; margin: 2px 0 10px; }
.statbars { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.statbars > div { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 8px; font-size: 12.5px; }
.statbars i { display: block; height: 10px; border: 1.5px solid var(--ink); border-radius: 5px; background: #f4eedd; overflow: hidden; }
.statbars b { display: block; height: 100%; background: linear-gradient(#ffe08a, var(--gold)); }
.hd-passive { font-size: 13px; line-height: 1.5; color: #2f8f57; font-weight: 700; }
.hd-tip { font-size: 12.5px; line-height: 1.55; color: var(--pencil); margin: 4px 0 10px; }
.hd-level { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: 12.5px; clear: both; }
.hd-level b { font-size: 16px; color: #2557b9; }
.hd-level .xpbar { grid-column: 1 / 3; }
.hd-level > span { color: var(--pencil); }
.hd-level > span.wide { grid-column: 1 / 3; }
.pts {
  padding: 3px 10px; background: #f1ede2; border: 2px solid var(--ink);
  border-radius: 10px 4px 12px 5px; font-weight: 700; font-size: 13.5px; white-space: nowrap;
}
.pts.hot { background: var(--gold); }
.xpbar { height: 11px; border: 2px solid var(--ink); border-radius: 6px; background: #f4eedd; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: linear-gradient(#ffe08a, var(--gold)); }
.big-btn.pick { margin-top: 10px; font-size: 19px; padding: 6px 22px; }
.big-btn.pick:disabled { opacity: 0.8; cursor: default; transform: none; box-shadow: 2px 3px 0 rgba(43,37,33,0.3); }
.big-btn.pick.isOn { background: #dfe9ff; color: #2557b9; }
.hd-note { margin-top: 10px; padding: 6px 10px; font-size: 13px; background: #fff6c9; border: 1.5px dashed var(--ink); border-radius: 10px 4px 12px 5px; }
.skill-list { display: flex; flex-direction: column; gap: 5px; }
.skill-row {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto auto; column-gap: 10px; align-items: center; padding: 3px 10px;
  background: #fff; border: 2px solid rgba(43,37,33,0.35); border-radius: 12px 5px 14px 6px;
}
.skill-row.locked { background: #f1ede2; }
.sk-ico { position: relative; width: 40px; height: 40px; margin-left: 3px; }
.sk-ico img { width: 40px; height: 40px; border: 2px solid var(--ink); border-radius: 50%; background: #fff; }
.sk-ico kbd {
  position: absolute; right: -6px; bottom: -4px; min-width: 18px; padding: 0 3px; font-family: var(--hand); font-size: 11px; font-weight: 700;
  background: var(--gold); border: 1.5px solid var(--ink); border-radius: 4px;
}
.skill-row.locked .sk-ico img { filter: grayscale(1); opacity: 0.6; }
.sk-txt { display: flex; flex-direction: column; line-height: 1.3; }
.sk-txt b { font-size: 16px; }
.sk-txt b em {
  font-style: normal; margin-left: 6px; padding: 0 5px; font-size: 10.5px; color: #fff; background: var(--red);
  border: 1.5px solid var(--ink); border-radius: 6px 2px 7px 3px; vertical-align: 2px;
}
.sk-txt span { font-size: 12.5px; color: var(--pencil); }
.sk-cd { font-style: normal; font-size: 12px; color: var(--pencil); white-space: nowrap; }
.uprows { display: flex; flex-direction: column; gap: 4px; }
.uprow {
  display: flex; align-items: center; gap: 12px; padding: 2px 10px; background: #fff;
  border: 2px solid rgba(43,37,33,0.35); border-radius: 10px 4px 12px 5px;
}
.uprow.locked { opacity: 0.55; background: #f1ede2; }
.upname { flex: 1; display: flex; align-items: baseline; gap: 8px; line-height: 1.25; min-width: 0; }
.upname b { font-size: 15.5px; white-space: nowrap; }
.upname span { font-size: 12.5px; color: var(--pencil); }
.upname em { font-style: normal; font-size: 12px; color: var(--red); white-space: nowrap; }
.pips { display: flex; gap: 4px; }
.pips i { width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 50%; }
.pips i.on { background: var(--blue); }
.plus, .unlock {
  min-width: 34px; height: 30px; padding: 0 6px; font-family: var(--hand); font-size: 20px; font-weight: 700; cursor: pointer;
  border: 2px solid var(--ink); border-radius: 8px 4px 9px 5px; background: var(--gold); box-shadow: 2px 2px 0 rgba(43,37,33,0.3);
}
.unlock { font-size: 13px; }
.plus:disabled, .unlock:disabled { opacity: 0.35; cursor: default; box-shadow: none; }

/* 军衔页 */
.rank { display: grid; grid-template-columns: minmax(230px, 0.72fr) minmax(0, 1.28fr); gap: 22px; align-items: start; }
.rank-now {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 14px; align-items: center; padding: 12px 16px;
  background: rgba(255,255,255,0.7); border: 2px dashed rgba(43,37,33,0.35); border-radius: 14px 6px 16px 7px / 7px 16px 6px 14px;
}
.rank-now svg { grid-row: 1 / 4; }
.rank-now b { font-size: 30px; line-height: 1; }
.rank-now span { font-size: 12.5px; color: var(--pencil); }
.xpbar.big { grid-column: 2; height: 12px; }
.record { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.record > div { display: flex; flex-direction: column; align-items: center; padding: 6px 4px; background: #fff; border: 2px solid rgba(43,37,33,0.35); border-radius: 12px 5px 14px 6px; }
.record b { font-size: 22px; }
.record span { font-size: 11.5px; color: var(--pencil); }
.usage { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.usage > div { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 3px 8px; background: #fff; border: 1.5px solid rgba(43,37,33,0.3); border-radius: 10px 4px 12px 5px; font-size: 13px; }
.usage img { height: 30px; }
.ladder { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.rung { display: flex; align-items: center; gap: 6px; padding: 3px 8px; background: #fff; border: 2px solid rgba(43,37,33,0.3); border-radius: 10px 4px 12px 5px; opacity: 0.6; }
.rung b { font-size: 14px; white-space: nowrap; }
.rung span { margin-left: auto; font-size: 11px; color: var(--pencil); }
.rung.done { opacity: 1; background: #eef7ee; }
.rung.now { opacity: 1; background: var(--gold); transform: rotate(-1deg); box-shadow: 2px 3px 0 rgba(43,37,33,0.3); }
.perks { list-style: none; display: flex; flex-direction: column; gap: 4px; margin: 0; }
.perks li { padding: 4px 10px; font-size: 13.5px; background: #fff; border: 1.5px solid rgba(43,37,33,0.3); border-radius: 10px 4px 12px 5px; opacity: 0.55; }
.perks li b { display: inline-block; min-width: 60px; color: #b1342c; }
.perks li.have { opacity: 1; }
.perks li.have b { color: #2f8f57; }

/* 玩法页 */
.subtabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.subtabs button {
  font-family: var(--hand); font-size: 15.5px; padding: 3px 16px; border: 2px solid var(--ink); background: #fff; color: var(--ink);
  border-radius: 14px 5px 16px 6px / 6px 16px 5px 14px; cursor: pointer;
}
.subtabs button.on { background: var(--gold); }
.how-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.how-grid > div { padding: 8px 12px; background: rgba(255,255,255,0.75); border: 1.5px solid rgba(43,37,33,0.3); border-radius: 12px 5px 14px 6px; }
.how-grid h4 { font-size: 16px; color: #2557b9; margin-bottom: 2px; }
.how-grid p { font-size: 13.5px; line-height: 1.6; }
.unit-grid, .hero-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.unit-card, .hero-brief {
  display: flex; flex-direction: column; align-items: center; padding: 8px 10px 10px; font-family: var(--hand); text-align: center; color: var(--ink);
  background: #fff; border: 2px solid var(--ink); border-radius: 14px 5px 16px 6px / 6px 16px 5px 14px;
}
.unit-card img { height: 92px; }
.unit-card b { font-size: 16px; }
.unit-card span { font-size: 12px; color: #2557b9; }
.unit-card p { font-size: 12px; color: var(--pencil); line-height: 1.45; }
.unit-card em { font-style: normal; font-size: 12.5px; margin-top: 3px; }
.counter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; background: #fff6c9; border: 2px dashed var(--ink); border-radius: 12px 5px 14px 6px; margin-bottom: 10px; }
.counter b { color: #b1342c; }
.counter span { font-size: 14px; padding: 1px 10px; background: #fff; border: 1.5px solid var(--ink); border-radius: 10px 4px 12px 5px; }
.tech-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tech-row > div { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 2px 8px; align-items: center; padding: 6px 10px; background: #fff; border: 2px solid rgba(43,37,33,0.35); border-radius: 12px 5px 14px 6px; }
.tech-row img { width: 28px; height: 28px; grid-row: 1 / 3; }
.tech-row b { font-size: 15px; }
.tech-row span { font-size: 12px; color: var(--pencil); }
.hero-brief { cursor: pointer; transition: transform 0.12s; }
.hero-brief:hover { transform: translateY(-3px); }
.hero-brief img { height: 96px; }
.hero-brief b { font-size: 17px; }
.hero-brief b i { display: block; font-style: normal; font-size: 11.5px; font-weight: 400; color: #2557b9; }
.hero-brief p { font-size: 12px; color: #2f8f57; line-height: 1.4; margin: 3px 0; }
.hero-brief > span { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 6px; font-size: 11.5px; }
.hero-brief > span img { width: 20px; height: 20px; vertical-align: -5px; }
.keys-table { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 14px; }
.keys-table > div { display: grid; grid-template-columns: 122px minmax(0, 1fr); align-items: center; gap: 8px; padding: 3px 8px; background: #fff; border: 1.5px solid rgba(43,37,33,0.3); border-radius: 10px 4px 12px 5px; font-size: 13.5px; }
.keys-table kbd { font-family: var(--hand); font-size: 12.5px; font-weight: 700; text-align: center; padding: 1px 6px; background: var(--gold); border: 1.5px solid var(--ink); border-radius: 5px 3px 6px 4px; }

/* 设置页 */
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 12px; margin-bottom: 6px; background: #fff; border: 2px solid rgba(43,37,33,0.35); border-radius: 12px 5px 14px 6px; max-width: 560px; }
.setrow > div { display: flex; flex-direction: column; line-height: 1.3; }
.setrow b { font-size: 16px; }
.setrow span { font-size: 12.5px; color: var(--pencil); }
.switch {
  display: flex; align-items: center; gap: 8px; padding: 3px 12px 3px 4px; font-family: var(--hand); font-size: 13.5px; font-weight: 700; color: var(--ink);
  background: #f4eedd; border: 2px solid var(--ink); border-radius: 16px; cursor: pointer; flex: none;
}
.switch i { width: 22px; height: 22px; border-radius: 50%; background: #b5ae9f; border: 1.5px solid var(--ink); }
.switch.on { background: #e6f4e6; }
.switch.on i { background: #2f8f57; }
.switch em { font-style: normal; min-width: 16px; }
.big-btn.danger { background: #fff; color: #b1342c; border-color: #b1342c; font-size: 18px; padding: 6px 20px; }
.big-btn.danger.armed { background: var(--red); color: #fff; }

/* 结算页 */
.result { max-width: 760px; margin: 0 auto; text-align: center; padding-top: 36px; }
.result h2.res-title { font-size: clamp(50px, 6.5vw, 78px); line-height: 1.1; margin-bottom: 4px; }
.result h2.res-title.win { color: var(--blue); text-shadow: 3px 3px 0 #fff, 6px 6px 0 var(--gold); transform: rotate(-2deg); }
.result h2.res-title.lose { color: var(--red); text-shadow: 3px 3px 0 #fff; transform: rotate(-1deg); }
.res-sub { margin: 6px 0 16px; font-size: 16px; color: var(--pencil); }
.res-stats { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.res-stats > div { display: flex; flex-direction: column; min-width: 108px; padding: 8px 10px; background: #fff; border: 2px solid var(--ink); border-radius: 12px 5px 14px 6px; }
.res-stats b { font-size: 28px; line-height: 1.1; }
.res-stats span { font-size: 12px; color: var(--pencil); }
.res-rewards { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.res-rewards > div { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 8px; background: #fff; border: 2px solid var(--ink); border-radius: 12px 5px 14px 6px / 6px 14px 5px 12px; }
.res-rewards svg g { stroke-width: 1.6; }
.res-rewards img { height: 46px; }
.res-rewards span { display: flex; flex-direction: column; line-height: 1.25; text-align: left; }
.res-rewards b { font-size: 16px; }
.res-rewards em { font-style: normal; font-size: 12.5px; color: var(--pencil); }
.res-rewards .up b { color: #2f8f57; }
.res-rewards .down b { color: var(--red); }
.res-tip { font-size: 14px; color: #2557b9; margin-bottom: 10px; }
.res-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* 课间小游戏 */
.mg-card { width: min(94vw, 640px); }
.mg-card h2 { margin-bottom: 2px; }
.mg-card .keys { margin: 0 0 10px; font-size: 14px; }
#mgStage {
  position: relative; width: 100%; aspect-ratio: 560 / 340; overflow: hidden;
  border: 3px solid var(--ink); border-radius: 10px; background: #fbf8ec; cursor: crosshair;
}
.mg-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#mgResult {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; background: rgba(251,248,236,0.93); text-align: center; padding: 16px;
}
#mgResult b { font-size: 44px; color: #2557b9; }
#mgResult b.win { color: #b8860b; text-shadow: 2px 2px 0 #fff, 4px 4px 0 rgba(246,196,69,0.6); }
#mgResult p { font-size: 16px; line-height: 1.6; }

.overlay.lite { background: rgba(24,15,8,0.45); }
.paused-card {
  font-size: 56px; font-weight: 700; background: var(--paper); color: var(--ink); padding: 18px 54px; transform: rotate(-1.5deg);
  border: 3px solid var(--ink); border-radius: 18px 8px 22px 10px / 10px 22px 8px 18px;
  box-shadow: 6px 8px 0 rgba(0,0,0,0.35); animation: cardIn 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.paused-card small { display: block; font-size: 15px; font-weight: 400; color: var(--pencil); margin-top: 4px; }

#loading {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: #14302a; color: #f5f0e1; font-size: 20px; text-align: center; line-height: 1.7;
}

/* 窗口窄的时候不再单独改排版：界面整体等比缩小（见文件末尾的 --ui） */

/* ---------- 联机页 ---------- */
.room-page { max-width: 760px; margin: 0 auto; display: grid; gap: 16px; }
.room-code { font-family: var(--hand); font-size: 54px; line-height: 1.15; letter-spacing: 0.3em; text-indent: 0.3em; text-align: center; color: var(--ink); user-select: all; padding: 8px 0 4px; }
.room-status { text-align: center; font-size: 16px; }
.room-lineup { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; font-size: 15px; }
.room-lineup img { height: 42px; }
.room-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; margin-top: 14px; }
.room-actions [disabled] { opacity: 0.45; cursor: not-allowed; }
.room-join { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; }
.room-join input { width: 120px; padding: 8px 10px; font-family: var(--hand); font-size: 22px; letter-spacing: 0.25em; text-transform: uppercase; text-align: center; border: 2px solid var(--ink); border-radius: 10px; background: #fff; color: var(--ink); outline: none; }
.room-join input:focus { box-shadow: 0 0 0 3px rgba(63, 125, 242, 0.3); }
.room-error { color: var(--red); text-align: center; font-weight: 700; }
.sbtn.nomp { opacity: 0.45; }

/* ---------- 克制关系 ---------- */
#counterTip {
  position: fixed; z-index: 6; display: grid; gap: 4px; padding: 8px 12px 7px; pointer-events: none; max-width: 340px;
  transform: rotate(-0.6deg); font-family: var(--hand);
}
#counterTip.hidden { display: none; }
#counterTip b { font-size: 16px; }
#counterTip small { font-size: 11px; color: var(--pencil); }
.cr { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 5px; font-size: 12.5px; line-height: 1.2; }
.cr em { font-style: normal; font-weight: 700; padding: 1px 6px; border-radius: 8px; color: #fff; white-space: nowrap; }
.cr.good em { background: #2fa24f; }
.cr.bad em { background: #dd4a3f; }
.cr i { font-style: normal; display: inline-flex; align-items: center; gap: 1px; white-space: nowrap; }
.cr i img { height: 22px; width: auto; position: static; transform: none; }
.cr i.none { color: var(--pencil); }
.crs { display: grid; gap: 2px; margin: 2px 0 3px; }
.unit-card .crs { justify-items: center; }
.unit-card .cr { justify-content: center; }
#selpanel .crs .cr { font-size: 11.5px; }
#selpanel .crs .cr i img { height: 18px; }
.matrix-wrap { margin: 4px 0 12px; padding: 8px 12px 10px; background: #fff6c9; border: 2px dashed var(--ink); border-radius: 10px; display: grid; gap: 6px; }
.matrix-wrap > b { font-size: 16px; }
.matrix-wrap > span { font-size: 12.5px; color: var(--pencil); }
.matrix-wrap i { font-style: normal; font-weight: 700; }
.matrix-wrap i.g { color: #238a3f; }
.matrix-wrap i.r { color: #cf3a30; }
.matrix { border-collapse: separate; border-spacing: 3px; margin: 0 auto; }
.matrix th { font-weight: 400; text-align: center; padding: 0 2px; }
.matrix th img { display: block; height: 30px; margin: 0 auto; }
.matrix th em { font-style: normal; font-size: 11px; }
.matrix td { width: 46px; height: 30px; text-align: center; font-size: 14px; font-weight: 700; border-radius: 6px; background: #fffdf2; border: 1.5px solid rgba(43,37,33,0.25); color: var(--pencil); }
.matrix td.g { background: #c9efcf; border-color: #2fa24f; color: #1c7a36; }
.matrix td.r { background: #ffd2cc; border-color: #dd4a3f; color: #b12c23; }
.matrix td.self { background: repeating-linear-gradient(45deg, #eee7d4, #eee7d4 4px, #fffdf2 4px, #fffdf2 8px); }
.unit-card .cr, #selpanel .cr { color: var(--ink); font-size: 11.5px; font-weight: 400; }
.unit-card .cr i img { height: 20px; }

/* ---------- 出战卡组 ---------- */
.deck-cards { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.deck-card {
  display: grid; justify-items: center; gap: 0; padding: 3px 2px 4px; cursor: pointer; color: var(--ink); font-family: var(--hand);
  background: var(--paper-2); border: 2px solid var(--ink); border-radius: 8px 12px 9px 13px / 12px 8px 13px 9px;
  opacity: 0.5; filter: grayscale(0.8); transition: transform 0.12s, opacity 0.12s, filter 0.12s;
}
.deck-card img { height: 46px; max-width: 100%; object-fit: contain; }
.deck-card b { font-size: 13px; white-space: nowrap; }
.deck-card i { font-style: normal; font-size: 11px; color: var(--pencil); }
.deck-card:hover { transform: translateY(-2px); opacity: 0.85; }
.deck-card.on { opacity: 1; filter: none; background: #fff6c9; box-shadow: 0 0 0 2.5px var(--gold); }
.deck-note { margin-top: 5px; font-size: 12.5px; color: var(--pencil); min-height: 17px; }
.deck-note b.warn { color: #cf3a30; font-weight: 700; }
.big-btn.dim { filter: grayscale(0.7); opacity: 0.6; }
#topbar .tr { display: grid; justify-items: end; gap: 6px; }
#foeDeck { display: flex; align-items: center; gap: 3px; padding: 3px 8px; transform: rotate(-0.8deg); font-size: 12px; }
#foeDeck.hidden { display: none; }
#foeDeck em { font-style: normal; margin-right: 3px; color: #b1342c; font-weight: 700; }
#foeDeck i { display: inline-flex; padding: 1px 2px; border-radius: 6px; border: 2px solid transparent; }
#foeDeck i img { height: 30px; }
#foeDeck i.ok { border-color: #2fa24f; background: #e6f7e9; }
#foeDeck i.warn { border-color: #dd4a3f; background: #ffe3df; }
.deck-card img { height: 40px; }
.home .block { margin-top: 8px; }
.home-cta { margin-top: 10px; }
.deck-card.core { cursor: default; box-shadow: 0 0 0 2.5px var(--ink); }
.deck-card.core i { color: var(--ink); font-weight: 700; }

.deck-cards { grid-template-columns: repeat(8, 1fr); gap: 5px; }
.deck-card { position: relative; }
.deck-card img { height: 34px; }
.deck-card b { font-size: 12px; }
.cat { font-style: normal; font-size: 10px; font-weight: 700; line-height: 1; padding: 2px 5px; border-radius: 7px; color: #fff; background: #7a7f8c; white-space: nowrap; }
.deck-card .cat { position: absolute; left: -3px; top: -4px; transform: rotate(-4deg); }
.unit-card .cat { justify-self: start; margin: 0; font-size: 11px; }
.cat.melee { background: #c0563c; } .cat.ranged { background: #2f7fc2; } .cat.air { background: #4aa7b5; } .cat.siege { background: #8a5a30; }
.cat.support { background: #4d9a4f; } .cat.building { background: #77808f; } .cat.spell { background: #8e6fd8; }
.matrix td { width: 34px; height: 26px; font-size: 12px; }
.matrix th img { height: 24px; }
.matrix th em { font-size: 10px; }
.unit-grid { grid-template-columns: repeat(5, 1fr); }
.unit-card img { height: 70px; }

/* 「开始游戏」放在右侧栏最上面：左边的选项再多也不会盖住或挤走它 */
.home-side .home-cta { display: grid; gap: 6px; margin: 0 0 4px; }
.home-side .home-cta .big-btn { width: 100%; }
.home-side .home-cta .foe-note { font-size: 12px; }
/* 主页内容比窗口高时要能往下滚：原来整页固定高度、内容上下居中，超出的部分上下各被裁掉一截、滚不到 */
.home { height: auto; min-height: 100%; align-items: start; }
.home-main, .home-side { justify-content: flex-start; }
.home-side { position: sticky; top: 0; align-self: start; }

/* 对手卡组别压在右上角那列按钮上 */
#topbar .tr { margin-right: 52px; }
/* 屏幕不够高时底部的卡片和技能栏缩小一号，少挡一点战场 */
@media (max-height: 820px) {
  .card { width: 84px; height: 122px; }
  .card img { height: 74px; }
  .cname { top: 76px; font-size: 12.5px; }
  .card.hero { width: 100px; }
  .card.hero img { height: 78px; }
  #bottomLeft { gap: 6px; bottom: 10px; }
  #skillbar { transform: scale(0.86); transform-origin: left bottom; }
  #placingTip { bottom: 196px; }
}

/* ---------- 手机 / 小屏幕 ---------- */
/* 界面整体等比缩小（--ui 由 main.js 按窗口大小算）：排版和桌面上一样，只是小一号 */
:root { --ui: 1; }
/* 用 transform 缩放（各家浏览器行为一致；zoom 在手机 Safari 上和 vw / vh 配合会算错） */
:root { --vw: 100vw; --vh: 100vh; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; } /* 手机横屏时浏览器会自作主张把字放大，把排版撑乱 */
#hud, .overlay {
  inset: auto; left: 0; top: 0; right: auto; bottom: auto;
  width: calc(var(--vw) / var(--ui)); height: calc(var(--vh) / var(--ui));
  transform: scale(var(--ui)); transform-origin: 0 0;
}
.sheet { width: min(1220px, 96%); height: min(760px, 94%); }
.menu-card { max-height: 94%; }
#counterTip { position: absolute; }
.pages, .menu-card, .rail-tabs { touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
html, body { overscroll-behavior: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
/* 刘海 / 圆角屏：两侧让出安全区 */
#hud { padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); box-sizing: border-box; }
/* 选中面板上的「取消选择」 */
.selx { position: absolute; right: -8px; top: -10px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; font-size: 15px; line-height: 1; cursor: pointer; font-family: var(--hand); box-shadow: 2px 3px 0 rgba(43,37,33,0.25); }
#selpanel { position: absolute; }
/* 触屏上按钮按得准一点：系统按钮加大，新手便签缩短 */
body.touch .sbtn { min-width: 54px; min-height: 54px; }
body.touch #hint { max-width: 420px; font-size: 13px; }

/* ---------- 自动指挥 ---------- */
#autoBar { display: inline-flex; align-items: center; gap: 0; pointer-events: auto; }
#autoBar em { font-style: normal; font-size: 13px; color: var(--pencil); margin-right: 6px; }
#autoBar button {
  font-family: var(--hand); font-size: 15px; font-weight: 700; padding: 9px 11px; cursor: pointer; color: var(--ink);
  background: var(--paper-2); border: 2px solid var(--ink); margin-left: -2px;
}
#autoBar button:first-of-type { border-radius: 10px 0 0 10px; margin-left: 0; }
#autoBar button:last-of-type { border-radius: 0 10px 10px 0; }
#autoBar button.on { background: var(--gold); position: relative; z-index: 1; }

/* ---------- 竖屏（手机竖着拿）：地图在屏幕中间，界面排在上下的空白里 ---------- */
body.portrait #topbar { flex-wrap: wrap; gap: 6px 8px; align-items: center; }
body.portrait .tl { flex-direction: row; align-items: center; }
body.portrait #versus { order: 3; width: 100%; justify-content: center; }
body.portrait #topbar .tr { margin-right: 0; grid-auto-flow: column; align-items: center; }
body.portrait #sysbtns { top: 172px; left: 8px; right: 8px; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
body.portrait #hint { top: 236px; left: 8px; max-width: 360px; font-size: 13px; }
body.portrait #centerTop { top: 236px; }
body.portrait #bottomLeft { left: 8px; right: 8px; bottom: 12px; gap: 8px; }
body.portrait #skillbar { flex-wrap: wrap; row-gap: 6px; transform: none; max-width: 100%; }
body.portrait #skillbar .vsep { display: none; }
body.portrait #cards { gap: 5px; }
body.portrait .card { width: 80px; height: 118px; }
body.portrait .card img { height: 70px; }
body.portrait .cname { top: 73px; font-size: 12.5px; }
body.portrait .card.hero { width: 92px; }
body.portrait .card.hero img { height: 74px; }
body.portrait #placingTip { bottom: 300px; left: 8px; right: 8px; max-width: none; transform: none; text-align: center; }
body.portrait #selpanel { left: auto; right: 8px; top: 236px; bottom: auto; max-width: 290px; }
body.portrait #selpanel .crs { display: none; }
body.portrait #autoBar button { padding: 10px 12px; font-size: 16px; }
/* 作业本：标签栏横到顶上，内容单列 */
body.portrait .sheet { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); width: 97%; height: 97%; }
body.portrait .rail { flex-direction: row; align-items: center; gap: 6px; padding: 6px 8px; border-right: 0; border-bottom: 2px dashed rgba(43,37,33,0.28); overflow-x: auto; }
body.portrait .rail-logo, body.portrait .rail-foot .ver { display: none; }
body.portrait .rail-tabs { flex-direction: row; }
body.portrait .rail-tabs .tab { white-space: nowrap; }
body.portrait .rail-foot { margin: 0 0 0 auto; padding: 0; flex-direction: row; }
body.portrait .pages { padding: 12px 14px 16px; }
body.portrait .home { grid-template-columns: minmax(0, 1fr); gap: 10px; }
body.portrait .home-side { position: static; order: -1; flex-direction: row; flex-wrap: wrap; gap: 8px; }
body.portrait .home-side .home-cta { flex: 1 1 100%; }
body.portrait .home-side .panel { flex: 1 1 240px; }
body.portrait .home-side .quick { display: none; }
body.portrait .title { font-size: 44px; }
body.portrait .deck-cards { grid-template-columns: repeat(5, 1fr); }
body.portrait .roster, body.portrait .unit-grid, body.portrait .hero-grid { grid-template-columns: repeat(2, 1fr); }
body.portrait .hero-detail, body.portrait .rank, body.portrait .how-grid, body.portrait .keys-table { grid-template-columns: minmax(0, 1fr); }
body.portrait .matrix-wrap { overflow-x: auto; }

/* 竖屏顶部精简：只留暂停、潜行、全选，其余收进「⋯」；军衔和部队数先不显示 */
.sbtn.more { display: none; font-size: 22px; font-weight: 700; }
body.portrait .sbtn.more { display: grid; place-items: center; }
body.portrait #sysbtns .minor { display: none; }
body.portrait #sysbtns.open .minor { display: grid; place-items: center; }
body.portrait #sysbtns.open .more { background: var(--gold); }
body.portrait #rankbox, body.portrait #army { display: none; }
body.portrait #sysbtns { top: 118px; }
body.portrait #hint, body.portrait #centerTop, body.portrait #selpanel { top: 182px; }

/* 最后一分钟：墨水翻倍 */
#timer.rush { background: var(--gold); animation: rushPulse 1s ease-in-out infinite; }
#inkbox.rush #income { color: #b8860b; font-weight: 700; }
#inkbox.rush { box-shadow: 0 0 0 3px var(--gold), 3px 5px 0 rgba(43,37,33,0.28); }
@keyframes rushPulse { 50% { transform: scale(1.08) rotate(-1deg); } }

.deck-note b.style { display: inline-block; padding: 0 7px; border-radius: 8px; color: #fff; background: #7a7f8c; margin-right: 4px; }
.deck-note b.style.rush { background: #dd6a3f; } .deck-note b.style.late { background: #6a56c4; } .deck-note b.style.turtle { background: #4d7f9a; } .deck-note b.style.mid { background: #5d9a4f; }
.deck-cards { grid-template-columns: repeat(9, 1fr); }
body.portrait .deck-cards { grid-template-columns: repeat(6, 1fr); }
