#encounter,
#expeditionDesk {
  color: #f3edcf;
  background: #19332f;
  border: 1px solid #779688;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 20px 85px #091c19a8;
}
#encounter::backdrop,
#expeditionDesk::backdrop {
  background: #0b1c1bea;
  backdrop-filter: blur(4px);
}
#encounter header,
#expeditionDesk > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  background: #142925;
}
#encounter button,
#expeditionDesk button {
  font: inherit;
  color: inherit;
  background: #294940;
  border: 1px solid #557468;
  border-radius: 8px;
  cursor: pointer;
  padding: 7px 12px;
}
#encounter button:focus-visible,
#expeditionDesk button:focus-visible {
  outline: 2px solid #edd28d;
}
#encounter button:disabled,
#expeditionDesk button:disabled {
  opacity: 0.5;
  cursor: default;
}
#encounter[open] {
  --gold: #d7bc82;
  --line: #576c54;
  --title-font: Georgia, "Songti SC", "Noto Serif CJK SC", serif;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: min(640px, calc(100vw - 16px));
  height: min(415px, calc(100dvh - 16px));
  max-width: none;
  max-height: none;
  overflow: auto;
  border: 1px solid #aa9566;
  border-radius: 12px;
  background: #132c24;
  color: #fff2ce;
}
#encounter header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: linear-gradient(105deg, #1d392b, #10271e);
  border-bottom: 1px solid #8c8158;
}
.duel-region,
#encounter .duel-back,
.duel-controls nav button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.duel-region {
  min-width: 0;
  color: var(--gold);
  font: bold 15px var(--title-font);
}
.duel-round {
  font: bold 13px var(--title-font);
  color: #f7e5b4;
  letter-spacing: 0.06em;
}
#encounter .duel-back {
  justify-self: end;
  padding: 3px 7px;
  border-color: var(--line);
  font-size: 12px;
}
#encounter .ui-icon {
  width: 14px;
  height: 14px;
  flex: none;
}

.duel-stage {
  flex: 1 1 auto;
  position: relative;
  min-height: 94px;
  isolation: isolate;
  overflow: hidden;
  container-type: size;
  background: var(--duel-backdrop, url("/art/battle-meadow.webp")) center 62% /
    cover #546b47;
  --cell-size: 6.25cqw;
  --map-padding-x: 0px;
  --map-padding-y: 0px;
}
.duel-sprite {
  position: absolute;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  isolation: isolate;
}
.foe-sprite {
  left: 26%;
  top: 36%;
  width: min(15%, 46cqh, 88px);
}
.ally-sprite {
  left: 74%;
  top: 70%;
  width: min(19%, 53cqh, 110px);
}
.duel-sprite::before {
  content: "";
  position: absolute;
  inset: 76% 12% 3%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(ellipse, #2634299c, transparent 72%);
}
#encounter
  .duel-sprite
  :is(.pixel-pet, .asset-sprite-wrap, .map-art-sprite, .asset-sprite) {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  max-width: none;
  max-height: none;
  object-fit: contain;
}
.duel-stage .battle-fx-canvas {
  pointer-events: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}
.duel-pop {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  white-space: nowrap;
  font: 700 14px/1.15 var(--title-font);
  font-variant-numeric: tabular-nums;
  color: #ffedbf;
  text-shadow:
    0 1px 3px #201408,
    1px 0 2px #201408;
  animation: duel-number 0.96s ease-out both;
}
.duel-pop.hit, .duel-pop.crit {
  color: #ff7974;
  -webkit-text-stroke: 2px #42121b;
  paint-order: stroke fill;
  text-shadow: 0 1px 2px #33111b;
}
.duel-pop.crit {
  color: #ff625d;
  font-size: 21px;
  font-weight: 850;
}
.duel-pop.restore {
  color: #c9ffac;
}
.duel-pop.ward {
  color: #c2eaff;
}
@keyframes duel-number {
  0% {
    transform: translate(-50%, 0) scale(0.9);
  }
  20% {
    transform: translate(-50%, -4px) scale(1.1);
  }
  75% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -17px);
    opacity: 0;
  }
}

/* A luminance mask lifts the illustrated strokes off the dark atlas background. */
.duel-paint {
  position: absolute;
  z-index: 3;
  width: min(var(--paint-size), 40cqh);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.duel-paint::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/art/duel-spells.webp") var(--atlas-pos) / 500% 200%;
  mask: url("/art/duel-spells.webp") var(--atlas-pos) / 500% 200% luminance;
  filter: brightness(1.45) saturate(1.2);
}
.duel-paint.flight {
  filter: drop-shadow(0 0 3px var(--ink));
}
.duel-paint.flight::after {
  content: "";
  position: absolute;
  right: 65%;
  top: 49%;
  width: 65%;
  height: 3px;
  border-radius: 50%;
  background: linear-gradient(90deg, transparent, var(--ink));
}
.duel-paint.charge {
  animation: duel-charge 210ms ease-out both;
}
@keyframes duel-charge {
  from {
    opacity: 0.75;
    transform: translate(-50%, -50%) scale(0.76);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.34);
  }
}
.duel-paint .skill-glyph {
  --combat-color: var(--ink);
  position: absolute;
  width: 44%;
  height: 44%;
  right: -7%;
  bottom: 0;
  opacity: 0.8;
  filter: drop-shadow(0 1px 2px #193329);
}
.duel-paint.strike {
  animation: duel-strike 370ms ease-out both;
}
.duel-paint.strike::after {
  content: "";
  position: absolute;
  inset: 21%;
  border-radius: 50%;
  border: 2px solid transparent;
  border-inline-color: var(--ink);
  filter: drop-shadow(0 0 2px var(--ink));
  animation: duel-impact-ring 300ms ease-out both;
}
.duel-paint.strike.critical::after {
  inset: 13%;
  border-color: #ffe1ad var(--ink);
  border-style: double;
  border-width: 4px;
  animation-duration: 355ms;
}
@keyframes duel-impact-ring {
  from { opacity: 1; transform: rotate(-28deg) scale(.38, .55); }
  to { opacity: 0; transform: rotate(18deg) scale(1.18, .93); }
}
.duel-paint.mend {
  animation: duel-mend 590ms ease-out both;
}
.duel-paint.ward {
  animation: duel-ward 520ms ease-out both;
}
.duel-paint.mend::after,
.duel-paint.ward::after {
  content: "";
  position: absolute;
  inset: 8%;
  border: 1px solid var(--ink);
  border-radius: 50%;
  box-shadow:
    0 0 7px var(--ink),
    inset 0 0 8px var(--ink);
}
.duel-paint.mend::after {
  inset: 68% 3% 9%;
  border-width: 0 0 2px;
  transform: rotate(-14deg);
}
.duel-paint.ward::after {
  border-radius: 48% 48% 50% 50% / 30% 30% 76% 76%;
  background: linear-gradient(130deg, transparent 33%, #fff7, transparent 60%);
}
@keyframes duel-strike {
  0% {
    transform: translate(-50%, -50%) rotate(-17deg) scale(0.58);
  }
  25% {
    transform: translate(-50%, -50%) scale(1.16);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(9deg) scale(1.28);
  }
}
@keyframes duel-mend {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.65);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -82%) scale(1.08);
  }
}
@keyframes duel-ward {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }
  22%,
  65% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.12);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.98);
  }
}

.duel-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 6px 10px;
  background: #1b362b;
  border-block: 1px solid var(--line);
}
.duel-hud {
  min-width: 0;
}
.duel-hud + .duel-hud {
  padding-inline-start: 12px;
  border-inline-start: 1px solid var(--line);
}
.duel-vitals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 9px;
}
.duel-name {
  grid-column: 1/-1;
  display: flex;
  gap: 6px;
  align-items: baseline;
  min-width: 0;
}
.duel-name b {
  font: bold 13px var(--title-font);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.duel-name span {
  color: #c8ceb7;
  font-size: 10px;
  white-space: nowrap;
}
.duel-hud .resource label {
  display: flex;
  gap: 4px;
  align-items: baseline;
  margin: 0;
  font:
    10px/1.3 system-ui,
    sans-serif;
  color: #dce4ca;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.duel-meter {
  position: relative;
  margin-top: 2px;
  height: 4px;
  background: #405749;
  border-radius: 3px;
  overflow: hidden;
}
.duel-meter i {
  position: relative;
  width: var(--fill);
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #60b776, #b4e481);
  transition: width 0.24s;
}
/* Hold the previous HP position through contact, then let the trail catch up. */
.hp .duel-meter::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--fill);
  background: #e89b7d;
  transition: width .26s ease-out .18s;
}
.mp .duel-meter i {
  background: linear-gradient(90deg, #608add, #7ed1ec);
}
.low .duel-meter i {
  background: #f3ac72;
}
.duel-stage-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  min-height: 23px;
  box-sizing: border-box;
  background: #14291f;
}
.duel-feedback {
  font-size: 11px;
  color: #e6e6ca;
  min-width: 0;
  line-height: 1.3;
}
.duel-turn {
  flex: none;
  display: flex;
  gap: 7px;
  align-items: baseline;
  font-size: 11px;
  color: var(--gold);
}
.duel-turn time {
  font-variant-numeric: tabular-nums;
}

.duel-controls {
  padding: 0 8px 7px;
}
.duel-controls nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-block: 1px solid #50634b;
}
#encounter .duel-controls nav button {
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 4px;
  min-width: 0;
  font:
    600 12px/1.3 system-ui,
    sans-serif;
  color: #d0d8bc;
}
#encounter .duel-controls nav button[aria-pressed="true"] {
  color: #f5d58c;
  box-shadow: inset 0 -2px #d1b57b;
}
.duel-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin-top: 5px;
  max-height: 88px;
  overflow: auto;
}
#encounter .duel-options button {
  text-align: left;
  padding: 4px 6px;
  min-width: 0;
  border-radius: 5px;
  border: 1px solid #526951;
  background: #203a2e;
  color: #f2ecd7;
  font-size: 12px;
  line-height: 1.3;
}
#encounter .spell-card {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  column-gap: 4px;
  align-content: center;
}
.spell-card .ui-icon {
  align-self: center;
  color: #f4c68f;
}
.spell-card[data-category="heal"] .ui-icon {
  color: #a7dba9;
}
.spell-card[data-category="defense"] .ui-icon {
  color: #a9cdec;
}
.spell-card b {
  overflow-wrap: anywhere;
  font-size: 12px;
}
.duel-options small {
  display: block;
  grid-column: 1/-1;
  color: #c3ceb8;
  font-size: 10px;
  margin-top: 2px;
}
#encounter .duel-options button:enabled:hover {
  background: #314b39;
  border-color: #b7a472;
}
.duel-options p {
  grid-column: 1/-1;
  margin: 5px;
  font-size: 12px;
}
.duel-controls > strong {
  margin-right: 10px;
  font-size: 13px;
}
@media (max-width: 480px) {
  #encounter[open] {
    width: calc(100vw - 12px);
    height: min(427px, calc(100dvh - 12px));
  }
  .duel-status {
    padding: 5px 7px;
    gap: 7px;
  }
  .duel-hud + .duel-hud {
    padding-inline-start: 7px;
  }
  .duel-hud .resource label {
    display: block;
    font-size: 10px;
  }
  .duel-hud .resource label span {
    display: block;
  }
  .duel-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 100px;
  }
  #encounter .duel-options button {
    min-height: 36px;
  }
  #encounter .duel-controls nav button {
    min-height: 29px;
  }
}
@media (max-height: 370px) {
  .duel-stage {
    min-height: 76px;
  }
  .duel-options {
    max-height: 68px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .duel-paint {
    display: none;
  }
  .duel-pop {
    animation: none;
    transform: translateX(-50%);
  }
  .duel-meter i, .hp .duel-meter::before {
    transition: none;
  }
}

.book-row small,
.shop-heading small {
  display: block;
  font-size: 0.75em;
  color: #b3cbbd;
}
#expeditionDesk {
  width: min(490px, 94vw);
  max-height: 85dvh;
}
#expeditionDesk h2 {
  margin: 0;
  font-size: 1.2rem;
}
.desk-body {
  padding: 16px;
}
.desk-body label,
.shop-heading,
.book-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.desk-body label {
  justify-content: space-between;
  margin: 8px 0;
}
.desk-body select {
  max-width: 75%;
  padding: 5px;
}
.desk-body p {
  font-size: 0.86em;
}
.shop-heading img {
  width: 92px;
  height: 92px;
  object-fit: contain;
}
.book-row {
  padding: 8px 0;
  border-bottom: 1px solid #6d8c713d;
}
.book-row span {
  flex: 1;
}
.book-row i {
  font-size: 0.8em;
}
.desk-body summary {
  padding: 12px 0;
  cursor: pointer;
}
#resumeEncounter:not([hidden]) {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 12px;
  z-index: 1800;
  color: #ffe8ad;
  background: #284037;
  border: 1px solid #dcc385;
  border-radius: 20px;
  padding: 7px 18px;
}

.map-battle-state,
.world-monster .map-battle-state {
  position: absolute;
  inset: 2% 0 auto auto;
  z-index: 3;
  display: grid;
  place-items: center;
  width: clamp(10px, calc(var(--cell-size, 40px) * 0.31), 16px);
  aspect-ratio: 1;
  box-sizing: border-box;
  padding: 1px;
  border-radius: 50%;
  border: 1px solid #ceb880;
  background: #263528ed;
  color: #f2db92;
  pointer-events: none;
}
.map-battle-state svg {
  width: 100%;
  height: 100%;
}
[data-name-tone="own"] {
  --paper-name-ink: #79550e;
  --pet-name-ink: #ffda79;
}
[data-name-tone="wild"] {
  --paper-name-ink: #39483e;
  --pet-name-ink: #fff;
}
[data-name-tone="other"] {
  --paper-name-ink: #286544;
  --pet-name-ink: #a8eda7;
}
[data-name-tone="guardian"] {
  --paper-name-ink: #6e467f;
  --pet-name-ink: #e4c5ff;
}
html body .world .pet-avatar .map-pet-name[data-name-tone],
html body .world .pet-avatar.selected .map-pet-name[data-name-tone],
html
  body
  .world
  .pet-avatar[aria-pressed="true"]
  .map-pet-name[data-name-tone] {
  color: var(--pet-name-ink) !important;
  background: linear-gradient(#314935f2, #172d21f5);
}
html body .world .pet-avatar.selected .map-pet-name[data-name-tone] {
  border-color: #f5d58c;
}
.duel-name [data-name-tone] {
  color: var(--pet-name-ink, #f6edcf);
}
.formation-slots [data-name-tone] {color:var(--paper-name-ink);}
#petProfileModal #petProfileTitle[data-name-tone],
#petName .pet-name-text[data-name-tone] {
  color: var(--paper-name-ink) !important;
  background: transparent;
  padding: 0;
}
.pet-chip [data-name-tone] {
  width: fit-content;
  max-width: 100%;
  color: var(--pet-name-ink);
  background: #293d2e;
  border-radius: 5px;
  padding: 1px 5px;
}
.formation-editor > p {
  margin: 0 0 12px;
  color: var(--sb-ink-soft);
  font-size: 13px;
}
.formation-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.formation-slots li {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border: 1px solid var(--sb-line);
  border-radius: 12px;
  background: radial-gradient(ellipse at center, #fffdf4, var(--sb-paper-2) 85%);
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 var(--sb-line-soft);
}
.formation-slots li:has(.formation-vacant) {
  border-style: dashed;
  color: var(--sb-ink-soft);
  background: #efedde;
}
.formation-slots li small,
.formation-slots li span:not(.formation-face):last-child {
  color: var(--sb-ink-soft);
  font-size: 11px;
}
.formation-slots li b,
.formation-roster b {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.formation-face,
.formation-vacant {
  display: grid;
  place-items: center;
  width: clamp(44px, 13vw, 76px);
  height: clamp(44px, 13vw, 76px);
}
.formation-vacant svg {
  width: 30px;
  height: 30px;
  opacity: 0.45;
}
#expeditionDesk
  .formation-face
  :is(.pixel-pet, .asset-sprite-wrap, .asset-sprite, .map-art-sprite, img) {
  padding: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
}
.formation-editor h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  margin: 16px 0 8px;
}
.formation-editor h3 small {
  color: var(--sb-forest);
  font-size: 12px;
}
.formation-roster {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
#expeditionDesk .formation-roster button {
  min-width: 0;
  display: flex;
  align-items: center;
  text-align: left;
  gap: 6px;
  padding: 5px 7px;
}
.formation-roster button[aria-pressed="true"] :is(small, em) {color:#f4edcd;}
.formation-roster .formation-face {
  width: 36px;
  height: 36px;
  flex: none;
}
.formation-roster button > span:nth-child(2) {
  display: grid;
  min-width: 0;
}
.formation-roster small {
  font-size: 10px;
  color: var(--sb-ink-soft);
}
.formation-roster em {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  color: var(--sb-forest);
}
.formation-editor footer {
  margin: 16px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
@media (max-width: 430px) {
  .formation-roster {
    grid-template-columns: 1fr;
  }
}

/* Camera settles on the arena as the combatants take their positions. */
@media (prefers-reduced-motion: no-preference) {
  #encounter[open] { animation: duel-arrive 480ms cubic-bezier(.16,.82,.28,1) both; }
  #encounter[open]::backdrop { animation: duel-map-dim 350ms ease-out both; }
  #encounter[open] .duel-stage::after {
    content:""; position:absolute; inset:0; z-index:1; pointer-events:none;
    background:radial-gradient(ellipse at 50% 54%,transparent 22%,#172922b8 67%,#101918 100%);
    animation:duel-focus 750ms ease-out both;
  }
  #encounter[open] .foe-sprite {animation:duel-land 600ms cubic-bezier(.16,.85,.3,1) both;}
  #encounter[open] :is(.ally-sprite,.raid-wing) {animation:duel-rush 520ms cubic-bezier(.15,.85,.2,1) both;}
  #encounter[open][data-leaving] { animation:duel-depart 180ms ease-in both; }
  #encounter[open][data-leaving]::backdrop { animation:duel-map-dim 180ms ease-in reverse both; }
}
@keyframes duel-arrive {from {opacity:.1;scale:1.095;filter:blur(2px);} to {opacity:1;scale:1;filter:blur(0);}}
@keyframes duel-focus {from {opacity:1;scale:.90;} to {opacity:0;scale:1.2;}}
@keyframes duel-land {from {opacity:0;translate:-8% -22%;scale:1.18;} 55% {opacity:1;translate:0 4%;} to {translate:0 0;scale:1;}}
@keyframes duel-rush {from {opacity:0;translate:29% 12%;} 70% {opacity:1;translate:-3% 0;} to {translate:0 0;}}
@keyframes duel-map-dim {from {opacity:0;} to {opacity:1;}}
@keyframes duel-depart {to {opacity:0; transform:scale(.97) translateY(5px);}}

/* Silver brush strokes are tinted with the caster's element. The central
   illustration stays in its own layer, so a trail never obscures the weapon. */
.duel-paint.has-recipe { --brush-position:0% 0%; }
.duel-paint.has-recipe::before {display:none;}
.duel-paint.has-recipe::after {
  content:""; position:absolute; inset:-18%; border:0; border-radius:0; box-shadow:none;
  background:linear-gradient(148deg,#fffce7,var(--ink) 38%,var(--ink) 72%,#fff);
  mask:url("/art/duel-brushlight.webp") var(--brush-position) / 200% 200% no-repeat;
  pointer-events:none;
}
.duel-paint.has-recipe .skill-glyph {
  --combat-color:var(--ink); z-index:1; inset:13%; width:74%; height:74%; opacity:1;
  filter:drop-shadow(0 1px 1px #26334299) drop-shadow(0 0 2px var(--ink));
}
.duel-paint.charge.has-recipe {animation:duel-gather 180ms ease-out both;}
.duel-paint.charge.has-recipe .skill-glyph {inset:29%; width:42%; height:42%;}
.duel-paint.flight.has-recipe {--brush-position:100% 0%;filter:none;}
.duel-paint.flight.has-recipe::after {
  inset:12% 46% 12% -60%;width:auto;height:auto;transform-origin:94% 50%;
  transform:rotate(var(--wake-angle,0deg));opacity:.84;
}
.duel-paint.flight.has-recipe .skill-glyph {inset:5%; width:90%; height:90%;}
.duel-paint.strike.has-recipe,.duel-paint.echo.has-recipe {--brush-position:0% 100%;}
.duel-paint.strike.has-recipe::after {animation:duel-shard-bloom 320ms ease-out both;}

.duel-paint.echo.has-recipe {animation:duel-echo 185ms ease-out both;}
.duel-paint.echo.has-recipe .skill-glyph {display:none;}
.duel-paint.mend.has-recipe,.duel-paint.ward.has-recipe {--brush-position:100% 100%;}
.duel-paint.mend.has-recipe::after,.duel-paint.ward.has-recipe::after {inset:-10% -25% -28%;transform:none;}
.duel-paint.ward.has-recipe .skill-glyph {inset:14% 23% 40%;width:54%;height:54%;}
@keyframes duel-gather {
  0% {opacity:0;transform:translate(-50%,-50%) scale(1.18) rotate(-20deg);}
  45% {opacity:1;}
  100% {opacity:0;transform:translate(-50%,-50%) scale(.35) rotate(16deg);}
}
@keyframes duel-shard-bloom {
  from {opacity:1;transform:scale(.42);}
  to {opacity:0;transform:scale(1.22);}
}
@keyframes duel-echo {
  from {opacity:.8;transform:translate(-50%,-50%) rotate(26deg) scale(.56);}
  to {opacity:0;transform:translate(-50%,-50%) rotate(32deg) scale(.94);}
}

/* The contact sheet is a transparent brush mask. The skill silhouette stays
   in front, while the shape behind it describes what happened on impact. */
.duel-paint.block, .duel-paint.slip {
  width:min(22cqw,48cqh,96px);
  animation:duel-contact .35s ease-out both;
}
.duel-paint:is(.block,.slip)::before, .duel-paint.mend:not(.has-recipe)::before {display:none;}
.duel-paint.block::after, .duel-paint.slip::after,
.duel-paint.mend::after, .duel-paint.strike.critical::after {
  content:"";
  position:absolute;
  inset:0;
  border:0;
  border-radius:0;
  box-shadow:none;
  mask:url("/art/duel-contact.webp") var(--contact-cell) / 200% 200% no-repeat;
  background:linear-gradient(125deg,#fffbe1 15%,var(--contact-ink) 57%,#fcfff0 84%);
}
.duel-paint.block {--contact-cell:0% 0%;--contact-ink:#78ddf6;}
.duel-paint.slip {--contact-cell:100% 0%;--contact-ink:#a0ddd4;}
.duel-paint.block::after {transform:translateX(calc(-13% * var(--facing))) scaleX(var(--facing));}
.duel-paint.slip::after {transform:scaleX(var(--facing));}
.duel-paint.mend {--contact-cell:0% 100%;--contact-ink:#97eea4;}
.duel-paint.mend.has-recipe::after {inset:-18% -15%;opacity:.88;}
.duel-paint.strike.critical {--contact-cell:100% 100%;--contact-ink:#ffbc79;}
.duel-paint.strike.critical::after {inset:-25%;animation:duel-critical-contact 345ms ease-out both;}
@keyframes duel-contact {
  0% {opacity:.3; transform:translate(-50%,-50%) scale(.76);}
  18%,38% {opacity:1; transform:translate(-50%,-50%) scale(1);}
  100% {opacity:0; transform:translate(-50%,-50%) scale(1.12);}
}
@keyframes duel-critical-contact {
  0% {opacity:.8;transform:scale(.46);}
  14%,34% {opacity:1;transform:scale(1);}
  100% {opacity:0;transform:scale(1.17);}
}

@media (prefers-reduced-motion: no-preference) {
  .duel-paint.flight:is([data-recipe="leaves"],[data-recipe="reed_blade"],[data-recipe="vortex"],[data-recipe="inferno"],[data-recipe="cyclone"]) .skill-glyph {
    animation:duel-blade-spin 280ms linear both;
  }
  .duel-paint.flight:is([data-recipe="waves"],[data-recipe="droplet"],[data-recipe="bubble"],[data-recipe="embers"]) .skill-glyph {
    animation:duel-surge 135ms ease-in-out infinite alternate;
  }
}
@keyframes duel-blade-spin {to {rotate:260deg;}}
@keyframes duel-surge {from {scale:.82 1.1;} to {scale:1.13 .87;}}

/* Three fixed field positions keep incoming attacks attached to their targets. */
#encounter.raid .duel-stage {min-height:110px;}
#encounter.raid .duel-sprite.duel-boss {width:min(32%,85cqh,165px); left:25%;top:50%;}
.duel-boss::before {background:radial-gradient(ellipse,#30182bbf,#81513e75 43%,transparent 72%);}
#encounter.raid .ally-sprite {width:min(17%,44cqh,89px);left:66%;top:70%;}
.raid-wing {width:min(15%,39cqh,80px);}
.raid-wing[data-wing="1"] {left:77%;top:32%;}
.raid-wing[data-wing="2"] {left:87%;top:69%;}
.duel-sprite.fallen {opacity:.35;filter:grayscale(1);}
#encounter.raid .duel-controls nav {grid-template-columns:repeat(4,minmax(0,1fr));}
.raid-orders {display:flex;gap:4px;padding:3px 0;}
#encounter .raid-orders button {
  flex:1;min-width:0;display:flex;align-items:center;justify-content:space-between;gap:3px;
  min-height:24px;padding:2px 6px 5px;font:11px/1.2 var(--title-font);
  background:linear-gradient(90deg,#8db895 var(--hp),#395548 var(--hp)) bottom/100% 2px no-repeat,#223b30;
  border:1px solid #546b58;border-radius:5px;
}
#encounter .raid-orders button[aria-pressed="true"] {border-color:var(--gold);color:#ffe4a7;}
.raid-orders b {overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}
.raid-orders small {font:9px/1.2 system-ui;white-space:nowrap;color:#e0e6d5;}
.raid .foe-card .duel-name b {color:#ffe1a1;}
.fusion-race-choice:not([hidden]) {display:grid;gap:5px;padding:7px 0;color:var(--sb-ink,#264836);}
.fusion-race-choice p {margin:0;font-size:12px;}
.fusion-race-choice div {display:flex;gap:5px;flex-wrap:wrap;}
.fusion-race-choice button {min-height:32px;padding:3px 8px;font-size:12px;}

#encounter .duel-sprite .duel-pet-facing {
  display:block; width:100%; height:100%; padding:0; border:0;
  border-radius:12%; background:transparent; box-shadow:none; cursor:pointer;
}
.duel-pet-facing:focus-visible { outline:2px solid #ffe2a3; }
.duel-pet-facing img.portrait-mirrored { scale:-1 1; }

/* Gold filigree frames the elemental shape throughout a legendary cast. */
.duel-paint.legendary .legend-halo {
  position:absolute; inset:3%; border-radius:50%; pointer-events:none;
  border:1px solid #ffe094a8; box-shadow:0 0 7px var(--ink),inset 0 0 8px #ffdc8755;
  animation:legend-seal .36s ease-out both;
}
.legend-halo::before,.legend-halo::after {
  content:""; position:absolute; inset:5%; border:2px dashed #fff0bd; border-radius:50%;
  mask-image:conic-gradient(#000 0 17%,transparent 20% 32%,#000 36% 53%,transparent 55% 67%,#000 70% 88%,transparent 91%);
}
.legend-halo::after {inset:13%; transform:rotate(52deg); border:1px solid var(--ink);}
.duel-paint.flight .legend-halo {inset:18%; animation:legend-orbit .45s linear infinite;}
.duel-paint:is(.strike,.mend,.ward) .legend-halo {animation:legend-release .38s ease-out both;}
@keyframes legend-seal {from {opacity:0; transform:rotate(-48deg) scale(1.28);} to {opacity:.94; transform:scale(.88);}}
@keyframes legend-orbit {to {transform:rotate(120deg);}}
@keyframes legend-release {from {opacity:.96; transform:scale(.45);} to {opacity:0; transform:scale(1.42) rotate(28deg);}}
.duel-paint .ancestral-stars path {
  stroke-dasharray:1; animation:legend-trace .26s ease-out both;
}
@keyframes legend-trace {from {stroke-dashoffset:1; opacity:.4;} to {stroke-dashoffset:0; opacity:.9;}}
.spell-card[data-quality="5"]:not(:disabled) .ui-icon {color:#ffdc8b;}
