/* Village Battles — candy-plum dialog, mint shields, cherry axes, gold stars. */
:root {
  --battle-plum: #4a2842;
  --battle-plum-soft: #7b5a73;
  --battle-cream: #fff6ec;
  --battle-cream-2: #ffe9f2;
  --battle-cherry: #e0368f;
  --battle-cherry-deep: #9c1a5c;
  --battle-mint: #2fbfa2;
  --battle-mint-deep: #0b6f63;
  --battle-gold: #ffd447;
  --battle-gold-deep: #b97a06;
}

/* Header entry chip */
.battle-entry {
  position: relative; display: inline-flex; align-items: center; gap: .4rem;
  min-height: 44px; padding: .3rem .75rem .3rem .45rem; border-radius: 999px;
  border: 2px solid #fff; color: var(--battle-plum); font: inherit; font-weight: 800; cursor: pointer;
  background: linear-gradient(180deg, #fffaf3, var(--battle-cream-2));
  box-shadow: 0 3px 0 rgba(156, 26, 92, .35), inset 0 -2px 0 rgba(224, 54, 143, .12);
  transition: transform .15s ease;
}
.battle-entry:hover:not(:disabled) { transform: translateY(-1px); }
.battle-entry:active:not(:disabled) { transform: translateY(1px); }
.battle-entry:disabled { opacity: .6; cursor: not-allowed; }
.battle-entry:focus-visible, .battle-btn:focus-visible, .battle-target:focus-visible, .battle-back:focus-visible, .battle-skip:focus-visible, .map-battles-button:focus-visible {
  outline: 3px solid var(--battle-cherry); outline-offset: 3px;
}
.battle-entry-item { display: inline-flex; align-items: center; gap: .15rem; font-variant-numeric: tabular-nums; }
.battle-entry-item img { width: 22px; height: 22px; filter: drop-shadow(0 1px 0 rgba(74, 40, 66, .35)); }
.battle-entry-label { font-size: .78rem; letter-spacing: .02em; }
.battle-activity-dot {
  position: absolute; top: -3px; right: -3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--battle-cherry); border: 2px solid #fff;
}
.battle-entry.has-activity .battle-activity-dot { animation: battle-ping 1.6s ease-out 3; }
@keyframes battle-ping { 50% { transform: scale(1.35); } }

/* Map entry */
.first-attack-dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.first-attack-dialog .battle-shell { min-height: 0; max-height: calc(100dvh - 32px); }
.first-attack-dialog .battle-body { overflow-y: auto; }
.first-attack-dialog .battle-actions { flex-wrap: wrap; justify-content: center; }
.first-attack-dialog h2 { font-size: clamp(1.25rem, 5vw, 1.8rem); overflow-wrap: anywhere; }
html body[data-theme="adventure"][data-theme][data-theme] #firstAttackDialog { --vs-window-height: 540px; width: min(520px, calc(100vw - 32px)); }
.map-entry-options {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 14px; margin: 10px 14px 12px; flex: none; min-width: 0;
}
.map-entry-options:not(:has(> button:not([hidden]))) { display: none; }
body .candy-map .map-entry-options #mapSkinsButton.map-skins-button,
body .candy-map .map-entry-options #mapBattlesButton {
  margin: 0; width: fit-content; max-width: min(300px, calc(100% - 16px));
  min-width: 0; min-height: 44px; flex: 0 1 auto; box-sizing: border-box;
  overflow-wrap: anywhere;
}
body .candy-map .map-entry-options :is(#mapSkinsButton, #mapBattlesButton).map-skins-button {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 10px; row-gap: 2px;
}
body .candy-map .map-entry-options :is(#mapSkinsButton, #mapBattlesButton) .map-skins-button-label,
body .candy-map .map-entry-options :is(#mapSkinsButton, #mapBattlesButton) .map-skins-button-hint {
  grid-column: 1;
}
body .candy-map .map-entry-options :is(#mapSkinsButton, #mapBattlesButton) .map-skins-button-arrow {
  grid-column: 2; grid-row: 1 / span 2;
}
body .candy-map .map-entry-options #mapBattlesButton.map-skins-button {
  grid-template-columns: auto minmax(0, 1fr) auto;
}
.map-battles-button img { grid-column: 1; grid-row: 1 / span 2; width: 30px; height: 30px; }
body .candy-map .map-entry-options #mapBattlesButton :is(.map-skins-button-label, .map-skins-button-hint) { grid-column: 2; }
body .candy-map .map-entry-options #mapBattlesButton .map-skins-button-arrow { grid-column: 3; }
body .candy-map .map-entry-options :is(#mapBattlesButton, #mapSkinsButton):disabled {
  cursor: not-allowed; transform: none !important;
}
@media (max-width: 540px) {
  .map-entry-options { margin-inline: 10px; }
  body .candy-map .map-entry-options #mapBattlesButton.map-skins-button { grid-template-columns: minmax(0, 1fr) auto; }
  .map-entry-options .map-battles-button img { display: none; }
  body .candy-map .map-entry-options #mapBattlesButton :is(.map-skins-button-label, .map-skins-button-hint) { grid-column: 1; }
  body .candy-map .map-entry-options #mapBattlesButton .map-skins-button-arrow { grid-column: 2; }
}
@media (max-height: 480px) and (min-width: 541px) {
  /* Keep both entries in the available row on short/large-text windows.
     Their text wraps inside equal, shrinkable columns instead of pushing
     the second entry below the fixed-height map. */
  .map-entry-options { margin-block: 6px; flex-wrap: nowrap; }
  body .candy-map .map-entry-options :is(#mapSkinsButton, #mapBattlesButton).map-skins-button { flex: 1 1 0; }
}
@media (max-height: 480px) {
  /* At enlarged text sizes a long activity hint plus the toolbar can exceed
     the screen. Scroll the overview rather than clip an entry or its focus
     ring, and leave a usable map region below the navigation. */
  body .candy-map #mapOverview.map-overview { overflow-y: auto; }
  body .candy-map #mapOverview .map-host { flex: 1 0 160px; }
  .map-entry-options {
    /* Leave the floating help control its own gutter, including after scroll. */
    margin-right: max(76px, env(safe-area-inset-right));
    padding-block: 7px;
  }
}

/* Dialog */
.battle-dialog {
  width: min(680px, calc(100vw - 1rem)); max-width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); margin: auto; padding: 0; border: 0;
  border-radius: 26px; color: var(--battle-plum); background: var(--battle-cream);
  box-shadow: 0 24px 60px rgba(74, 40, 66, .35), 0 0 0 4px #fff;
  overflow: hidden;
}
.battle-dialog::backdrop { background: rgba(74, 40, 66, .45); backdrop-filter: blur(3px); }
.battle-shell { position: relative; display: flex; flex-direction: column; max-height: calc(100dvh - 1rem); }
.battle-head {
  display: flex; flex-wrap: wrap; gap: .5rem .75rem;
  align-items: center; padding: .85rem 1rem .7rem;
  background: radial-gradient(120% 140% at 0% 0%, #ffd2e6 0%, #ffb3d4 40%, #c9f5e8 100%);
  border-bottom: 3px solid #fff;
}
.battle-back {
  grid-area: back; min-height: 40px; padding: .3rem .8rem; border-radius: 999px; border: 2px solid #fff;
  background: rgba(255, 255, 255, .85); color: var(--battle-plum); font: inherit; font-weight: 800; cursor: pointer;
}
.battle-title { flex: 1 0 9em; min-width: 0; max-width: 100%; margin: 0; font-size: 1.35rem; font-weight: 900; letter-spacing: -.01em; overflow-wrap: anywhere; }
.battle-inventory { flex: 1 0 100%; display: flex; gap: .5rem; flex-wrap: wrap; }
.battle-inv {
  display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .65rem .25rem .3rem; border-radius: 14px;
  background: rgba(255, 255, 255, .85); border: 2px solid #fff; font-variant-numeric: tabular-nums;
}
.battle-inv img { width: 28px; height: 28px; }
.battle-inv b { display: block; font-size: 1rem; line-height: 1; }
.battle-inv small { display: block; font-size: .68rem; color: var(--battle-plum-soft); font-weight: 700; }
.battle-inv.is-shield b { color: var(--battle-mint-deep); }
.battle-inv.is-axe b { color: var(--battle-cherry-deep); }
.battle-inv.is-coins { padding-left: .6rem; }
.battle-inv.is-coins b { color: var(--battle-gold-deep); }
.battle-status { margin: 0; padding: .5rem 1rem; font-weight: 700; font-size: .9rem; min-height: 1.2em; }
.battle-status:empty { display: none; }
.battle-status[data-kind="error"] { background: #ffe3e9; color: #8f1238; }
.battle-body { overflow: auto; padding: .75rem 1rem 1.1rem; display: grid; gap: .75rem; }

.battle-card {
  background: #fff; border-radius: 20px; padding: .9rem 1rem; display: grid; gap: .55rem; min-width: 0; overflow-wrap: anywhere;
  box-shadow: 0 2px 0 rgba(224, 54, 143, .15), 0 8px 20px rgba(74, 40, 66, .08);
}
.battle-card h3 { margin: 0; font-size: 1.15rem; }
.battle-card p { margin: 0; line-height: 1.4; }
.battle-pending { background: #fff4d1; border: 2px dashed var(--battle-gold-deep); }
.battle-error { background: #fff0f3; }
.battle-note { font-size: .85rem; color: var(--battle-plum-soft); }
.battle-note.is-warn { color: #9a3b0a; font-weight: 700; }
.battle-how { font-size: .92rem; }
.battle-inline { width: 20px; height: 20px; vertical-align: -4px; }
.battle-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.battle-btn {
  position: relative; display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; padding: .45rem 1rem;
  border-radius: 999px; border: 2px solid #fff; font: inherit; font-weight: 800; cursor: pointer;
  color: var(--battle-plum); background: var(--battle-cream-2);
  box-shadow: 0 3px 0 rgba(74, 40, 66, .25); transition: transform .12s ease;
}
.battle-btn:hover:not(:disabled) { transform: translateY(-1px); }
.battle-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(74, 40, 66, .25); }
.battle-btn:disabled { opacity: .55; cursor: not-allowed; }
.battle-btn.is-primary { color: #fff; background: linear-gradient(180deg, #34d3b4, var(--battle-mint-deep)); box-shadow: 0 3px 0 #064a42; }
.battle-btn.is-attack { color: #fff; background: linear-gradient(180deg, #ff6fae, var(--battle-cherry-deep)); box-shadow: 0 3px 0 #640f3a; }
.battle-btn.is-small { min-height: 36px; padding: .25rem .75rem; font-size: .85rem; }
.battle-new { margin-left: .2rem; padding: 0 .4rem; border-radius: 999px; background: var(--battle-cherry); color: #fff; font-size: .7rem; }

.battle-hero { position: relative; height: 84px; display: flex; justify-content: center; align-items: center; }
.battle-hero img { width: 78px; height: 78px; filter: drop-shadow(0 6px 8px rgba(74, 40, 66, .25)); }
.battle-hero-axe { margin-left: -24px; transform: rotate(12deg); }
.battle-rules { margin: 0; padding-left: 1.2rem; display: grid; gap: .3rem; font-size: .92rem; }
.battle-empty-state, .battle-join { text-align: center; justify-items: center; }
.battle-join .battle-rules { text-align: left; }
.battle-empty { text-align: center; color: var(--battle-plum-soft); }

.battle-damage.is-clear { display: flex; align-items: center; gap: .5rem; background: #effdf8; color: var(--battle-mint-deep); font-weight: 700; }
.battle-damage-list { margin: 0; padding: 0; list-style: none; display: grid; gap: .3rem; }
.battle-damage-list li { display: flex; justify-content: space-between; gap: .5rem; align-items: center; font-size: .9rem; }
.battle-stars { display: inline-flex; gap: 2px; }
.battle-star { width: 18px; height: 18px; }
.battle-star.is-unearned { opacity: .22; filter: grayscale(1); }

/* Opponent village */
.battle-opp-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; }
.battle-opp-name { font-size: 1.15rem; }
.battle-opp-village { font-size: .85rem; color: var(--battle-plum-soft); }
.battle-stage {
  position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; padding: .7rem;
  border-radius: 18px; overflow: visible;
  background: linear-gradient(180deg, var(--b-sky, #cdeffd) 0 55%, var(--b-land, #bfeaa0) 55%);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .06);
}
.battle-target {
  position: relative; display: grid; justify-items: center; gap: .15rem; padding: .4rem .25rem .5rem; min-height: 44px; min-width: 0;
  border-radius: 16px; border: 3px solid transparent; background: rgba(255, 255, 255, .6); cursor: pointer;
  font: inherit; color: var(--battle-plum); transition: transform .15s ease, border-color .15s ease;
}
.battle-target:hover:not(:disabled) { transform: translateY(-2px); border-color: #fff; }
.battle-target.is-selected { border-color: var(--battle-cherry); background: #fff; box-shadow: 0 0 0 3px rgba(224, 54, 143, .25); }
.battle-target:disabled { cursor: not-allowed; }
.battle-target:disabled .battle-target-art { opacity: .7; }
.battle-target-art { display: block; width: 100%; aspect-ratio: 1; }
.battle-target-art > * { width: 100%; height: 100%; display: block; }
.battle-target-art.is-damaged { filter: saturate(.75); }
.battle-target-name { font-size: .78rem; font-weight: 800; text-align: center; line-height: 1.15; overflow-wrap: anywhere; max-width: 100%; }
.battle-target-meta { font-size: .68rem; color: var(--battle-plum-soft); font-weight: 700; overflow-wrap: anywhere; max-width: 100%; }

/* History */
.battle-history { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.battle-history-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; padding: .6rem .75rem;
  border-radius: 16px; background: #fff; border-left: 5px solid var(--battle-cherry);
}
.battle-history-item.is-blocked { border-left-color: var(--battle-mint); }
.battle-history-item.is-outgoing { background: #fffaf3; }
.battle-history-icon { width: 30px; height: 30px; }
.battle-history-text { display: grid; gap: .1rem; font-size: .88rem; }
.battle-history-text small { color: var(--battle-plum-soft); }

/* Skeleton */
.battle-skeleton { gap: .5rem; }
.battle-skel-line { display: block; height: 14px; border-radius: 8px; background: linear-gradient(90deg, #ffe9f2, #fff, #ffe9f2); background-size: 200% 100%; animation: battle-shimmer 1.2s linear infinite; }
.battle-skel-line:nth-child(2) { width: 80%; } .battle-skel-line:nth-child(3) { width: 60%; }
@keyframes battle-shimmer { to { background-position: -200% 0; } }

/* Effects */
.battle-fx { position: absolute; right: 1rem; bottom: 1rem; z-index: 5; }
.battle-skip {
  min-height: 44px; padding: .4rem 1.1rem; border-radius: 999px; border: 2px solid #fff; cursor: pointer;
  font: inherit; font-weight: 800; color: #fff; background: rgba(74, 40, 66, .85);
}
.battle-strike-layer, .battle-repair-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.battle-axe { position: absolute; left: 0; top: 0; width: 76px; height: 76px; filter: drop-shadow(0 6px 6px rgba(74, 40, 66, .35)); }
.battle-barrier {
  position: absolute; width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle, rgba(228, 255, 246, .9) 0 35%, rgba(94, 226, 196, .45) 60%, rgba(94, 226, 196, 0) 72%);
  border: 3px solid rgba(255, 255, 255, .9);
}
.battle-barrier-icon { width: 56px; height: 56px; }
.battle-debris { position: absolute; width: 10px; height: 10px; border-radius: 3px; border: 1.5px solid rgba(74, 40, 66, .4); }
.battle-star-half { position: absolute; width: 22px; height: 22px; }
.battle-star-half.is-left { clip-path: inset(0 50% 0 0); }
.battle-star-half.is-right { clip-path: inset(0 0 0 50%); }
.battle-coin {
  position: absolute; width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff7c2, #f2c94c 55%, #b98a10); border: 2px solid #8a5a14;
}
.battle-float { position: absolute; font-weight: 900; color: var(--battle-mint-deep); text-shadow: 0 1px 0 #fff; white-space: nowrap; }
.battle-sparkle { position: absolute; bottom: 25%; width: 10px; height: 10px; background: var(--battle-gold); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }
.battle-repair-star { position: absolute; left: 50%; top: 10%; width: 34px; height: 34px; }

/* Village damage (map village view) */
.village-plot-rubble { position: absolute; left: 10%; right: 10%; bottom: 6%; height: 22%; pointer-events: none; }
.village-rubble-chunk { position: absolute; bottom: 0; width: 18%; height: 60%; border-radius: 30% 40% 20% 35%; background: linear-gradient(160deg, #ffc1dc, #c7568d); border: 2px solid #7a1f4e; transform: rotate(-12deg); }
.village-rubble-chunk.is-1 { left: 18%; height: 45%; transform: rotate(18deg); background: linear-gradient(160deg, #fff1b8, #d9a21c); border-color: #8a5a14; }
.village-rubble-chunk.is-2 { left: 40%; height: 70%; transform: rotate(-4deg); }
.village-rubble-chunk.is-3 { left: 62%; height: 40%; transform: rotate(25deg); background: linear-gradient(160deg, #c9fff0, #2fbfa2); border-color: #0b6f63; }
.village-rubble-chunk.is-4 { left: 80%; height: 50%; transform: rotate(-20deg); }
.village-plot.is-damaged .village-plot-art { filter: saturate(.8); }
.village-plot.is-ruined .village-plot-art { opacity: .55; }
.village-pip.is-broken { background: #e9dfe8 !important; box-shadow: inset 0 0 0 2px #8b6f88; position: relative; }
.village-pip.is-broken::after { content: ""; position: absolute; inset: 20% 45%; background: #8b6f88; transform: rotate(25deg); }
.village-repair-tag { display: block; font-size: .68rem; font-weight: 800; color: #8f1238; }
.village-plaque-cost.is-repair { background: linear-gradient(180deg, #e4fff6, #9cf0da); color: var(--battle-mint-deep); }
.map-node.needs-repair, .needs-repair { position: relative; }
.needs-repair::after {
  content: attr(data-repair); position: absolute; top: -8px; right: -10px; z-index: 3; padding: 0 .35rem; border-radius: 999px;
  font-size: .62rem; font-weight: 900; color: #fff; background: var(--battle-cherry); border: 2px solid #fff; pointer-events: none;
}

/* Keno board loot badges */
#numberGrid .number-label { pointer-events: none; }
#gameApp #numberGrid .number.has-battle-badge { position: relative; }
#numberGrid .has-battle-badge > .number-label {
  /* The button keeps its numeric accessible name and pick value. Artwork,
     not a corner numeral, is the visible primary content of symbol tiles. */
  visibility: hidden;
}
html body #gameApp #numberGrid button.number.has-battle-badge:is(.is-selected, .is-match)::after {
  z-index: 4;
}
#numberGrid .battle-badge {
  /* The available tile height, not its width, bounds the artwork below the
     check/star, including the thicker hit border in high-contrast mode. */
  position: absolute; top: 50%; left: 50%; width: auto; height: 72%;
  max-width: 72%; aspect-ratio: 1; z-index: 1; translate: -50% -50%;
  pointer-events: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--badge-face); border: 2px solid var(--badge-ink);
  box-sizing: border-box; box-shadow: 0 1px 0 var(--badge-ink);
  opacity: 1; filter: none;
}
#numberGrid .battle-badge.is-shield { --badge-face: #ddfff3; --badge-ink: #085c50; }
#numberGrid .battle-badge.is-axe { --badge-face: #ffe1ed; --badge-ink: #7d0f3e; }
#numberGrid .battle-badge.is-raid { --badge-face: #fff0a6; --badge-ink: #67410f; }
#numberGrid .battle-badge img { display: block; width: 100%; height: 100%; }
/* Clip the light to the badge's inner face, not the button, artwork or rim.
   The full-colour SVG stays opaque underneath a white/gold diagonal stripe. */
#numberGrid .battle-badge-shimmer-clip {
  position: absolute; inset: 0; border-radius: inherit; overflow: hidden;
  pointer-events: none;
}
#numberGrid .battle-badge-shimmer {
  background: linear-gradient(120deg, transparent 34%, #ffe38d99 43%,
    #fff9df 48%, #ffffff 51%, #ffe38daa 58%, transparent 67%);
}
#numberGrid .battle-badge.is-collected { box-shadow: 0 0 0 2px #f9c435, 0 2px 0 var(--badge-ink); }
#numberGrid .battle-badge.is-full { border-style: double; border-width: 3px; }
#numberGrid .battle-badge.is-missed { border-style: dashed; }
/* Last-round receipts are rounded squares, not faded current opportunities.
   Retain each outcome's solid/double/dashed edge and the full-colour artwork. */
#numberGrid .battle-badge.is-historical { border-radius: 7px; box-shadow: 0 0 0 1px var(--badge-ink); }
#numberGrid .battle-badge.is-historical.is-collected { box-shadow: 0 0 0 2px #f9c435; }
@media (forced-colors: active) {
  /* Bundled SVG colours remain readable on a known opaque surface; the outer
     edge still follows the user's high-contrast palette. */
  #numberGrid .battle-badge { forced-color-adjust: none; outline: 1px solid CanvasText; outline-offset: 1px; }
}
/* Routine live/final/history feedback uses .sr-only, never a results row.
   Keep this free of surface or spacing styles so themes cannot leave a strip. */

@media (max-width: 767px) {
  .battle-dialog { width: calc(100vw - .5rem); max-width: calc(100vw - .5rem); border-radius: 20px; }
  .battle-stage { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .battle-history-item { grid-template-columns: auto 1fr; }
  .battle-history-item .battle-btn { grid-column: 1 / -1; justify-self: start; }
  .battle-entry-label { display: none; }
}
@media (min-width: 1025px) {
  body:not([data-theme="adventure"]) #gameApp .header {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, .9fr) minmax(0, 1.4fr) auto auto;
  }
  body:not([data-theme="adventure"]) .battle-entry { padding-inline: .4rem; gap: .2rem; }
  body:not([data-theme="adventure"]) .battle-entry-label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .battle-entry.has-activity .battle-activity-dot, .battle-skel-line { animation: none; }
  .battle-btn, .battle-target, .battle-entry { transition: none; }
}

/* Attack chooser (parchment panel, ribbon, tabs, rows) — scoped to .is-attack-menu */
.battle-dialog.is-attack-menu .battle-head { gap: .4rem .6rem; }
.battle-dialog.is-attack-menu .battle-body { padding: .6rem .75rem 1rem; gap: .6rem; overscroll-behavior: contain; }
.battle-menu { display: grid; gap: .6rem; min-width: 0; }
.battle-menu-heading { display: grid; justify-items: center; text-align: center; gap: .15rem; }
.battle-menu-heading p { margin: 0; font-size: .85rem; color: var(--battle-plum-soft); overflow-wrap: anywhere; }
.battle-menu-eyebrow { font-size: .68rem; font-weight: 900; letter-spacing: .14em; color: var(--battle-cherry-deep); }
.battle-menu-ribbon {
  position: relative; margin: .2rem 0; padding: .35rem 1.6rem; font-size: 1.3rem; font-weight: 900; color: #fff;
  background: linear-gradient(180deg, #ff6fae, var(--battle-cherry-deep)); border-radius: 6px;
  text-shadow: 0 2px 0 rgba(100, 15, 58, .6); box-shadow: 0 3px 0 #640f3a; overflow-wrap: anywhere;
  clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 50%, 100% 100%, 0 100%, 12px 50%);
}
.battle-menu-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.battle-menu-tab {
  min-height: 44px; padding: .3rem .5rem; border-radius: 12px; border: 2px solid #fff; font: inherit; font-weight: 900;
  cursor: pointer; color: var(--battle-mint-deep); background: #e4fff6; box-shadow: 0 3px 0 rgba(11, 111, 99, .35);
}
.battle-menu-tab[aria-selected="true"] { color: #fff; background: linear-gradient(180deg, #34d3b4, var(--battle-mint-deep)); box-shadow: 0 3px 0 #064a42; }
.battle-menu-tab:focus-visible, .battle-menu-panel:focus-visible { outline: 3px solid var(--battle-cherry); outline-offset: 3px; }
.battle-menu-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .6rem; margin: 0;
  padding: .5rem .6rem; border-radius: 14px; background: #fff; border: 2px solid #f6dcc8;
  box-shadow: 0 2px 0 rgba(224, 54, 143, .12);
}
.battle-menu-row.is-random { background: #fff4d1; border-color: var(--battle-gold); }
.battle-menu-avatar {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; flex: none;
  font-weight: 900; color: #fff; border: 2px solid #fff; box-shadow: 0 2px 0 rgba(74, 40, 66, .25);
  background: var(--battle-cherry);
}
.battle-menu-avatar.is-color-1 { background: var(--battle-mint-deep); }
.battle-menu-avatar.is-color-2 { background: var(--battle-gold-deep); }
.battle-menu-avatar.is-color-3 { background: var(--battle-plum-soft); }
.battle-menu-avatar.is-random { background: #fff; }
.battle-menu-avatar img { width: 30px; height: 30px; }
.battle-menu-person { display: grid; gap: .05rem; min-width: 0; font-size: .85rem; overflow-wrap: anywhere; }
.battle-menu-person strong { font-size: .95rem; }
.battle-menu-person small, .battle-menu-person time, .battle-menu-outcome { color: var(--battle-plum-soft); font-size: .75rem; }
.battle-menu-action { justify-content: center; min-width: 86px; color: #fff; }
.battle-menu-action.is-random { background: linear-gradient(180deg, #ffb64a, #d9780b); box-shadow: 0 3px 0 #8a4a05; }
.battle-menu-action.is-revenge { background: linear-gradient(180deg, #ff6fae, var(--battle-cherry-deep)); box-shadow: 0 3px 0 #640f3a; }
.battle-menu-panel {
  display: grid; gap: .5rem; padding: .6rem; border-radius: 16px; min-width: 0;
  background: linear-gradient(180deg, #f9ecd6, #f3dfc2); border: 2px solid #e8cfae;
}
.battle-menu-list-title { margin: 0; font-size: .9rem; }
.battle-menu-list { list-style: none; margin: 0; padding: 0 .2rem 0 0; display: grid; gap: .45rem; }
.battle-menu-list.is-attackers { max-height: min(46dvh, 320px); overflow: auto; overscroll-behavior: contain; }
.battle-menu-empty { margin: 0; font-size: .85rem; color: var(--battle-plum-soft); text-align: center; }
.battle-menu-error { display: grid; justify-items: start; gap: .4rem; padding: .5rem; border-radius: 12px; background: #fff0f3; }
.battle-menu-error p { margin: 0; }
.battle-menu-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.battle-menu-footer small { color: var(--battle-plum-soft); }
@media (max-width: 350px) {
  .battle-menu-row { grid-template-columns: auto minmax(0, 1fr); }
  .battle-menu-row .battle-menu-action { grid-column: 1 / -1; width: 100%; }
  .battle-menu-ribbon { padding-inline: 1.3rem; font-size: 1.1rem; }
}
@media (forced-colors: active) {
  .battle-menu-tab[aria-selected="true"] { border-color: Highlight; outline: 2px solid Highlight; }
  .battle-menu-row, .battle-menu-panel, .battle-menu-avatar { border: 2px solid CanvasText; forced-color-adjust: none; background: Canvas; color: CanvasText; }
  .battle-menu-ribbon { clip-path: none; border: 2px solid CanvasText; background: Canvas; color: CanvasText; text-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { .battle-menu * { transition: none !important; animation: none !important; } }

/* ===== Village attack mode: reuses the own-village diorama; axes replace hammers ===== */
#battleDialog.is-village-attack { width: min(560px, calc(100vw - .5rem)); }
#battleDialog.is-village-attack .battle-body { padding: .5rem .5rem .9rem; overscroll-behavior: contain; }
#battleDialog.is-village-attack .battle-opponent { padding: .6rem .5rem .7rem; overflow: visible; }
#battleDialog.is-village-attack .battle-opp-head { padding-inline: .35rem; }
/* neutralise the legacy 4-up grid stage so scene geometry is untouched */
#battleDialog.is-village-attack .battle-stage.battle-village-host {
  display: block; position: relative; padding: 0; gap: 0; background: none; box-shadow: none; border-radius: 0; overflow: visible; min-width: 0;
}
#battleDialog.is-village-attack .candy-village.is-battle-village { padding: 4px 4px 8px; gap: 6px; min-height: 0; flex: none; max-width: 100%; }
#battleDialog.is-village-attack .candy-village .village-stagewrap { --v-stage-min: 420px; flex: none; height: calc(var(--v-stage-min) + var(--v-frame-bottom)); }
/* hidden build UI */
#battleDialog.is-village-attack .candy-village :is(.village-head, .village-back, .village-next, .village-status, .village-note, .village-done, .village-lockveil, .village-plaque-cost, .village-plaque-level, .village-plaque-row .village-plaque-level, .village-repair-tag, .village-hammer) { display: none !important; }
#battleDialog.is-village-attack .candy-village.is-complete .village-scene { box-shadow: 0 0 0 5px #fff4dc, 0 0 0 7px #ffc7dc, 0 9px 0 7px #c9246a, 0 20px 34px rgba(123, 30, 90, .3); }
/* target buttons: restore plot geometry over old .battle-target rules */
#battleDialog.is-village-attack .candy-village .village-plot.battle-target {
  position: absolute; display: block; width: var(--v-bw); min-height: 44px; min-width: 44px; padding: 0; gap: 0;
  border: 0; border-radius: 18px; background: transparent; box-shadow: none; justify-items: initial;
  transform: translate(-50%, -92%) !important; transition: none; color: inherit;
}
#battleDialog.is-village-attack .candy-village .village-plot.battle-target:hover:not(:disabled) { border: 0; transform: translate(-50%, -92%) !important; }
#battleDialog.is-village-attack .candy-village .village-plot.battle-target.is-selected { background: transparent; box-shadow: none; border: 0; }
#battleDialog.is-village-attack .candy-village .village-plot.battle-target.is-selected .village-plot-stage { filter: drop-shadow(0 0 0 #fff) drop-shadow(0 0 5px var(--battle-cherry)) drop-shadow(0 0 2px #fff); }
#battleDialog.is-village-attack .candy-village .village-plot.battle-target.is-selected .village-plaque { border-color: var(--battle-cherry); box-shadow: 0 3px 0 var(--battle-cherry-deep), 0 0 0 3px #fff; }
#battleDialog.is-village-attack .candy-village .village-plot.battle-target:disabled,
#battleDialog.is-village-attack .candy-village .village-plot.battle-target[aria-disabled="true"] { cursor: not-allowed; }
#battleDialog.is-village-attack .candy-village .village-plot.battle-target:disabled .village-plot-art { opacity: .7; }
#battleDialog.is-village-attack .candy-village .village-plot-art.battle-target-art { position: absolute; inset: 0; width: auto; aspect-ratio: auto; display: block; }
#battleDialog.is-village-attack .candy-village .village-plot-art.battle-target-art > * { width: 100%; height: 100%; display: block; }
/* battleaxe control, same corner slots as the hammer */
#battleDialog.is-village-attack .candy-village .village-battleaxe {
  position: absolute; top: 4%; right: 4%; z-index: 3; display: grid; place-items: center; pointer-events: none;
  width: 24%; min-width: 34px; max-width: 54px; aspect-ratio: 1; border-radius: 50%;
  background: #fff8e8; border: 2px solid var(--battle-cherry); box-shadow: 0 3px 0 var(--battle-cherry-deep), 0 4px 8px rgba(74, 40, 66, .3);
}
#battleDialog.is-village-attack .candy-village .village-battleaxe img { width: 78%; height: 78%; display: block; transform: rotate(-12deg); }
#battleDialog.is-village-attack .candy-village .village-plot.is-right .village-battleaxe { right: auto; left: 4%; }
#battleDialog.is-village-attack .candy-village .village-plot.is-right .village-battleaxe img { transform: scaleX(-1) rotate(-12deg); }
#battleDialog.is-village-attack .candy-village .village-plot:is([data-index="2"], [data-index="3"]) .village-battleaxe { top: max(14%, calc(66px - 13%)); left: 6%; right: auto; }
#battleDialog.is-village-attack .candy-village .village-plot.is-right:is([data-index="2"], [data-index="3"]) .village-battleaxe { left: auto; right: 6%; }
#battleDialog.is-village-attack .candy-village .village-plot.battle-target.is-selected .village-battleaxe { background: var(--battle-cherry); border-color: #fff; }
#battleDialog.is-village-attack .candy-village .village-plot.battle-target:not(:disabled):not(.is-selected) .village-battleaxe { animation: battle-axe-bob 1.6s ease-in-out infinite; }
#battleDialog.is-village-attack .candy-village .village-plot.battle-target:disabled .village-battleaxe,
#battleDialog.is-village-attack .candy-village .village-plot.battle-target[aria-disabled="true"] .village-battleaxe { filter: grayscale(.9); opacity: .6; animation: none; border-style: dashed; }
@keyframes battle-axe-bob { 50% { transform: translateY(-3px); } }
/* plaque: name, three stars, earned/intact meta */
#battleDialog.is-village-attack .candy-village .village-plaque { max-width: 150%; min-width: 0; padding: 2px 6px 3px; }
#battleDialog.is-village-attack .candy-village .village-plaque .battle-target-name { font-family: var(--v-font); font-size: clamp(.62rem, 2.4vw, .8rem); font-weight: 700; color: var(--ck-purple-dark, #4e2193); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#battleDialog.is-village-attack .candy-village .village-plaque .battle-stars { display: inline-flex; gap: 2px; }
#battleDialog.is-village-attack .candy-village .village-plaque img.battle-star.village-pip { width: 14px; height: 14px; border-radius: 0; background: none; box-shadow: none; }
#battleDialog.is-village-attack .candy-village .village-plaque .battle-target-meta { display: block; font-size: .62rem; line-height: 1.15; font-weight: 800; color: var(--battle-plum); white-space: nowrap; }
/* focus */
#battleDialog.is-village-attack .candy-village .village-plot.battle-target:focus-visible { outline: 4px solid var(--v-focus, #2b1a5c) !important; outline-offset: 3px !important; box-shadow: 0 0 0 7px #fff !important; z-index: 200 !important; }
/* actions below the scene */
#battleDialog.is-village-attack .battle-actions { justify-content: center; }
#battleDialog.is-village-attack [data-battle="attack"] { min-height: 48px; }
@media (max-width: 560px) {
  #battleDialog.is-village-attack .candy-village .village-stagewrap { --v-stage-min: 340px; }
  #battleDialog.is-village-attack .candy-village .village-battleaxe { min-width: 36px; }
}
@media (max-width: 350px) {
  #battleDialog.is-village-attack .battle-body { padding-inline: .25rem; }
  #battleDialog.is-village-attack .candy-village .village-stagewrap { --v-stage-min: 296px; }
  #battleDialog.is-village-attack .candy-village .village-plaque .battle-target-meta { font-size: .58rem; }
  #battleDialog.is-village-attack .candy-village .village-plaque img.battle-star.village-pip { width: 12px; height: 12px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  #battleDialog.is-village-attack .candy-village .village-stagewrap { --v-stage-min: 300px; }
  #battleDialog.is-village-attack { width: min(560px, calc(100vw - 1rem)); }
}
@media (prefers-reduced-motion: reduce) {
  #battleDialog.is-village-attack .candy-village .village-battleaxe { animation: none !important; }
}
@media (forced-colors: active) {
  #battleDialog.is-village-attack .candy-village .village-battleaxe { forced-color-adjust: none; background: Canvas; border: 2px solid CanvasText; }
  #battleDialog.is-village-attack .candy-village .village-plot.battle-target.is-selected .village-battleaxe { background: Highlight; border-color: HighlightText; }
  #battleDialog.is-village-attack .candy-village .village-plot.battle-target:focus-visible { outline-color: Highlight !important; }
  #battleDialog.is-village-attack .candy-village .village-plaque { forced-color-adjust: none; background: Canvas; color: CanvasText; border: 2px solid CanvasText; }
  #battleDialog.is-village-attack .candy-village .village-plaque .battle-target-name, #battleDialog.is-village-attack .candy-village .village-plaque .battle-target-meta { color: CanvasText; }
}
/* Finished builder landmarks hide their pips; battle targets must keep all
   three stars visible, including the star that the strike will break. */
#battleDialog.is-village-attack .candy-village .village-plot.is-max .village-plaque-row { display: inline-flex; }

/* Browsable targets + illustrated avatars */
.battle-targets { display: grid; gap: .45rem; min-width: 0; padding: .6rem; border-radius: 16px; background: #fff8ef; border: 2px solid #f6dcc8; text-align: left; justify-self: stretch; }
.battle-targets-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem .6rem; }
.battle-targets-head small { color: var(--battle-plum-soft); font-size: .75rem; }
.battle-menu-list.is-targets { max-height: min(42dvh, 300px); overflow: auto; overscroll-behavior: contain; }
.battle-menu-avatar.is-illustrated, .battle-opp-avatar { padding: 0; overflow: hidden; background: none; }
.battle-opp-avatar { display: inline-block; width: 36px; height: 36px; border-radius: 10px; border: 2px solid #fff; box-shadow: 0 2px 0 rgba(74, 40, 66, .25); align-self: center; }
.battle-avatar-svg { display: block; width: 100%; height: 100%; }
.battle-target-status { font-size: .75rem; font-weight: 800; color: var(--battle-mint-deep); }
.battle-target-status.is-repairing, .battle-opp-repairing { color: #9a3b0a; }
.battle-opp-repairing { font-size: .8rem; font-weight: 800; }
.battle-menu-row.is-repairing { background: #fbf4ee; border-style: dashed; }
.battle-menu-row.is-repairing .battle-menu-avatar { filter: saturate(.55); }
.battle-menu-action.is-preview { background: linear-gradient(180deg, #34d3b4, var(--battle-mint-deep)); box-shadow: 0 3px 0 #064a42; }
.battle-menu-row.is-repairing .battle-menu-action.is-preview { background: linear-gradient(180deg, #b79bb0, var(--battle-plum-soft)); box-shadow: 0 3px 0 #4a2842; }
.battle-menu-row.is-skeleton { grid-template-columns: 1fr; gap: .35rem; }
.battle-menu-empty.is-repairing { color: #9a3b0a; font-weight: 700; }
@media (max-width: 350px) { .battle-targets { padding: .45rem; } }
@media (forced-colors: active) { .battle-targets { border: 2px solid CanvasText; } .battle-avatar-svg { forced-color-adjust: none; } }
