/* Battlefield and hand share a single bounded play surface. */
main:has(.combat-board) {
  padding-top: 14px;
}
.combat-board {
  --red: #ff846a;
  --blue: #9ad7ef;
  --purple: #d9b2ff;
  --gilt: #f1d18e;
}
.field {
  height: clamp(352px, 35vw, 480px);
  isolation: isolate;
  position: relative;
  overflow: hidden;
  border: 1px solid #8b7350;
  border-bottom: 3px solid #aa8c55;
  background: #302f21;
  color: #fff6e8;
}
.fieldArt,
.field:before {
  position: absolute;
  inset: 0;
  height: 100%;
  width: 100%;
  z-index: -2;
  object-fit: fill;
}
.field:before {
  content: "";
  z-index: -1;
  background: linear-gradient(
    180deg,
    #121411ca 0%,
    #18181628 22%,
    transparent 52%,
    #0b0c0a12 75%,
    #161611ba 100%
  );
}
.fieldHeading {
  position: absolute;
  inset: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 24px;
  z-index: 2;
  pointer-events: none;
  text-shadow: 0 2px 6px #171711;
}
.fieldHeading p,
.tell small {
  font: 700 0.64rem/1.3 var(--body);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #ffe2a2;
}
.fieldHeading h1 {
  font: 500 clamp(1.3rem, 2.3vw, 2.05rem)/1.12 var(--display);
  letter-spacing: -0.035em;
  color: #fff3d9;
}
.turnFlag,
.tell,
.actorVitals {
  color: #fff6de;
  background: #1a1a18f5;
  border: 1px solid #b59a64;
  box-shadow: 0 3px 8px #1a100b80;
}
.turnFlag {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 13px;
  border-radius: 2px;
  font-size: 0.77rem;
  max-width: 55%;
  line-height: 1.15;
}
.turnFlag i {
  height: 4px;
  width: 4px;
  transform: rotate(45deg);
  background: #f1cc80;
}
.turnFlag b {
  color: #f4d58e;
}
.stageActors,
.effectLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.stageActors {
  z-index: 1;
}
.effectLayer {
  z-index: 6;
  overflow: hidden;
}
.fieldActor {
  position: absolute;
  inset: 0 auto 0 9%;
  width: 32%;
  z-index: 1;
}
.fieldActor.enemy {
  left: auto;
  right: 9%;
}
.actorDock {
  position: absolute;
  bottom: 22%;
  width: 100%;
  height: 51%;
  isolation: isolate;
}
.figureMover,
.fieldActor .boardModel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.boardModel:before {
  display: none;
}
.boardModel .modelFallback {
  width: auto;
  max-width: 80%;
  height: 85%;
  inset: auto auto 1% 50%;
  transform: translateX(-50%);
  border-radius: 9px;
  box-shadow: 0 4px 15px #0008;
  border: 1px solid #b19a6e;
}
.groundShadow {
  position: absolute;
  bottom: 1%;
  height: 11%;
  left: 17%;
  right: 17%;
  border-radius: 50%;
  background: radial-gradient(
    ellipse,
    #191617a6 0%,
    #201c1860 38%,
    transparent 72%
  );
  z-index: -1;
}
.actorVitals {
  position: absolute;
  top: 77%;
  left: 50%;
  transform: translateX(-50%);
  width: min(91%, 220px);
  padding: 5px 7px 6px;
  border-radius: 3px;
}
.actorName {
  text-align: center;
  font: 600 clamp(0.86rem, 1.42vw, 1.17rem)/1.1 var(--display);
  margin: 0 0 4px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.lifeRow {
  display: flex;
  gap: 5px;
  align-items: center;
}
.hpTrack {
  position: relative;
  isolation: isolate;
  flex: 1;
  height: 16px;
  overflow: hidden;
  border: 1px solid #b29d7d;
  border-radius: 3px;
  background: #341e20;
}
.hpFill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(#c96553, #a83d32);
  z-index: -1;
  transition: width 0.18s ease-out;
}
.hpTrack > b {
  display: block;
  text-align: center;
  font: 700 0.71rem/14px var(--body);
  color: #fff;
  text-shadow:
    0 1px 2px #000,
    0 0 3px #000;
}
.blockCount {
  display: flex;
  gap: 2px;
  color: #bce9ff;
  font-size: 0.78rem;
  align-items: center;
  line-height: 1;
}
.blockCount .emblem {
  width: 16px;
  height: 16px;
}
.fieldStatuses {
  position: absolute;
  top: 91%;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
}
.fieldStatuses span {
  padding: 1px 5px;
  background: #181b17f0;
  border: 1px solid #7a7057;
  color: #f8e8b8;
  font-size: 0.65rem;
}
.tell {
  position: absolute;
  left: 50%;
  bottom: 74%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1px 8px;
  padding: 5px 10px 6px;
  min-width: 148px;
  max-width: 100%;
  width: max-content;
  border-color: #cbb58a;
  border-radius: 5px;
}
.tell:after {
  position: absolute;
  content: "";
  height: 8px;
  width: 8px;
  bottom: -5px;
  left: calc(50% - 4px);
  transform: rotate(45deg);
  border: solid #cbb58a;
  border-width: 0 1px 1px 0;
  background: #1a1a18;
}
.tellWords {
  display: grid;
}
.tell small {
  color: #e8c99d;
  font-size: 0.55rem;
  letter-spacing: 0.1em;
}
.tell b {
  font: 600 1rem/1.07 var(--display);
}
.tellIcon {
  color: #f1bb74;
  display: flex;
}
.tell-attack .tellIcon,
.tell-attack .tellAmount {
  color: #ff987c;
}
.tell-guard .tellIcon {
  color: #a3d8fa;
}
.tellIcon .emblem {
  width: 26px;
  height: 26px;
}
.tellAmount {
  font: 700 1.4rem/1 var(--display);
  white-space: nowrap;
}
.tellExtra {
  grid-column: 2/-1;
  font-size: 0.66rem;
  line-height: 1.1;
  color: #e7d9ba;
}
.emblem {
  width: 17px;
  height: 17px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
.floatLayer {
  position: absolute;
  inset: 7% -35% auto;
  text-align: center;
  z-index: 8;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.floatText {
  font: 800 clamp(1.2rem, 2.9vw, 2.65rem)/1.12 var(--display);
  color: #ffb098;
  white-space: nowrap;
  text-shadow:
    -2px -2px #301a15,
    2px -2px #301a15,
    -2px 2px #301a15,
    2px 2px #301a15,
    0 4px 6px #0009;
}
.floatText.guard {
  color: #b4e5ff;
}
.floatText.gain {
  color: #f6dc9f;
  font-size: clamp(1rem, 2.4vw, 2rem);
}
.spellTrail {
  position: absolute;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  box-shadow:
    0 0 7px 5px #ad9bff,
    0 0 20px 10px #6c6be0;
  background: white;
}
.battleTray {
  background: linear-gradient(#282720, #1a1d19 46%, #20221d);
  border: 1px solid #63543c;
  border-top: 0;
  padding: 0 clamp(9px, 2vw, 26px) 0;
}
.turnTools {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 72px;
}
.energyWrap {
  display: flex;
  gap: 9px;
  align-items: center;
}
.energyOrb {
  height: 45px;
  width: 45px;
  border: 2px solid #e3c582;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 27%, #527da1, #233f68 65%, #192a46);
  color: #ffedbc;
  font: 700 1.7rem/1 var(--display);
  box-shadow:
    inset 0 0 0 2px #213345,
    0 3px 7px #0008;
}
.energyWrap div,
.handTitle {
  display: grid;
}
.energyWrap b {
  font: 600 1rem var(--display);
}
.energyWrap small,
.handTitle small {
  font-size: 0.69rem;
  color: #d7cbb4;
  font-weight: 500;
  line-height: 1.2;
}
.handTitle {
  text-align: center;
}
.handTitle h2 {
  font: 500 1.35rem/1.15 var(--display);
}
.turnActions {
  justify-self: end;
  display: flex;
  gap: 7px;
  align-items: center;
}
.endTurn,
.skipFx {
  color: #ffedbc;
  border: 1px solid #b49961;
  box-shadow: inset 0 0 0 2px #353427;
  border-radius: 3px;
  background: linear-gradient(#4d523c, #383d2e);
  padding: 8px 16px;
  font: 600 1.03rem var(--display);
  min-height: 44px;
}
.endTurn span {
  margin-left: 5px;
}
.endTurn:hover,
.skipFx:hover {
  border-color: #ffe7b5;
}
.skipFx,
.combat-board[data-playing] .endTurn {
  display: none;
}
.combat-board[data-playing] .skipFx {
  display: block;
}
.battleHand {
  display: flex;
  justify-content: safe center;
  align-items: stretch;
  gap: clamp(6px, 1.05vw, 15px);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 6px 5px 12px;
  scroll-snap-type: x proximity;
  scrollbar-color: #867653 #242620;
}
.battleHand .handSlot {
  flex: 0 0 clamp(140px, 14.6vw, 195px);
  min-width: 0;
  scroll-snap-align: start;
}
.gamecard {
  --role: #b29ccb;
  --face: #3f354d;
  position: relative;
  background: linear-gradient(130deg, var(--face), #24241f 68%);
  border: 2px solid var(--role);
  border-radius: 10px 10px 7px 7px;
  box-shadow:
    inset 0 0 0 2px #141412,
    0 3px 6px #0006;
  padding: 4px;
}
.gamecard.role-attack {
  --role: #d18e70;
  --face: #5a3029;
}
.gamecard.role-defend {
  --role: #83b4ca;
  --face: #284a57;
}
.gamecard.role-prayer {
  --role: #d7bb71;
  --face: #544727;
}
.roleRibbon {
  position: relative;
  align-self: stretch;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  border-radius: 5px 5px 0 0;
  background: var(--face);
  font: 700 0.62rem/1 var(--body);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #fff4dd;
}
.roleRibbon .emblem {
  width: 14px;
  height: 14px;
}
.gamecard .cost {
  top: 4px;
  left: 4px;
  z-index: 2;
  width: 26px;
  height: 26px;
  font-size: 0.98rem;
  border-color: #e5cf91;
  background: radial-gradient(circle at top, #507295, #243449);
  box-shadow: 0 1px 3px #0008;
}
.gamecard img {
  border-block: 1px solid var(--role);
  aspect-ratio: 1.9;
  object-fit: cover;
}
.battleHand .gamecard img {
  aspect-ratio: 1.75;
}
.cardtext {
  padding: 6px 7px 9px;
}
.cardtext strong {
  font-size: clamp(0.96rem, 1.45vw, 1.25rem);
  margin: 1px 0 5px;
  color: #fff2d8;
}
.cardtext .rules {
  font-size: 0.78rem;
  color: #f0eadd;
}
.cardtext .minor {
  font-size: 0.6rem;
  color: #f6d99d;
  letter-spacing: 0.06em;
  margin-top: 5px;
}
.gamecard.playable:hover {
  transform: translateY(-3px);
  border-color: #f8d99f;
}
.gamecard:disabled {
  border-color: color-mix(in srgb, var(--role) 65%, #3c3b38);
}
.gamecard:disabled img {
  filter: saturate(0.75) brightness(0.75);
}
.prepareCard {
  background: #2b303f;
  border: 1px solid #787896;
  color: #eddfec;
  padding: 3px 7px;
  min-height: 32px;
  font-size: 0.76rem;
}
.pilebar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 15px;
  align-items: center;
  border-top: 1px solid #5c523d;
  padding: 8px 0;
  color: #c9c4b6;
  font-size: 0.77rem;
}
.pilebar > span {
  display: flex;
  align-items: center;
  gap: 5px;
}
.pilebar b {
  color: #fff1ca;
}
.pilebar button {
  min-height: 32px;
  padding: 3px 8px;
  font-size: 0.77rem;
}
.pilebar button:first-of-type {
  margin-left: auto;
}
.combat-board .log {
  margin-top: 8px;
}
.combat-board[data-playing] .battleHand {
  pointer-events: none;
  opacity: 0.8;
}
@media (max-width: 850px) {
  .field {
    height: 340px;
  }
  .battleHand .handSlot {
    flex-basis: 145px;
  }
  .fieldActor {
    left: 6%;
    width: 36%;
  }
  .fieldActor.enemy {
    right: 6%;
  }
  .turnTools {
    min-height: 66px;
  }
  .tell b {
    font-size: 0.9rem;
  }
  .fieldHeading {
    padding: 11px 14px;
  }
  .fieldStatuses {
    top: 92%;
  }
  .cardtext .rules {
    font-size: 0.75rem;
  }
}
@media (max-width: 520px) {
  main:has(.combat-board) {
    padding: 8px 6px 24px;
  }
  .field {
    height: 300px;
  }
  .fieldHeading {
    padding: 8px;
  }
  .fieldHeading h1 {
    font-size: 1.18rem;
  }
  .fieldHeading p {
    font-size: 0.53rem;
  }
  .fieldActor {
    left: 1.5%;
    width: 42%;
  }
  .fieldActor.enemy {
    right: 1.5%;
  }
  .actorDock {
    height: 44%;
    bottom: 26%;
  }
  .actorVitals {
    top: 73%;
    width: 98%;
  }
  .fieldStatuses {
    top: 89%;
  }
  .tell {
    bottom: 71%;
    padding: 4px 6px;
    gap: 1px 5px;
    min-width: 112px;
  }
  .tellWords b {
    font-size: 0.76rem;
  }
  .tellAmount {
    font-size: 1.1rem;
  }
  .tellIcon .emblem {
    width: 19px;
    height: 19px;
  }
  .tellExtra {
    font-size: 0.59rem;
  }
  .turnFlag {
    font-size: 0.65rem;
    gap: 5px;
    padding: 5px 7px;
  }
  .turnTools {
    min-height: 60px;
    gap: 5px;
  }
  .energyOrb {
    width: 35px;
    height: 35px;
    font-size: 1.35rem;
  }
  .energyWrap {
    gap: 4px;
  }
  .energyWrap b {
    font-size: 0.86rem;
  }
  .energyWrap small,
  .handTitle small {
    font-size: 0.58rem;
  }
  .handTitle h2 {
    font-size: 1.05rem;
  }
  .turnActions {
    gap: 3px;
    flex-wrap: wrap;
    justify-content: end;
  }
  .endTurn,
  .skipFx {
    padding: 6px 8px;
    font-size: 0.86rem;
  }
  .battleHand {
    gap: 7px;
  }
  .battleHand .handSlot {
    flex-basis: 137px;
  }
  .battleTray {
    padding-inline: 7px;
  }
  .pilebar {
    gap: 5px 9px;
    font-size: 0.7rem;
  }
  .fieldArt {
    object-fit: cover;
  }
  .battleHand .gamecard {
    min-height: 183px;
  }
  .energyWrap div {
    max-width: 82px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .gamecard.playable:hover {
    transform: none;
  }
  .floatText {
    position: relative;
  }
  .hpFill {
    transition: none;
  }
}

.roleRibbon {
  font-size: 0.68rem;
  letter-spacing: 0.055em;
  min-height: 24px;
}
.roleRibbon .emblem {
  width: 16px;
  height: 16px;
}
.boardModel[data-hero="fighter"] .modelFallback,
.boardModel[data-slot="enemy"] .modelFallback {
  height: 94%;
  width: 100%;
  max-width: none;
  bottom: 2%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.boardModel[data-ready] canvas {
  animation: breathe 3.5s ease-in-out infinite;
  transform-origin: center 93%;
}
.fieldActor.enemy .boardModel[data-ready] canvas {
  animation-delay: -1.6s;
}
.combat-board[data-playing] .boardModel canvas {
  animation: none;
}
.slashFlash,
.shieldFlash {
  position: absolute;
  pointer-events: none;
  z-index: 4;
  left: 26%;
  width: 48%;
  top: 44%;
  height: 5px;
  background: #fff7d9;
  box-shadow:
    0 0 4px #ffad62,
    0 0 12px 3px #d56f49;
  border-radius: 90% 5% 90% 5%;
}
.shieldFlash {
  inset: 22% 25%;
  width: 50%;
  height: 60%;
  border: 3px solid #d0f5ff;
  border-radius: 50%;
  background: radial-gradient(ellipse, transparent 45%, #a4ddfc61 90%);
  box-shadow:
    0 0 9px #a7e1ff,
    inset 0 0 8px #a7e1ff;
}
.spellTrail[data-caster="cleric"],
.spellTrail[data-caster="enemy-6"],
.spellTrail[data-caster="enemy-15"] {
  box-shadow:
    0 0 8px 4px #ffcf76,
    0 0 16px 9px #ff7847;
}
.spellTrail[data-caster="enemy-11"] {
  box-shadow:
    0 0 8px 4px #b6f3ff,
    0 0 18px 10px #67bce3;
}
@keyframes breathe {
  0%,
  100% {
    transform: scale(1, 1);
  }
  50% {
    transform: scale(1.006, 1.012);
  }
}
.lastAction {
  margin-left: 10px;
  color: #c4c1b4;
  font: 400 0.79rem/1.4 var(--body);
}
@media (max-width: 520px) {
  .lastAction {
    display: block;
    margin-left: 14px;
  }
}
.statusRail {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 5px 15px;
  border-bottom: 1px solid #514b3a;
  padding: 6px 0;
}
.statusRail > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  color: #e8dabc;
  font: 500 0.72rem/1.25 var(--body);
}
.statusRail span {
  background: #38372c;
  padding: 2px 5px;
  border: 1px solid #726649;
  border-radius: 2px;
}
.heroTile[data-val="fighter"] {
  background:
    linear-gradient(0deg, #1a1816a6, #21201938),
    url(assets/battlefield-0.webp) 27% center/cover;
}
.heroTile[data-val="fighter"] > img {
  object-fit: contain;
  object-position: 50% 36%;
  height: 88%;
}
@media(max-width:520px){.floatLayer{left:-4%;right:-4%}.floatText{white-space:normal;max-width:100%;text-wrap:balance}}
