#master-level-editor { display:grid; gap:.65rem; min-width:0; }
#lab-setup {display:grid;gap:.8rem}
#lab-setup fieldset {min-width:0;margin:0;padding:.7rem .85rem;border:1px solid #506c5e;border-radius:.6rem}
#lab-setup legend {color:#f0ce87;font-weight:700}
#lab-setup label {display:grid;gap:.2rem;margin:.35rem 0;min-width:0}
#lab-setup :is(input,select) {box-sizing:border-box;width:100%;min-width:0;padding:.4rem;border-radius:.3rem;font:inherit}
.lab-pair,.lab-skill {display:grid;grid-template-columns:1fr 1fr;gap:.5rem}
.lab-skill {grid-template-columns:minmax(0,1fr) 4.5rem}
.lab-skill small {grid-column:1/-1;color:#d6c7a6;line-height:1.4;overflow-wrap:anywhere}
#lab-setup small:empty {display:none}
#lab-setup label:has(>input[type=checkbox]),#lab-freeze-controls label:has(input[type=checkbox]) {display:flex;align-items:center;gap:.5rem}
#lab-setup input[type=checkbox] {width:auto}
#lab-drag {cursor:grab;width:100%;border-style:dashed;color:#f3d593}
#lab-build-charms,#lab-freeze-controls {margin:0;border:1px solid #506c5e;padding:.65rem;border-radius:.5rem}
#lab-freeze-controls label {display:grid;gap:.25rem;margin:.35rem 0}
#lab-freeze-controls select {width:100%;min-width:0;font:inherit}
#lab-replay .battle-actions {margin:.45rem 0}
#lab-setup .lab-start-bar {position:sticky;bottom:0;background:#142423;padding:.6rem 0;border-top:1px solid #647567;z-index:1}
@media(min-width:900px){
  #battle.in-test-lab .battle-layout:has(#lab-setup:not([hidden])) {max-width:1500px;grid-template-columns:minmax(0,1fr) minmax(350px,26%)}
  #battle.in-test-lab aside:has(>#lab-setup:not([hidden])) {position:sticky;top:8px;max-height:calc(100vh - 50px);overflow:auto;box-sizing:border-box}
}
#lab-status {margin:0;color:#efd49a}
#lab-replay {margin-bottom:.8rem}
.in-test-lab :is(#lab-studio,#lab-presets,#lab-debug) {margin:.4rem 0;padding:.55rem .7rem;border:1px solid #506c5e;border-radius:.5rem}
.in-test-lab summary {cursor:pointer;color:#f0ce87;font-weight:bold}
.lab-controls {display:grid;gap:.45rem;margin-top:.55rem}
.lab-controls label {display:grid;gap:.15rem;min-width:0}
.lab-controls select,.lab-controls input:not([type=checkbox]) {box-sizing:border-box;width:100%;min-width:0;padding:.35rem;font:inherit}
.lab-controls label:has(input[type=checkbox]),#lab-setup .lab-controls label:has(input[type=checkbox]) {display:flex;align-items:center;gap:.45rem}
#lab-setup .lab-controls input[type=checkbox] {width:auto;order:-1}
.lab-controls details {border-top:1px solid #496151;padding:.4rem 0}
.lab-controls output,#lab-debug-note {display:block;color:#f2cf94;font-size:.9em}
.lab-studio-layer {z-index:8;pointer-events:none}
.lab-previewing .tile-art .battle-token {visibility:hidden}
.lab-pivot,.lab-foot {position:absolute;z-index:2;pointer-events:none}
.lab-pivot {width:7px;height:7px;border:1px solid #15221b;background:#ffca52;border-radius:50%;transform:translate(-50%,50%)}
.lab-foot {left:12%;right:12%;bottom:30%;border-top:1px dashed #8fe9d3}
#battle-grid .lab-choice {--rim:#ffe5a4;--grid-line-inset:5%}
#battle-grid .lab-gate {--rim:#f7af5b;--paint:repeating-linear-gradient(45deg,#e99a453d 0 4px,transparent 4px 10px)}
#battle-grid .lab-raised .tile-hit {background-color:#82996c99;box-shadow:inset 0 -7px #495b3c}
#battle-grid.grid-lines-hidden :is(.lab-choice,.lab-gate) .tile-hit::after {opacity:1}
#battle.in-test-lab :is(#combat-settings,#combat-layers) {display:none}
#master-level-editor[hidden],#master-play-report[hidden] { display:none; }
#master-level-editor fieldset,#master-level-editor details { min-width:0; margin:.4rem 0; }
#master-level-editor fieldset { border:1px solid #516957; border-radius:.55rem; padding:.7rem; }
#master-level-editor legend,#master-level-editor summary { color:#ead69f; }
#master-level-editor label { display:grid; gap:.25rem; margin:.4rem 0; min-width:0; }
#master-level-editor label:has(input[type=checkbox]) {display:flex; align-items:center;gap:.6rem;}
#master-level-editor input:not([type=checkbox]),#master-level-editor select { box-sizing:border-box; min-width:0; width:100%; }
.master-tabs,.master-buttons { display:flex; flex-wrap:wrap; gap:.35rem; }
#master-level-editor button { padding:.4rem .6rem; }
#master-level-editor:has(.boss-placement-tools) { padding:0; border:0; background:transparent; }
.boss-placement-tools { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,6rem),1fr)); gap:.4rem; }
.boss-placement-tools :is(label,small,#master-place-boss) { grid-column:1/-1; }
#master-level-editor [aria-pressed=true] { border-color:#e6bc65;background:#41543c; }
#master-level-editor [data-feedback] { white-space:pre-line; overflow-wrap:anywhere; }
.master-pin {position:absolute; left:50%; top:50%; transform:translate(-50%,-60%); color:#ffe2a1; background:#1e352e; border:1px solid #c1a265; padding:0 .22em; border-radius:3px;pointer-events:none;font-weight:700;}
#master-play-report { padding:.4rem 0; }
.master-pin b {padding:0 .08em;color:#a4e6c5;}
.master-pin [data-overlay=attack],.master-pin [data-overlay=overlap],.master-pin [data-overlay=hazard],.master-pin [data-overlay=pit] {color:#ffa98c;}
.master-pin [data-overlay=walk],.master-pin [data-overlay=hero],.master-pin [data-overlay=root] {color:#9dd9ff;}
#battle {
  --tile-pit: url("tilemap/spike-pit.png");
  position: absolute;
  inset: 0 0 auto;
  min-height: 100dvh;
  padding: clamp(14px, 3vw, 40px);
  border: 0;
  border-radius: 0;
  background: radial-gradient(ellipse at 15% 0, #293d34, #101b1b 62%);
  color: #fff2d5;
}
#battle button:disabled { opacity: .46; cursor: default; }
.battle-header, .battle-layout { max-width: 1200px; margin-inline: auto; display: grid; gap: 20px; }
.battle-header { grid-template-columns: 1fr auto auto; align-items: center; margin-bottom: 18px; }
.battle-header h1 { margin: 0; font-size: clamp(1.5rem, 4vw, 3rem); }
.battle-header > div:first-child > p { margin: 0 0 4px; color: #e6b675; font: 700 .78rem system-ui; letter-spacing: .24em; }
.battle-header:has(.editor-header-tools:not([hidden])) { max-width: 1600px; }
.editor-header-tools {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(240px, .65fr) minmax(0, 1.35fr);
  gap: 14px;
  align-items: start;
  padding: 12px;
  border: 1px solid #63776a;
  border-radius: 12px;
  background: #142423;
}
.editor-header-tools .editor-settings-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
}
.editor-header-tools h3, .editor-header-tools #editor-name-help { grid-column: 1 / -1; margin: 0; }
.editor-header-tools .editor-range { grid-column: 1 / -1; }
.editor-header-tools label { display: grid; gap: 4px; }
.editor-header-tools :is(select, input) { min-width: 0; width: 100%; padding: 6px; border-radius: 5px; font: inherit; }
#battle-stats { color: #e9bf82; font-weight: 750; }
.battle-layout { grid-template-columns: minmax(0, 1fr) minmax(250px, 330px); align-items: start; }
.battle-layout.editing-layout {
  --grid-line-color: #e6f3e5c4;
  --grid-line-inset: 3.5%;
  max-width: 1600px;
  grid-template-columns: minmax(175px, 220px) minmax(0, 1fr) minmax(240px, 300px);
  gap: clamp(10px, 1.5vw, 20px);
}
.battle-field, .battle-panel { border: 1px solid #627364; border-radius: 14px; background: #142423; }
.battle-field { padding: clamp(7px, 2vw, 22px); }
.battle-field {
  background: radial-gradient(ellipse at 50% 45%, #354d39, #142423 76%);
}
#battle-grid {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  aspect-ratio: 1 / .56;
  margin: 5% 0 8%;
}
.editor-board-zoom { display: flex; justify-content: flex-end; gap: 4px; margin-top: 8px; }
#battle .editor-board-zoom button { min-height: 36px; padding: 4px 10px; font-variant-numeric: tabular-nums; }
#battle-board-viewport.editor-workspace { overflow: auto; height: clamp(280px, 61dvh, 740px); scrollbar-gutter: stable; }
.editor-workspace .battle-board-frame { width: max(100%, var(--board-zoom)); min-height: 100%; display: flow-root; }
.editor-workspace #battle-grid {
  width: min(100%, var(--board-zoom));
  margin-inline: auto;
  translate: var(--board-pan-x, 0px) var(--board-pan-y, 0px);
}
.editor-workspace.pan-mode { touch-action: none; }
.editor-workspace.pan-mode :is(.battle-board-frame, #battle-grid, #battle-grid .tile-hit, #editor-art-handle, .art-resize-corner) { cursor: grab; }
.editor-workspace.panning :is(.battle-board-frame, #battle-grid, #battle-grid .tile-hit, #editor-art-handle, .art-resize-corner) { cursor: grabbing; }
#editor-pan-mode[aria-pressed="true"] { border-color: #ffe194; background: #425c48; }
#battle-grid::before, #battle-grid::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#battle-grid::before {
  translate: 0 8%;
  clip-path: polygon(50% 0, 100% 50%, 100% 55%, 50% 100%, 0 55%, 0 50%);
  background: #0d1711;
}
#battle-grid::after {
  inset: 0 0 -7%;
  clip-path: polygon(0 46.73%, 50% 93.46%, 100% 46.73%, 100% 53.27%, 50% 100%, 0 53.27%);
  background: linear-gradient(90deg, #5d4c31 50%, #34473c 50%);
}
#battle-artwork, #battle-foreground { position: absolute; inset: 0; pointer-events: none; }
#battle-artwork { z-index: 0; }
#battle-foreground { z-index: 18; }
#battle-cells { position: absolute; z-index: 20; inset: 0; pointer-events: none; }
.battle-intercept-cue {
  position: absolute;
  z-index: 201;
  transform: translate(-50%,-100%);
  color: #bafaff;
  font: bold 12px/1.15 sans-serif;
  text-shadow: 1px 1px 2px #132b36, -1px -1px 2px #132b36;
  pointer-events: none;
}
#battle-lighting, #battle-lamps, #battle-lamp-glows, .battle-night, .battle-sunbeam, .art-light-receiver {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#battle-lighting { isolation: isolate; }
#battle-lamps { z-index: 21; }
#battle #editor-light-handle {
  position: absolute;
  z-index: 22;
  translate: -50% -50%;
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-color: #ffe29a;
  border-radius: 50%;
  color: #ffe9a2;
  background: #453320;
  cursor: grab;
  touch-action: none;
}
#battle #editor-light-handle:active { cursor: grabbing; }
#editor-light-drag-pad { cursor: grab; touch-action: none; }
#editor-light-drag-pad:active { cursor: grabbing; }
#editor-light-position { display: block; margin-top: 4px; font-size: .8rem; }
.battle-night { background: #080e39a8; opacity: var(--scene-night, 0); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.battle-sunbeam {
  background: conic-gradient(from var(--beam-angle, 0deg) at var(--light-x, 16%) var(--light-y, 9%),
    transparent 0deg, var(--sun-color, #ffdc91) 14deg, transparent 28deg);
  mask-image: radial-gradient(ellipse at var(--light-x, 16%) var(--light-y, 9%), #000, transparent 80%);
  opacity: var(--sun-opacity, 0);
  mix-blend-mode: screen;
}
.battle-lamp-glow {
  position: absolute;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--lamp-color), transparent 69%);
  opacity: var(--lamp-opacity);
  mix-blend-mode: screen;
}
#battle .battle-lamp-dot {
  position: absolute;
  translate: -50% -50%;
  width: 16px;
  min-height: 16px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #211607;
  background: #fff1bd;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
}
#battle .battle-lamp-dot:active { cursor: grabbing; }
.battle-lamp-dot.selected { outline: 2px solid #f9d485; outline-offset: 3px; }
.art-casts-shadow {
  filter: drop-shadow(var(--shadow-x, 0px) var(--shadow-y, 0px) 4px var(--shadow-color, transparent));
}
#battle-grid.grid-under-light .tile-art {
  filter: drop-shadow(var(--shadow-x, 0px) var(--shadow-y, 0px) 3px var(--shadow-color, transparent));
}
.battle-art-layer, #battle-grid #editor-art-handle {
  position: absolute;
  translate: -50% -50%;
}
.battle-art-layer { display: block; height: auto; max-width: none; }
#battle-grid.has-artwork::before, #battle-grid.has-artwork::after { display: none; }
#battle-grid .tile-hit::after {
  --edge: var(--grid-line-inset, 2%);
  --far-edge: calc(100% - var(--edge));
  content: '';
  position: absolute;
  inset: 0;
  background: var(--rim, var(--grid-line-color, #d2ead843));
  clip-path: polygon(evenodd, 50% 0, 100% 50%, 50% 100%, 0 50%, 50% 0,
    50% var(--edge), var(--edge) 50%, 50% var(--far-edge), var(--far-edge) 50%, 50% var(--edge));
}
#battle-grid.grid-lines-hidden .tile-hit::after { opacity: 0; }
#battle-grid.grid-lines-hidden :is(.reachable, .team-spawn-point, .skill-range, .target, .danger, .enemy-shot-path, .selected, .spawn-point) .tile-hit::after,
#battle-grid.grid-lines-hidden .tile-hit:is(:hover, :focus-visible)::after { opacity: 1; }
#battle-grid .water:not(.has-environment-art) .tile-hit::before {
  background: var(--paint, linear-gradient(transparent, transparent)), var(--tile-pit) center / 60% 60% no-repeat;
  image-rendering: pixelated;
}
#battle-grid .tile-hit:is(:hover, :focus-visible) { background: #fff0bd35; --rim: #fff0bd; }
#battle-grid.arranging-art .tile-hit { pointer-events: none; }
#battle-grid #editor-art-handle {
  z-index: 22;
  touch-action: none;
  min-height: 0;
  border: 2px dashed #ffe29a;
  border-radius: 0;
  cursor: grab;
  padding: 0;
  background: transparent;
}
#battle-grid #editor-art-handle:active { cursor: grabbing; }
.art-resize-corner {
  position: absolute;
  width: clamp(13px, 2.3cqw, 19px);
  aspect-ratio: 1;
  border: 2px solid #4f3920;
  border-radius: 3px;
  background: #ffe29a;
  z-index: 1;
}
.art-resize-corner.nw { top: 0; left: 0; translate: -50% -50%; cursor: nwse-resize; }
.art-resize-corner.ne { top: 0; right: 0; translate: 50% -50%; cursor: nesw-resize; }
.art-resize-corner.sw { bottom: 0; left: 0; translate: -50% 50%; cursor: nesw-resize; }
.art-resize-corner.se { bottom: 0; right: 0; translate: 50% 50%; cursor: nwse-resize; }
.art-rotate-handle {
  position: absolute;
  top: -30px;
  left: 50%;
  translate: -50% 0;
  display: grid;
  place-items: center;
  width: 23px;
  aspect-ratio: 1;
  border: 1px solid #6d512b;
  border-radius: 50%;
  background: #ffe29a;
  color: #302013;
  cursor: grab;
}
.art-rotate-handle::after {
  content: '';
  position: absolute;
  top: 100%;
  height: 8px;
  border-left: 1px solid #ffe29a;
}
#battle-grid .timed-hazard { --rim: #f2aa65; --paint: repeating-linear-gradient(-45deg,#ffb65b50 0 2px,transparent 2px 8px); }
.battle-cell {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  pointer-events: none;
}
#battle-grid .reachable { --rim: #c9f6ff; --action-fill: #43b7fa94; }
#battle-grid .reachable .tile-hit::before { clip-path: url(#walk-fill); }
#battle-grid .reachable .tile-hit::after { clip-path: none; mask: url(#walk-rim); }
#battle-grid .reachable .tile-hit:is(:hover,:focus-visible) { background: transparent; --rim: white; }
#battle-grid .skill-range { --rim: #ffb372; --action-fill: #ff851f63; }
#battle-grid .target { --rim: #ffdda1; --action-fill: #ff791994; }
#battle-grid :is(.reachable, .skill-range, .target) { --paint: linear-gradient(var(--action-fill), var(--action-fill)); }
#battle-grid .has-environment-art:not(.object-in-front):is([data-base-tile="."], .dirt, .water):is(.reachable, .skill-range) > .tile-hit { z-index: 1; }
#battle-grid :is(.target, .aim-picked) .tile-hit::after { --edge: max(3%, var(--grid-line-inset, 2%)); }
#battle-grid .team-spawn-point { --rim: #67c9ff; --paint: linear-gradient(#215bd6a8, #12429bc4); }
.team-spawn-key { color: #67c9ff; }
#battle-grid .enemy-shot-path { --rim: #ef9f8f; --paint: linear-gradient(#b5364078, #b5364078), linear-gradient(var(--action-fill, transparent), var(--action-fill, transparent)); }
#battle-grid .danger { --rim: #ff9686; --paint: repeating-linear-gradient(-45deg,#db545dbd 0 3px,transparent 3px 8px), linear-gradient(var(--action-fill, #8b3f3a65), var(--action-fill, #8b3f3a65)); }
#battle-grid .aim-picked, #battle-grid .selected { --rim: #ffde83; }
#battle-grid .preview-strike { --rim: #ffd48b; --paint: linear-gradient(#ee8c524f, #ee8c524f); }
#battle-grid .preview-push { --rim: #b1f2ff; --paint: linear-gradient(#69d6e950, #69d6e950); }
#battle-grid .preview-enemy-source { --rim: #ffe191; --paint: linear-gradient(#f4c76450, #f4c76450); }
#battle-grid .preview-enemy-strike { --rim: #ffb0a1; --paint: repeating-linear-gradient(-45deg,#ec675abf 0 3px,#742d2c55 3px 8px); }
.battle-hover-preview {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  color: #fff4d9;
  text-shadow: 0 1px 3px #11201c;
  font: 400 clamp(.9rem, 2.35cqw, 1.15rem)/1.2 var(--battle-pixel-font);
}
.preview-range-label { bottom: -9%; left: 50%; transform: translateX(-50%); white-space: nowrap; font: 600 11px/1.1 system-ui, sans-serif; color: #fff1ba; text-shadow: 0 1px 2px #182018, 1px 0 2px #182018; }
.preview-combo-ready { left: 64%; bottom: 16%; color: #88fff0; font-size: 12px; text-shadow: 0 1px 2px #0b332d; }
#battle-grid .preview-combo-target { --rim: #80f4df; }
.preview-trail-dot { width: 14%; aspect-ratio: 1; background: #b95152; border: 1px solid #692f35; border-radius: 50%; }
.intent-damage-label {
  position: absolute; z-index: 24; pointer-events: none;
  transform: translate(-50%,-50%); white-space: nowrap;
  font: 900 clamp(13px,2cqw,18px)/1 system-ui,sans-serif; color: #ffb39c;
  paint-order: stroke fill; -webkit-text-stroke: 3px #491d22; text-shadow: 0 2px 2px #241418;
}
.preview-health { bottom: 128%; display: flex; gap: 1px; background: #101c16; border: 1px solid #f5e9c8; padding: 1px; border-radius: 2px; }
.preview-health i { width: clamp(3px, .48cqw, 6px); height: clamp(3px, .62cqw, 7px); background: #424b44; }
.preview-health .kept { background: #9be487; }
.preview-health .lost { background: #ffa05c; box-shadow: 0 0 4px #ff985f; }
.preview-damage {
  right: 4%;
  bottom: 124%;
  color: #ffca77;
  font-size: 12px;
  line-height: 1;
  paint-order: stroke fill;
  -webkit-text-stroke: 1px #261710;
  text-shadow: 0 1px 2px #1e130f;
}
.preview-push-arrow { left:50%; top:50%; transform:translate(-50%,-50%); font:900 clamp(22px,4.4cqw,42px)/1 system-ui,sans-serif; color:#fff074; paint-order:stroke fill; -webkit-text-stroke:4px #362520; text-shadow:0 2px 1px #251a18; }
#battle-grid .preview-push-source { --paint:linear-gradient(#82658b85,#82658b85); }
#battle-grid .preview-push-source > .tile-hit::after { --edge:8%; background:#ae91b7; opacity:1; }
.preview-status { right:0; top:5%; font:700 11px/1 system-ui; color:#ffdb78; }
.preview-fire { left:8%; bottom:8%; font:700 11px/1 system-ui; color:#ffba67; }
.battle-ground-flame { position:absolute; left:50%; top:50%; width:130.6%; max-width:none; translate:-50% -50%; pointer-events:none; image-rendering:pixelated; opacity:var(--combat-vfx,1); }
.tile-art.blink-cast > :is(.battle-status-vfx,.battle-status-list) { opacity:var(--blink-alpha); }
.preview-shield-gain { bottom:100%; left:4%; z-index:7; padding:2px 4px; border-radius:4px; background:#142835; color:#b6edff; white-space:nowrap; font:700 12px/1.2 system-ui,sans-serif; }
.battle-hit-number {
  position: absolute;
  z-index: 40;
  pointer-events: none;
  white-space: nowrap;
  color: #ffd384;
  font: 400 clamp(1.5rem, 5.4cqw, 2.5rem)/1 var(--battle-pixel-font);
  paint-order: stroke fill;
  -webkit-text-stroke: 3px #241511;
  text-shadow: 0 2px 5px #22140c, 0 0 9px #ff965caa;
  animation: battle-hit-float .72s ease-out both;
}
.tower-slot-icon { width: 28px; height: 28px; margin-inline-end: 6px; object-fit: contain; vertical-align: middle; image-rendering: pixelated; }
.battle-skill-icon { display: inline-grid; position: relative; width: 28px; height: 28px; margin-inline-end: 6px; vertical-align: middle; }
.battle-skill-icon .tower-slot-icon { margin: 0; }
.battle-skill-cooldown { position: absolute; inset: 0; display: grid; place-items: center; background: #181714d9; color: #fff2be; border-radius: 3px; font-weight: bold; font-variant-numeric: tabular-nums; }
.battle-projectile { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 38; pointer-events: none; image-rendering: pixelated; }
@keyframes battle-hit-float {
  0% { transform: translate(-50%, -75%) scale(.82); opacity: 1; }
  20% { transform: translate(-50%, -110%) scale(1.16); opacity: 1; }
  65% { transform: translate(-50%, -145%); opacity: 1; }
  100% { transform: translate(-50%, -180%); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .battle-hit-number { animation-name: battle-hit-fade; transform: translate(-50%, -100%); }
}
@keyframes battle-hit-fade { 0%, 65% { opacity: 1; } 100% { opacity: 0; } }
#battle-grid .spawn-point { --rim: #ff993f; }
#battle-grid .tile-hit {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: transparent;
  pointer-events: auto;
}
.tile-hit::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--paint, transparent);
}
.tile-art {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.battle-prop, .battle-token {
  font-size: clamp(.85rem, 4.8cqw, 2.65rem);
  line-height: 1;
  filter: drop-shadow(0 4px 2px #132016c9);
  translate: 0 -26%;
}
.battle-token {
  display: grid;
  place-items: center;
  width: 66%;
  height: 60%;
  border: 1px solid #a4ebd3;
  border-radius: 50%;
  background: radial-gradient(ellipse,#27675d,#153f3b);
  font-size: clamp(.75rem, 3.8cqw, 2.1rem);
}
.battle-token.enemy { background: #743745; border-color: #f5a99e; }
.frost-shell,.frost-event { position:absolute; inset:0; pointer-events:none; z-index:4; font-style:normal; }
.frost-event { z-index:7; }
.frost-shell canvas,.frost-event canvas,.battle-token .frost-shell canvas { position:absolute; left:50%; top:50%; bottom:auto; width:195.92%; height:auto; max-width:none; transform:translate(-50%,-50%); image-rendering:pixelated; }
.frost-held > canvas[data-pose] { filter:sepia(var(--frost-tint)) hue-rotate(154deg) saturate(1.4); }
.frost-shell b,.frost-event b,.preview-frost { position:absolute; width:max-content; max-width:none; border:1px solid #6cafd5; border-radius:4px; padding:1px 4px; background:#112e46; color:#e7faff; font:600 11px/1.3 system-ui; white-space:nowrap; }
.frost-shell b { top:73%; left:50%; transform:translateX(-50%); display:flex; align-items:center; gap:3px; }
.frost-shell b img { width:13px; height:13px; image-rendering:pixelated; }
.frost-event b { left:65%; bottom:76%; color:#b6faff; }
.tile-art .preview-frost { top:80%; left:50%; transform:translateX(-50%); z-index:9; }
.tile-art .venom-stack,.tile-art .preview-venom {
  position:absolute; z-index:9; left:50%; top:78%; transform:translateX(-50%);
  width:max-content; padding:1px 4px; border:1px solid #79af53; border-radius:3px;
  color:#e0ffb1; background:#172a1d; font:600 11px/1.3 system-ui; pointer-events:none;
}
.tile-art .preview-venom { top:100%; }
.battle-monster-corpse,.battle-pit-arrival,.battle-hero-death { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.battle-walking,.battle-gate-entrant,.battle-warp-gate,.gate-art { position:absolute; inset:0; display:grid; place-items:center; pointer-events:none; }
.battle-warp-gate { z-index:1; }
.battle-cell:has(> .battle-warp-gate) .tile-art,.battle-gate-entrant { z-index:2; }
.gate-ring { width:62%; height:48%; border:2px dashed #ffcf74; border-radius:50%; background:#462c305e; box-shadow:inset 0 0 5px #ffad56; }
[data-gate-phase="open"] .gate-ring { animation:gate-open .2s ease-out both; }
[data-gate-phase="close"] .gate-ring { animation:gate-open .2s ease-in reverse both; }
@keyframes gate-open { from { transform:scale(.2); opacity:0; } to { transform:scale(1); opacity:1; } }
.battle-facing { position: absolute; left: 0; bottom: 0; font-size: .6em; color: #fff3c6; text-shadow: 0 1px 3px #101c17; }
.battle-token.battle-token-sprite {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: none;
  box-shadow: none;
  translate: none;
  filter: none;
}
.battle-token-sprite::before {
  content: '';
  position: absolute;
  left: var(--battle-shadow-left, 50%);
  top: var(--battle-shadow-top, 50%);
  width: 77.55%;
  height: 44%;
  transform: translate(-50%, -50%) scale(var(--battle-shadow-scale, 1));
  border-radius: 50%;
  background: #142824aa;
}
.battle-token-sprite canvas {
  position: absolute;
  left: 50%;
  bottom: 30%;
  transform: translateX(-50%);
  height: auto;
  max-width: none;
  image-rendering: pixelated;
}
.battle-ice-bind {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  left: 50%;
  top: 56%;
  width: 58%;
  height: 54%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 2px 0 #133f5b80);
}
.battle-ice-bind canvas {
  position: absolute;
  left: 8%;
  bottom: 8%;
  width: 42%;
  height: auto;
  image-rendering: pixelated;
  transform: scaleX(var(--shard-facing, 1));
  --shard-shift: -70%;
}
.battle-ice-bind canvas:nth-child(2) { left: 34%; bottom: 0; width: 31%; --shard-shift: 0%; --shard-facing: -1; }
.battle-ice-bind canvas:nth-child(3) { left: 60%; bottom: 13%; width: 36%; --shard-shift: 65%; --shard-facing: -1; }
.battle-ice-bind.releasing { animation: battle-ice-release .48s ease-out both; }
.battle-ice-bind.releasing canvas { animation: battle-ice-shatter .48s ease-out both; animation-delay: inherit; }
@keyframes battle-ice-shatter {
  to { transform: translate(var(--shard-shift), 40%) rotate(28deg) scale(.35) scaleX(var(--shard-facing, 1)); }
}
@keyframes battle-ice-release {
  to { opacity: 0; }
}
.danger .battle-prop { filter: drop-shadow(0 0 4px #ff746c) drop-shadow(0 0 2px #ffd3bd); }
.battle-hp, .battle-spawn {
  position: absolute;
  bottom: 10%;
  right: 21%;
  font: 800 clamp(.55rem, 1.8cqw, .9rem) system-ui;
  background: #172222;
  padding: 0 3px;
  border-radius: 3px;
}
.battle-spawn {
  display: grid;
  place-items: center;
  width: clamp(17px, 4cqw, 30px);
  aspect-ratio: 1;
  right: auto;
  left: 50%;
  bottom: 50%;
  translate: -50% 50%;
  border: 1px solid #ffe0a6;
  border-radius: 50%;
  background: #682914;
  box-shadow: 0 0 8px #ff873b;
  color: #fff0bd;
  font-size: clamp(.8rem, 3cqw, 1.2rem);
}
.battle-hp + .battle-spawn { left: 24%; bottom: 15%; }
.battle-hp { display: none; }
.battle-shield {
  position:absolute; z-index:4; left:50%; bottom:135%; translate:-50% 0;
  display:inline-flex; align-items:center; gap:2px; pointer-events:none; white-space:nowrap;
  color:#e7faff; font:800 clamp(11px,1.65cqw,15px)/1 system-ui;
  paint-order:stroke fill; -webkit-text-stroke:2px #142738; text-shadow:0 1px 1px #142738;
}
.battle-shield::before,.battle-hit-number.shield::before {
  content:''; display:inline-block; width:1em; height:1.15em; vertical-align:-.12em;
  background:linear-gradient(90deg,#e3f8ff 0 16%,#74c8f0 16% 49%,#3987b6 49% 84%,#c2ebff 84%);
  clip-path:polygon(0 10%,50% 0,100% 10%,100% 51%,84% 74%,50% 100%,16% 74%,0 51%);
}
.battle-shield-vfx {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  left: 50%;
  top: 50%;
  max-width: none;
  translate: -50% -72%;
  image-rendering: pixelated;
}
#battle .editor-cell-remove {
  position: absolute;
  z-index: 2;
  top: 19%;
  left: 66%;
  translate: -50% -50%;
  width: clamp(16px, 3.2cqw, 25px);
  aspect-ratio: 1;
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border-color: #ffd0bc;
  border-radius: 50%;
  background: #6e2e26;
  color: #fff5e3;
  line-height: 1;
  pointer-events: auto;
}
#battle .editor-cell-remove:hover { background: #93463a; }
.battle-shot-dot {
  position: absolute;
  z-index: 1;
  border-radius: 50%;
  pointer-events: none;
}
.battle-shot-dot {
  width: clamp(6px, 1.7cqw, 13px);
  aspect-ratio: 1;
  border: 1px solid #ffe1d8;
  background: #ff736d;
  box-shadow: 0 0 7px #a8282d;
}
#battle-next { margin-inline-start: 5px; }
#battle-editor label { display: grid; gap: 4px; margin-block: 8px; }
#battle-editor select, #battle-editor input { width: 100%; font: inherit; padding: 7px; border-radius: 5px; }
.editor-range { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#editor-status { color: #ffe194; }
#battle-editor .editor-settings-section { margin: 14px 0 0; padding: 11px 0 0; border: 0; border-top: 1px solid #63776a; border-radius: 0; background: transparent; }
#battle-editor .editor-settings-section h3 { margin: 0 0 8px; color: #ffe5ad; font-size: .95rem; }
#editor-quest-section legend { padding-right: 8px; color: #ffe5ad; font-weight: 750; }
.quest-crystal .tile-art:has(> .crystal-idle)::before,
.quest-crystal .editor-card-icon {
  background: center / contain no-repeat url("character/Crytal/quest-crystal-idle.webp");
  image-rendering: pixelated;
}
/* The tile-art stays mounted when combat overlays are refreshed. */
.quest-crystal .tile-art:has(> .crystal-idle)::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: 24%;
  width: 100%;
  aspect-ratio: 1;
  filter: drop-shadow(0 3px 2px #132016c9);
}
.quest-crystal.danger .tile-art:has(> .crystal-idle)::before { filter: drop-shadow(0 0 4px #ff746c); }
.quest-crystal .editor-card-icon { width: 2.5rem; aspect-ratio: 1; }
#editor-art-panel h3 { margin-top: 0; margin-bottom: 8px; }
#editor-art-panel label { display: grid; gap: 4px; margin-block: 8px; }
#editor-art-panel :is(select, input) { width: 100%; min-width: 0; font: inherit; }
#editor-art-panel p { font-size: .82rem; }
.editor-layer-list { margin-top: 8px; }
.editor-layer-list summary { cursor: pointer; padding-block: 5px; }
#editor-image-library { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 38dvh; overflow-y: auto; }
#editor-image-library button { min-width: 0; padding: 5px; overflow-wrap: anywhere; font-size: .72rem; }
#editor-image-library img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; }
.library-image-card { position: relative; min-width: 0; }
.library-image-card > button:first-child { width: 100%; height: 100%; }
#editor-image-library .library-image-remove { position: absolute; top: 2px; right: 2px; min-height: 25px; width: 25px; padding: 0; background: #482d2b; }
#editor-art-list { display: grid; gap: 6px; margin-top: 4px; max-height: 38dvh; overflow-y: auto; }
#editor-spawn-actions [aria-pressed="true"] { border-color: #ffe194; }
#editor-spawn-actions { margin-block: 10px; }
.editor-art-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
.editor-art-row.image-layer { grid-template-columns: minmax(0, 1fr) auto auto; }
.editor-art-row.layer-hidden > button:first-child { opacity: .55; }
#editor-art-list .layer-visibility { min-width: 30px; padding-inline: 5px; }
.layer-visibility svg { display: block; width: 16px; height: 16px; }
.editor-art-row[draggable="true"] { cursor: grab; }
.editor-art-row.layer-drop { border-top: 2px solid #ffe194; }
.editor-art-row.layer-drop-after { border-bottom: 2px solid #ffe194; }
.editor-art-row button { padding: 6px 10px; }
.editor-art-row button:first-child { overflow-wrap: anywhere; text-align: left; }
.editor-art-row [aria-pressed="true"] { border-color: #ffe194; }
#battle [hidden] { display: none !important; }
.battle-field { position: relative; }
#editor-toolbar button[aria-pressed="true"], .editor-card[aria-pressed="true"] { border-color: #ffe194; background: #425c48; }
.editor-palette { position: absolute; z-index: 30; top: clamp(57px, 9vw, 75px); left: 2%; right: 2%; padding: 12px; background: #1a2d27; border: 1px solid #a2b183; border-radius: 10px; box-shadow: 0 12px 28px #07110eaa; }
.editor-palette.monster-palette { position: static; margin-top: 8px; }
.editor-cards { display: flex; gap: 8px; flex-wrap: wrap; }
.editor-cards button { display: grid; justify-items: center; gap: 3px; padding: 8px 12px; }
.editor-card-icon { font-size: 1.6rem; }
.editor-roster { border-top: 1px solid #627364; padding-top: 10px; }
.editor-roster h3 { margin: 0 0 8px; font-size: .9rem; }
#battle-editor .editor-pool-card label { display:flex; align-items:center; gap:5px; font-size:.8rem; }
#battle-editor .editor-pool-card input { width:auto; }
.editor-roster p, #editor-name-help { margin: 0 0 8px; font-size: .82rem; }
.editor-roster-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.editor-roster-header h3 { margin: 0; }
#editor-pool-available { margin-bottom: 10px; }
.editor-pool-card { position: relative; display: grid; justify-items: center; gap: 4px; padding: 10px 32px 10px 12px; border: 1px solid #a2b183; border-radius: 9px; background: #304439; }
#editor-pool .editor-pool-place { padding: 2px 4px; border-color: transparent; background: transparent; }
#editor-pool .editor-pool-place:hover { border-color: #e1b879; background: #3d5545; }
#editor-pool .editor-pool-remove { position: absolute; top: 3px; right: 3px; min-height: 28px; width: 28px; padding: 0; place-items: center; background: #482d2b; color: #ffe7db; }
#editor-pool .editor-pool-remove:hover { background: #774039; }
#editor-summary, #battle-quests { padding-left: 20px; color: #e6c794; font-size: .86rem; }
#editor-summary { margin-block: 0; }
#editor-quests input[type="checkbox"] { width: auto; margin: 0; }
#battle-editor #editor-quests label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 0;
  border-bottom: 1px solid #62736462;
}
#battle-editor #editor-quests label:last-child { border-bottom: 0; }
#editor-quests input[type="number"] { max-width: 4.25rem; }
.editor-quest-row { border-bottom: 1px solid #62736462; padding-bottom: 8px; }
#battle-editor #editor-quests .editor-quest-row label { border: 0; }
.quest-reward-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 10px; }
#battle-editor #editor-quests .quest-reward-fields label { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 3px 0; font-size: .78rem; }
.quest-reward-icons { display: inline-flex; gap: 6px; flex-wrap: wrap; color: #ffe194; margin-inline-start: 6px; }
.quest-reward-icon { white-space: nowrap; }
#battle-reward-result { color: #ffe194; }
.village-rewards { position: absolute; z-index: 2; top: clamp(72px, 10vw, 108px); left: clamp(12px, 3vw, 36px); margin: 0; padding: 6px 10px; border: 1px solid #e1b879; border-radius: 6px; background: #1b211bed; color: #ffe5ad; }
.battle-legend, .battle-actions { display: flex; gap: 9px 13px; flex-wrap: wrap; }
.move-range-key { color: #83dcff; }
.skill-range-key { color: #ffb372; }
.skill-target-key { color: #ffdda1; }
.battle-legend { margin-bottom: 0; font-size: .84rem; }
.battle-panel { padding: 16px; }
.battle-panel h2, .battle-panel h3 { margin: 0; }
.battle-panel h3 { margin-top: 16px; font-size: 1rem; }
#battle-message { min-height: 3em; margin: 6px 0 12px; }
#battle-party { display: grid; gap: 6px; margin-bottom: 12px; }
#battle-party button { text-align: left; padding: 7px 10px; }
#battle-party [aria-pressed="true"] { border-color: #f9d485; background: #40534b; }
.battle-actions button, #battle-restart { padding: 7px 10px; }
#battle-intents { padding-inline-start: 20px; color: #efc3ac; min-height: 1em; font-size: .86rem; }
@media (max-width: 760px) {
  .editor-header-tools { grid-template-columns: minmax(0, 1fr); }
  .battle-layout, .battle-layout.editing-layout { grid-template-columns: minmax(0, 1fr); }
  .battle-header { grid-template-columns: 1fr auto; }
  #battle-stats { grid-row: 2; }
}
@font-face {
  font-family: BoldPixels;
  src: url("boldpixels.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0020-007E, U+00A0-024F, U+2212;
}

#battle {
  --battle-pixel-font: BoldPixels, "Leelawadee UI", system-ui, sans-serif;
}

#battle-stats, #battle-play-panel, #battle-play-panel button {
  font-family: var(--battle-pixel-font);
}


.goblin-blessing {
  pointer-events: none;
  position: absolute;
  inset: 0;
}
.arc-aim-guide { position:absolute; inset:0; width:100%; height:100%; overflow:visible; z-index:23; pointer-events:none; }
.arc-aim-guide path { fill:none; stroke:#d6b852; stroke-width:8; stroke-dasharray:.1 18; stroke-linecap:round; filter:drop-shadow(0 1px 1px #382809); }
.lightning-aim-guide path { stroke:#93eaff; stroke-width:3; stroke-dasharray:5 6; }
.battle-token.arc-link-shade > canvas[data-pose], .battle-token.arc-link-shade > img,
.battle-token.arc-link-shade:not(.battle-token-sprite) { filter: brightness(var(--arc-link-light)); }
.blessing-column,.blessing-staff { position:absolute; z-index:36; pointer-events:none; image-rendering:pixelated; }
.blessing-column { width:10.5%; aspect-ratio:80/128; translate:-50% -98%; background:url('assets/skill/blessing-v1-5986f590.png') no-repeat; background-size:1200% 800%; }
.blessing-staff { width:5%; aspect-ratio:1; translate:-50% -50%; background:radial-gradient(circle,#fffde0 5%,#ffe464 22%,#ffbe35aa 36%,transparent 70%); }
.blessing-staff::after { content:''; position:absolute; inset:-12%; background:#fff2ac; clip-path:polygon(50% 0,56% 41%,100% 50%,56% 56%,50% 100%,44% 58%,0 50%,44% 43%); }
.blessing-active { z-index:3; }
.goblin-blessing::before, .goblin-blessing::after {
  position: absolute;
  content: '';
  left: 50%;
  top: 40%;
  width: 4px;
  height: 4px;
}
.battle-status-count {
  position: absolute;
  left: 5%;
  top: -9%;
  font: 700 11px/1 system-ui, sans-serif;
  color: #ffe29c;
  text-shadow: 0 1px 2px #271800;
}
.battle-status-vfx { position:absolute; left:50%; top:50%; translate:-50% -50%; width:522.45%; max-width:none; pointer-events:none; image-rendering:pixelated; }
.battle-status-list { position:absolute; bottom:8%; left:0; display:flex; gap:2px; font:700 11px/1 system-ui,sans-serif; color:#fff1a8; text-shadow:0 1px 2px #142018; pointer-events:none; }
.battle-status-list img { vertical-align:middle; image-rendering:pixelated; }
.blessing-active::before {
  width:7px; height:7px; background:transparent;
  box-shadow: -24px -12px #fffbd3, 24px -17px #ffed53, -19px 7px #ffe74a,
    20px 9px #fff6a2, -14px -30px #ffec55, 14px -36px #fffbd3;
  filter:drop-shadow(0 1px 1px #94621b) drop-shadow(0 0 2px #ffe958);
  animation: blessing-glimmer 1.1s steps(4) infinite alternate;
}
.blessing-arrival::after {
  background: #fff6bf;
  box-shadow: 0 -4px #fff6bf, 0 -8px #ffe185, 0 -12px #ffe185, 0 -16px #d99435,
    -4px 0 #ffce59, 4px 0 #ffce59, -11px 6px #ffdd73, 11px 6px #ffdd73;
  animation: blessing-drop 680ms steps(12) var(--blessing-delay) both;
}
.blessing-removal::after {
  background: #fff2b0;
  box-shadow: -13px -9px #ffd668, 17px -4px #ffdf87, -20px 6px #db962e, 11px -18px #fff4bc;
  animation: blessing-break 680ms steps(10) var(--blessing-delay) both;
}
@keyframes blessing-glimmer { from { opacity: .8; transform: translateY(2px); } to { opacity: 1; transform: translateY(-7px); } }
@keyframes blessing-drop {
  from { transform: translateY(-76px); }
  56% { transform: translateY(-8px); }
  75% { transform: translateY(0) scaleX(2); opacity: 1; }
  to { transform: translateY(3px) scaleX(2.7); opacity: 0; }
}
@keyframes blessing-break { to { transform: translateY(-18px) scale(2.2); opacity: 0; } }
.battle-contact-vfx { position: absolute; left: 50%; top: 50%; height: auto; transform: translate(-50%, -75%); pointer-events: none; image-rendering: pixelated; z-index: 6; }
.possible-threat:not(.preview-enemy-strike) .battle-ground {outline:1px dashed #9aafd1}
.battle-cell.possible-threat .battle-tile,.battle-cell.possible-threat button {outline:1px dashed #91adcb}
.battle-cell.overlapping-threat button {outline:2px double #ff967a}
.battle-cell.future-threat button {outline:2px dashed #dfb3ff}
.battle-cell.lesson-cell button {outline:3px solid #ffe38c}
#combat-inspect {white-space:pre-line;color:#f2e0ac;line-height:1.45;font-size:.9rem}
#combat-inspect:empty,#combat-bosses:empty {display:none}
.boss-readout {display:grid;gap:.3rem;margin-block:.6rem}
.boss-readout progress {width:100%;height:.55rem;accent-color:#e89a69}
#combat-debug ol,#combat-record ol {max-height:15rem;overflow:auto}
#combat-settings label,#combat-layers label {display:flex;align-items:center;justify-content:space-between;gap:.6rem;margin:.45rem 0}
#combat-settings input[type=number] {width:5rem}
#battle :is(.marker-effect,.battle-projectile,.battle-contact-vfx,.battle-burst,.battle-shield-vfx,.battle-status-vfx,.battle-ice-bind) {opacity:var(--combat-vfx,1);pointer-events:none}
.battle-hit-number.heal {color:#91efa5}.battle-hit-number.shield {color:#a5deff}
main:has(> #tutorial-editor:not([hidden])) {width:min(100%,900px)}
#tutorial-editor {padding:clamp(16px,3vw,32px);background:#152520}
#tutorial-editor header,.lesson-toolbar {display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:.7rem}
#tutorial-author {display:grid;gap:.75rem;margin-top:1rem}
#tutorial-author details {border:1px solid #526b59;border-radius:8px;padding:.75rem}
#tutorial-author summary {cursor:pointer;font-weight:bold}
#tutorial-author label {display:flex;flex-wrap:wrap;gap:.55rem;align-items:center;margin:.45rem 0}
#tutorial-author input:not([type=checkbox]),#tutorial-author select {max-width:100%;font:inherit;padding:.4rem}
#lesson-guide:not([hidden]) {position:fixed;bottom:.75rem;left:.75rem;z-index:40;max-width:min(29rem,90vw);padding:.7rem 1rem;background:#182c24;color:#faf0ce;border:1px solid #c3a369;border-radius:8px;box-shadow:0 3px 15px #0007}
#lesson-guide button {padding:.35rem .7rem;margin-right:.4rem}
#lesson-guide p {margin:.45rem 0}

/* Combat HUD */
.party-rail { display:none }
.battle-layout:not(.editing-layout):has(#battle-play-panel:not([hidden])) > .party-rail {
  display:block; background:#172b26; border:1px solid #887448; padding:10px; border-radius:8px;
}
.party-rail h2,.mission-panel h3 {color:#f0ce8e;font-size:1rem;margin:0 0 8px}
.party-rail #battle-party {margin:0}
.party-rail #battle-party button:not([hidden]) {display:flex;align-items:center;gap:8px;line-height:1.35}
.hud-portrait {display:grid;place-items:center;flex:0 0 44px;height:48px;background:#0e201c;border-radius:5px}
.hud-portrait > * {max-width:44px;max-height:48px;object-fit:contain;image-rendering:pixelated}
#battle-party [aria-pressed=true] {box-shadow:inset 3px 0 #edc778}
.mission-panel {padding:12px 14px;background:#20352e;border:1px solid #887448;border-radius:6px;margin-bottom:14px}
.mission-panel h3 {margin:0 0 5px}
.mission-panel ul {padding-left:18px;margin:6px 0 0}
.mission-panel ul:empty {display:none}
#battle-play-panel #battle-end {flex-basis:100%;border-color:#f7d492}
@media(min-width:1150px){
 .battle-layout:not(.editing-layout):has(#battle-play-panel:not([hidden])) {max-width:1650px;grid-template-columns:minmax(155px,.65fr) minmax(0,3.4fr) minmax(250px,1fr);gap:12px}
 .battle-header:has(#editor-header-tools[hidden]) {max-width:1650px;grid-template-columns:1fr auto auto auto}
}
@media(max-width:1149px){
 .battle-layout > .party-rail {grid-column:1/-1}
 .party-rail #battle-party {grid-template-columns:repeat(auto-fit,minmax(min(100%,170px),1fr))}
}

/* Frame the playable scene and anchor its HUD independently of board art. */
#battle:has(.battle-layout:not(.editing-layout) #battle-play-panel:not([hidden])) {
  --hud-brass:#ad9057;
  background:#101c19;
}
.battle-layout:not(.editing-layout):has(#battle-play-panel:not([hidden])) {
  isolation:isolate;
  background:linear-gradient(115deg,#10251ee8,#182b23cc 50%,#0e1c18eb),url("assets/village/forest.png") center/cover;
  border:2px solid #74613f;
  box-shadow:inset 0 0 0 2px #232e23,inset 0 0 0 3px #a28953;
  padding:10px;
}
.battle-layout:not(.editing-layout):has(#battle-play-panel:not([hidden])) > :is(.party-rail,aside.battle-panel:last-child) {
  border:3px double var(--hud-brass);
  border-radius:3px;
  background:linear-gradient(135deg,#253c30f7,#12251ff7);
  box-shadow:0 4px 12px #08110dbb;
}
@media(min-width:1000px) and (min-height:560px){
 #battle:has(.battle-layout:not(.editing-layout) #battle-play-panel:not([hidden])) {
   position:fixed;inset:0;box-sizing:border-box;height:100dvh;overflow:hidden;
   padding:10px;display:flex;flex-direction:column;
 }
 #battle[hidden]{display:none!important}
 #battle:has(.battle-layout:not(.editing-layout) #battle-play-panel:not([hidden])) .battle-header {
   width:100%;margin:0 auto 6px;grid-template-columns:1fr auto auto auto;
 }
 #battle .battle-layout:not(.editing-layout):has(#battle-play-panel:not([hidden])) {
   position:relative;display:block;flex:1;min-height:0;width:100%;box-sizing:border-box;overflow:hidden;
 }
 .battle-layout:not(.editing-layout):has(#battle-play-panel:not([hidden])) > .battle-field {
   position:absolute;inset:0;overflow:auto;border:0;border-radius:0;background:transparent;
   padding:clamp(16px,4vh,52px) 18% 12px 15%;
 }
 .battle-layout:not(.editing-layout):has(#battle-play-panel:not([hidden])) > .party-rail {
   position:absolute;top:14px;left:14px;width:14%;box-sizing:border-box;z-index:2;max-height:90%;overflow:auto;
 }
 .battle-layout:not(.editing-layout):has(#battle-play-panel:not([hidden])) > .party-rail #battle-party {grid-template-columns:1fr}
 .battle-layout:not(.editing-layout):has(#battle-play-panel:not([hidden])) > aside.battle-panel:last-child {
   position:absolute;right:14px;top:14px;width:17%;box-sizing:border-box;max-height:calc(100% - 28px);overflow:auto;z-index:2;padding:10px;
 }
}

.root-hud {margin-bottom:12px;padding-bottom:10px;border-bottom:1px solid #77673f;color:#ffdc99}
.root-hud > div:first-child {display:flex;justify-content:space-between;align-items:center;font-weight:bold}
#root-hud-bar {display:grid;grid-template-columns:repeat(10,minmax(0,1fr));gap:2px;margin-top:4px;background:#101915;padding:3px}
#root-hud-bar i {height:17px;background:#2b302a;border:1px solid #666653}
#root-hud-bar i.filled {background:linear-gradient(#f9d16d,#de932f);border-color:#f0b755}

.hud-portrait.expression-sheet {width:clamp(40px,3.5vw,58px);height:auto;aspect-ratio:1;flex:0 0 auto;background-size:300% 200%;background-position:0 0;background-repeat:no-repeat;border:0;background-color:transparent;image-rendering:auto}
#battle-party [aria-pressed="true"] .expression-sheet {background-position:50% 100%}
#battle-party button[data-reaction="shocked"] .expression-sheet {background-position:100% 100%}
#battle-party button[data-reaction="happy"] .expression-sheet {background-position:50% 0}
.battle-header[hidden] {display:none!important}
.player-hud #battle-play-panel > :is(h3:has(+ #battle-intents),#battle-intents,#combat-inspect,#combat-layers,#combat-record,#combat-debug,#battle-restart) {display:none!important}
.player-hud .party-rail #combat-settings {margin-top:8px}
.player-hud .party-rail #combat-settings summary {cursor:pointer;width:fit-content}
#map-quota-summary {padding:8px 10px;border-left:3px solid #edc778;background:#263a31;color:#ffe5ad} #map-caps small {display:block;margin-block:6px}

@media(min-width:1000px) and (min-height:560px){
  .player-hud .battle-field {display:flex;flex-direction:column}
  .player-hud #battle-board-viewport {flex:none;margin-block:auto;width:100%}
}
@media(min-width:1000px) and (min-height:700px){.player-hud #battle-board-viewport {position:relative;top:clamp(0px,calc(43dvh - 21vw),8dvh)}}
.tile-art.blink-cast > :is(.battle-token,.battle-hp,.battle-shield,[data-shield-owner]) { opacity:var(--blink-alpha); }
.tile-art.blink-cast > .battle-token { filter:brightness(var(--blink-light)); }
.tile-art .preview-swap { left:50%; top:56%; transform:translateX(-50%); white-space:nowrap; font:bold 13px system-ui; color:#f4dcff; background:#352444; border:1px solid #d2a7ee; border-radius:4px; padding:1px 5px; z-index:8; }
.hero-charm-row{min-width:0}.hero-charm-row[hidden]{display:none}.hero-charm-row>button{width:100%}.hero-charm-strip{display:flex;gap:4px;margin:3px 0 0 4px}
.party-rail #battle-party .hero-charm-icon{display:grid;place-items:center;width:27px;height:27px;min-width:0;padding:0;color:#fbd988;font:16px system-ui;background:#243a33;border:1px solid #889478;border-radius:4px}
.hero-charm-icon:focus-visible{outline:2px solid #ffe5a3}.hero-charm-icon img{width:23px;height:23px;image-rendering:pixelated}
.hero-charm-tip{position:fixed;z-index:2000;max-width:min(230px,calc(100vw - 12px));padding:7px 10px;border:1px solid #d2b781;border-radius:5px;background:#182921;color:white;font:14px/1.45 system-ui;pointer-events:auto;overflow-wrap:anywhere}.hero-charm-tip[hidden]{display:none}


[data-fallen-target] .hud-portrait{filter:grayscale(1);opacity:.65}[data-revive-site] .tile-hit{box-shadow:inset 0 0 0 5px #8af5a7!important;background:#43ac664d!important}[data-revive-site=blocked] .tile-hit{box-shadow:inset 0 0 0 5px #ff5555!important;background:#ff444466!important}

#battle-grid .battle-cell:has(> .tile-hit:hover)::after {
  content:"";position:absolute;inset:8%;pointer-events:none;z-index:20;
  background:white;clip-path:polygon(50% 0,100% 50%,50% 100%,0 50%,50% 0,50% 5%,5% 50%,50% 95%,95% 50%,50% 5%);
}
#player-skill-dock {display:flex;align-items:center;gap:.6rem;flex-wrap:wrap;width:fit-content;max-width:100%;margin:.3rem auto .4rem 0;padding:.4rem .65rem;background:#162628;color:#fff;border:1px solid #769990;border-radius:.4rem;}
#battle:has(#battle-play-panel[hidden]) #player-skill-dock {display:none}
#dock-hero,.dock-skills {display:flex;align-items:center;gap:.45rem;flex-wrap:wrap}
#dock-hero .hud-portrait {width:42px;height:42px;display:inline-block}
.dock-skills button small {display:block;font-size:.78em}

#battle-turn-banner {position:fixed;z-index:24;left:50%;top:10px;transform:translateX(-50%);max-width:92vw;padding:.35em .9em;border:1px solid #a9cbb5;border-radius:.4rem;background:#18302cf2;color:#fff;font-weight:700;pointer-events:none;animation:turn-banner-fade 650ms linear forwards}
#battle-turn-banner[hidden],body:has(dialog[open]) #battle-turn-banner {display:none}
@keyframes turn-banner-fade {0%,64%{opacity:1}100%{opacity:0}}
