@import url('./citadel-settings.css');
@import url('./turn-clock.css');
:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  /* Card colours, gold, text and serif: card-face.css. */
  --bg: #0f0d0b; --line: #5a4a35; --muted: #b5a88e; --actor: #58cfff; --danger: #e5534b;
  /* The board has the whole width; cards grow with it, but no taller than the window holds. */
  --card-w: clamp(5.5rem, min(9vw, (100dvh - 24rem) / 4), 11rem); --minion-w: calc(var(--card-w) * 0.76);
  --support-w: clamp(3rem, min(4.5vw, 7dvh), 4.5rem); --support-ratio: 0.78;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
main { position: relative; display: grid; padding: 0.5rem; min-height: 100dvh; }
button { font: inherit; color: inherit; }
.visual-filters { position: absolute; pointer-events: none; }

/* The retail playmat; the opponent sits at the top. */
#board { --board-top: 0.8rem; --opponent-card-w: clamp(3.4rem, 4vw, 6rem);
  --opponent-hand-pad: calc(var(--opponent-card-w) * 0.05);
  --opponent-hand-height: calc(var(--opponent-card-w) / 0.64 + var(--opponent-hand-pad));
  position: relative; display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; min-height: max(40rem, calc(100dvh - 1rem)); padding: var(--board-top) 1rem 0;
  /* Map the whole native composition to the responsive board; cover cuts off its props. */
  border-radius: 0.8rem; background: var(--art-board, radial-gradient(#3a2e22, #15110d)) center / 100% 100% no-repeat, #1b1611;
  box-shadow: inset 0 0 3rem #000c; }
.empty { color: var(--muted); }

/* Physical decks sit on the right edge of the playmat, not in the count HUD.
   Each surface inherits its owner's equipped back from the match intro. */
.draw-pile { --pile-w: clamp(2rem, 7.2vw, 11.5rem);
  position: absolute; left: 91.5%; top: 71%; width: var(--pile-w); aspect-ratio: .64;
  transform: translate(-50%, -50%); pointer-events: none; z-index: 3; }
/* Keep the whole upper stack above Original's crystal, including on short windows. */
.draw-pile.opponent { --pile-w: clamp(2rem, min(7.2vw, 12dvh), 11.5rem); top: 12%; }
.pile-surface { position: absolute; inset: 0; transform: rotate(15deg) scaleY(.88); }
.opponent > .pile-surface { transform: rotate(-30deg) scaleY(.88); }
.pile-card { position: absolute; inset: 0; border: 1px solid #c9b994; border-radius: 3%;
  background: var(--card-back, var(--art-back)) center / 100% 100%;
  transform: translate(calc(var(--depth) * var(--pile-w) * -.0065), calc(var(--depth) * var(--pile-w) * .022));
  box-shadow: -1px 2px 0 #88847a, -2px 4px 0 #333a3e, 0 8px 14px #0008; }
@media (max-width: 48rem) {
  .draw-pile { top: 60%; }
  .draw-pile.opponent { top: 20%; }
}

.hand { display: flex; justify-content: center; align-items: flex-start; min-height: 1rem; }
/* Full compact cards in the band above the lanes, with room for cost/stat ornaments. */
.hand.opponent { --card-w: var(--opponent-card-w); --back-w: var(--card-w);
  position: absolute; top: var(--board-top); left: var(--rank-space, 0px); right: calc(50% + 4.5rem);
  height: var(--opponent-hand-height); padding-top: var(--opponent-hand-pad);
  overflow: visible; justify-content: flex-end; gap: 0.4rem; pointer-events: none; }
.back { flex: none; width: var(--back-w); aspect-ratio: 0.64; margin: 0;
  border-radius: 0.4rem; box-shadow: 0 0.15rem 0.5rem #000c;
  background: var(--card-back, var(--art-back, repeating-linear-gradient(45deg, #6a2a22, #6a2a22 4px, #4a1d18 4px, #4a1d18 8px))) center / cover; }
/* Keep the normal face/art/header and stable hover surface; full-size inspection is unchanged. */
.hand.opponent .card { z-index: 2; pointer-events: auto; }
/* Scale the whole face, rather than letting minimum-size rules obscure the thumbnail art. */
.hand.opponent .card .box { font-size: 1em; }
.hand.opponent .card:hover { filter: brightness(1.2); }
/* Hand cards show their text, so they sit apart; slots narrow, and cards overlap, only when the hand is wider than the board. */
.hand.you { gap: 0.4rem; min-height: calc(var(--card-w) / 0.68); }
.hand .slot { display: flex; flex: 0 1 auto; min-width: 0; }
/* Reserve the last card's full width: earlier slots may overlap, not spill past the board. */
.hand .slot:last-child { flex-shrink: 0; }
.hand.you .slot:hover .card:not(.selected) { transform: translateY(-0.6rem); z-index: 3; }

.player { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 1rem; min-height: 7rem; }
/* The header, not the playing lanes, makes room for the complete enemy hand. */
.player.opponent { min-height: max(7rem, var(--opponent-hand-height)); }
.hud { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 4.5rem 4.5rem; align-items: center; gap: 0.35rem 0.55rem;
  width: 16.2rem; margin-left: clamp(1rem, 12vw, 15rem); filter: drop-shadow(0 2px 2px #000); }
.identity { grid-column: 1 / -1; min-width: 0; text-align: center; }
.name-line { display: flex; justify-content: center; align-items: center; gap: 0.15rem; min-width: 0; }
.deck-color { flex: none; width: 1.6rem; height: 1.6rem; object-fit: contain; border-radius: 50%; font: bold 0.9rem var(--serif); }
.deck-color:is(span) { display: grid; place-items: center; background: var(--neutral); }
.deck-color.strength { background-color: var(--strength); } .deck-color.intelligence { background-color: var(--intelligence); }
.deck-color.willpower { background-color: var(--willpower); } .deck-color.agility { background-color: var(--agility); } .deck-color.endurance { background-color: var(--endurance); }
.player-title { display: block; margin-top: 0.1rem; padding: 0.1rem 1.5rem; color: #e1d9c1; font: bold 0.85rem var(--serif);
  background: var(--art-title-common) center / 100% 100% no-repeat; text-shadow: 0 1px 2px #000; }
.player-title.rare { background-image: var(--art-title-rare); } .player-title.epic, .player-title.legendary { background-image: var(--art-title-epic); }
/* Keep ranks in a left-side rail, outside the opponent's card strip. */
#board:has(.player > .rank) { --rank-space: 7.2rem; }
/* Retail's rank widget: the sign in a 100-unit circle, the number in a 59-unit one on its lower edge. */
.player > .rank { --rank-w: 4.2rem; position: absolute; left: 1rem; top: 50%; display: grid; place-items: center; width: var(--rank-w); aspect-ratio: 1;
  transform: translateY(-62%); filter: drop-shadow(0 2px 2px #000); }
.rank, .rank-number { background: var(--art-rank-frame, radial-gradient(#2d261c, #0c0a07)) center / 100% 100% no-repeat; border-radius: 50%; }
.rank-sign { width: 69%; height: 69%; object-fit: contain; }
.rank-number { position: absolute; top: 100%; left: 50%; display: grid; place-items: center; width: 59%; aspect-ratio: 1;
  transform: translate(-50%, -50%); color: #e4dfc9; font: bold 1rem var(--serif); text-shadow: 0 1px 2px #000; }
.zone-counts { display: flex; justify-content: flex-end; gap: 0.35rem; }
.zone-count { display: grid; place-items: center; min-width: 1.8rem; height: 2.1rem; border: 1px solid #8c8461; border-radius: 50%; background: #080a08cc;
  font: bold 0.8rem var(--serif); }
.zone-count::before { color: #bdb69a; font-size: 0.65rem; } .deck-count::before { content: 'D'; } .hand-count::before { content: 'H'; }
/* The skull opens the discard pile. */
.discard-count { padding: 0; color: inherit; cursor: pointer; }
.discard-count::before { content: ''; width: 0.65rem; height: 0.75rem; opacity: 0.85;
  background: var(--art-skull, radial-gradient(circle, #bdb69a 45%, transparent 50%)) center / contain no-repeat; }
.discard-count:hover, .discard-count.open { border-color: var(--target); box-shadow: 0 0 0 1px var(--target), 0 0 0.6rem #f2c14e99; }
.turn-button { width: 4.5rem; aspect-ratio: 1; border: 0; padding: 0; border-radius: 50%; color: var(--gold); font-size: 2rem;
  background: var(--art-end-turn, radial-gradient(circle, #090c08 61%, #aaa279 63%, #16170e 70%, transparent 73%)) center / contain no-repeat;
  filter: grayscale(1) brightness(0.45); }
.turn-button.usable { cursor: pointer; filter: hue-rotate(-65deg) drop-shadow(0 0 0.4rem #e9ad3c66); }
.turn-button.usable:hover { filter: hue-rotate(-65deg) brightness(1.25) drop-shadow(0 0 0.5rem #e9ad3c88); }
/* The retail sprite is green; keep its native hue when only End turn remains. */
.turn-button.usable.no-actions { color: #54cf8c; filter: drop-shadow(0 0 0.4rem #54cf8c66); }
.turn-button.usable.no-actions:hover { filter: brightness(1.25) drop-shadow(0 0 0.5rem #54cf8c88); }
/* The Ring of Magicka at the holder's corner: yours at the right, the opponent's at the left.
   Its three sockets light up per charge left. */
.ring { position: absolute; top: 0; left: -5.5rem; width: 4.5rem; aspect-ratio: 203 / 224; padding: 0; border: 0;
  background: var(--art-ring, radial-gradient(circle, transparent 42%, #a8854a 44%, #5e4724 64%, transparent 66%)) center / contain no-repeat;
  filter: drop-shadow(0 0.2rem 0.5rem #000c); }
.ring.usable { cursor: pointer; filter: drop-shadow(0 0 0.45rem #28b9ff) drop-shadow(0 0 1rem #147aff); }
.ring.usable:hover { transform: scale(1.06); }
/* Over the sprite's sockets: left, front, right. */
.ring .charge { position: absolute; top: 51%; left: 37%; width: 25%; height: 20%; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #d8f2ff, #3a9cff 40%, #0b3c94 75%); box-shadow: 0 0 0.6rem #4aa8ff; }
.ring .charge:nth-child(1) { top: 46%; left: 16%; width: 11%; height: 16%; }
.ring .charge:nth-child(3) { top: 43.5%; left: 72.5%; width: 17%; height: 19%; }
.ring .charge.empty { background: radial-gradient(circle at 50% 45%, #070605 30%, #2e261a 75%); box-shadow: inset 0 0.1rem 0.3rem #000; }
.supports { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-end; align-self: end; gap: 0.4rem; min-height: 2rem; }
@media (min-width: 48.001rem) {
  /* Use the open space between the portrait and HUD, clear of the enemy hand. */
  .player > .avatar { grid-column: 2; grid-row: 1; }
  .player > .hud { grid-column: 3; grid-row: 1; }
  .supports { position: absolute; left: calc(50% + 4rem); top: 50%; transform: translateY(-50%);
    width: calc(clamp(1rem, 12vw, 15rem) - 1rem); flex-wrap: nowrap; justify-content: flex-start; }
  .supports .card { flex-shrink: 1; min-width: 0; }
  /* Mirror the upper rank's screen-edge gap, including the number's 29.5% overhang. */
  .player.opponent > .rank { anchor-name: --opponent-rank; }
  .player.you > .rank { position: fixed; left: anchor(--opponent-rank left);
    top: calc(100dvh - anchor(--opponent-rank top) - var(--rank-w) * 1.295); transform: none; }
}
.player-name { min-width: 0; overflow: hidden; font: bold 1.05rem var(--serif); color: #e4dfc9; text-overflow: ellipsis; white-space: nowrap;
  text-shadow: 0 1px 2px #000; }
.magicka { display: grid; place-items: center; width: 4.5rem; aspect-ratio: 1; border: 3px solid #8d8764; border-radius: 50%; color: #082d48;
  font: bold 1.4rem var(--serif); text-shadow: 0 1px 1px #65d6ff; box-shadow: 0 0 0 2px #131b20, inset 0 0 0 2px #16476f;
  background: var(--orb) center / contain no-repeat; }

.avatar { position: relative; display: grid; place-items: center; width: 6rem; aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%;
  background: var(--art-avatar, radial-gradient(#3a2e22, #15110d)) center / contain no-repeat; box-shadow: 0 0.2rem 0.8rem #000c; }
.avatar.opponent { background-image: var(--art-avatar-enemy, var(--art-avatar, radial-gradient(#3a2e22, #15110d))); }
.player .avatar.final-blow { background: none; box-shadow: none; }
.avatar.final-blow .portrait, .avatar.final-blow .label { visibility: hidden; }
/* The study's 206-unit rim sits in an 800-unit canvas (final-blow.mjs); its shards fly over the board. */
.player .avatar.final-blow { z-index: 30; }
.final-blow-canvas { position: absolute; inset: calc(-100% * 297 / 206); width: calc(100% * 800 / 206); height: calc(100% * 800 / 206); pointer-events: none; }
.avatar.final-blow .health { z-index: 1; }
.avatar .label { font: 0.85rem var(--serif); color: var(--muted); }
.avatar .portrait { position: absolute; inset: 4.5%; width: 91%; height: 91%; border-radius: 50%; object-fit: cover; pointer-events: none; }
.avatar .health { position: absolute; bottom: -0.5rem; left: 50%; transform: translateX(-50%); min-width: 2.3rem; padding: 0.1rem 0.4rem;
  border: 2px solid var(--gold); border-radius: 1rem 1rem 1.2rem 1.2rem; background: linear-gradient(#c7372c, #6d120c); font: bold 1.15rem var(--serif); }
.player.active .avatar { box-shadow: 0 0 0 3px var(--actor), 0 0 1.2rem var(--actor); }
.avatar.target, .avatar.drop { box-shadow: 0 0 0 3px var(--target), 0 0 1.4rem var(--target); cursor: pointer; }
/* Portrait context menu: the retail four-by-two choices flank an open center. */
.emote-menu { position: fixed; z-index: 80; display: grid; grid-auto-flow: column; grid-template-rows: repeat(4, auto);
  column-gap: 7rem; width: min(30rem, calc(100vw - 16px)); padding: 0.4rem;
  filter: drop-shadow(0 3px 6px #000); }
.emote-menu button { padding: 0.5rem 0.65rem; border: 0; border-radius: 0; background: #100e0bea; color: #e4dfc9;
  font: 1.15rem var(--serif); white-space: nowrap; text-shadow: 0 1px 2px #000; }
.emote-menu button:hover, .emote-menu button:focus-visible { color: #ffe5a4; background: #34281ef5; outline: 1px solid var(--gold); }
.emote-mute-menu { grid-template-rows: auto; width: 10rem; column-gap: 0; }
/* Retail runes baked from above: one square around the coin, 139% of the avatar, housings under five faces. */
.runes { position: absolute; inset: -19.5%; pointer-events: none; background: var(--art-rune-housings) center / contain no-repeat; }
.rune { position: absolute; inset: 0; background: center / contain no-repeat; }
.rune.broken { display: none; }
.rune:nth-child(1) { background-image: var(--art-rune-1); } .rune:nth-child(2) { background-image: var(--art-rune-2); }
.rune:nth-child(3) { background-image: var(--art-rune-3); } .rune:nth-child(4) { background-image: var(--art-rune-4); }
.rune:nth-child(5) { background-image: var(--art-rune-5); }

.lanes { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; border-radius: 0.7rem; }
.lane { display: flex; flex-direction: column; min-width: 0; border: 1px solid #ffffff14; border-radius: 0.6rem; background: #0006; }
.lane-1 { background: linear-gradient(#1a2a4066, #0b142466); }
.row { flex: 1; display: flex; justify-content: center; align-items: center; gap: 0.4rem; min-height: calc(var(--minion-w) / 0.78 + 1rem); padding: 0.35rem;
  border: 2px dashed transparent; border-radius: 0.6rem; }
.row.opponent { border-bottom: 1px solid #ffffff1a; }
.row.target, .row.drop, .lanes.drop { border-color: var(--target); }
.lanes.drop { outline: 2px dashed var(--target); }
.row.drop.over, .lanes.drop.over { background: #f2c14e26; }
.place { padding: 0.5rem 1rem; border: 2px solid var(--target); border-radius: 0.4rem; background: #0008; cursor: pointer; }
.prophecy { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.5rem; padding: 0.5rem; border: 2px solid var(--target); border-radius: 0.5rem; background: #000a; }
.prophecy h2 { flex-basis: 100%; margin: 0; font: 1rem var(--serif); }
/* Keep the normal portrait/hand layout underneath; Prophecy adds no height. */
.player-area { position: relative; display: flex; flex-direction: column; gap: 0.4rem; }
.prophecy-overlay { position: absolute; inset: 0; z-index: 25; justify-content: center; align-items: center;
  border: 0; border-radius: 0; background: #000d; }
.prophecy-card { position: relative; display: flex; }
.prophecy-overlay .prophecy-card .card.selected { transform: none; z-index: auto; }
.return-to-hand { position: absolute; top: -0.5rem; right: -0.5rem; z-index: 3; display: grid; place-items: center;
  width: 1.8rem; height: 1.8rem; padding: 0; border: 1px solid var(--gold); border-radius: 50%; background: #17130f;
  color: var(--text); font: 1.5rem/1 var(--serif); cursor: pointer; }
.return-to-hand:hover, .return-to-hand:focus-visible { color: #fff; border-color: var(--target); box-shadow: 0 0 0.5rem var(--target); }
.return-to-hand:disabled { opacity: 0.5; cursor: default; box-shadow: none; }

/* On the board a card is its portrait: art, keywords and stats. */
:is(.row, .supports) .card { width: var(--minion-w); aspect-ratio: 0.78; border-radius: 0.9em; }
/* Readable support art; inspection still uses the unchanged full hand face. */
.supports .card { width: var(--support-w); aspect-ratio: var(--support-ratio); overflow: hidden; }
/* In-flight creatures use full faces: round their art, never clip their counters. */
.row .card .art { border-radius: inherit; }
:is(.row, .supports) .card .art { top: 0; height: 100%; }
:is(.row, .supports) .card :is(.gem, .kind, .text, .cost), .row .card .name { display: none; }
:is(.row, .supports) .card .box { top: auto; padding: 0.2em 0.3em 3em; background: linear-gradient(transparent, #000c 55%); }
.supports .card :is(.name, .box) { display: none; }
.support-counter { position: absolute; bottom: 0.12em; left: 50%; z-index: 2; transform: translateX(-50%);
  display: grid; place-items: center; min-width: 1.65em; height: 1.65em; padding: 0 0.2em; border: 1px solid #b9ad82; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #24271d, #080a07 75%); color: #fff6da;
  font: bold clamp(10px, 0.9vw, 14px)/1 var(--serif); text-shadow: 0 1px 2px #000; box-shadow: 0 0 0 1px #15140f; pointer-events: none; }
.row .card.guard { border-color: var(--gold); box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--gold), 0 0.25rem 0.6rem #000b; }

/* Availability comes only from the command-derived actor/selected marks. The shared
   filter puts uneven blue light behind the card; disabled/pending/carried cards
   have none. Gold targets take precedence. No animation or art color wash. */
.card:is(.actor, .selected):not(:disabled, .pending, .carried, .target, .drop) { --card-aura: url(#playable-glow); }
.card.selected:not(:disabled, .pending, .carried, .target, .drop) { --card-aura: url(#playable-glow) drop-shadow(0 0 3px #62cfff); }
.card:not(.board-creature) { filter: var(--card-aura); }
.card.actor, .card.selected { cursor: grab; touch-action: none; }
.card.selected:not(:disabled) { transform: translateY(-0.75rem); z-index: 2; }
.card.target, .card.drop { box-shadow: 0 0 0 3px var(--target), 0 0 1rem var(--target); cursor: pointer; }
.card.drop.over, .avatar.drop.over { box-shadow: 0 0 0 4px #fff, 0 0 1.4rem var(--target); }
.card.mulligan-replace > * { filter: grayscale(0.8) brightness(0.6); }
.card.mulligan-replace::after { content: ''; position: absolute; inset: 0; z-index: 3; filter: drop-shadow(0 0 0.3em #000);
  background: linear-gradient(45deg, transparent 46%, var(--danger) 46% 54%, transparent 54%) center / 55% 40% no-repeat,
    linear-gradient(-45deg, transparent 46%, var(--danger) 46% 54%, transparent 54%) center / 55% 40% no-repeat; }
.card.pending { opacity: 0.45; }

/* Retail lane creatures: the 120-unit portrait sits in a 160-unit ornament area.
   SVG scales the whole composition, including numbers. No ornament animation. */
.row .card.board-creature { width: calc(var(--minion-w) * 4 / 3); aspect-ratio: 160 / 216; min-width: 0;
  flex-shrink: 1; border: 0; border-radius: 0; background: none; overflow: visible; box-shadow: none; }
/* The standard hand face replaces the portrait during inspection. Opacity keeps
   the original input surface in place, so hover, selection and drag still work. */
.board-creature .box { display: none; }
.board-card.reading { opacity: 0; }
.creature-ornaments { display: block; width: 100%; height: 100%; pointer-events: none; overflow: visible;
  filter: drop-shadow(2px 6px 4px #0009); }
.creature-frame { stroke: #d3c698; stroke-width: 1.2; }
.creature-frame.lethal-rim { stroke: #8aef47; stroke-width: 2.5; }
/* Retail draws the silence X additively. */
.silence-mark { mix-blend-mode: plus-lighter; }
.board-creature:has(.lethal-rim) .attack-value { fill: #a4ff68; }
.board-creature .stat-value.damaged { fill: #ffb3ad; }
/* Glow only the clipped portrait, behind the original gold/Lethal frame and
   Guard, Ward, counters and medallions. Their colors and silhouettes stay intact. */
.board-creature .creature-portrait { filter: var(--card-aura); }
.board-creature:is(.target, .drop) .creature-frame { stroke: var(--target); stroke-width: 3; }
.board-creature.drop.over .creature-frame { stroke: #fff; stroke-width: 4; }
/* Linked cards (Zumog Phoom and its chosen creature): violet, apart from gold targets and blue
   playables. Hovering one breathes on the other; a new link flares on both. */
.card:is(.linked, .linking) { --link: #c98bff; }
.card:not(.board-creature):is(.linked, .linking) { box-shadow: 0 0 0 3px var(--link), 0 0 1.2rem var(--link); }
.board-creature:is(.linked, .linking) .creature-frame { stroke: var(--link); stroke-width: 3; }
.board-creature:is(.linked, .linking) .creature-ornaments { filter: drop-shadow(0 0 0.35rem var(--link)) drop-shadow(0 0 0.9rem #9b5cff99); }
.card.linked { animation: linked 1.3s ease-in-out infinite; }
.card.linking { animation: linking 0.55s ease-in-out 2; }
@keyframes linked { 50% { filter: brightness(1.18); } }
@keyframes linking { 50% { transform: scale(1.07); filter: brightness(1.35); } }
@media (prefers-reduced-motion: reduce) { .card:is(.linked, .linking) { animation: none; } }
.card.carried { z-index: 30; pointer-events: none; transition: none; box-shadow: 0 1rem 2rem #000; }
.card.moving { z-index: 10; }
.card.preview { position: absolute; top: 45%; left: 50%; z-index: 40; --card-w: 12rem; transform: translate(-50%, -50%);
  pointer-events: none; box-shadow: 0 1rem 3rem #000; }

#inspect { z-index: 50; }
#inspect .card { box-shadow: 0 1rem 3rem #000; }
.equipped-items { position: absolute; display: grid; gap: 0.45rem; }
.equipped-item { position: relative; width: var(--support-w); aspect-ratio: var(--support-ratio); overflow: hidden;
  border: 1px solid #b9a26b; border-radius: 0.35rem; background: #201a14; box-shadow: 0 0.25rem 0.6rem #000b; }
.equipped-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.equipped-stats { position: absolute; inset: auto 0 0; padding: 0.55rem 0.1rem 0.2rem; text-align: center;
  background: linear-gradient(transparent, #100c09f2 75%); color: #fff0d1; text-shadow: 0 1px 2px #000;
  white-space: nowrap; font: bold clamp(0.625rem, 0.9vw, 0.875rem)/1 system-ui; }
.equipped-stats .buffed { color: #adf887; }
#aim { position: fixed; inset: 0; z-index: 45; display: none; width: 100vw; height: 100vh; pointer-events: none; }
#aim.aiming { display: block; }
#aim line { stroke: var(--target); stroke-width: 5; stroke-dasharray: 12 8; stroke-linecap: round; }
#aim circle { fill: #f2c14e33; stroke: var(--target); stroke-width: 4; }

.banner { position: absolute; top: 45%; left: 50%; z-index: 40; padding: 0.6rem 2.6rem; transform: translate(-50%, -50%); pointer-events: none;
  background: linear-gradient(90deg, transparent, #000d 20%, #000d 80%, transparent); color: var(--gold); font: bold 2rem var(--serif); white-space: nowrap; }
.float { position: absolute; z-index: 41; pointer-events: none; font: bold 2rem var(--serif); text-shadow: 0 0 0.3rem #000, 0 2px 2px #000; }
.float.damage { color: #ff5a4a; }
.float.heal { color: #7dff9a; }

.actions { position: sticky; bottom: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;
  margin: 0 -1rem; padding: 0.6rem 1rem; border-radius: 0 0 0.8rem 0.8rem; background: linear-gradient(transparent, #000e 35%); }
.headline { margin: 0; font-family: var(--serif); font-weight: bold; }
.hint { flex: 1 0 100%; margin: 0; pointer-events: none; text-align: center; color: #f3e6c4; font: bold 1.15rem var(--serif); text-shadow: 0 0 0.5rem #000, 0 1px 2px #000; }
.buttons { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.choice { padding: 0.5rem 1rem; border: 2px solid var(--target); border-radius: 0.4rem; background: #2a2219; cursor: pointer; }
.choice.end-turn { margin-left: auto; padding: 0.7rem 1.6rem; border-color: var(--gold); border-radius: 2rem; color: #1b1208;
  background: radial-gradient(circle at 50% 30%, #f6d68b, #9c6b1c); font: bold 1rem var(--serif); box-shadow: 0 0 1rem #f2c14e66; }
.choice:disabled { opacity: 0.5; cursor: default; }
/* The retail cancel X, centred on the right edge of the card it cancels; at the bottom right, with a caption,
   only when that card isn't on the board. A creature's frame is x 20-140, y 35-189 of its 160 x 216 ornament area. */
.cancel-anchor { position: relative; display: flex; flex: 0 1 auto; min-width: 0; }
.hand .cancel-anchor { flex: none; }
.cancel-anchor > .cancel-x { position: absolute; top: 50%; right: 0; z-index: 5; width: 3.2rem; transform: translate(50%, -50%); }
.cancel-anchor > .board-creature + .cancel-x { top: 51.85%; right: 12.5%; }
.cancel-anchor > .card.selected:not(:disabled) + .cancel-x { margin-top: -0.75rem; }
.actions:has(.cancel) { padding-right: 15rem; }
.cancel { position: absolute; right: 1rem; bottom: 0.5rem; display: flex; flex-direction: row-reverse; align-items: center; gap: 0.6rem; }
.cancel-x { width: 3.6rem; aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%; cursor: pointer; color: var(--danger); font-size: 1.6rem;
  background: var(--art-cancel-x) center / 50% no-repeat, var(--art-cancel, radial-gradient(circle, #000 62%, #b3363a 64%, #6e1b1e 70%, transparent 72%)) center / contain no-repeat; }
.cancel-x:hover { filter: brightness(1.3) drop-shadow(0 0 0.5rem var(--danger)); }
.cancel-x:disabled { opacity: 0.5; cursor: default; filter: none; }
.cancel .caption { max-width: 10rem; font: bold 0.95rem var(--serif); text-align: right; text-shadow: 0 1px 2px #000; }
/* Betray adds no row or backdrop; board targets stay clickable underneath. */
.betray-prompt { position: fixed; display: grid; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 25; pointer-events: none; }
.betray-prompt .card { pointer-events: none; box-shadow: 0 1rem 3rem #0009; }
.betray-prompt > .cancel-anchor > .cancel-x { width: 3.6rem; pointer-events: auto; }
@media (max-width: 48rem) {
  .betray-prompt { --card-w: min(11rem, calc(100vw - 5rem)); }
}

/* The opening hand, large in the middle of the board. */
.mulligan { position: absolute; inset: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  border-radius: 0.8rem; background: radial-gradient(ellipse at center, #000a, #000d 70%); }
/* Let both players' identity, portrait and ranked badge clear the tint.
   The HUD's filter would trap its identity in a stacking context below the overlay. */
#board:has(> .mulligan) .player .hud { filter: none; }
#board:has(> .mulligan) .player .identity { position: relative; filter: drop-shadow(0 2px 2px #000); }
#board:has(> .mulligan) .player :is(.avatar, .identity, .rank) { z-index: 26; pointer-events: none; }
/* Retail's banner and prompt: gold serif on a dark band that fades out at both ends. */
.mulligan .mulligan-title, .mulligan .prompt { margin: 0; padding: 0.35rem 4rem; text-align: center; text-shadow: 0 0 0.6rem #000, 0 2px 2px #000;
  background: linear-gradient(90deg, transparent, #000c 22%, #000c 78%, transparent); border-image: linear-gradient(90deg, transparent, var(--gold), transparent) 1;
  border-width: 2px 0; border-style: solid; }
.mulligan .mulligan-title { color: #f3d68e; font: bold 2.6rem var(--serif); letter-spacing: 0.04em; text-transform: uppercase;
  background: linear-gradient(90deg, transparent, #3a2508e6 22%, #3a2508e6 78%, transparent); }
.mulligan .prompt { color: #efe3c4; font: 1.5rem var(--serif); }
.mulligan .hand.you { flex-wrap: wrap; gap: 1.5rem; min-height: 0; padding: 0 1rem; }
.mulligan .proceed { padding: 0.45rem 2rem; border: 2px solid #8a7550; border-radius: 0.4rem; color: #efe3c4; cursor: pointer;
  background: linear-gradient(#3a3226, #17130e); font: 1.3rem var(--serif); text-shadow: 0 1px 2px #000; box-shadow: 0 0 0 2px #000, 0 0.25rem 0.6rem #000b; }
.mulligan .proceed:hover { border-color: var(--gold); filter: brightness(1.2); }
.mulligan .proceed:disabled { opacity: 0.5; cursor: default; filter: none; }

@media (max-width: 60rem) {
  main { padding: 0.5rem; }
  #board { --board-top: 0.4rem; padding: var(--board-top) 0.5rem 0; }
  .actions { margin: 0 -0.5rem; }
  .actions:has(.cancel) { padding-right: 10rem; }
  .cancel { right: 0.5rem; }
  .cancel-x { width: 2.8rem; }
  .cancel-anchor > .cancel-x { width: 2.5rem; }
  .cancel .caption { max-width: 6rem; font-size: 0.85rem; }
  .avatar { width: 4.6rem; }
  .player { gap: 0.5rem; }
  .hud { margin-left: 5.5rem; width: min(calc(100% - 5.5rem), 15rem); grid-template-columns: minmax(0, 1fr) 4rem 4rem; }
  .supports { left: calc(50% + 3.3rem); width: 4.5rem; }
  .magicka, .turn-button { width: 4rem; }
  .ring { width: 3.8rem; }
}

@media (max-width: 48rem) {
  .player { grid-template-columns: 4.4rem minmax(0, 1fr); padding: 0 0.4rem; min-height: 7rem; }
  .player.opponent { padding-top: var(--opponent-hand-height); }
  .hand.opponent { left: 0; right: 0; justify-content: center; }
  .avatar { grid-column: 1; grid-row: 1; width: 4.4rem; }
  .hud { grid-column: 2; grid-row: 1; justify-self: end; margin: 0; width: min(100%, 14rem);
    grid-template-columns: minmax(0, 1fr) 3.4rem 3.4rem; gap: 0.3rem; }
  .magicka, .turn-button { width: 3.4rem; font-size: 1.2rem; }
  .zone-counts { gap: 0.2rem; }
  .zone-count { min-width: 1.5rem; }
  .ring { width: 3.4rem; left: -3.5rem; top: auto; bottom: 0; z-index: 2; }
  .supports { grid-column: 1 / -1; grid-row: 2; justify-content: center; min-height: 0; width: auto; }
  .supports:empty { display: none; }
  /* Between the avatar and the HUD, above the ring; the opponent's hand takes the top row. */
  .player > .rank { left: 5rem; top: 0.2rem; width: 2rem; transform: none; }
  .player:has(> .rank) .hud { width: min(calc(100% - 3rem), 14rem); }
  .player.opponent > .rank { top: calc(var(--opponent-hand-height) + 0.2rem); }
  .rank-number { top: 50%; left: 100%; font-size: 0.7rem; }
  .deck-color { width: 1.35rem; height: 1.35rem; }
  .player-name { font-size: 0.95rem; }
}
