/* Echo Reapers game UI — map stage: painted backdrop, worksite, roads, site tiles (ER-0067: the painted UI kit).
   Tokens come from er.css. Motion lives in fx.css (ER-0022). Kit images are /art/ui/<name>; derivatives keep them light. */

.stage-root { position: absolute; inset: 0; overflow: hidden; background: #2f4a25; }
.stage-terrain { position: absolute; inset: 0; background-repeat: no-repeat; background-position: center bottom; background-size: cover; }
.stage-terrain.fallback { background-image: linear-gradient(180deg, #1c2233 0%, #26302a 46%, #141a14 100%); }
.stage-worksite { position: absolute; left: 50%; transform: translateX(-50%); width: auto; max-width: 92%; object-fit: contain; pointer-events: none;
  filter: drop-shadow(0 6px 5px rgba(20, 30, 10, .35)); }
.stage-roads { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
/* the roads are painted into the backdrop; ours stay invisible (echoes walk them) and light up under the hovered site */
.stage-roads .road-verge { stroke: rgba(40,25,13,.62); }
.stage-roads .road-dirt { stroke: rgba(196,139,75,.72); }
.stage-roads .road-track { stroke: rgba(255,224,171,.7); }
.stage-roads .road.hot .road-dirt { stroke-width: 9px; }
.stage-roads .road-echo { color: #6ff0e0; fill: currentColor; stroke: currentColor; filter: drop-shadow(0 0 5px rgba(79,255,232,.95)); }
.stage-roads .road.faded { opacity: .8; }
.stage-tiles { position: absolute; inset: 0; pointer-events: none; }

/* -- tile shell: the box is the frame; the pedestal, pips and plaque hang below it ------------------------- */
.site-tile {
  --brass: var(--brass, #b98a3c);
  position: absolute; pointer-events: auto; box-sizing: border-box;
  margin: 0; padding: 0; border: 0; background: none; color: #f2ead8;
  font: inherit; cursor: pointer; text-align: center; -webkit-tap-highlight-color: transparent;
}
.stage-health { position: absolute; z-index: 20; left: 3%; top: 81%; width: 94%; box-sizing: border-box;
  display: grid; gap: 1px; padding: 2px 4px; border: 1px solid #7bcc79; border-radius: 3px;
  background: #101b12f2; color: #f6f4e9; font: 700 10px/1.1 var(--font-body); text-align: left;
  box-shadow: 0 1px 4px #000; pointer-events: auto; cursor: help; }
.stage-health-title { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.stage-health-track { display: block; height: 5px; border: 1px solid #657165; background: #201e1b; border-radius: 2px; }
.stage-health-fill { display: block; height: 100%; background: #5fda69; }
.stage-health-value { display: block; text-align: right; font-variant-numeric: tabular-nums; }
.stage-health.damaged { border-color: #e5ad45; }
.stage-health.damaged .stage-health-fill { background: #e5ad45; }
.stage-health.critical, .stage-health.fallen { border-color: #ee6556; }
.stage-health.critical .stage-health-fill, .stage-health.fallen .stage-health-fill { background: #dc493d; }
.stage-health.cooling, .stage-health.unknown { border-color: #a9a6a0; }
.stage-health.cooling .stage-health-fill, .stage-health.unknown .stage-health-fill { background: #858987; }
.stage-health-tip { position: fixed; z-index: 9999; width: max-content; max-width: min(280px, calc(100vw - 16px));
  padding: 8px 10px; border: 1px solid #d5a648; border-radius: 4px; background: #171713f7;
  color: #f5eddc; font: 12px/1.35 var(--font-body); box-shadow: 0 6px 18px #000c; pointer-events: none; }
.stage-health-tip > div:first-child { color: #f2ca78; font-weight: 700; }
.garrison-cards { z-index: 21; position: absolute; top: 105%; left: 50%; transform: translateX(-50%);
  display: flex; justify-content: center; gap: 3px; width: max-content; max-width: 165%; pointer-events: none; }
.garrison-card { position: relative; display: block; width: clamp(32px, calc(var(--tile-w) * .3), 48px); height: 78px;
  border: 1px solid #9c7a3c; border-radius: 3px; background: #16130eec; box-shadow: 0 2px 5px #0009; }
.garrison-card .tile-art { position: absolute; left: 2px; top: 2px; width: calc(100% - 4px); height: 36px; }
.garrison-card .stage-health { top: 39px; left: 1px; width: calc(100% - 2px); padding: 1px; font-size: 8px; }
.garrison-card .stage-health-track { height: 4px; }
.garrison-card .stage-health-title { font-size: 7px; }
.site-tile:has(.garrison-card) > .tile-plaque { top: calc(105% + 82px); }
.site-tile:has(.stage-health) > .tile-pips { display: none; }
.state-outpost > .stage-health { top: 88%; }
.state-outpost > .tile-plaque { top: 120%; }
.plot-plaque { min-width: 0; max-width: min(80vw, 680px); white-space: nowrap; }
.plot-plaque > span, .plot-plaque .plaque-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-tile .tile-plaque { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-tile .tile-plaque.pending-plaque { max-width: 100%; }
.site-tile.selected::before { inset: -3px; }
.state-empty.selected::before { inset: -3px; border-radius: 12px; }
.site-tile:focus-visible { outline: 3px solid var(--amber, #f0a020); outline-offset: 6px; border-radius: 8px; }
.site-tile > * { position: absolute; pointer-events: none; }

.tile-plinth {
  z-index: 0; left: -24%; width: 148%; top: 79%; aspect-ratio: 1413 / 626;
  background: url("/art/ui/tile-pedestal.png?w=640") center / 100% 100% no-repeat;
}
.tile-art {
  z-index: 1; overflow: hidden;
  left: calc(var(--wx) * 100% - 2%); top: calc(var(--wy) * 100% - 1%); width: calc(var(--ww) * 100% + 4%); height: calc(var(--wh) * 100% + 4%);
  background: radial-gradient(ellipse at 50% 45%, #2b2620, #0d0c0a 85%);
}
.tile-frame {
  z-index: 3; inset: 0; background: url("/art/ui/tile-frame.png?w=640") center / 100% 100% no-repeat;
  filter: var(--tint, brightness(1));
}
/* per-band frames (tile-frame-<band>.png) where the kit has them; the CSS tints below stay as the fallback for a band without its own file */
.band-silver { --tint: grayscale(.92) brightness(1.18) contrast(1.05); }
.band-bronze { --tint: hue-rotate(-16deg) saturate(.8) brightness(.95) contrast(1.05); }
.band-subbronze { --tint: saturate(.3) brightness(.62) contrast(1.1); }
html.kit-tile-frame-gold .band-gold .tile-frame { background-image: url("/art/ui/tile-frame-gold.png?w=640"); --tint: none; }
html.kit-tile-frame-silver .band-silver .tile-frame { background-image: url("/art/ui/tile-frame-silver.png?w=640"); --tint: none; }
html.kit-tile-frame-bronze .band-bronze .tile-frame { background-image: url("/art/ui/tile-frame-bronze.png?w=640"); --tint: none; }
html.kit-tile-frame-subbronze .band-subbronze .tile-frame { background-image: url("/art/ui/tile-frame-subbronze.png?w=640"); --tint: none; }
html.kit-tile-frame-diamond .band-diamond .tile-frame { background-image: url("/art/ui/tile-frame-diamond.png?w=640"); --tint: none; }
.tile-frame.build {
  inset: auto; left: calc(var(--sx) * 100%); top: calc(var(--sy) * 100%); width: calc(var(--sw) * 100%); height: calc(var(--sh) * 100%);
  background-image: url("/art/ui/tile-frame-build.png?w=640");
}
html:not(.kit-tile-frame) .tile-frame { border: 3px solid var(--brass); border-radius: 10px; background: none; }

/* -- band crest: sits in the socket at the top of the frame ------------------------------------------------- */
.tile-crest { z-index: 5; left: 50%; top: -3%; width: 33%; transform: translate(-50%, -34%); }
.tile-crest img { display: block; width: 100%; height: auto; user-select: none; }
.tile-crest.stand-in.band-silver img { filter: grayscale(1) brightness(1.2); }
.tile-crest.stand-in.band-bronze img { filter: hue-rotate(-14deg) saturate(.75) brightness(.78); }
.tile-crest.stand-in.band-subbronze img { filter: saturate(.3) brightness(.55); }

/* -- art window ---------------------------------------------------------------------------------------------- */
.tile-art img { position: absolute; display: block; max-width: none; user-select: none; -webkit-user-drag: none; }
.tile-art img.crop { left: -47%; top: -31%; width: 194%; height: 187%; object-fit: fill; }          /* land tower card: the picture above its ribbon */
.tile-art img.crop-monster { left: -34%; top: -9%; width: 168%; height: 176%; object-fit: fill; }     /* monster card: the round picture */
.tile-art.is-skin img { inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: 50% 60%; }
.tile-art.full { background: none; overflow: visible; }
.tile-art.full img { filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .5)); }
.tile-art.full img.crop-monster { -webkit-mask-image: radial-gradient(ellipse 36% 42% at 50% 42%, #000 45%, transparent 100%); mask-image: radial-gradient(ellipse 36% 42% at 50% 42%, #000 45%, transparent 100%); filter: none; }
.tile-art.full img:not(.crop-monster) { inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%; }
.tile-art.full.is-skin { overflow: hidden; }
/* -- placed towers (ER-0231, ER-0288): bare elevated art, no card frame, contact shadow, cropped rock base ------------ */
.site-tile:has(.tile-art.tower-bare) > .tile-frame, .site-tile:has(.tile-art.tower-bare) > .tile-crest,
.site-tile:has(.tile-art.tower-bare) > .tile-bar, .site-tile:has(.tile-art.tower-bare) > .tile-cracks { display: none; }
.tile-art.tower-bare {
  --tw: var(--tile-w, 140px); --k: 1.08;   /* art width as a share of the tile width */
  --ring-y: .80;                           /* where the rock ring's centre sits in the image (share of its height) */
  --base-rx: 38%; --base-ry: 17%;          /* the base crop: the widest the rock ring may be, as a share of the image */
  overflow: visible; z-index: 2;
  left: calc(var(--tw) * (1 - var(--k)) / 2); width: calc(var(--tw) * var(--k)); height: calc(var(--tw) * var(--k) * 1.5);
  top: calc(var(--tw) * (1.36 - var(--k) * 1.5 * var(--ring-y)));   /* ring centre on the pedestal centre */
}
.tile-art.tower-bare img.tower-img {
  inset: 0; width: 100%; height: 100%; object-fit: contain;
  -webkit-mask-image: linear-gradient(#000, #000), radial-gradient(ellipse var(--base-rx) var(--base-ry) at 50% calc(var(--ring-y) * 100%), #000 96%, transparent 100%);
  -webkit-mask-size: 100% calc(var(--ring-y) * 100% - 2%), 100% 100%; -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: 0 0, 0 0;
  mask-image: linear-gradient(#000, #000), radial-gradient(ellipse var(--base-rx) var(--base-ry) at 50% calc(var(--ring-y) * 100%), #000 96%, transparent 100%);
  mask-size: 100% calc(var(--ring-y) * 100% - 2%), 100% 100%; mask-repeat: no-repeat; mask-position: 0 0, 0 0;
}
.tile-art.tower-bare:not(.is-skin):not(.full) { background: none; }
.tile-art.tower-bare .tower-shadow {
  position: absolute; left: 50%; top: calc(var(--ring-y) * 100% + 5%); width: 96%; height: 25%; transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at 50% 50%, rgba(14, 10, 6, .92) 0, rgba(20, 14, 8, .74) 38%, rgba(28, 20, 12, .34) 62%, transparent 76%);
  mix-blend-mode: multiply; filter: blur(3px); z-index: -1; pointer-events: none;
}
/* the health plate is a compact pill under the rock base, overlapping only the bottom of the plinth; the garrison cards
   and the label plaque hang below it (--plate-top / --plate-h keep the three in step) */
.site-tile:has(.tile-art.tower-bare) { --plate-top: 118%; --plate-h: 27px; }
.site-tile:has(.tile-art.tower-bare) > .stage-health {
  top: var(--plate-top); left: 4%; width: 92%; padding: 2px 6px 3px; border-radius: 11px;
  grid-template-columns: minmax(0, 1fr) auto; column-gap: 6px; font-size: 9px; line-height: 1.1;
}
.site-tile:has(.tile-art.tower-bare) > .stage-health .stage-health-title { grid-column: 1 / -1; }
.site-tile:has(.tile-art.tower-bare) > .stage-health .stage-health-track { align-self: center; }
.site-tile:has(.tile-art.tower-bare) > .stage-health .stage-health-value { white-space: nowrap; }
.site-tile:has(.tile-art.tower-bare):has(.garrison-card) { z-index: 2; }   /* its cards hang over the tile below, never under it */
.site-tile:has(.tile-art.tower-bare) > .garrison-cards { top: calc(var(--plate-top) + var(--plate-h) + 2px); }
.site-tile:has(.tile-art.tower-bare) > .tile-plaque { top: calc(var(--plate-top) + var(--plate-h) + 4px); }
.site-tile:has(.tile-art.tower-bare):has(.garrison-card) > .tile-plaque { top: calc(var(--plate-top) + var(--plate-h) + 100px); }
@media (max-width: 600px) and (orientation: portrait) {
  .site-tile:has(.tile-art.tower-bare) { --plate-h: 37px; }
  .site-tile:has(.tile-art.tower-bare) > .stage-health { left: 2%; width: 96%; grid-template-columns: 1fr; border-radius: 8px; }
  .site-tile:has(.tile-art.tower-bare) > .stage-health .stage-health-track { grid-column: 1; }
  .site-tile:has(.tile-art.tower-bare) > .stage-health .stage-health-title { grid-column: 1; }
  .site-tile:has(.tile-art.tower-bare) > .stage-health .stage-health-value { text-align: right; }
}
.tile-art.tower-bare.ghost img.tower-img { opacity: .6; }
.tile-art.hollow { display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .7); }
.tile-art.ghost img { opacity: .6; }
.tile-art.is-skin { --sp: #8a8f99; background: radial-gradient(ellipse at 50% 55%, color-mix(in srgb, var(--sp) 85%, #fff 0%) 0, color-mix(in srgb, var(--sp) 40%, #000) 70%, #0d0c0a 100%); }
.tile-art.sp-fire { --sp: #e0552b; } .tile-art.sp-water { --sp: #3b8fe0; } .tile-art.sp-earth { --sp: #4fa04a; }
.tile-art.sp-life { --sp: #e8e2c8; } .tile-art.sp-death { --sp: #7a4a9a; } .tile-art.sp-dragon { --sp: #d8a838; } .tile-art.sp-neutral { --sp: #8a8f99; }
.tile-skintag {
  position: absolute; left: 3px; bottom: 3px; letter-spacing: .02em;
}

/* -- durability bricks in the frame's bar plate --------------------------------------------------------------- */
.tile-bar {
  z-index: 4; display: flex; align-items: center;
  left: calc((var(--bx) + var(--bw) * .07) * 100%); width: calc(var(--bw) * 86%);
  top: calc((var(--by) + var(--bh) * .2) * 100%); height: calc(var(--bh) * 60%);
}
.tile-bricks { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; width: 100%; height: 100%; }
.brick { display: block; border-radius: 1px; background: linear-gradient(180deg, #c9c7bd, #9b988d 55%, #74716a); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 0 0 1px rgba(0, 0, 0, .55); }
.brick.miss { background: rgba(0, 0, 0, .45); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .7), 0 0 0 1px rgba(0, 0, 0, .5); }
.tile-bricks.warn .brick:not(.miss) { background: linear-gradient(180deg, #ffd08a, var(--warn, #d9822b) 60%, #a85a14); }
.tile-bricks.danger .brick { box-shadow: 0 0 0 1px rgba(208, 57, 43, .7); }

/* -- garrison pips: painted medallions on the plate's lower edge ---------------------------------------------- */
.tile-pips {
  z-index: 5; left: 0; right: 0; top: 100%; transform: translateY(-4%);
  display: flex; justify-content: center; align-items: center; gap: max(2px, calc(var(--tile-w, 100px) * .03));
}
.pip {
  --pip: max(18px, calc(var(--tile-w, 100px) * .13));
  position: relative; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
  width: var(--pip); height: var(--pip); border-radius: 50%; color: #f0d78e;
  background: radial-gradient(circle at 50% 38%, #4a3b1e, #1a1408 72%); box-shadow: 0 0 0 2px #d5a648, 0 0 0 3px #2a1c06, 0 2px 3px rgba(0, 0, 0, .6);
}
.pip.live::before, .pip.empty::before { content: ""; width: 44%; height: 44%; border-radius: 50%; background: currentColor; } /* fallback: a dot, until the kit's person icon is there */
html.kit-icon-person .pip.live::before, html.kit-icon-person .pip.empty::before {
  width: 68%; height: 68%; border-radius: 0; background: url("/art/ui/icon-person.png?w=160") center / contain no-repeat;
}
.pip.live.mine::before { filter: none; }
.pip.live:not(.mine) { box-shadow: 0 0 0 2px #5fbf5a, 0 0 0 3px #10260c, 0 2px 3px rgba(0, 0, 0, .6); }
.pip.live:not(.mine)::before { filter: hue-rotate(75deg) saturate(1.2) brightness(1.05); }
.pip.empty { background: radial-gradient(circle at 50% 38%, #3a3a3c, #151517 72%); box-shadow: 0 0 0 2px #77777b, 0 0 0 3px #1a1a1c, 0 2px 3px rgba(0, 0, 0, .6); }
.pip.empty::before { filter: grayscale(1) brightness(.55); }
.pip.fallen { width: var(--pip); height: var(--pip); color: #8b8578; background: radial-gradient(circle at 50% 38%, #2c2a26, #100f0d 72%); box-shadow: 0 0 0 2px #5c5850, 0 0 0 3px #161513; }
html.kit-icon-lantern .pip.fallen::before { content: ""; width: 60%; height: 72%; background: url("/art/ui/icon-lantern.png?w=160") center / contain no-repeat; filter: grayscale(1) brightness(.6); }
html.kit-icon-lantern .pip.fallen > .ico { display: none; } /* without the kit the sprite lantern icon stays */

/* -- label plaque on the pedestal ---------------------------------------------------------------------------- */
.tile-plaque {
  z-index: 6; left: 50%; top: 116%; transform: translateX(-50%);
  box-sizing: border-box; min-width: 70%; max-width: 150%; padding: 5px 16px 4px; white-space: nowrap;
  font: 600 clamp(12px, calc(var(--tile-w, 100px) * .1), 21px)/1.25 var(--font-body); letter-spacing: .01em; font-variant-caps: normal; text-transform: none; color: #f6eedb; text-align: center;
  background: linear-gradient(180deg, #24211d, #14120f); border: 2px solid #d5a648; border-radius: 4px;
  box-shadow: 0 0 0 1px #000, inset 0 0 0 1px rgba(0, 0, 0, .7), 0 3px 4px rgba(0, 0, 0, .55);
  text-shadow: 0 1px 1px #000;
}
html.kit-plaque-label .tile-plaque {
  border: 0; border-radius: 0; box-shadow: none; background: none; padding: 8px 28px 7px; min-width: 76%;
  border-image: url("/art/ui/plaque-label.png?w=640") 25% 9% 25% 9% fill / 9px 13px / 0 stretch;
}
.tile-plaque.warn { color: #fff1ea; background: linear-gradient(180deg, #4a1512, #2a0b09); border-color: #d64a3a; }
html.kit-plaque-danger .tile-plaque.warn { background: none; border-color: transparent; border-image: url("/art/ui/plaque-danger.png?w=640") 25% 9% 25% 9% fill / 9px 13px / 0 stretch; }
.tile-plaque.outpost { white-space: nowrap; font-size: clamp(12px, calc(var(--tile-w, 100px) * .075), 16px); }
.tile-plaque.empty-cap { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.tile-plaque.empty-cap .tile-title { line-height: 1.1; }
.tile-plaque.empty-cap .tile-subtitle { font-size: .78em; font-weight: 500; line-height: 1.05; opacity: .86; }
@media (max-width: 600px) and (orientation: portrait) {
  .tile-plaque { font-size: 12px; padding: 4px 5px 3px; white-space: normal; max-width: 150%; min-width: 0; overflow-wrap: normal; word-break: normal; }
  .tile-plaque.empty-cap { width: max-content; max-width: calc(100% - 8px); white-space: normal; padding: 4px 7px 3px; }
  html.kit-plaque-label .tile-plaque { padding: 6px 18px 5px; }
  html.kit-plaque-label .tile-plaque.empty-cap { padding: 4px 7px 3px; }
  .tile-plaque.warn { white-space: normal; width: 150%; }
  .tile-plaque.outpost { white-space: normal; width: 155%; }
}

/* -- empty site: the stone clearing --------------------------------------------------------------------------- */
.state-empty .tile-plinth { display: none; }
.tile-clearing {
  z-index: 0; left: -34%; width: 168%; top: 20%; aspect-ratio: 1413 / 866;
  background: url("/art/ui/empty-site.png?w=640") center / 100% 100% no-repeat; filter: drop-shadow(0 6px 5px rgba(15, 25, 8, .4));
}
.tile-plus {
  z-index: 2; left: 0; right: 0; top: 46%; display: flex; align-items: center; justify-content: center; font-size: 52px; font-weight: 700; line-height: 1;
  color: var(--accent, var(--amber, #f0a020)); text-shadow: 0 2px 3px rgba(0, 0, 0, .8), 0 0 10px rgba(240, 160, 32, .5);
}
.tile-plus.dim { position: static; font-size: 34px; opacity: .55; }
.state-empty .tile-plaque { top: 96%; }

/* -- outpost ------------------------------------------------------------------------------------------------- */
.state-outpost .tile-plinth { left: -22%; width: 144%; top: 62%; }
.state-outpost .tile-art { left: -14%; top: -6%; width: 128%; height: 110%; }
/* the outpost crest (kit crest-outpost.png) tops the figure; a skin (a transparent cut-out) stands on the pedestal, no window */
.state-outpost .tile-crest { top: -14%; width: 27%; }
.state-outpost .tile-crest.stand-in img { filter: hue-rotate(-14deg) saturate(.75) brightness(.78); }
.tile-art.full.is-skin { background: none; overflow: visible; }
.state-outpost .tile-art.full.is-skin { left: -32%; top: -40%; width: 164%; height: 140%; }
.state-outpost .tile-art.full.is-skin img { inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%; filter: drop-shadow(0 6px 5px rgba(0, 0, 0, .5)); }
.state-outpost .tile-art.full.is-skin .tile-skintag { left: 50%; transform: translateX(-50%); bottom: -2px; }
.tile-stake { z-index: 2; bottom: 8%; width: 7px; height: 30%; background: linear-gradient(90deg, #a06a30, #5a3a18); border-radius: 2px 2px 0 0; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); }
.tile-stake.left { left: 6%; } .tile-stake.right { right: 6%; }
.state-outpost .tile-pips { top: 96%; }
.state-outpost .tile-plaque { top: 112%; }

/* -- constructing / grace ------------------------------------------------------------------------------------- */
.state-constructing .tile-frame:not(.build) { display: none; }
.state-grace .tile-art img { filter: grayscale(.55) brightness(.8); }
.tile-cracks { z-index: 4; inset: 0; }
.tile-cracks svg { width: 100%; height: 100%; }
.tile-cracks path { stroke: rgba(0, 0, 0, .8); stroke-width: 1.8; vector-effect: non-scaling-stroke; }

/* docked construction chip: the scaffold frame at half size around the card being built */
.tile-chip { z-index: 6; left: calc(95% - var(--chip-w, .66) * 50%); top: 44%; width: calc(var(--chip-w, .66) * 100%); aspect-ratio: var(--build-ar, 942 / 907); }
.tile-chip > * { position: absolute; }
.chip-art {
  overflow: hidden; background: #14110d;
  left: calc(var(--cwx, .124) * 100% - 1%); top: calc(var(--cwy, .077) * 100% - 1%); width: calc(var(--cww, .752) * 100% + 2%); height: calc(var(--cwh, .848) * 100% + 2%);
}
.chip-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; opacity: .78; }
.chip-frame { inset: 0; background: url("/art/ui/tile-frame-build.png?w=320") center / 100% 100% no-repeat; }

/* pending intent: amber corner flag */
.tile-flag {
  z-index: 8; left: -8px; top: -14px; padding: 2px 8px 2px 6px; border-radius: 3px 3px 3px 0;
  background: var(--amber, #f0a020); color: #1a1208; font-size: 12px; font-weight: 700; line-height: 1.25; white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .5);
}

.pending-plaque { z-index: 9; left: 50%; top: -23%; transform: translateX(-50%); width: max-content; max-width: 150%; padding: 4px 7px; border: 1px solid #c7a04e; border-radius: 3px; background: rgba(18,20,23,.92); color: #f1e6d0; font-size: 12px; line-height: 1.25; box-shadow: 0 2px 8px #000b; }
.site-tile.has-pending .pending-plaque, .site-tile.has-pending .pending-card { filter: none; }
.pending-tower .tile-clearing, .pending-tower .tile-plus, .pending-tower .empty-cap { display: none; }
.pending-tower .tile-art, .pending-worker .pending-card .tile-art { filter: none; }
.pending-tower::after { content: ''; position: absolute; z-index: 2; left: calc(var(--wx) * 100% - 2%); top: calc(var(--wy) * 100% - 1%); width: calc(var(--ww) * 100% + 4%); height: calc(var(--wh) * 100% + 4%); background: rgba(11,16,17,.24); pointer-events: none; }
.pending-card { position: absolute; z-index: 9; right: -24%; top: 17%; display: grid; justify-items: center; width: 44%; padding: 4px; border: 1px solid #70cbbf; border-radius: 6px; background: rgba(14,23,23,.86); box-shadow: 0 0 10px #48e8d277; }
.pending-card .tile-art { position: relative; left: auto; top: auto; width: 100%; height: 48px; }
.pending-card .pending-caption { position: static; color: #f2ead8; font-size: 11px; }
.pending-hourglass { position: absolute; z-index: 10; right: -9%; top: -9%; width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid #c9aa61; border-radius: 50%; background: #171615; color: #f4d385; filter: drop-shadow(0 0 5px #e8a23a99); }
.pending-hourglass .ico { width: 16px; height: 16px; }

/* mine: an amber glow behind the frame */
.site-tile.mine .tile-frame { filter: var(--tint, brightness(1)); box-shadow: none; }
.site-tile.mine .tile-plaque { color: var(--amber-glow, #ffd27a); }

/* selected: an amber ring around the frame */
.site-tile.selected::before {
  content: ''; position: absolute; z-index: 7; inset: -3px -3px 0; border: 3px solid var(--amber, #f0a020); border-radius: 14px 14px 8px 8px; pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .6), 0 0 14px rgba(240, 160, 32, .55);
}
.state-empty.selected::before { inset: 22% -30% -6%; border-radius: 50%; }

/* -- painted tile parts (kit-tiles-2, ER-0127): each is gated on its kit file, the CSS look above stays the fallback -- */
html.kit-pip-gold .pip.live.mine, html.kit-pip-green .pip.live:not(.mine), html.kit-pip-hollow .pip.empty, html.kit-pip-lantern .pip.fallen {
  background-color: transparent; background-position: center; background-repeat: no-repeat; background-size: 100% 100%; box-shadow: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .6));
}
html.kit-pip-gold .pip.live.mine { background-image: url("/art/ui/pip-gold.png?w=160"); }
html.kit-pip-green .pip.live:not(.mine) { background-image: url("/art/ui/pip-green.png?w=160"); }
html.kit-pip-hollow .pip.empty { background-image: url("/art/ui/pip-hollow.png?w=160"); }
html.kit-pip-lantern .pip.fallen { background-image: url("/art/ui/pip-lantern.png?w=160"); }
html.kit-pip-gold .pip.live.mine::before, html.kit-pip-green .pip.live:not(.mine)::before, html.kit-pip-hollow .pip.empty::before { content: none; }
html.kit-pip-lantern .pip.fallen::before, html.kit-pip-lantern .pip.fallen > .ico { display: none; }

/* durability: 10 painted bricks as a wall of two courses of five, filled from the bottom-left; missing = rubble */
html.kit-brick-ok .tile-bricks { grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(2, 1fr); gap: 0 3%; }
html.kit-brick-ok .brick {
  background: url("/art/ui/brick-ok.png?w=160") center / 100% 100% no-repeat; box-shadow: none; border-radius: 0; grid-row: 1;
}
html.kit-brick-ok .brick:nth-child(-n+5) { grid-row: 2; }
html.kit-brick-ok .brick.miss { background-image: url("/art/ui/brick-rubble.png?w=160"); }
html.kit-brick-ok .tile-bricks.warn .brick:not(.miss) { background-image: url("/art/ui/brick-warn.png?w=160"); }
html.kit-brick-ok .tile-bricks.danger .brick { background-image: url("/art/ui/brick-danger.png?w=160"); box-shadow: none; }

/* grace: the painted crack overlay covers the frame (it is frame-sized) */
.tile-cracks.painted { background: url("/art/ui/crack-overlay.png?w=640") center / 100% 100% no-repeat; }

/* outposts stand on the painted plinth (stakes, flag and stone ring in one piece) */
html.kit-outpost-plinth .state-outpost .tile-plinth {
  left: -30%; width: 160%; top: 58%; aspect-ratio: 1158 / 741; background-image: url("/art/ui/outpost-plinth.png?w=640");
}
html.kit-outpost-plinth .tile-stake { display: none; }

/* the painted backdrop of any terrain: magical and occupied plots get a light tint on it (the art stays the natural one) */
.stage-terrain::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.stage-terrain[class*="tint-"]::after { opacity: 1; }
.stage-terrain.tint-occupied::after { background: linear-gradient(180deg, rgba(20, 14, 8, .18), rgba(40, 24, 8, .3)); }
.stage-terrain.tint-magical::after { background: radial-gradient(ellipse at 50% 40%, rgba(190, 150, 255, .16), rgba(80, 40, 140, .22)); mix-blend-mode: soft-light; }
.stage-terrain.tint-magical-fire::after { background: radial-gradient(ellipse at 50% 40%, rgba(255, 120, 40, .2), rgba(150, 30, 10, .25)); mix-blend-mode: soft-light; }
.stage-terrain.tint-magical-water::after { background: radial-gradient(ellipse at 50% 40%, rgba(70, 160, 255, .2), rgba(10, 50, 140, .25)); mix-blend-mode: soft-light; }
.stage-terrain.tint-magical-earth::after { background: radial-gradient(ellipse at 50% 40%, rgba(120, 200, 80, .2), rgba(30, 90, 20, .25)); mix-blend-mode: soft-light; }
.stage-terrain.tint-magical-life::after { background: radial-gradient(ellipse at 50% 40%, rgba(255, 245, 190, .22), rgba(200, 170, 80, .22)); mix-blend-mode: soft-light; }
.stage-terrain.tint-magical-death::after { background: radial-gradient(ellipse at 50% 40%, rgba(150, 90, 200, .2), rgba(30, 10, 50, .3)); mix-blend-mode: soft-light; }
.stage-terrain.tint-magical-dragon::after { background: radial-gradient(ellipse at 50% 40%, rgba(255, 210, 90, .22), rgba(160, 60, 10, .22)); mix-blend-mode: soft-light; }

/* Painted scene cards make use of the open band on sparse plots while keeping the map visible. */
.stage-details { position: absolute; z-index: 2; left: 15%; right: 15%; bottom: 88px; display: grid; grid-template-columns: minmax(250px, .8fr) minmax(420px, 2fr); gap: 8px; pointer-events: none; }
.stage-info-card { min-width: 0; min-height: 94px; padding: 12px 20px 8px; color: #e5dfd1; background: linear-gradient(180deg, rgba(20,18,16,.94), rgba(14,13,12,.93)); border: 1px solid var(--brass, #b58b45); box-shadow: 0 3px 12px #0008; }
.stage-info-card h2 { margin: 0 0 7px; padding: 2px 12px 5px; color: #f2e6cb; font: 700 17px/1.1 var(--font-display); letter-spacing: .07em; text-align: center; text-shadow: 0 1px 2px #000; }
.stage-info-card p { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.stage-info-card.work-info h2 { text-align: center; }
.stage-info-card .stat-icon { color: var(--amber); width: 18px; height: 18px; }
.stage-info-card.flow-info { text-align: center; }
.region-map { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; max-width: 150px; margin: 3px auto; }
.region-cell { display: grid; place-items: center; min-height: 20px; background: #30302d; border: 1px solid #78694c; color: #bbb; font-size: 10px; }
.region-cell.current { background: #724d20; color: #fff1c8; font-size: 11px; }
.site-info-strips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.site-info-strip { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 4px 9px; background: rgba(16,14,12,.9); border: 1px solid #8f7040; color: #eee6d7; font-size: 14px; line-height: 1.25; }
.site-info-strip b { flex: none; color: #edbd65; }
@media (min-width: 601px) and (max-height: 650px) { .stage-details { bottom: 62px; } .stage-info-card { padding: 3px 6px; } }
@media (max-width: 600px) { .stage-details { display: none; } }

/* Keep the focused site in the exposed part of a desktop/tablet map beside a panel. */
@media (min-width: 601px) {
  body.has-panel #stage { width: calc(100vw - min(640px, max(42vw, 380px))); right: auto; }
  body.has-panel:has(#layers .panel-right) #stage { left: 0; right: auto; }
  body.has-panel:has(#layers .panel-left) #stage { left: auto; right: 0; }
  body.has-panel:has(#layers .panel-wide) #stage { width: calc(100vw - min(640px, max(60vw, 380px))); }
  /* Match panel footprints that have their own narrow/wide desktop sizing rules. */
  body.has-panel:has(#layers .panel.info-panel) #stage,
  body.has-panel:has(#layers .panel.keeper-panel) #stage { width: calc(100vw - min(480px, max(30vw, 360px))); }
  /* The plot plaque opens plot info from the left, so keep that plaque in view by docking this panel right. */
  body.has-panel:has(#layers .panel.info-panel) #stage { left: 0; right: auto; }
  body.has-panel:has(#layers .panel.info-panel.panel-left) #layers .panel.info-panel { left: auto; right: 0; }
  body.has-panel:has(#layers .panel.sign-sheet) #stage,
  body.has-panel:has(#layers .panel.card-panel) #stage,
  body.has-panel:has(#layers .panel.queue-panel) #stage { width: calc(100vw - min(760px, max(38vw, 400px))); }
  /* Picker audit: its 76vw sizing hid most of the map; the accepted design uses a slim side panel. */
  html body.has-panel .panel.pick-panel { width: min(42vw, 640px); min-width: 380px; max-width: 640px; }
}

@media (min-width: 601px) {
  /* Match the stage to the actual panel width (including its min/max), eliminating the dead strip. */
  body.has-panel #stage { transition: width 180ms ease-out; }
}

.plot-load-error { position: absolute; z-index: 31; left: 50%; top: 48%; transform: translate(-50%,-50%); width: min(420px, calc(100% - 32px)); box-sizing: border-box; padding: 22px; text-align: center; color: var(--body); background: linear-gradient(180deg, #26221c, #121110); border: 2px solid var(--brass); box-shadow: 0 12px 32px #000b; }
.plot-load-error .error-mark { color: var(--warn); }
.plot-load-error h2 { margin: 8px 0; color: var(--heading); }
.plot-load-error p { margin: 8px 0 14px; overflow-wrap: anywhere; }
.error-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.error-actions .btn { min-height: 44px; }

@media (min-width: 601px) {
  .stage-details { bottom: 86px; align-items: end; gap: 4px; }
  .stage-info-card { min-height: 96px; align-self: end; padding: 9px 16px 7px; overflow: hidden; border: 0; border-image: url("/art/ui/plaque-label.png?w=640") 25% 9% 25% 9% fill / 9px 13px / 0 stretch; background: linear-gradient(180deg, rgba(35,32,26,.94), rgba(14,13,11,.93)); }
  .stage-info-card.work-info { text-align: left; }
  .stage-info-card h2 { text-align: center; font-size: 16px; }
  .stage-info-card p, .site-info-strip { font-size: 14px; }
  .site-info-strips { align-self: end; }
}
@media (max-height: 520px) and (orientation: landscape) { .stage-details { display: none !important; } }
.stage-details[hidden] { display: none !important; }
body.has-panel .stage-details { display: none !important; }
.stage-info-card { border: 1px solid var(--brass, #b58b45); }
html.kit-plaque-label .stage-info-card { border: 0; border-image: url("/art/ui/plaque-label.png?w=640") 25% 9% 25% 9% fill / 9px 13px / 0 stretch; }

/* Health affordances stay above the painted kit and the noninteractive FX canvas. */
.stage-tiles { z-index: auto; }
.fx-under { z-index: 0; }
.fx-over, .fx-pops { z-index: 6; }
.site-tile > .stage-health, .garrison-card .stage-health { pointer-events: auto; }
.site-tile > .garrison-cards { pointer-events: none; }
.site-tile:has(.garrison-card) > .tile-plaque { top: calc(105% + 82px); }
.site-tile .tile-plaque:not(.empty-cap) { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.site-tile.pending-tower .tile-plaque.pending-plaque { top: 106%; }
.plot-plaque .plaque-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.garrison-card { width: clamp(48px, calc(250px / var(--garrison-count)), 80px); height: 96px; flex: none; }
.garrison-card .tile-art { height: 45px; }
.garrison-card .stage-health { top: 48px; font-size: 10px; }
.garrison-card .stage-health-title { font-size: 9px; white-space: normal; line-height: 1.05; max-height: 2.1em; }
.site-tile:has(.garrison-card) > .tile-plaque { top: calc(105% + 100px); }
.site-tile.selected::before, .state-empty.selected::before { inset: -3px; border-radius: 12px; }
.site-tile > .tile-plaque.timed { box-sizing: border-box; width: 100%; max-width: 100%; padding: 4px 3px;
  font-size: 11px; line-height: 1.15; white-space: normal; overflow: visible; overflow-wrap: normal; }
@media (max-width: 600px) and (orientation: portrait) {
  .garrison-card { width: clamp(36px, calc(138px / var(--garrison-count)), 48px); height: 80px; }
  .garrison-card .tile-art { height: 36px; }
  .garrison-card .stage-health { top: 39px; font-size: 8px; }
  .garrison-card .stage-health-title { font-size: 8px; }
  .site-tile:has(.garrison-card) > .tile-plaque { top: calc(105% + 84px); }
}

/* Plot renderer: attach each name plate to its own plinth at every desktop size. */
@media (min-width: 601px) {
  .plot-view .plot-site .plinth { anchor-name: --site-plinth; }
  .plot-view .plot-site .plaque {
    position-anchor: --site-plinth;
    top: anchor(bottom) !important;
    margin-top: -8px;
  }
  .plot-view .plot-site:is(.state-tower, .state-grace) .plaque {
    left: anchor(center) !important;
    transform: translateX(-50%);
  }
  .plot-view .plot-site.state-tower .plaque { width: 266px !important; }
  .plot-view .plot-site.state-grace .plaque { width: 290px !important; }
  .plot-view .plot-site.state-outpost .plaque { width: 266px !important; left: anchor(center) !important; transform: translateX(-50%); }
}
.plot-view .plot-site .plaque .t { top: 12px; bottom: 12px; }
.plot-view .plot-site.state-grace .plaque .t b {
  font-size: 11px;
  line-height: 12px;
  -webkit-line-clamp: 2;
}
.plot-view .plot-site.state-grace .plaque .subtitle {
  font-size: 11px;
  line-height: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-align: center;
}
.plot-view .plot-site.state-tower .plaque .subtitle {
  font-size: 10px;
  line-height: 12px;
}

/* Picker bottom sheet: reserve the upper 28% for the map and its pinned selected tile. */
@media (max-width: 600px) and (orientation: portrait) {
  html.kit-panel-frame body.has-panel #layers .panel.pick-panel { top: 28% !important; bottom: 0 !important; height: auto; }
}

/* HUD A3: the HP / durability / construction bar sits fully inside the dark well of the painted plaque. */
.plot-view .plot-site .plaque .bar {
  --bar-h: 4px;
  left: calc(var(--plaque-inner-left) + 12px); right: calc(var(--plaque-inner-right) + 12px);
  bottom: calc(var(--plaque-inner-bottom) + 3px);
  height: var(--bar-h); box-sizing: border-box;
  border: 1px solid rgba(107, 83, 32, .55); border-radius: 999px;
  background: rgba(8, 6, 4, .72); box-shadow: inset 0 1px 1px #000a;
}
.plot-view .plot-site .plaque.compact .bar { height: var(--bar-h); }
.plot-view .plot-site .plaque .bar i { border-radius: 999px; }
/* ER-1088: a taller plate gives the bigger name room (min-height beats the inline height). */
.plot-view .plot-site .plaque { min-height: 80px; }
/* HUD A4 (ER-1088): larger card names on tower/outpost plaques; title + subtitle (+ bar) are ONE group centred in the painted well. */
.plot-view .plot-site .plaque .t {
  top: var(--plaque-inner-top); bottom: var(--plaque-inner-bottom);
  left: calc(var(--plaque-inner-left) + 8px); right: calc(var(--plaque-inner-right) + 8px);
  justify-content: center;
}
.plot-view .plot-site .plaque .t b.title {
  font-size: var(--plaque-name-size, 18px); line-height: 1.04;
  -webkit-line-clamp: 2; overflow-wrap: break-word; text-overflow: ellipsis;
}
.plot-view .plot-site .plaque .t .subtitle { font-size: 12px; line-height: 13px; }
.plot-view .plot-site.state-tower .plaque .subtitle { font-size: 11px; line-height: 13px; }
.plot-view .plot-site.state-grace .plaque .t b.title { font-size: 14px; line-height: 15px; }
.plot-view .plot-site.state-grace .plaque .subtitle { font-size: 11px; line-height: 13px; }
.plot-view .plot-site:is(.state-constructing, .state-empty, .state-fallen) .plaque .t b.title { font-size: 16px; }
/* With a bar the plaque becomes a column inside the well: text block, 4px gap, bar; the whole stack is centred, so the gap above equals the gap below. */
.plot-view .plot-site .plaque:has(> .bar) {
  container-type: size;
  display: flex; flex-direction: column; align-items: stretch;
  padding: 0;
}
.plot-view .plot-site .plaque:has(> .bar)::before { content: ""; flex: 0 0 19.6cqh; }
.plot-view .plot-site .plaque:has(> .bar)::after { content: ""; flex: 0 0 21.6cqh; }
.plot-view .plot-site .plaque:has(> .bar) > .t {
  position: relative; z-index: 1; left: auto; right: auto; top: auto; bottom: auto; flex: 0 0 auto; width: auto; padding: 0; margin: auto calc(12.7cqw + 4px) 0;
}
.plot-view .plot-site .plaque:has(> .bar) > .bar {
  position: relative; left: auto; right: auto; bottom: auto; flex: 0 0 auto; margin: 3px calc(12.7cqw + 12px) auto; width: auto;
}
/* Plaques with a bar keep the name on ONE line (ellipsis, full name stays in title/aria-label); the 80px plate has no room for a second 18px line. */
.plot-view .plot-site .plaque:has(> .bar) .t b.title { display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
