:root {
  --ink: #181714;
  --ink-soft: #4e4a41;
  --paper: #e9dfc8;
  --paper-light: #f6efdf;
  --paper-deep: #cbb994;
  --bronze: #a66d2e;
  --gold: #d6a54b;
  --jade: #315f54;
  --cinnabar: #9d3325;
  --cinnabar-dark: #632119;
  --night: #111210;
  --night-soft: #1c201d;
  --line: rgba(70, 56, 39, .2);
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --kai: "STKaiti", "KaiTi", "Kaiti SC", var(--serif);
  --sans: "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body {
  margin: 0; overflow: hidden; color: var(--ink);
  background: #090b0a;
  font-family: var(--serif);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; touch-action: manipulation; }
button:focus-visible { outline: 2px solid #efbd5d; outline-offset: 2px; }
.device-shell {
  width: 100%; height: 100dvh; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 12%, rgba(116, 81, 42, .28), transparent 36%), linear-gradient(145deg, #080a09, #191611 58%, #080908);
}
.game-app {
  position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(100vw, 480px); height: 100dvh; max-height: 920px; overflow: hidden;
  background: radial-gradient(circle at 25% 15%, rgba(185, 139, 69, .12), transparent 28%), linear-gradient(180deg, #eee3ca 0%, #d9c8a6 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 28px 80px rgba(0,0,0,.72); isolation: isolate;
}
.game-app::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 100; opacity: .16; mix-blend-mode: multiply;
  background-image: repeating-radial-gradient(circle at 20% 30%, rgba(50,36,23,.25) 0 .5px, transparent .6px 5px), repeating-linear-gradient(96deg, transparent 0 8px, rgba(255,255,255,.16) 9px 10px);
}
.battle-hud {
  position: relative; z-index: 20; display: grid; grid-template-columns: 38px minmax(0, 1fr) 78px 57px 34px;
  align-items: center; gap: 6px; min-height: 56px; padding: max(7px, env(safe-area-inset-top)) 8px 7px; color: #f2e3c6;
  background: linear-gradient(90deg, rgba(157,51,37,.96), rgba(55,36,28,.98) 42%, rgba(19,22,20,.99));
  border-bottom: 1px solid rgba(229,178,92,.38); box-shadow: 0 8px 22px rgba(22,15,10,.32);
}
.hud-icon {
  width: 34px; height: 34px; border: 1px solid rgba(231,199,142,.42); border-radius: 9px 7px 10px 6px;
  color: #f4deb1; background: rgba(255,255,255,.06); font-family: var(--kai); font-weight: 900; cursor: pointer;
}
.hud-icon.sound { font-size: 13px; }
.hud-title { min-width: 0; }
.hud-title strong { display: block; overflow: hidden; color: #f5ddb0; font-size: 15px; letter-spacing: .08em; text-overflow: ellipsis; white-space: nowrap; }
.hud-title span { display: block; margin-top: 1px; overflow: hidden; color: rgba(245,230,202,.65); font: 9px var(--sans); text-overflow: ellipsis; white-space: nowrap; }
.hud-health { display: grid; grid-template-columns: 13px 1fr; grid-template-rows: auto auto; gap: 1px 5px; align-items: center; }
.hud-health > span { grid-row: 1 / 3; display: grid; place-items: center; width: 13px; height: 28px; color: #f1c271; font-size: 10px; border: 1px solid rgba(223,180,101,.4); border-radius: 3px; }
.hud-health i { width: 100%; height: 5px; overflow: hidden; background: rgba(0,0,0,.4); border-radius: 9px; }
.hud-health i b { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #ba3f2d, #e18c55); transition: width 180ms ease; }
.hud-health strong { font: 800 10px var(--sans); }
.hud-coins { display: flex; align-items: center; justify-content: center; gap: 4px; font: 800 12px var(--sans); }
.hud-coins span { display: grid; place-items: center; width: 20px; height: 20px; color: #533617; background: #d7a64a; border-radius: 50%; font-family: var(--kai); }
.field-area { position: relative; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) 49px; overflow: hidden; background: #cfc0a0; }
.board-wrap {
  position: relative; min-height: 0; overflow: hidden; touch-action: none;
  background: linear-gradient(rgba(239,229,207,.78), rgba(207,191,158,.75)), repeating-linear-gradient(0deg, transparent 0 33px, rgba(70,55,37,.06) 34px), repeating-linear-gradient(90deg, transparent 0 33px, rgba(70,55,37,.06) 34px);
  border-bottom: 1px solid rgba(66,51,34,.24); box-shadow: inset 0 0 52px rgba(56,42,27,.18);
}
.board { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(10, 1fr); }
.tile {
  position: relative; min-width: 0; min-height: 0; padding: 0; border: 1px solid rgba(73,58,40,.09);
  color: rgba(62,48,32,.23); background: rgba(255,255,255,.025); cursor: default;
}
.tile.buildable::after { content: "＋"; font: 13px var(--sans); opacity: .45; }
.tile.path {
  color: rgba(115,42,28,.55);
  background: linear-gradient(145deg, rgba(160,63,42,.20), rgba(115,50,31,.29)), repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 5px, transparent 5px 10px);
  border-color: rgba(112,50,31,.13);
}
.tile.path::after { content: "·"; font-size: 20px; }
.tile.path.start::after { content: "敌"; font-size: 12px; font-weight: 900; }
.tile.path.end::after { content: "城"; color: rgba(133,39,27,.82); font-size: 18px; font-weight: 900; }
.tile.path.path-n::before, .tile.path.path-e::before, .tile.path.path-s::before, .tile.path.path-w::before { content: ""; position: absolute; z-index: 0; background: rgba(137,52,35,.13); }
.tile.path.path-n::before { left: 23%; bottom: 0; width: 54%; height: 100%; }
.tile.path.path-s::before { left: 23%; top: 0; width: 54%; height: 100%; }
.tile.path.path-e::before { left: 0; top: 23%; width: 100%; height: 54%; }
.tile.path.path-w::before { right: 0; top: 23%; width: 100%; height: 54%; }
.game-app.can-build .tile.buildable:active, .game-app.can-build .tile.buildable:hover { background: rgba(49,95,84,.18); box-shadow: inset 0 0 0 2px rgba(49,95,84,.48); }
.tile.range { background: rgba(49,95,84,.11); box-shadow: inset 0 0 0 1px rgba(49,95,84,.18); }
.tile.origin { background: rgba(214,165,75,.23) !important; box-shadow: inset 0 0 0 2px rgba(151,97,33,.48) !important; }
.tile.invalid { background: rgba(157,51,37,.12) !important; }
.field-actions {
  position: relative; z-index: 22; display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center; gap: 7px; padding: 6px 8px; color: var(--paper-light);
  background: linear-gradient(90deg, #20241f, #151815); border-top: 1px solid rgba(209,158,75,.26);
}
.selected-summary { min-width: 0; display: flex; align-items: center; gap: 7px; }
.summary-mark { display: grid; place-items: center; flex: 0 0 auto; width: 27px; height: 27px; color: #f4dfb3; background: var(--cinnabar); border-radius: 6px; font-weight: 900; }
.selected-summary p { margin: 0; overflow: hidden; color: rgba(244,231,206,.78); font: 10px/1.25 var(--sans); text-overflow: ellipsis; white-space: nowrap; }
.reroll-button, .start-war { min-height: 35px; padding: 0 10px; border-radius: 7px; cursor: pointer; font-weight: 900; font-size: 12px; }
.reroll-button { color: #ead7b1; background: rgba(255,255,255,.07); border: 1px solid rgba(226,186,111,.28); }
.reroll-button span { color: #e7b95e; }
.start-war { color: #fff0c9; background: linear-gradient(145deg, #ad3d2b, #6e241b); border: 1px solid #c15a3e; box-shadow: 0 5px 13px rgba(99,32,22,.42); }
.start-war:disabled, .reroll-button:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }

.projectile-layer, .effects-layer, .floating-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.projectile-layer { z-index: 12; }
.effects-layer { z-index: 14; }
.floating-layer { z-index: 22; }
.defender-token, .enemy-token { position: absolute; transform: translate(-50%, -50%); user-select: none; }
.defender-token { z-index: 10; width: 10.8%; min-width: 28px; max-width: 57px; aspect-ratio: 1; padding: 0; border: 0; background: transparent; cursor: pointer; overflow: visible; }
.soldier-word {
  position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--kai); font-size: clamp(23px, 7vw, 36px); font-weight: 900; line-height: 1;
  color: #285e52; paint-order: stroke fill; -webkit-text-stroke: 1px rgba(22,62,54,.42);
  text-shadow: 0 2px 0 rgba(255,255,255,.72), 0 5px 10px rgba(52,35,21,.25); transform: rotate(-5deg); animation: soldier-idle 2.5s ease-in-out infinite;
}
.defender-token[data-role="archer"] .soldier-word { color: #516a34; -webkit-text-stroke-color: rgba(61,80,38,.42); left: -4%; top: 5%; transform: translate(var(--bow-word-x, 0px), var(--bow-word-y, 0px)) rotate(var(--bow-word-rotate, 5deg)) skewX(var(--bow-word-skew, 0deg)) scaleX(var(--bow-word-scale-x, 1)) scaleY(var(--bow-word-scale-y, 1)); transform-origin: 72% 72%; animation-duration: 2.9s; }
.defender-token[data-role="spear"] .soldier-word { color: #7d5525; -webkit-text-stroke-color: rgba(83,52,18,.45); transform: rotate(-8deg); animation-duration: 2.25s; }
.defender-token[data-role="cavalry"] .soldier-word { color: #8b3c2d; -webkit-text-stroke-color: rgba(91,35,25,.46); transform: rotate(7deg); animation-duration: 1.85s; }
.defender-token.hero .soldier-word { font-size: clamp(18px, 5.2vw, 29px); letter-spacing: -.12em; color: #fff1c6; -webkit-text-stroke: 2px #74291e; text-shadow: 0 2px 0 #d3983f, 0 5px 12px rgba(82,28,17,.42); }
.defender-token.hero::before { content: ""; position: absolute; inset: 9%; z-index: -1; border: 1px solid rgba(225,174,76,.72); border-radius: 46% 54% 50% 44%; background: radial-gradient(circle, rgba(157,51,37,.92), rgba(101,29,21,.7) 66%, transparent 70%); box-shadow: 0 0 12px rgba(191,124,40,.45); transform: rotate(12deg); }
.defender-token.hero::after { content: "将"; position: absolute; right: -1px; top: -5px; display: grid; place-items: center; width: 17px; height: 17px; color: #6d2118; background: #efcb7b; border: 1px solid #8c5924; border-radius: 50%; font: 900 9px var(--kai); box-shadow: 0 2px 5px rgba(56,29,15,.28); }
.unit-level { position: absolute; right: -1px; bottom: -1px; z-index: 2; min-width: 16px; height: 15px; padding: 0 3px; display: grid; place-items: center; color: #612217; background: #f0d9a1; border: 1px solid rgba(93,52,24,.45); border-radius: 8px; font: 800 8px var(--sans); }
.defender-token.attacking.infantry { animation: infantry-throw .52s cubic-bezier(.2,.8,.25,1); }
.defender-token.attacking.archer { animation: archer-draw .8s cubic-bezier(.2,.8,.25,1); }
.defender-token.attacking.spear { animation: spear-thrust .42s ease-out; }
.defender-token.attacking.cavalry { animation: cavalry-charge .5s ease-out; }
.defender-token.disabled { filter: grayscale(.8); opacity: .48; }
.defender-token.disabled::after { content: "断"; position: absolute; inset: 12%; display: grid; place-items: center; color: #7c2d21; font: 900 20px var(--kai); }
@keyframes soldier-idle { 50% { transform: translateY(-2px) rotate(calc(-5deg + 2deg)) scale(1.03); } }
@keyframes melee-strike { 45% { transform: translate(-50%, -50%) translate(5%, -4%) scale(1.16); filter: brightness(1.4); } }
@keyframes archer-release { 45% { transform: translate(-50%, -50%) translate(-4%, -2%) scale(.9) rotate(-5deg); } }
@keyframes spear-thrust { 45% { transform: translate(-50%, -50%) translate(8%, -2%) scale(1.12); } }
@keyframes cavalry-charge { 42% { transform: translate(-50%, -50%) translate(12%, -5%) scale(1.18); } 72% { transform: translate(-50%, -50%) translate(-2%, 0) scale(.96); } }
@keyframes infantry-throw {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
  28% { transform: translate(-50%, -50%) translate(-4%, -3%) rotate(-8deg) scale(.96); }
  58% { transform: translate(-50%, -50%) translate(10%, -5%) rotate(5deg) scale(1.14); }
}
@keyframes archer-draw {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
  30% { transform: translate(-50%, -50%) translate(-3%, 2%) rotate(-4deg) scale(.97, 1.03); }
  48%, 62% { transform: translate(-50%, -50%) translate(-5%, 4%) rotate(-8deg) scale(.94, 1.07); }
  72% { transform: translate(-50%, -50%) translate(4%, -2%) rotate(4deg) scale(1.08, .94); }
  86% { transform: translate(-50%, -50%) translate(0, 0) rotate(0deg) scale(1.02, .98); }
}
.enemy-token { z-index: 16; width: 9.3%; min-width: 25px; max-width: 50px; aspect-ratio: 1; }
.enemy-body { position: absolute; inset: 15% 8% 0; display: grid; place-items: center; color: #f1dcc4; background: radial-gradient(circle at 38% 25%, #81503f, #4b2c25 70%, #2e1b18); border: 1px solid rgba(49,25,20,.9); border-radius: 48% 45% 43% 50%; box-shadow: 0 5px 9px rgba(43,31,20,.24); font: 900 clamp(16px, 5.4vw, 28px)/1 var(--kai); }
.enemy-token.infantry .enemy-body { animation: enemy-march .72s ease-in-out infinite alternate; }
.enemy-token.cavalry .enemy-body { border-radius: 52% 28% 48% 34%; background: radial-gradient(circle at 38% 25%, #8e5b40, #553126 70%, #2f1b16); animation: enemy-gallop .34s ease-in-out infinite alternate; }
.enemy-token.cavalry::after { content: ""; position: absolute; left: -36%; bottom: 5%; width: 46%; height: 20%; background: radial-gradient(ellipse, rgba(104,71,47,.35), transparent 70%); animation: dust .45s ease-out infinite; }
.enemy-token.spear .enemy-body { border-radius: 22% 48% 28% 48%; background: radial-gradient(circle at 38% 25%, #71807a, #414d49 70%, #28302d); animation: spear-sway .92s ease-in-out infinite alternate; }
.enemy-token.shield .enemy-body { border-radius: 20% 20% 42% 42%; background: radial-gradient(circle at 38% 25%, #857a6c, #4b443c 70%, #2b2723); box-shadow: 0 0 0 2px #857b6d, 0 5px 10px rgba(43,31,20,.25); animation: shield-stomp .95s ease-in-out infinite; }
.enemy-token.crossbow .enemy-body { background: radial-gradient(circle at 38% 25%, #696f89, #3d405a 70%, #242638); animation: crossbow-march .7s ease-in-out infinite alternate; }
.enemy-token.general { width: 13%; min-width: 37px; }
.enemy-token.general .enemy-body { color: #30130f; background: radial-gradient(circle at 38% 25%, #dc5b3e, #8f2a20 68%, #581813); box-shadow: 0 0 0 3px rgba(152,52,34,.24), 0 0 18px rgba(211,75,48,.55); animation: general-pulse 1.2s ease-in-out infinite; }
.enemy-token.hurt .enemy-body { animation: enemy-hit .18s ease; filter: brightness(1.7); }
.enemy-token.slowed .enemy-body { box-shadow: 0 0 0 3px rgba(94,170,188,.55), 0 5px 10px rgba(43,31,20,.25); }
.enemy-token.firing .enemy-body { animation: enemy-fire .32s ease-out; }
.enemy-hp { position: absolute; top: 1px; left: 5%; right: 5%; height: 4px; overflow: hidden; border-radius: 5px; background: rgba(33,22,17,.7); z-index: 3; }
.enemy-hp i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #be3e2c, #e38455); }
.enemy-mark { position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); display: none; color: #69c0d2; font: 900 12px var(--sans); }
.enemy-token.slowed .enemy-mark { display: block; }
@keyframes enemy-march { to { transform: translateY(-2px) rotate(2deg); } }
@keyframes enemy-gallop { from { transform: translateY(-2px) rotate(-5deg) scale(1.04); } to { transform: translateY(2px) rotate(5deg) scale(.98); } }
@keyframes dust { to { opacity: 0; transform: translateX(-40%) scale(1.5); } }
@keyframes spear-sway { to { transform: rotate(-5deg); } }
@keyframes shield-stomp { 50% { transform: translateY(2px) scale(1.04); } }
@keyframes crossbow-march { to { transform: translateY(-2px) rotate(-3deg); } }
@keyframes general-pulse { 50% { filter: brightness(1.18); transform: scale(1.06); } }
@keyframes enemy-fire { 45% { transform: translate(-7%, -8%) scale(.9); filter: brightness(1.7); } }
@keyframes enemy-hit { 50% { transform: translate(8%, -4%); } }

.projectile-layer, .effects-layer, .floating-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.projectile-layer { z-index: 12; }
.effects-layer { z-index: 14; }
.floating-layer { z-index: 22; }
.defender-token, .enemy-token { position: absolute; transform: translate(-50%, -50%); user-select: none; }
.defender-token { z-index: 10; width: 10.8%; min-width: 28px; max-width: 57px; aspect-ratio: 1; padding: 0; border: 0; background: transparent; cursor: pointer; overflow: visible; }
.soldier-word { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--kai); font-size: clamp(23px, 7vw, 36px); font-weight: 900; line-height: 1; color: #285e52; paint-order: stroke fill; -webkit-text-stroke: 1px rgba(22,62,54,.42); text-shadow: 0 2px 0 rgba(255,255,255,.72), 0 5px 10px rgba(52,35,21,.25); transform: rotate(-5deg); animation: soldier-idle 2.5s ease-in-out infinite; }
.defender-token[data-role="archer"] .soldier-word { color: #516a34; -webkit-text-stroke-color: rgba(61,80,38,.42); left: -4%; top: 5%; transform: translate(var(--bow-word-x, 0px), var(--bow-word-y, 0px)) rotate(var(--bow-word-rotate, 5deg)) skewX(var(--bow-word-skew, 0deg)) scaleX(var(--bow-word-scale-x, 1)) scaleY(var(--bow-word-scale-y, 1)); transform-origin: 72% 72%; animation-duration: 2.9s; }
.defender-token[data-role="spear"] .soldier-word { color: #7d5525; -webkit-text-stroke-color: rgba(83,52,18,.45); transform: rotate(-8deg); animation-duration: 2.25s; }
.defender-token[data-role="cavalry"] .soldier-word { color: #8b3c2d; -webkit-text-stroke-color: rgba(91,35,25,.46); transform: rotate(7deg); animation-duration: 1.85s; }
.defender-token.hero .soldier-word { font-size: clamp(18px, 5.2vw, 29px); letter-spacing: -.12em; color: #fff1c6; -webkit-text-stroke: 2px #74291e; text-shadow: 0 2px 0 #d3983f, 0 5px 12px rgba(82,28,17,.42); }
.defender-token.hero::before { content: ""; position: absolute; inset: 9%; z-index: -1; border: 1px solid rgba(225,174,76,.72); border-radius: 46% 54% 50% 44%; background: radial-gradient(circle, rgba(157,51,37,.92), rgba(101,29,21,.7) 66%, transparent 70%); box-shadow: 0 0 12px rgba(191,124,40,.45); transform: rotate(12deg); }
.defender-token.hero::after { content: "将"; position: absolute; right: -1px; top: -5px; display: grid; place-items: center; width: 17px; height: 17px; color: #6d2118; background: #efcb7b; border: 1px solid #8c5924; border-radius: 50%; font: 900 9px var(--kai); box-shadow: 0 2px 5px rgba(56,29,15,.28); }
.unit-level { position: absolute; right: -1px; bottom: -1px; z-index: 2; min-width: 16px; height: 15px; padding: 0 3px; display: grid; place-items: center; color: #612217; background: #f0d9a1; border: 1px solid rgba(93,52,24,.45); border-radius: 8px; font: 800 8px var(--sans); }
.defender-token.attacking.infantry { animation: infantry-throw .52s cubic-bezier(.2,.8,.25,1); }
.defender-token.attacking.archer { animation: archer-draw .8s cubic-bezier(.2,.8,.25,1); }
.defender-token.attacking.spear { animation: spear-thrust .42s ease-out; }
.defender-token.attacking.cavalry { animation: cavalry-charge .5s ease-out; }
.defender-token.disabled { filter: grayscale(.8); opacity: .48; }
.defender-token.disabled::after { content: "断"; position: absolute; inset: 12%; display: grid; place-items: center; color: #7c2d21; font: 900 20px var(--kai); }
@keyframes soldier-idle { 50% { transform: translateY(-2px) rotate(calc(-5deg + 2deg)) scale(1.03); } }
@keyframes melee-strike { 45% { transform: translate(-50%, -50%) translate(5%, -4%) scale(1.16); filter: brightness(1.4); } }
@keyframes archer-release { 45% { transform: translate(-50%, -50%) translate(-4%, -2%) scale(.9) rotate(-5deg); } }
@keyframes spear-thrust { 45% { transform: translate(-50%, -50%) translate(8%, -2%) scale(1.12); } }
@keyframes cavalry-charge { 42% { transform: translate(-50%, -50%) translate(12%, -5%) scale(1.18); } 72% { transform: translate(-50%, -50%) translate(-2%, 0) scale(.96); } }
@keyframes infantry-throw {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
  28% { transform: translate(-50%, -50%) translate(-4%, -3%) rotate(-8deg) scale(.96); }
  58% { transform: translate(-50%, -50%) translate(10%, -5%) rotate(5deg) scale(1.14); }
}
@keyframes archer-draw {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
  30% { transform: translate(-50%, -50%) translate(-3%, 2%) rotate(-4deg) scale(.97, 1.03); }
  48%, 62% { transform: translate(-50%, -50%) translate(-5%, 4%) rotate(-8deg) scale(.94, 1.07); }
  72% { transform: translate(-50%, -50%) translate(4%, -2%) rotate(4deg) scale(1.08, .94); }
  86% { transform: translate(-50%, -50%) translate(0, 0) rotate(0deg) scale(1.02, .98); }
}
.enemy-token { z-index: 16; width: 9.3%; min-width: 25px; max-width: 50px; aspect-ratio: 1; }
.enemy-body { position: absolute; inset: 15% 8% 0; display: grid; place-items: center; color: #f1dcc4; background: radial-gradient(circle at 38% 25%, #81503f, #4b2c25 70%, #2e1b18); border: 1px solid rgba(49,25,20,.9); border-radius: 48% 45% 43% 50%; box-shadow: 0 5px 9px rgba(43,31,20,.24); font: 900 clamp(16px, 5.4vw, 28px)/1 var(--kai); }
.enemy-token.infantry .enemy-body { animation: enemy-march .72s ease-in-out infinite alternate; }
.enemy-token.cavalry .enemy-body { border-radius: 52% 28% 48% 34%; background: radial-gradient(circle at 38% 25%, #8e5b40, #553126 70%, #2f1b16); animation: enemy-gallop .34s ease-in-out infinite alternate; }
.enemy-token.cavalry::after { content: ""; position: absolute; left: -36%; bottom: 5%; width: 46%; height: 20%; background: radial-gradient(ellipse, rgba(104,71,47,.35), transparent 70%); animation: dust .45s ease-out infinite; }
.enemy-token.spear .enemy-body { border-radius: 22% 48% 28% 48%; background: radial-gradient(circle at 38% 25%, #71807a, #414d49 70%, #28302d); animation: spear-sway .92s ease-in-out infinite alternate; }
.enemy-token.shield .enemy-body { border-radius: 20% 20% 42% 42%; background: radial-gradient(circle at 38% 25%, #857a6c, #4b443c 70%, #2b2723); box-shadow: 0 0 0 2px #857b6d, 0 5px 10px rgba(43,31,20,.25); animation: shield-stomp .95s ease-in-out infinite; }
.enemy-token.crossbow .enemy-body { background: radial-gradient(circle at 38% 25%, #696f89, #3d405a 70%, #242638); animation: crossbow-march .7s ease-in-out infinite alternate; }
.enemy-token.general { width: 13%; min-width: 37px; }
.enemy-token.general .enemy-body { color: #30130f; background: radial-gradient(circle at 38% 25%, #dc5b3e, #8f2a20 68%, #581813); box-shadow: 0 0 0 3px rgba(152,52,34,.24), 0 0 18px rgba(211,75,48,.55); animation: general-pulse 1.2s ease-in-out infinite; }
.enemy-token.hurt .enemy-body { animation: enemy-hit .18s ease; filter: brightness(1.7); }
.enemy-token.slowed .enemy-body { box-shadow: 0 0 0 3px rgba(94,170,188,.55), 0 5px 10px rgba(43,31,20,.25); }
.enemy-token.firing .enemy-body { animation: enemy-fire .32s ease-out; }
.enemy-hp { position: absolute; top: 1px; left: 5%; right: 5%; height: 4px; overflow: hidden; border-radius: 5px; background: rgba(33,22,17,.7); z-index: 3; }
.enemy-hp i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #be3e2c, #e38455); }
.enemy-mark { position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); display: none; color: #69c0d2; font: 900 12px var(--sans); }
.enemy-token.slowed .enemy-mark { display: block; }
@keyframes enemy-march { to { transform: translateY(-2px) rotate(2deg); } }
@keyframes enemy-gallop { from { transform: translateY(-2px) rotate(-5deg) scale(1.04); } to { transform: translateY(2px) rotate(5deg) scale(.98); } }
@keyframes dust { to { opacity: 0; transform: translateX(-40%) scale(1.5); } }
@keyframes spear-sway { to { transform: rotate(-5deg); } }
@keyframes shield-stomp { 50% { transform: translateY(2px) scale(1.04); } }
@keyframes crossbow-march { to { transform: translateY(-2px) rotate(-3deg); } }
@keyframes general-pulse { 50% { filter: brightness(1.18); transform: scale(1.06); } }
@keyframes enemy-fire { 45% { transform: translate(-7%, -8%) scale(.9); filter: brightness(1.7); } }
@keyframes enemy-hit { 50% { transform: translate(8%, -4%); } }

.projectile { position: absolute; width: 5.2%; min-width: 22px; max-width: 38px; aspect-ratio: 3 / 1; transform: translate(-50%, -50%) rotate(var(--angle, 0deg)); transform-origin: center; will-change: left, top; }
.projectile.arrow::before, .projectile.enemy-arrow::before { content: ""; position: absolute; inset: 40% 0 auto; height: 2px; border-radius: 6px; background: linear-gradient(90deg, #805324, #f2cd72 62%, #fff2b6); box-shadow: 0 0 7px rgba(226,166,61,.78); }
.projectile.arrow::after, .projectile.enemy-arrow::after { content: ""; position: absolute; right: 0; top: 20%; width: 9px; height: 7px; background: #fff0a0; clip-path: polygon(0 50%, 100% 0, 75% 50%, 100% 100%); }
.projectile.enemy-arrow::before { background: linear-gradient(90deg, #5b2620, #d76a47 62%, #ffd0a3); box-shadow: 0 0 7px rgba(174,55,39,.72); }
.projectile.enemy-arrow::after { background: #ffb688; }
.projectile.fire { width: 4.4%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 40% 38%, #fff3a6, #f3a63d 38%, #be4f2a 72%, rgba(113,35,21,.08)); box-shadow: 0 0 13px #f2a441, 0 0 24px rgba(220,83,36,.65); animation: fire-pulse .2s ease-in-out infinite alternate; }
.projectile.spear { width: 7.3%; min-width: 32px; aspect-ratio: 4 / 1; }
.projectile.spear::before { content: ""; position: absolute; left: 0; right: 7px; top: 47%; height: 2px; background: #8e5a28; box-shadow: 0 1px rgba(255,244,214,.6); }
.projectile.spear::after { content: ""; position: absolute; right: 0; top: 22%; width: 12px; height: 10px; background: #e2ba68; clip-path: polygon(0 50%, 100% 0, 80% 50%, 100% 100%); }
@keyframes fire-pulse { to { transform: translate(-50%, -50%) scale(1.18); filter: brightness(1.25); } }
.effect-line { fill: none; stroke-linecap: round; }
.effect-line.arrow, .effect-line.enemy-arrow { stroke: #f3c868; stroke-width: 3; filter: drop-shadow(0 0 4px #d59232); }
.effect-line.fire { stroke: #ff9e43; stroke-width: 4; filter: drop-shadow(0 0 7px #e45c2d); }
.effect-line.thunder { stroke: #fff1a4; stroke-width: 3; filter: drop-shadow(0 0 7px #d9a334); }
.effect-line.spear { stroke: #d9aa52; stroke-width: 3; stroke-dasharray: 8 3; filter: drop-shadow(0 0 4px #8b5723); }
.effect-hit { fill: none; stroke: #f7e7bb; stroke-width: 1.8; stroke-linecap: round; filter: drop-shadow(0 0 2px rgba(216,175,94,.5)); }
.effect-hit.fire { stroke: #f3ba76; }
.effect-hit.enemy { stroke: #efb59b; }
.effect-slash { fill: none; stroke: #f3d18a; stroke-width: 4; stroke-linecap: round; filter: drop-shadow(0 0 5px rgba(178,98,31,.8)); }
.effect-ring { fill: none; stroke: #d2a257; stroke-width: 2; }
.effect-ring.slow { stroke: #7ed1dc; stroke-width: 3; }
.effect-ring.buff { stroke: rgba(225,170,72,.72); stroke-dasharray: 4 5; }
.effect-burst { fill: #efbf62; filter: drop-shadow(0 0 7px rgba(183,93,31,.85)); }
.effect-burst.fire { fill: #ef6b38; }
.effect-spark { stroke: #fff0aa; stroke-width: 2; stroke-linecap: round; }
.effect-muzzle { fill: rgba(244,204,115,.15); stroke: #f1c96e; stroke-width: 2; }
.wave-banner, .merge-banner { position: absolute; z-index: 30; left: 50%; top: 12%; transform: translateX(-50%); min-width: 150px; padding: 8px 18px; text-align: center; pointer-events: none; color: #f6e6c7; background: linear-gradient(90deg, transparent, rgba(94,31,24,.94) 18%, rgba(94,31,24,.94) 82%, transparent); border-top: 1px solid rgba(237,190,100,.6); border-bottom: 1px solid rgba(237,190,100,.6); animation: banner-in 1.5s ease forwards; }
.wave-banner small, .merge-banner small { display: block; color: #dcb166; font: 800 8px var(--sans); letter-spacing: .22em; }
.wave-banner strong, .merge-banner strong { display: block; margin-top: 2px; font-size: 19px; letter-spacing: .12em; }
.merge-banner { top: 34%; min-width: 190px; background: linear-gradient(90deg, transparent, rgba(126,49,25,.96) 15%, rgba(88,28,22,.98) 50%, rgba(126,49,25,.96) 85%, transparent); }
.merge-banner strong { color: #ffe6a4; font-family: var(--kai); font-size: 30px; text-shadow: 0 0 13px rgba(235,174,67,.7); }
@keyframes banner-in { 0% { opacity: 0; transform: translate(-50%, -12px) scale(.9); } 16%, 74% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -8px) scale(1.03); } }
.floating-text { position: absolute; transform: translate(-50%, -50%); padding: 2px 5px; border-radius: 6px; color: #8d2d1e; background: rgba(247,237,216,.88); font: 800 10px var(--sans); animation: float-away .72s ease-out forwards; white-space: nowrap; }
.floating-text.gain { color: #2f6958; }
.floating-text.hero { color: #9d531d; background: #fff0bd; }
@keyframes float-away { to { opacity: 0; transform: translate(-50%, -180%); } }
.hand-panel { position: relative; z-index: 24; min-height: 126px; padding: 7px 8px max(8px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, #262a25, #121411); border-top: 1px solid rgba(226,179,92,.34); box-shadow: 0 -10px 24px rgba(20,15,10,.22); }
.hand-heading { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.hand-heading strong { display: block; margin-top: 1px; color: #f0ddbb; font-size: 13px; letter-spacing: .1em; }
.section-kicker { color: #d8a557; font: 800 8px var(--sans); letter-spacing: .18em; text-transform: uppercase; }
.hand-heading p { margin: 0; color: rgba(240,226,199,.55); font: 9px var(--sans); text-align: right; }
.hand-row { display: flex; gap: 7px; overflow-x: auto; padding: 1px 1px 5px; scrollbar-width: none; }
.hand-row::-webkit-scrollbar { display: none; }
.char-card { position: relative; flex: 0 0 68px; min-height: 77px; padding: 5px; overflow: hidden; cursor: pointer; color: #291f16; background: linear-gradient(145deg, #f4e8cd, #d8c39d); border: 1px solid rgba(154,106,48,.48); border-radius: 7px 10px 6px 9px; box-shadow: 0 5px 12px rgba(0,0,0,.28); transition: transform 130ms ease, filter 130ms ease, box-shadow 130ms ease; }
.char-card.selected { transform: translateY(-5px); box-shadow: 0 0 0 2px #e5b758, 0 0 18px rgba(229,183,88,.5); }
.char-card.unaffordable { filter: grayscale(.7); opacity: .46; }
.char-card.card-new { animation: card-draw .5s cubic-bezier(.2,.8,.2,1); }
@keyframes card-draw { from { opacity: 0; transform: translateX(30px) rotateY(70deg) scale(.75); } }
.char-card-word { display: block; font-family: var(--kai); font-size: 39px; font-weight: 900; line-height: 1; text-align: center; color: #275f51; text-shadow: 0 2px 0 rgba(255,255,255,.65); }
.char-card[data-role="archer"] .char-card-word { color: #58712f; }
.char-card[data-role="spear"] .char-card-word { color: #8b5a21; }
.char-card[data-role="cavalry"] .char-card-word { color: #913a2b; }
.char-card-role { position: absolute; left: 5px; top: 5px; display: grid; place-items: center; width: 18px; height: 18px; color: #f7e7c5; background: #28332e; border-radius: 4px; font: 800 9px var(--kai); }
.char-card-cost { position: absolute; right: 5px; bottom: 4px; color: #74401e; font: 800 9px var(--sans); }
.char-card::after { content: ""; position: absolute; inset: auto 5px 19px; height: 1px; background: rgba(91,60,32,.18); }

.unit-sheet {
  position: absolute; z-index: 70; left: 9px; right: 9px; bottom: 132px; padding: 14px;
  color: #f4e6c9; background: linear-gradient(145deg, rgba(40,45,39,.98), rgba(19,22,19,.99));
  border: 1px solid rgba(222,171,82,.38); border-radius: 11px 13px 9px 12px;
  box-shadow: 0 18px 44px rgba(0,0,0,.48);
}
.unit-sheet[hidden], .toast[hidden], .result-overlay[hidden], .help-overlay[hidden], .campaign-overlay[hidden], .wave-banner[hidden], .merge-banner[hidden] { display: none; }
.unit-sheet-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.unit-sheet h2 { margin: 2px 0 9px; color: #f4d99c; font-size: 22px; }
.sheet-close { width: 29px; height: 29px; border: 1px solid rgba(226,184,107,.28); border-radius: 50%; color: #ebdbbd; background: rgba(255,255,255,.05); cursor: pointer; }
.unit-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.unit-stat { padding: 6px; text-align: center; background: rgba(255,255,255,.04); border-radius: 6px; }
.unit-stat small { display: block; color: rgba(240,225,196,.5); font: 8px var(--sans); }
.unit-stat strong { display: block; margin-top: 2px; color: #f3dfb6; font: 800 13px var(--sans); }
.unit-actions, .result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.primary, .secondary { min-height: 40px; border-radius: 7px; cursor: pointer; font-weight: 900; }
.primary { color: #fff0ca; background: linear-gradient(145deg, #ae3d2b, #6d241a); border: 1px solid #c05b3f; }
.secondary { color: #ecd9b5; background: rgba(255,255,255,.06); border: 1px solid rgba(226,184,107,.26); }
.primary:disabled, .secondary:disabled { opacity: .4; cursor: not-allowed; }
.toast { position: absolute; z-index: 90; left: 50%; top: 73px; transform: translateX(-50%); width: max-content; max-width: 88%; padding: 8px 14px; color: #f7e5bd; background: rgba(25,27,24,.92); border: 1px solid rgba(224,177,88,.34); border-radius: 7px; font: 11px var(--sans); box-shadow: 0 9px 24px rgba(0,0,0,.35); animation: toast-in .24s ease; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

.campaign-overlay, .result-overlay, .help-overlay {
  position: absolute; z-index: 80; inset: 0; display: grid; place-items: center; padding: max(14px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
  background: radial-gradient(circle at 50% 12%, rgba(151,71,38,.34), transparent 36%), linear-gradient(165deg, rgba(22,27,24,.97), rgba(11,13,12,.99));
  backdrop-filter: blur(5px);
}
.campaign-inner { width: 100%; height: 100%; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 12px; }
.campaign-brand { display: flex; align-items: center; gap: 12px; padding: 15px 5px 4px; color: #f2e1c0; }
.campaign-seal { display: grid; place-items: center; flex: 0 0 auto; width: 55px; height: 55px; color: #f7dfad; background: linear-gradient(145deg, #ad3d28, #642119); border: 1px solid #d99648; border-radius: 9px 13px 8px 12px; box-shadow: inset 0 0 0 3px rgba(255,226,174,.1); font: 900 29px var(--kai); transform: rotate(-4deg); }
.campaign-brand h1 { margin: 3px 0 2px; font-family: var(--kai); font-size: 31px; letter-spacing: .12em; }
.campaign-brand p { margin: 0; color: rgba(241,223,190,.65); font: 11px var(--sans); }
.campaign-rule { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; padding: 9px; color: #eee0c4; background: rgba(255,255,255,.045); border: 1px solid rgba(219,169,82,.2); border-radius: 8px; }
.campaign-rule > span { display: grid; place-items: center; min-height: 30px; color: #f4dca6; background: rgba(162,64,42,.35); border-radius: 5px; font: 900 17px var(--kai); }
.campaign-rule p { grid-column: 1 / -1; margin: 3px 0 0; color: rgba(238,224,195,.62); font: 10px/1.45 var(--sans); }
.level-grid { min-height: 0; overflow-y: auto; display: grid; gap: 8px; padding: 2px 2px 7px; scrollbar-width: none; }
.level-grid::-webkit-scrollbar { display: none; }
.level-card {
  position: relative; display: grid; grid-template-columns: 45px minmax(0, 1fr) auto; gap: 9px; align-items: center;
  min-height: 69px; padding: 10px 11px; color: #efdfbf; text-align: left; cursor: pointer;
  background: linear-gradient(110deg, rgba(58,49,35,.9), rgba(30,34,30,.94)); border: 1px solid rgba(206,154,67,.25); border-radius: 8px 12px 8px 10px;
}
.level-card:hover:not(:disabled) { border-color: rgba(228,181,88,.7); transform: translateY(-1px); }
.level-card:disabled { filter: grayscale(.8); opacity: .38; cursor: not-allowed; }
.level-index { display: grid; place-items: center; width: 42px; height: 42px; color: #f4d99d; background: rgba(159,57,39,.52); border-radius: 7px; font: 900 22px var(--kai); }
.level-copy strong { display: block; font-size: 16px; letter-spacing: .06em; }
.level-copy small { display: block; margin-top: 3px; overflow: hidden; color: rgba(238,220,188,.57); font: 9px var(--sans); text-overflow: ellipsis; white-space: nowrap; }
.level-stars { color: #d6a54b; font-size: 12px; letter-spacing: 1px; white-space: nowrap; }
.text-button { justify-self: center; padding: 7px 14px; color: #e6cf9f; background: transparent; border: 1px solid rgba(221,173,83,.28); border-radius: 7px; cursor: pointer; }
.result-card, .help-card { width: min(94%, 390px); padding: 24px 19px 19px; color: #f1dfbd; text-align: center; background: linear-gradient(145deg, #302f28, #171a17); border: 1px solid rgba(226,179,88,.42); border-radius: 10px 16px 10px 14px; box-shadow: 0 24px 60px rgba(0,0,0,.55); }
.result-card h2, .help-card h2 { margin: 6px 0 10px; color: #f3d896; font-family: var(--kai); font-size: 25px; }
.result-card p { margin: 0 0 16px; color: rgba(239,221,186,.66); font: 11px/1.6 var(--sans); }
.star-rating { display: flex; justify-content: center; gap: 9px; margin: 6px 0 12px; color: rgba(119,101,71,.46); font-size: 36px; line-height: 1; }
.star-rating span.earned { color: #e2ae4b; text-shadow: 0 0 12px rgba(227,169,59,.55); transform: scale(1.08); }
.help-overlay { z-index: 92; }
.help-card { position: relative; max-height: 90dvh; overflow-y: auto; text-align: left; }
.help-steps { display: grid; gap: 8px; margin: 12px 0; }
.help-steps article { position: relative; padding: 10px 10px 10px 40px; background: rgba(255,255,255,.045); border-radius: 7px; }
.help-steps b { position: absolute; left: 10px; top: 10px; color: #e3b151; font-family: var(--kai); }
.help-steps h3 { margin: 0 0 3px; color: #efd6a0; font-size: 13px; }
.help-steps p { margin: 0; color: rgba(236,221,191,.65); font: 10px/1.5 var(--sans); }
.hero-examples { display: flex; flex-wrap: wrap; gap: 5px; }
.hero-examples span { padding: 5px 7px; color: #f2d797; background: rgba(159,57,39,.28); border: 1px solid rgba(222,168,78,.18); border-radius: 5px; font: 10px var(--sans); }

@media (max-height: 740px) {
  .hand-panel { min-height: 112px; }
  .char-card { flex-basis: 62px; min-height: 68px; }
  .char-card-word { font-size: 34px; }
  .battle-hud { min-height: 50px; }
}
@media (max-width: 370px) {
  .battle-hud { grid-template-columns: 34px minmax(0,1fr) 67px 50px; }
  .hud-icon.sound { display: none; }
  .hud-title strong { font-size: 13px; }
  .char-card { flex-basis: 61px; }
}

.field-actions { grid-template-columns: minmax(0, 1fr) 58px 66px; overflow: hidden; }
.reroll-button, .start-war { width: 100%; min-width: 0; padding: 0 4px; font-size: 11px; }
.selected-summary p { max-width: 100%; }

.char-card.rare {
  border-color: rgba(201, 140, 52, .92);
  background: linear-gradient(145deg, #fff0c9, #d8b166);
  box-shadow: 0 0 0 1px rgba(255,229,157,.7), 0 0 16px rgba(216,157,59,.5), 0 5px 12px rgba(0,0,0,.28);
}
.char-card.rare::before { content: "将缘"; position: absolute; right: 4px; top: 4px; color: #7f291e; font: 800 8px var(--kai); }
.char-card.rare .char-card-word { color: #8a2f20; text-shadow: 0 1px 0 #fff4cd, 0 0 8px rgba(180,96,37,.36); }

.tile.move-target {
  background: rgba(48, 96, 83, .18) !important;
  box-shadow: inset 0 0 0 2px rgba(48, 96, 83, .5);
  animation: move-target-pulse 1s ease-in-out infinite;
}
@keyframes move-target-pulse { 50% { background: rgba(48, 96, 83, .31) !important; } }
.defender-token.moving { animation: unit-relocate .52s cubic-bezier(.2,.8,.3,1); }
@keyframes unit-relocate { 45% { transform: translate(-50%, -80%) scale(.82) rotate(-8deg); filter: brightness(1.5); } }
.effect-line.move { stroke: #e1b65e; stroke-width: 2; stroke-dasharray: 3 5; opacity: .8; }
.unit-actions { grid-template-columns: repeat(3, 1fr); }

.selected-summary { overflow: hidden; }
.selected-summary p { flex: 1 1 auto; min-width: 0; }
.field-actions { grid-template-columns: minmax(0, 1fr) 58px 66px !important; }

/* Weapons and drag placement */
.soldier-word { z-index: 2; }
.weapon {
  position: absolute; z-index: 3; left: 50%; top: 50%; display: block; pointer-events: none;
  transform-origin: 0 50%; filter: drop-shadow(0 2px 2px rgba(47,30,17,.3));
}
.weapon[data-weapon="spear"], .weapon[data-weapon="lance"] {
  width: 78%; height: 3px; border-radius: 4px;
  background: linear-gradient(90deg, #70451f 0 72%, #e0b963 72% 100%);
  transform: translate(2%, -105%) rotate(-42deg);
}
.weapon[data-weapon="lance"] { width: 94%; height: 4px; background: linear-gradient(90deg, #64371a 0 76%, #f1ca70 76% 100%); transform: translate(2%, -50%) rotate(var(--lance-angle, -42deg)) translateX(var(--lance-thrust, 0px)); }
.weapon[data-weapon="spear"]::after, .weapon[data-weapon="lance"]::after {
  content: ""; position: absolute; right: -8%; top: 50%; width: 17%; height: 10px;
  background: #dfc16b; clip-path: polygon(0 50%, 100% 0, 78% 50%, 100% 100%); transform: translateY(-50%);
}
.weapon[data-weapon="blade"] {
  left: 56%; top: 38%; width: 52%; height: 7px; border-radius: 2px 7px 3px 2px;
  background: linear-gradient(180deg, #f0ddb0, #a77938 68%, #62421f);
  clip-path: polygon(0 24%, 84% 0, 100% 50%, 84% 100%, 0 76%);
  transform: translate(0, 0) rotate(38deg);
}
.weapon[data-weapon="bow"] {
  left: auto; right: -5%; top: -3%; width: 48%; height: 90%; background: transparent;
  border: 0; border-radius: 0; transform: translate(var(--bow-x, 0px), var(--bow-y, 0px)) rotate(var(--bow-angle, -16deg));
  transform-origin: 50% 62%; filter: drop-shadow(1px 2px 2px rgba(59,35,16,.34));
}
.weapon[data-weapon="bow"]::before, .weapon[data-weapon="bow"]::after { content: none; display: none; }
.bow-rig { display: block; width: 100%; height: 100%; overflow: visible; }
.bow-limb { fill: none; stroke: #8b5723; stroke-width: 2.8; stroke-linecap: round; transform: scaleX(var(--bow-limb-scale, 1)); transform-box: view-box; transform-origin: 53px 60px; }
.bow-string { fill: none; stroke: #493020; stroke-width: 1.35; stroke-linecap: round; transform: scaleX(var(--bow-string-scale, 1)); transform-box: view-box; transform-origin: 53px 60px; }
.bow-grip { fill: #d3a75c; stroke: #70441f; stroke-width: 1.5; }
.bow-arrow { transform: translateX(var(--bow-arrow-x, 0px)); opacity: var(--bow-arrow-opacity, .75); transform-box: view-box; transform-origin: 55px 60px; }
.bow-shaft { stroke: #6f4825; stroke-width: 4.2; stroke-linecap: round; filter: drop-shadow(0 1px 1px rgba(48,27,12,.32)); }
.bow-head { fill: #d8d0b2; stroke: #654a2a; stroke-width: 1.2; stroke-linejoin: round; }
.bow-feather { fill: #b74e35; stroke: #61291e; stroke-width: .8; stroke-linejoin: round; }
.weapon[data-weapon="bow"], .bow-limb, .bow-string, .bow-arrow, .defender-token[data-role="archer"] .soldier-word { will-change: transform; }
.defender-token.hero .weapon { filter: drop-shadow(0 0 4px rgba(240,190,78,.78)); }
.defender-token.attacking.spear .weapon[data-weapon="spear"],
.defender-token.attacking.cavalry .weapon[data-weapon="lance"] { animation: none; will-change: transform; }
.defender-token.attacking.infantry .weapon[data-weapon="blade"] { animation: weapon-swing .38s ease-out; }
.defender-token.attacking.archer .weapon[data-weapon="bow"] { animation: none; }
@keyframes weapon-thrust {
  0%, 100% { transform: translate(2%, -105%) rotate(-42deg); }
  45% { transform: translate(48%, -108%) rotate(-42deg) scaleX(1.22); }
}
@keyframes weapon-swing {
  0%, 100% { transform: translate(0, 0) rotate(38deg); }
  42% { transform: translate(22%, -45%) rotate(-46deg) scaleX(1.15); }
}
@keyframes bow-release {
  0%, 100% { transform: rotate(8deg) scaleY(1); }
  45% { transform: rotate(8deg) scaleY(.72) translateX(25%); }
}
.char-card { touch-action: pan-x; }
.defender-token { touch-action: none; }
.drag-ghost {
  position: fixed !important; z-index: 240; pointer-events: none !important; opacity: .94;
  transform: translate(-50%, -50%) scale(1.1) rotate(-2deg) !important; filter: drop-shadow(0 14px 18px rgba(0,0,0,.34));
}
.drag-ghost.char-card { width: 68px; min-height: 77px; }
.drag-ghost.defender-token { width: 54px; height: 54px; background: transparent; border: 0; }
.drag-source { opacity: .3 !important; }
.tile.drag-hover {
  background: rgba(49,95,84,.28) !important;
  box-shadow: inset 0 0 0 3px rgba(49,95,84,.72), 0 0 16px rgba(49,95,84,.3) !important;
}
.is-dragging { cursor: grabbing; }

.game-app { grid-template-columns: minmax(0, 1fr); }
.field-area { width: 100%; min-width: 0; grid-template-columns: minmax(0, 1fr); }
.board-wrap { min-width: 0; }
.field-actions { width: 100%; min-width: 0; box-sizing: border-box; }
.hand-panel { min-width: 0; }

/* Weapon release and refresh */
.weapon { transition: opacity .08s linear, filter .12s ease; }
.weapon-hand {
  position: absolute; z-index: 3; left: 69%; top: 44%; width: 9px; height: 9px; border-radius: 50%;
  opacity: 0; pointer-events: none; background: radial-gradient(circle, #fff5bf, #e3ad4d 48%, transparent 72%);
  box-shadow: 0 0 8px rgba(238,185,75,.8);
}
.defender-token.weapon-empty .weapon { opacity: 0; filter: none; animation: none; }
.defender-token.weapon-empty .weapon-hand { opacity: .82; animation: hand-empty .42s ease-in-out infinite alternate; }
.defender-token.weapon-refreshing .weapon { animation: weapon-return .46s cubic-bezier(.2,.85,.3,1); }
.defender-token.weapon-refreshing .weapon-hand { animation: hand-gather .46s ease-out; }
@keyframes hand-empty { to { opacity: .35; transform: scale(.72); } }
@keyframes hand-gather { from { opacity: 1; transform: scale(1.45); } to { opacity: 0; transform: scale(.2); } }
@keyframes weapon-return {
  0% { opacity: 0; filter: brightness(2.6); }
  55% { opacity: 1; filter: brightness(2); }
  100% { opacity: 1; filter: brightness(1); }
}
.projectile.spear { filter: drop-shadow(0 0 7px rgba(193,124,43,.85)); }

/* Enemies are the characters themselves */
.enemy-token { width: 11.5%; min-width: 31px; max-width: 58px; overflow: visible; }
.enemy-word {
  position: absolute; inset: 9% 0 0; display: grid; place-items: center; background: none; border: 0; box-shadow: none;
  color: #6d4033; font-family: var(--kai); font-size: clamp(26px, 8vw, 42px); font-weight: 900; line-height: 1;
  paint-order: stroke fill; -webkit-text-stroke: 1.5px rgba(71,35,28,.62);
  text-shadow: 0 2px 0 rgba(255,244,224,.62), 0 6px 12px rgba(45,25,18,.34);
  transform: rotate(-4deg); animation: enemy-march .72s ease-in-out infinite alternate;
}
.enemy-token.cavalry .enemy-word { color: #963b2a; -webkit-text-stroke-color: rgba(91,30,23,.64); transform: rotate(7deg); animation: enemy-gallop .34s ease-in-out infinite alternate; }
.enemy-token.spear .enemy-word { color: #4f6262; -webkit-text-stroke-color: rgba(36,55,55,.68); transform: rotate(-8deg) skewX(-4deg); animation: spear-sway .92s ease-in-out infinite alternate; }
.enemy-token.shield .enemy-word { color: #4d4a44; -webkit-text-stroke: 2px rgba(30,29,27,.72); text-shadow: 0 2px 0 #b8aa91, 0 7px 13px rgba(31,27,23,.4); transform: rotate(2deg); animation: shield-stomp .95s ease-in-out infinite; }
.enemy-token.crossbow .enemy-word { color: #474d75; -webkit-text-stroke-color: rgba(31,35,62,.68); transform: rotate(-5deg); animation: crossbow-march .55s ease-in-out infinite alternate; }
.enemy-token.general { width: 15%; min-width: 42px; }
.enemy-token.general .enemy-word { color: #9a291d; -webkit-text-stroke: 2px #d49843; text-shadow: 0 0 12px rgba(221,73,43,.75), 0 3px 0 #6e1c15; animation: general-word 1.05s ease-in-out infinite; }
.enemy-token.hurt .enemy-word { animation: enemy-word-hit .18s ease; filter: brightness(1.8); }
.enemy-token.slowed .enemy-word { color: #376f83; -webkit-text-stroke-color: rgba(39,105,125,.72); text-shadow: 0 0 8px rgba(104,207,230,.75); }
.enemy-token.firing .enemy-word { animation: enemy-word-fire .32s ease-out; }
@keyframes general-word { 50% { transform: scale(1.08) rotate(2deg); filter: brightness(1.18); } }
@keyframes enemy-word-hit { 50% { transform: translate(9%, -5%) rotate(5deg); } }
@keyframes enemy-word-fire { 45% { transform: translate(-8%, -10%) scale(.86) rotate(-10deg); filter: brightness(1.8); } }

/* Final UX polish */
button { -webkit-user-select: none; user-select: none; }
.campaign-progress {
  grid-column: 1 / -1; margin-top: 3px; color: #d9b570; font: 800 10px var(--sans); letter-spacing: .08em;
}
.level-card { transition: transform 130ms ease, border-color 130ms ease, filter 130ms ease; }
.level-card:active:not(:disabled) { transform: scale(.985); border-color: #e2b95f; }
.level-card:disabled { opacity: .48; }
.level-index { box-shadow: inset 0 0 0 1px rgba(255,219,150,.18); }
.char-card { flex: 0 0 61px; min-height: 74px; scroll-snap-align: start; }
.char-card:active { transform: translateY(-2px) scale(.97); }
.char-card.selected { transform: translateY(-5px); }
.hand-row { gap: 6px; scroll-snap-type: x proximity; mask-image: linear-gradient(90deg, transparent 0, #000 5px, #000 calc(100% - 7px), transparent 100%); -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 5px, #000 calc(100% - 7px), transparent 100%); }
.card-new { animation-duration: .58s; }
.game-app.can-build .tile.buildable { background: rgba(49,95,84,.07); }
.game-app.can-build .tile.buildable::after { color: rgba(42,88,76,.52); }
.unit-stats { grid-template-columns: repeat(4, 1fr); }
.unit-trait { margin: -2px 0 10px; padding: 7px 9px; color: #e7c986; background: rgba(214,165,75,.09); border-left: 2px solid rgba(214,165,75,.55); border-radius: 4px; font: 10px/1.45 var(--sans); }
.unit-sheet { animation: sheet-up .22s cubic-bezier(.2,.8,.3,1); }
@keyframes sheet-up { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.merge-flash::after {
  content: ""; position: absolute; z-index: 190; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 38%, rgba(255,226,146,.42), rgba(160,56,33,.12) 32%, transparent 65%);
  animation: merge-flash .62s ease-out forwards;
}
@keyframes merge-flash { from { opacity: 0; } 30% { opacity: 1; } to { opacity: 0; } }
.start-war:not(:disabled):active, .reroll-button:not(:disabled):active, .primary:not(:disabled):active, .secondary:not(:disabled):active { transform: translateY(1px) scale(.98); }
.toast { backdrop-filter: blur(8px); }
.campaign-overlay .level-grid { padding-bottom: 12px; }
@media (max-width: 380px) {
  .char-card { flex-basis: 57px; }
  .char-card-word { font-size: 35px; }
  .unit-stats { grid-template-columns: repeat(2, 1fr); }
}

.char-card, .defender-token { cursor: grab; }
.char-card:active, .defender-token:active { cursor: grabbing; }
.char-card, .defender-token, .hand-row { -webkit-user-select: none; user-select: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

.char-card.is-common .char-card-role { display: none; }
.char-card.is-common .char-card-word { margin-top: 2px; }

.field-actions { grid-template-columns: minmax(0, 1fr) 82px 66px !important; }
.reroll-button { white-space: nowrap; font-size: 11px; }
.reroll-button::before { content: "AD"; margin-right: 4px; padding: 1px 3px; color: #5f3d13; background: #d9a84d; border-radius: 3px; font: 800 7px var(--sans); vertical-align: 1px; }
.reroll-button:disabled::before { opacity: .5; }
.hand-row.row-refreshing .char-card { animation: hand-refresh .5s cubic-bezier(.2,.8,.3,1) both; }
.hand-row.row-refreshing .char-card:nth-child(2) { animation-delay: .05s; }
.hand-row.row-refreshing .char-card:nth-child(3) { animation-delay: .1s; }
.hand-row.row-refreshing .char-card:nth-child(4) { animation-delay: .15s; }
@keyframes hand-refresh { from { opacity: 0; transform: translateY(18px) rotateY(50deg) scale(.78); } }
.ad-overlay { position: absolute; z-index: 95; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(9,11,10,.78); backdrop-filter: blur(5px); }
.ad-overlay[hidden] { display: none; }
.ad-card { position: relative; width: min(94%, 370px); padding: 24px 20px 20px; color: #f3e2c0; text-align: center; background: linear-gradient(150deg, #343027, #181b18); border: 1px solid rgba(226,179,88,.42); border-radius: 11px 17px 10px 15px; box-shadow: 0 24px 64px rgba(0,0,0,.55); }
.ad-card h2 { margin: 5px 0 16px; color: #f1d489; font-family: var(--kai); font-size: 24px; }
.ad-visual { position: relative; display: grid; place-items: center; width: 142px; height: 112px; margin: 0 auto 15px; overflow: hidden; background: radial-gradient(circle, rgba(218,165,73,.2), transparent 66%); border: 1px solid rgba(224,176,87,.24); border-radius: 10px; }
.ad-visual span { color: #dfb558; font: 900 62px var(--kai); text-shadow: 0 0 18px rgba(231,176,73,.42); }
.ad-visual i { position: absolute; left: 10px; right: 10px; bottom: 9px; height: 4px; overflow: hidden; background: rgba(255,255,255,.09); border-radius: 8px; }
.ad-visual i b { display: block; width: 8%; height: 100%; background: linear-gradient(90deg, #9e3a28, #e1ad4a); transition: width .3s linear; }
.ad-card p { min-height: 18px; margin: 0 0 6px; color: rgba(239,221,185,.7); font: 11px var(--sans); }
.ad-countdown { display: block; margin-bottom: 14px; color: #efc76f; font: 900 26px var(--sans); }
.ad-card .primary { width: 100%; }
@media (min-width: 430px) { .hand-row { justify-content: center; } }
@media (max-width: 390px) { .field-actions { grid-template-columns: minmax(0, 1fr) 72px 60px !important; } .reroll-button::before { display: none; } }

.gold-refresh { min-height: 35px; padding: 0 5px; color: #f2d8a0; background: rgba(183,126,42,.18); border: 1px solid rgba(226,186,111,.35); border-radius: 7px; cursor: pointer; font-weight: 900; font-size: 11px; white-space: nowrap; }
.gold-refresh:disabled { opacity: .38; cursor: not-allowed; }
.gold-refresh:not(:disabled):active { transform: translateY(1px) scale(.98); }
.field-actions { grid-template-columns: minmax(0, 1fr) 60px 76px 62px !important; gap: 5px; }
@media (max-width: 420px) { .field-actions { grid-template-columns: minmax(0, 1fr) 54px 66px 56px !important; } .gold-refresh, .reroll-button, .start-war { font-size: 10px; padding: 0 3px; } }

.tile.merge-target { background: rgba(206, 153, 55, .24) !important; box-shadow: inset 0 0 0 2px rgba(154, 91, 23, .75), 0 0 16px rgba(203, 139, 46, .34) !important; animation: merge-target-pulse .72s ease-in-out infinite alternate; }
.tile.merge-target::before { content: "合"; position: absolute; z-index: 0; left: 50%; top: 50%; transform: translate(-50%, -50%); color: rgba(126, 62, 23, .68); font: 900 19px var(--kai); }
@keyframes merge-target-pulse { to { box-shadow: inset 0 0 0 3px rgba(176, 101, 25, .92), 0 0 22px rgba(216, 149, 48, .5) !important; } }
.tile.swap-target { background: rgba(52, 102, 115, .2) !important; box-shadow: inset 0 0 0 2px rgba(56, 116, 128, .7), 0 0 14px rgba(61, 128, 137, .25) !important; }
.tile.swap-target::before { content: "换"; position: absolute; z-index: 0; left: 50%; top: 50%; transform: translate(-50%, -50%); color: rgba(37, 91, 100, .62); font: 900 19px var(--kai); }
.tile.card-merge-hover { background: rgba(206, 153, 55, .3) !important; box-shadow: inset 0 0 0 3px rgba(154, 91, 23, .86), 0 0 18px rgba(203, 139, 46, .42) !important; }
.tile.card-merge-hover::before { content: "合"; position: absolute; z-index: 0; left: 50%; top: 50%; transform: translate(-50%, -50%); color: rgba(126, 62, 23, .78); font: 900 20px var(--kai); }

.soldier-word, .enemy-word { isolation: isolate; font-weight: 900; color: transparent; -webkit-text-fill-color: transparent; background-clip: text; -webkit-background-clip: text; -webkit-text-stroke: 1px var(--edge, rgba(34,45,38,.6)); filter: drop-shadow(0 6px 4px rgba(49,31,18,.32)); }
.soldier-word { --face1: #f5fff5; --face2: #27614f; --edge: #173d33; --depth: #7b633d; --depth2: #3a2b18; background-image: linear-gradient(145deg, var(--face1) 0 20%, var(--face2) 72%, color-mix(in srgb, var(--face2) 78%, #101713)); }
.soldier-word::before, .enemy-word::before { content: attr(data-text); position: absolute; inset: 0; z-index: -1; display: grid; place-items: center; color: var(--depth); background: none; -webkit-text-fill-color: var(--depth); -webkit-text-stroke: 1px var(--depth2); transform: translate(3px, 4px); text-shadow: 1px 1px 0 var(--depth2), 2px 2px 0 var(--depth2), 3px 3px 0 rgba(18,10,6,.38), 0 8px 8px rgba(36,23,14,.26); }
.defender-token[data-role="archer"] .soldier-word { --face1: #f4f7c7; --face2: #59722f; --edge: #2f4218; --depth: #7a6a37; --depth2: #3e3519; }
.defender-token[data-role="spear"] .soldier-word { --face1: #ffe6ae; --face2: #895720; --edge: #4c2b0e; --depth: #806234; --depth2: #412a13; }
.defender-token[data-role="cavalry"] .soldier-word { --face1: #ffc7a9; --face2: #92392a; --edge: #511d14; --depth: #7b4939; --depth2: #401913; }
.defender-token.hero .soldier-word { --face1: #fff3ae; --face2: #be3c26; --edge: #f0c05f; --depth: #671b12; --depth2: #32100b; -webkit-text-stroke-width: 2px; }
.enemy-word { --face1: #e6ac83; --face2: #6b3d30; --edge: #341b15; --depth: #6a4433; --depth2: #2d140f; background-image: linear-gradient(145deg, var(--face1) 0 20%, var(--face2) 72%, color-mix(in srgb, var(--face2) 80%, #140d0a)); }
.enemy-token.cavalry .enemy-word { --face1: #f3a376; --face2: #933927; --edge: #50180f; --depth: #723c2c; --depth2: #38120d; }
.enemy-token.spear .enemy-word { --face1: #b9c9c5; --face2: #506263; --edge: #223333; --depth: #52615e; --depth2: #263333; }
.enemy-token.shield .enemy-word { --face1: #bbb09a; --face2: #4e4a44; --edge: #201f1d; --depth: #58534a; --depth2: #26231f; }
.enemy-token.crossbow .enemy-word { --face1: #b7bbe7; --face2: #484e78; --edge: #202342; --depth: #535779; --depth2: #242743; }
.enemy-token.general .enemy-word { --face1: #ffe596; --face2: #9c2b1e; --edge: #d79c3e; --depth: #67150f; --depth2: #310b07; -webkit-text-stroke-width: 2px; }
.char-card-word { position: relative; text-shadow: 1px 1px 0 #fff6d9, 2px 2px 0 rgba(116,82,37,.38), 3px 3px 0 rgba(65,43,22,.28), 0 6px 7px rgba(49,31,18,.2); }

.soldier-word::before, .enemy-word::before { display: none !important; content: none !important; }
.soldier-word, .enemy-word { background-image: none !important; -webkit-background-clip: initial !important; background-clip: initial !important; -webkit-text-fill-color: currentColor !important; -webkit-text-stroke: 0 !important; filter: none !important; text-shadow: 0 1px 0 rgba(255,255,255,.42), 0 4px 4px rgba(51,31,18,.2) !important; }
.soldier-word { color: #245e4d !important; }
.defender-token[data-role="archer"] .soldier-word { color: #55702d !important; }
.defender-token[data-role="spear"] .soldier-word { color: #88551d !important; }
.defender-token[data-role="cavalry"] .soldier-word { color: #91392a !important; }
.defender-token.hero .soldier-word { color: #9b2f20 !important; text-shadow: 0 1px 0 #f8d98b, 0 0 9px rgba(221,157,52,.48), 0 5px 5px rgba(55,25,14,.28) !important; }
.enemy-word { color: #6d4033 !important; }
.enemy-token.cavalry .enemy-word { color: #963b2a !important; }
.enemy-token.spear .enemy-word { color: #4f6262 !important; }
.enemy-token.shield .enemy-word { color: #4d4a44 !important; }
.enemy-token.crossbow .enemy-word { color: #474d75 !important; }
.enemy-token.general .enemy-word { color: #9a291d !important; text-shadow: 0 1px 0 #e2b55c, 0 0 10px rgba(221,73,43,.65), 0 5px 5px rgba(48,13,8,.3) !important; }
.defender-token.hero::before { background: transparent !important; border-color: rgba(230,182,87,.36) !important; box-shadow: 0 0 12px rgba(213,145,45,.25) !important; }
.ground-shadow { position: absolute; z-index: 0; left: 10%; right: 10%; bottom: 2%; height: 18%; border-radius: 50%; pointer-events: none; filter: blur(2px); background: radial-gradient(ellipse at center, rgba(67,42,25,.52) 0%, rgba(67,42,25,.28) 42%, transparent 72%); transform-origin: center; animation: shadow-breathe 2.5s ease-in-out infinite; }
.enemy-token .ground-shadow { left: 7%; right: 7%; bottom: 0; height: 21%; background: radial-gradient(ellipse at center, rgba(84,35,25,.52) 0%, rgba(84,35,25,.26) 45%, transparent 74%); }
.defender-token[data-role="cavalry"] .ground-shadow, .enemy-token.cavalry .ground-shadow { left: -2%; right: -2%; height: 24%; transform: scaleX(1.28); }
.defender-token.hero .ground-shadow { background: radial-gradient(ellipse at center, rgba(122,67,25,.58) 0%, rgba(220,166,71,.26) 48%, transparent 76%); filter: blur(2.5px); }
.enemy-token.general .ground-shadow { left: -6%; right: -6%; height: 26%; background: radial-gradient(ellipse at center, rgba(103,27,19,.62) 0%, rgba(211,72,44,.28) 46%, transparent 76%); }
.defender-token.attacking .ground-shadow { animation: shadow-strike .42s ease-out; }
.defender-token.attacking.cavalry .ground-shadow, .enemy-token.cavalry .ground-shadow { animation-name: shadow-charge; animation-duration: .42s; }
@keyframes shadow-breathe { 50% { opacity: .72; transform: scaleX(.93) scaleY(.9); } }
@keyframes shadow-strike { 45% { opacity: .5; transform: translateX(8%) scaleX(1.18) scaleY(.82); } }
@keyframes shadow-charge { 45% { opacity: .45; transform: translateX(16%) scaleX(1.45) scaleY(.78); } }
.char-card-word { text-shadow: 0 4px 5px rgba(49,31,18,.24) !important; }

@font-face { font-family: "SanguoHand"; src: url("./assets/mashan-subset.ttf") format("truetype"); font-style: normal; font-weight: 400; font-display: swap; }
.soldier-word, .enemy-word, .char-card-word, .merge-banner strong, .unit-sheet h2, .campaign-seal, .level-index { font-family: "SanguoHand", var(--kai) !important; font-weight: 400 !important; font-variant-east-asian: normal; text-rendering: geometricPrecision; }
.soldier-word { transform: rotate(var(--unit-tilt, -4deg)); transform-origin: 50% 76%; }
@keyframes soldier-idle { 0%, 100% { transform: translateY(0) rotate(var(--unit-tilt, -4deg)) scale(1); } 48% { transform: translateY(-3px) rotate(calc(var(--unit-tilt, -4deg) + 3deg)) scale(1.045); } 72% { transform: translateY(-1px) rotate(calc(var(--unit-tilt, -4deg) - 1.5deg)) scale(1.02); } }
.enemy-word { transform-origin: 50% 78%; letter-spacing: .01em; }
.char-card-word { transform: rotate(var(--card-tilt, 0deg)); }
.char-card:nth-child(odd) .char-card-word { --card-tilt: -3deg; }
.char-card:nth-child(even) .char-card-word { --card-tilt: 2.5deg; }
.merge-banner strong { letter-spacing: .04em !important; }
.campaign-seal { font-weight: 400 !important; }

.tile.blocked { display: grid; place-items: center; cursor: not-allowed; font-family: var(--kai); font-weight: 900; border-color: rgba(48,43,37,.14); box-shadow: inset 0 0 18px rgba(45,38,30,.16); }
.terrain-mountain { color: rgba(72,67,61,.68); background: linear-gradient(145deg, #c9c0ad, #aaa18e); }
.terrain-river { color: rgba(52,92,112,.72); background: repeating-linear-gradient(165deg, #b9d1d3 0 6px, #94b9bf 7px 10px); }
.terrain-wall { color: rgba(85,67,48,.72); background: linear-gradient(145deg, #b9a88c, #8e7b61); }
.terrain-forest { color: rgba(48,83,51,.72); background: radial-gradient(circle at 35% 36%, #8ba17b, #56705a 68%, #3e5544); }

.campaign-inner { grid-template-rows: auto auto auto auto minmax(0, 1fr) auto; gap: 8px; }
.faction-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.faction-tab { display: grid; grid-template-columns: 32px 1fr; grid-template-rows: auto auto; align-items: center; gap: 0 7px; min-height: 54px; padding: 6px 8px; color: rgba(242,224,190,.65); text-align: left; cursor: pointer; background: rgba(255,255,255,.045); border: 1px solid rgba(222,175,90,.18); border-radius: 8px; }
.faction-tab b { grid-row: 1 / 3; display: grid; place-items: center; width: 31px; height: 31px; color: #f6e4bd; background: rgba(91,67,44,.72); border-radius: 7px; font: 400 20px "SanguoHand", var(--kai); }
.faction-tab span { font-weight: 800; font-size: 13px; }
.faction-tab small { color: rgba(238,221,189,.45); font: 8px var(--sans); }
.faction-tab.active { color: #fff0c9; border-color: var(--faction-color, #b77c35); background: color-mix(in srgb, var(--faction-color, #9d3325) 42%, #262c27); box-shadow: inset 0 0 0 1px rgba(255,227,166,.12), 0 5px 16px rgba(0,0,0,.25); }
.faction-tab.active b { background: var(--faction-color, #9d3325); }
.faction-intro { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 1px 4px; }
.faction-intro strong { color: #f0cd83; font: 400 23px "SanguoHand", var(--kai); }
.faction-intro span { overflow: hidden; color: rgba(239,221,186,.62); font: 9px var(--sans); text-overflow: ellipsis; white-space: nowrap; }
.faction-intro em { color: #d8a759; font: 800 9px var(--sans); font-style: normal; white-space: nowrap; }
.level-grid { position: relative; display: flex; align-items: center; gap: 12px; overflow-x: auto; overflow-y: hidden; padding: 36px max(20px, calc((100vw - 280px) / 2)) 20px; scroll-snap-type: x mandatory; scroll-behavior: smooth; }
.level-grid::before { content: ""; position: absolute; z-index: 0; left: 0; right: 0; top: 50%; height: 2px; background: linear-gradient(90deg, transparent, rgba(219,171,84,.36) 8%, rgba(219,171,84,.36) 92%, transparent); }
.timeline-card { position: relative; z-index: 1; flex: 0 0 min(76vw, 280px); min-height: min(46vh, 350px); padding: 38px 17px 16px; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto auto 1fr auto; align-content: start; gap: 7px; scroll-snap-align: center; text-align: left; overflow: visible; }
.timeline-card .timeline-dot { position: absolute; left: 50%; top: -19px; transform: translateX(-50%); display: grid; place-items: center; width: 31px; height: 31px; color: #f7e4b8; background: var(--faction-color, #315f54); border: 2px solid #d9ad58; border-radius: 50%; box-shadow: 0 4px 12px rgba(0,0,0,.35); font: 400 15px "SanguoHand", var(--kai); }
.timeline-card .level-year { color: #d8a85b; font: 800 10px var(--sans); letter-spacing: .08em; }
.timeline-card > strong { color: #f1d99f; font: 400 28px "SanguoHand", var(--kai); }
.timeline-card > small { min-height: 30px; color: rgba(239,222,188,.65); font: 10px/1.5 var(--sans); }
.timeline-card .map-badge { justify-self: start; padding: 3px 7px; color: #f5ddb0; background: color-mix(in srgb, var(--faction-color, #315f54) 52%, #2b2b25); border-radius: 4px; font: 9px var(--sans); }
.timeline-card .level-roster, .timeline-card .level-enemy { display: block; overflow: hidden; padding-top: 7px; border-top: 1px dashed rgba(222,179,96,.18); font: 9px/1.45 var(--sans); text-overflow: ellipsis; }
.timeline-card .level-roster { color: rgba(146,211,181,.8); }
.timeline-card .level-enemy { color: rgba(232,149,119,.78); }
.timeline-card .level-stars { justify-self: end; color: #d7a64a; font-size: 13px; }
.timeline-card:disabled { opacity: .46; filter: grayscale(.45); }
.timeline-card:not(:disabled):active { transform: scale(.98); }

.campaign-overlay { overflow: hidden; }
.campaign-inner { width: 100%; min-width: 0; overflow: hidden; }
.faction-tabs, .faction-intro, .campaign-rule { width: 100%; min-width: 0; }
.level-grid { width: 100%; min-width: 0; max-width: 100%; }

.campaign-inner { grid-template-columns: minmax(0, 1fr); }
.level-grid { padding-left: max(20px, calc((100% - 280px) / 2)); padding-right: max(20px, calc((100% - 280px) / 2)); }

.event-overlay { position: absolute; z-index: 120; inset: 0; display: grid; place-items: center; pointer-events: none; background: radial-gradient(circle, rgba(67,20,10,.18), transparent 68%); }
.event-overlay[hidden] { display: none; }
.event-card { width: min(92%, 390px); padding: 28px 22px; text-align: center; color: #f7e5bd; background: linear-gradient(90deg, transparent, rgba(86,24,16,.96) 15%, rgba(119,40,22,.98) 50%, rgba(86,24,16,.96) 85%, transparent); border-top: 1px solid rgba(244,201,105,.7); border-bottom: 1px solid rgba(244,201,105,.7); animation: event-enter 2.8s ease forwards; }
.event-kicker { color: #e4b55f; font: 800 9px var(--sans); letter-spacing: .24em; }
.event-card h2 { margin: 7px 0; color: #ffe3a0; font: 400 34px "SanguoHand", var(--kai); text-shadow: 0 4px 10px rgba(34,8,4,.45); }
.event-card p { margin: 0; color: rgba(255,231,190,.9); font: 13px/1.7 var(--kai); }
.event-overlay[data-type="roar"] .event-card h2 { font-size: 42px; transform: scale(1.04); }
.event-shake { animation: screen-shake .18s linear 4; }
.screen-flash { position: absolute; z-index: 110; inset: 0; pointer-events: none; opacity: 0; background: rgba(255,228,157,.6); }
.screen-flash.active { animation: flash-screen .7s ease-out; }
@keyframes event-enter { 0% { opacity: 0; transform: scale(.88); } 12%, 78% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.03); } }
@keyframes screen-shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes flash-screen { 20% { opacity: .62; } 100% { opacity: 0; } }

/* Softer attack highlights */
.effect-line.arrow { stroke: #f1dfad; filter: drop-shadow(0 0 2px rgba(205,171,104,.42)); }
.effect-line.spear { stroke: #eadbb3; filter: drop-shadow(0 0 2px rgba(175,137,81,.38)); }
.effect-line.fire { stroke: #f6be7b; filter: drop-shadow(0 0 5px rgba(213,116,55,.45)); }
.effect-line.thunder { stroke: #fff2c8; filter: drop-shadow(0 0 4px rgba(211,172,83,.48)); }
.effect-slash { stroke: #efddb2; opacity: .7 !important; filter: drop-shadow(0 0 3px rgba(178,132,62,.42)); }
.effect-ring { stroke: #dfcca3; opacity: .62 !important; }
.effect-burst.arrow { fill: #ffe9b7; opacity: .66 !important; filter: drop-shadow(0 0 4px rgba(190,143,62,.42)); }
.effect-burst.fire { fill: #f8c18b; opacity: .72 !important; filter: drop-shadow(0 0 5px rgba(201,97,45,.42)); }
.effect-spark { stroke: #fff3d2; opacity: .68 !important; }
.effect-muzzle { stroke: #ead9ad; opacity: .62 !important; }
.projectile.arrow { width: 3.25%; min-width: 10px; max-width: 19px; aspect-ratio: 4.5 / 1; }
.arrow-rig { display: block; width: 100%; height: 100%; overflow: visible; }
.projectile.arrow.rigged::before, .projectile.arrow.rigged::after, .projectile.arrow.rigged i { display: none; }
.projectile.arrow::before { background: linear-gradient(90deg, #b89b68, #f0dca9 60%, #fff3d0); box-shadow: 0 0 4px rgba(211,179,113,.46); }
.projectile.arrow::before {
  left: 7%; right: 15%; top: 45%; height: 3px; border-radius: 1px;
  background: linear-gradient(90deg, #5f3b1d, #8a5526 72%, #d4b77b);
  box-shadow: 0 1px 2px rgba(49,29,14,.42);
}
.projectile.arrow::after {
  right: 0; top: 24%; width: 18%; height: 52%;
  background: #d8d0b2; clip-path: polygon(0 50%, 100% 0, 78% 50%, 100% 100%);
  filter: drop-shadow(0 1px 1px rgba(47,35,22,.35));
}
.projectile.arrow i { position: absolute; left: 2%; top: 16%; width: 28%; height: 68%; }
.projectile.arrow i::before, .projectile.arrow i::after { content: ""; position: absolute; left: 0; width: 100%; height: 48%; background: #b74e35; }
.projectile.arrow i::before { top: 0; clip-path: polygon(0 100%, 100% 0, 66% 100%); }
.projectile.arrow i::after { bottom: 0; clip-path: polygon(0 0, 100% 100%, 66% 0); }
.projectile.spear { filter: drop-shadow(0 0 4px rgba(180,143,83,.48)); }

.weapon[data-weapon="guandao"] { width: 104%; height: 5px; border-radius: 5px; background: linear-gradient(90deg, #493620 0 76%, #d8b45a 76% 100%); transform: translate(-2%, -112%) rotate(-45deg); }
.weapon[data-weapon="guandao"]::after { content: ""; position: absolute; right: -15%; top: 50%; width: 25%; height: 15px; background: linear-gradient(180deg, #f2d487, #698b58 60%, #2f5038); clip-path: polygon(0 50%, 100% 0, 82% 50%, 100% 100%); transform: translateY(-50%); }
.weapon[data-weapon="banner"] { width: 5px; height: 100%; background: linear-gradient(#86612e, #d6b065); transform: translate(4%, -108%) rotate(-5deg); border-radius: 3px; }
.weapon[data-weapon="banner"]::after { content: "仁"; position: absolute; left: 4px; top: 2px; display: grid; place-items: center; width: 24px; height: 22px; color: #7b2b20; background: #e9c26f; font: 400 15px "SanguoHand", var(--kai); border-radius: 2px; }
.defender-token.attacking[data-hero="关羽"] { animation: guanyu-strike .72s cubic-bezier(.2,.8,.2,1); }
.defender-token.attacking[data-hero="刘备"] { animation: liubei-command .66s ease-out; }
.defender-token.attacking[data-hero="关羽"] .weapon { animation: guandao-slash .72s ease-out; }
.defender-token.attacking[data-hero="刘备"] .weapon { animation: banner-rally .66s ease-out; }
@keyframes guanyu-strike { 52% { transform: translate(-50%, -50%) translate(10%, -8%) scale(1.18) rotate(-5deg); filter: brightness(1.45); } }
@keyframes liubei-command { 48% { transform: translate(-50%, -50%) translateY(-5%) scale(1.12); filter: brightness(1.3); } }
@keyframes guandao-slash { 0%, 100% { transform: translate(-2%, -112%) rotate(-45deg); } 48% { transform: translate(38%, -118%) rotate(72deg) scaleX(1.12); } }
@keyframes banner-rally { 48% { transform: translate(4%, -118%) rotate(6deg) scaleY(1.1); } }
.effect-crescent { fill: none; stroke: #e8d198; stroke-width: 7; stroke-linecap: round; filter: drop-shadow(0 0 7px rgba(88,139,82,.55)); }
.effect-crescent.echo { stroke: #8fb083; stroke-width: 3; }
.effect-command-ring { fill: rgba(232,211,151,.08); stroke: #ead7a7; stroke-width: 2; stroke-dasharray: 5 5; }
.effect-command-wave { fill: none; stroke: #fff0bd; stroke-width: 2; filter: drop-shadow(0 0 5px rgba(213,173,80,.55)); }
.death-layer { position: absolute; inset: 0; z-index: 30; pointer-events: none; overflow: visible; }
.death-word { position: absolute; width: 11%; min-width: 32px; max-width: 54px; aspect-ratio: 1; transform: translate(-50%, -50%); }
.death-word > span { position: absolute; inset: 0; display: grid; place-items: center; font: 400 clamp(24px, 7.5vw, 40px)/1 "SanguoHand", var(--kai); color: #714334; text-shadow: 0 4px 6px rgba(42,24,16,.35); animation: death-fall 1.02s cubic-bezier(.2,.8,.3,1) forwards; }
.death-word > i { position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; border-radius: 50%; background: rgba(92,52,35,.7); animation: death-shard .78s ease-out forwards; }
.death-word > i:nth-of-type(2) { --dx: -24px; --dy: -28px; }
.death-word > i:nth-of-type(3) { --dx: 27px; --dy: -20px; }
.death-word > i:nth-of-type(4) { --dx: -20px; --dy: 24px; }
.death-word > i:nth-of-type(5) { --dx: 23px; --dy: 25px; }
.death-word.death-cavalry > span { color: #9a3c2b; animation-name: death-gallop; }
.death-word.death-spear > span { color: #566a68; animation-name: death-topple; }
.death-word.death-shield > span { color: #514b43; animation-name: death-collapse; }
.death-word.death-crossbow > span { color: #4e5578; animation-name: death-shatter; }
.death-word.death-general { width: 16%; min-width: 45px; max-width: 72px; }
.death-word.death-general > span { color: #a32f21; animation-name: death-general; }
.death-word.death-general > i { width: 8px; height: 8px; background: #d9a34c; animation-duration: 1.15s; }
@keyframes death-fall { 60% { opacity: .75; transform: translateY(14px) rotate(24deg) scale(.88); } 100% { opacity: 0; transform: translateY(34px) rotate(55deg) scale(.55); } }
@keyframes death-gallop { 50% { opacity: .8; transform: translate(22px, -8px) rotate(-18deg); } 100% { opacity: 0; transform: translate(58px, 18px) rotate(-42deg); } }
@keyframes death-topple { 45% { transform: rotate(64deg); } 100% { opacity: 0; transform: translateY(28px) rotate(105deg); } }
@keyframes death-collapse { 55% { transform: scale(1.12); filter: brightness(1.25); } 100% { opacity: 0; transform: translateY(20px) scale(.35); } }
@keyframes death-shatter { 42% { transform: translateX(-8px) rotate(-15deg) scale(1.15); } 100% { opacity: 0; transform: translateX(30px) rotate(35deg) scale(.3); } }
@keyframes death-general { 28% { transform: scale(1.35); filter: brightness(1.8); } 100% { opacity: 0; transform: scale(.28) rotate(22deg); } }
@keyframes death-shard { 0% { opacity: .9; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.3); } }

.enemy-token.general { width: 22%; min-width: 52px; max-width: 98px; }
.enemy-token.general .enemy-word { inset: 8% -34%; font-size: clamp(17px, 4.5vw, 27px); letter-spacing: -.12em; white-space: nowrap; }
.enemy-token.general[data-length="3"] .enemy-word { inset-left: -48%; inset-right: -48%; font-size: clamp(14px, 3.8vw, 23px); letter-spacing: -.18em; }
.death-word.death-general { width: 24%; min-width: 68px; max-width: 118px; }
.death-word.death-general[data-length="2"] > span { font-size: clamp(18px, 5vw, 30px); letter-spacing: -.1em; }
.death-word.death-general[data-length="3"] > span { font-size: clamp(14px, 4.2vw, 25px); letter-spacing: -.16em; }

.hud-coins span { width: auto; height: auto; color: #e0b45e; background: transparent; border-radius: 0; font: 800 8px var(--sans); letter-spacing: .04em; }
.hud-coins strong { color: #f7e6bd; }

.level-grid { touch-action: pan-x; overscroll-behavior-x: contain; cursor: grab; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.level-grid::-webkit-scrollbar { display: none; }
.level-grid:active { cursor: grabbing; }
.timeline-card.current { border-color: rgba(229,186,94,.85); background: linear-gradient(145deg, rgba(87,74,48,.96), rgba(35,41,35,.97)); box-shadow: 0 0 0 1px rgba(241,204,119,.2), 0 12px 28px rgba(0,0,0,.32); }
.timeline-card.current .timeline-dot { box-shadow: 0 0 0 4px rgba(221,176,84,.16), 0 4px 12px rgba(0,0,0,.35); }

.defender-token.attacking .soldier-word { animation: word-attack .42s cubic-bezier(.2,.8,.25,1); }
.defender-token.attacking[data-hero="刘备"] .soldier-word { animation: liubei-word .62s cubic-bezier(.2,.8,.25,1); }
.defender-token.attacking[data-hero="关羽"] .soldier-word { animation: guanyu-word .72s cubic-bezier(.2,.8,.25,1); }
@keyframes word-attack { 45% { transform: translateY(-4px) rotate(calc(var(--unit-tilt, -4deg) + 9deg)) scaleX(1.18) scaleY(.9); filter: brightness(1.35); } }
@keyframes liubei-word { 42% { transform: translate(-5px, -4px) rotate(-12deg) scaleX(1.32) scaleY(.82); filter: brightness(1.45); } }
@keyframes guanyu-word { 38% { transform: translate(10px, -5px) rotate(13deg) scaleX(1.22) scaleY(.84); filter: brightness(1.5); } }
.defender-token.attacking.archer .weapon[data-weapon="bow"] { animation: none; }
.defender-token.attacking.archer .weapon-hand { opacity: 0 !important; animation: none !important; }
.defender-token.attacking.archer .soldier-word {
  animation: none;
  transform-origin: 72% 72%;
}
.projectile.blade, .projectile.guandao { width: 5.4%; min-width: 23px; max-width: 40px; aspect-ratio: 1; }
.projectile.blade i { position: absolute; inset: 12%; display: block; background: linear-gradient(145deg, #fff0c4, #b8873d 62%, #62401e); clip-path: polygon(5% 42%, 76% 0, 100% 50%, 76% 100%, 5% 58%, 21% 50%); filter: drop-shadow(0 0 5px rgba(201,157,73,.6)); animation: thrown-spin .34s linear infinite; }
.projectile.guandao { width: 8%; min-width: 34px; max-width: 58px; aspect-ratio: 2.2 / 1; }
.projectile.guandao i { position: absolute; inset: 38% 0 auto; height: 4px; display: block; background: linear-gradient(90deg, #6c4725 0 72%, #d2aa55 72% 100%); border-radius: 3px; animation: thrown-spin .42s linear infinite; }
.projectile.guandao i::after { content: ""; position: absolute; right: -14%; top: -12px; width: 28%; height: 27px; background: linear-gradient(180deg, #f3d991, #73935e 62%, #31583e); clip-path: polygon(0 50%, 100% 0, 80% 50%, 100% 100%); }
@keyframes thrown-spin { to { transform: rotate(360deg); } }

.defender-token.hero::after { display: none !important; content: none !important; }
.unit-level:empty { display: none !important; }

.defender-token:not(.attacking) .soldier-word {
  animation-duration: var(--attack-cadence, 2.5s) !important;
  animation-delay: var(--attack-cadence-delay, 0s) !important;
}
@media (max-width: 560px) {
  .level-grid {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 36px max(16px, calc((100% - min(82vw, 320px)) / 2)) 20px;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: max(16px, calc((100% - min(82vw, 320px)) / 2));
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: none;
    touch-action: pan-x;
  }
  .level-grid::before { display: block; }
  .timeline-card {
    flex: 0 0 min(82vw, 320px);
    width: min(82vw, 320px);
    min-height: min(34vh, 260px);
    padding: 28px 14px 12px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(7, auto);
    gap: 4px;
    scroll-snap-align: center;
    scroll-snap-stop: always;
  }
  .timeline-card .timeline-dot { top: -17px; left: 50%; transform: translateX(-50%); }
  .timeline-card > strong { font-size: 22px; line-height: 1.05; }
  .timeline-card > small { min-height: 0; font-size: 9px; line-height: 1.35; }
  .timeline-card .map-badge { padding: 2px 6px; font-size: 8px; }
  .timeline-card .level-roster, .timeline-card .level-enemy { padding-top: 5px; line-height: 1.35; }
  .text-button { margin-top: 2px; }
}
/* Three Kingdoms weapon families */
.weapon[data-weapon="twin_swords"] {
  left: 54%; top: 35%; width: 56%; height: 7px; border-radius: 2px 7px 3px 2px;
  background: linear-gradient(180deg, #fff0c6, #b8873d 62%, #62401e);
  clip-path: polygon(0 24%, 84% 0, 100% 50%, 84% 100%, 0 76%);
  transform: translate(0, 0) rotate(38deg);
}
.weapon[data-weapon="twin_swords"]::before {
  content: ""; position: absolute; inset: 0; transform: rotate(-78deg); transform-origin: 18% 50%;
  background: linear-gradient(180deg, #f4e4b7, #a97938 62%, #5b3b1d);
  clip-path: polygon(0 24%, 84% 0, 100% 50%, 84% 100%, 0 76%);
}
.weapon[data-weapon="twin_swords"]::after {
  content: ""; position: absolute; left: 8%; top: 50%; width: 20%; height: 4px; border-radius: 3px;
  background: #8f5b28; transform: translateY(-50%);
}
.weapon[data-weapon="twin_ji"] {
  left: 50%; top: 39%; width: 64%; height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, #53351c 0 70%, #cfaa61 70% 100%);
  transform: rotate(36deg);
}
.weapon[data-weapon="twin_ji"]::before {
  content: ""; position: absolute; inset: 0; transform: rotate(-78deg); transform-origin: 18% 50%;
  background: linear-gradient(90deg, #53351c 0 70%, #cfaa61 70% 100%);
  border-radius: 4px;
}
.weapon[data-weapon="twin_ji"]::after {
  content: ""; position: absolute; right: -14%; top: 50%; width: 22%; height: 13px;
  background: #dcc06c; clip-path: polygon(0 50%, 100% 0, 72% 50%, 100% 100%); transform: translateY(-50%);
}
.weapon[data-weapon="halberd"] {
  width: 108%; height: 5px; border-radius: 5px;
  background: linear-gradient(90deg, #513620 0 75%, #cfa953 75% 100%);
  transform: translate(-2%, -50%) rotate(var(--lance-angle, -45deg)) translateX(var(--lance-thrust, 0px));
}
.weapon[data-weapon="halberd"]::before {
  content: ""; position: absolute; right: -8%; top: 50%; width: 23%; height: 14px;
  background: linear-gradient(180deg, #fff0b3, #b98d36 58%, #67441d);
  clip-path: polygon(0 50%, 100% 0, 72% 50%, 100% 100%); transform: translateY(-50%);
}
.weapon[data-weapon="halberd"]::after {
  content: ""; position: absolute; right: -24%; top: 50%; width: 34%; height: 19px;
  background: linear-gradient(180deg, #f6dc91, #6a8f62 62%, #274e38);
  clip-path: polygon(0 50%, 100% 0, 72% 50%, 100% 100%); transform: translateY(-50%);
}
.weapon[data-weapon="fan"] {
  left: 54%; top: 20%; width: 44%; height: 64%;
  --fan-light: #f7edd0; --fan-dark: #bda46d; --fan-rib: #80633a;
  background: repeating-linear-gradient(82deg, transparent 0 8%, rgba(116,87,45,.32) 8% 10%), radial-gradient(circle at 50% 100%, var(--fan-light), var(--fan-dark) 72%);
  clip-path: polygon(50% 100%, 0 34%, 15% 8%, 50% 0, 85% 8%, 100% 34%);
  border-radius: 48% 48% 10% 10%; transform: rotate(14deg);
}
.weapon[data-weapon="fan"]::after {
  content: ""; position: absolute; left: 48%; bottom: -18%; width: 5%; height: 28%; border-radius: 4px;
  background: var(--fan-rib); transform: translateX(-50%);
}
.weapon[data-weapon="banner"]::after { content: attr(data-mark); }
.weapon[data-variant="command_flag"]::after { color: #3f2a14; background: #e8d49b; border: 1px solid #9b7435; }
.weapon[data-variant="fire_flag"]::after { color: #fff0c2; background: #b64026; border: 1px solid #e6a24e; }
.weapon[data-variant="feather_fan"] { --fan-light: #fffdf2; --fan-dark: #d9d2b7; --fan-rib: #8a724b; }
.weapon[data-variant="dragon_spear"] { background: linear-gradient(90deg, #6f7f88 0 72%, #eef7ff 72% 100%); }
.weapon[data-variant="dragon_spear"]::after { background: #edf8ff; filter: drop-shadow(0 0 3px rgba(195,230,255,.75)); }
.weapon[data-variant="green_spear"] { background: linear-gradient(90deg, #2e604d 0 72%, #9fd3ae 72% 100%); }
.weapon[data-variant="green_spear"]::after { background: #b9dfb7; }
.weapon[data-variant="overlord_spear"] { background: linear-gradient(90deg, #6d2f1d 0 72%, #f0c768 72% 100%); }
.weapon[data-variant="tiger_spear"] { background: linear-gradient(90deg, #73501d 0 72%, #ffe18a 72% 100%); box-shadow: 0 0 4px rgba(223,172,63,.48); }
.weapon[data-variant="serpent_spear"]::after { clip-path: polygon(0 50%, 24% 18%, 42% 52%, 66% 12%, 100% 50%, 72% 88%, 48% 58%, 24% 88%); }
.weapon[data-variant="yitian_sword"] { background: linear-gradient(180deg, #fffdf0, #a9c3d8 62%, #41556b); }
.weapon[data-variant="guding_saber"], .weapon[data-variant="great_saber"] { background: linear-gradient(180deg, #f0d9a2, #9c642d 66%, #503116); }
.weapon[data-variant="wu_sword"] { background: linear-gradient(180deg, #fff3bf, #d2a950 54%, #6d4721); }
.weapon[data-variant="eagle_sword"] { background: linear-gradient(180deg, #e7edf6, #718aa4 58%, #263749); }
.weapon[data-variant="ring_blade"] { filter: drop-shadow(1px 0 0 #e9c26e) drop-shadow(-1px 0 0 #8d5a24); }
.weapon[data-variant="war_bow"] .bow-limb { stroke: #b9822f; }
.weapon[data-variant="fire_bow"] .bow-limb { stroke: #a24029; }
.weapon[data-variant="fire_bow"] .bow-string { stroke: #6d2b1d; }
.defender-token.attacking .weapon[data-weapon="blade"],
.defender-token.attacking .weapon[data-weapon="twin_swords"],
.defender-token.attacking .weapon[data-weapon="twin_ji"] { animation: weapon-swing .38s ease-out; }
.defender-token.attacking .weapon[data-weapon="spear"] { animation: weapon-thrust .44s ease-out; }
.defender-token.attacking .weapon[data-weapon="fan"],
.defender-token.attacking .weapon[data-weapon="banner"] { animation: weapon-cast .46s ease-out; }
@keyframes weapon-cast { 48% { filter: brightness(1.35) drop-shadow(0 0 5px rgba(224,187,102,.55)); transform: translate(4%, -108%) rotate(5deg) scale(1.08); } }
.projectile.twin_swords, .projectile.twin_ji { width: 5.6%; min-width: 23px; max-width: 40px; aspect-ratio: 1; }
.projectile.twin_swords i, .projectile.twin_ji i { position: absolute; left: 12%; top: 44%; width: 76%; height: 12%; border-radius: 3px; background: linear-gradient(90deg, #70451f, #e3c16d); transform: rotate(38deg); }
.projectile.twin_swords i::before, .projectile.twin_ji i::before { content: ""; position: absolute; inset: 0; transform: rotate(-76deg); background: linear-gradient(90deg, #70451f, #e3c16d); border-radius: 3px; }
.projectile.twin_swords i::after, .projectile.twin_ji i::after { content: ""; position: absolute; right: -18%; top: 50%; width: 28%; height: 140%; background: #e5ca79; clip-path: polygon(0 50%, 100% 0, 74% 50%, 100% 100%); transform: translateY(-50%); }
.projectile.halberd { width: 8.4%; min-width: 36px; max-width: 60px; aspect-ratio: 3 / 1; }
.projectile.halberd i { position: absolute; inset: 43% 0 auto; height: 4px; background: linear-gradient(90deg, #54371f 0 76%, #d4ad56 76% 100%); border-radius: 3px; }
.projectile.halberd i::before { content: ""; position: absolute; right: -9%; top: 50%; width: 25%; height: 16px; background: #e5ca79; clip-path: polygon(0 50%, 100% 0, 72% 50%, 100% 100%); transform: translateY(-50%); }
.projectile.halberd i::after { content: ""; position: absolute; right: -24%; top: 50%; width: 34%; height: 20px; background: linear-gradient(180deg, #f0d48b, #62865c); clip-path: polygon(0 50%, 100% 0, 72% 50%, 100% 100%); transform: translateY(-50%); }
.defender-token.cavalry .weapon[data-weapon="spear"] {
  transform: translate(2%, -50%) rotate(var(--lance-angle, -42deg)) translateX(var(--lance-thrust, 0px));
}
.defender-token.cavalry .weapon[data-weapon="blade"] {
  transform: translate(0, 0) rotate(var(--lance-angle, 38deg)) translateX(var(--lance-thrust, 0px));
}
.defender-token.attacking.cavalry .weapon { animation: none !important; will-change: transform; }
.weapon[data-weapon="fan"] { left: 56%; top: 25%; width: 38%; height: 55%; }
.weapon[data-weapon="twin_swords"],
.weapon[data-weapon="twin_ji"] {
  left: 50%; top: 50%; width: 66%; height: 66%; background: transparent; border: 0;
  clip-path: none; transform: translate(-50%, -50%); transform-origin: 50% 50%;
}
.weapon[data-weapon="twin_swords"]::before, .weapon[data-weapon="twin_swords"]::after,
.weapon[data-weapon="twin_ji"]::before, .weapon[data-weapon="twin_ji"]::after { content: none; display: none; }
.weapon-rig { display: block; width: 100%; height: 100%; overflow: visible; }
.defender-token.attacking .weapon[data-weapon="twin_swords"],
.defender-token.attacking .weapon[data-weapon="twin_ji"] { animation: twin-weapon-slash .38s ease-out; }
@keyframes twin-weapon-slash {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg) scale(1); filter: brightness(1); }
  46% { transform: translate(-46%, -54%) rotate(10deg) scale(1.08); filter: brightness(1.34); }
}