[hidden], #app[hidden] { display: none !important; }
body { background: radial-gradient(ellipse at 50% 15%, #28333c, #100f13 75%); }
button:focus-visible { outline: 2px solid #f2c979; outline-offset: -3px; }
.enemy-head { width: 100%; padding: 0; border: 0; border-bottom: 1px solid #ac7d4a; }
.unit-slot { padding: 0; }
.unit-slot.eligible, .perm.eligible, .enemy-head.eligible { outline: 2px solid #e7bb70; outline-offset: -2px; }
.handcard .effect { width: 100%; }
.handcard .art { min-height: 0; pointer-events: none; }
.handcard { touch-action: pan-x; }
#footerInfo { line-height: 1.25; }
#settingsBtn { flex-shrink: 0; }
#cancelBtn { flex-shrink: 0; }
.overlay { overflow: auto; }
.dialog { max-height: 100%; overflow: auto; }
.reward-art { width: min(100%, 236px); border: 1px solid #bda373; border-radius: 8px; }
.story {
  min-height: 100dvh;
  position: relative;
  isolation: isolate;
  overflow: clip;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  max-width: 520px;
  margin-inline: auto;
  background: linear-gradient(#0812229c, transparent 38%, #0b101974), url('assets/ui-harbor_background.png') center/cover no-repeat;
  border-inline: 1px solid #8c7651;
}
.story-title { padding: max(2rem, env(safe-area-inset-top)) 1.3rem 0; text-shadow: 0 2px 12px #0e1119; }
.story-title p { color: #f2d9a6; font-size: 0.95rem; letter-spacing: .16em; margin: 0; }
.story-title h1 { font-size: clamp(1.7rem, 6vw, 2.5rem); font-weight: 600; margin: .45rem 0 0; }
.story-panel {
  position: relative;
  margin: 1rem;
  margin-bottom: max(1rem, env(safe-area-inset-bottom));
}
.story-text { position: relative; background: linear-gradient(142deg, #f3e6c9, #d7bc8b); color: #211a16; padding: .85rem 1rem; border-radius: 3px; min-height: 8rem; }
#storyBackMark { position: absolute; left: -.84rem; top: 50%; transform: translateY(-50%); font-size: .62rem; color: #d8b988; animation: back-mark-blink 1.6s ease-in-out infinite; z-index: 1; }
#storyForwardMark { position: absolute; right: -.84rem; top: 50%; transform: translateY(-50%); font-size: .62rem; color: #d8b988; animation: back-mark-blink 1.6s ease-in-out infinite; z-index: 1; }
@keyframes back-mark-blink { 0%, 100% { opacity: .9; } 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { #storyBackMark, #storyForwardMark { animation: none; opacity: .85; } }
.story-text strong { font-size: .85rem; color: #5c3a26; }
.story-text p { margin: .4em 0 0; line-height: 1.7; white-space: pre-line; }
@media (max-height: 690px) { .footer { height: 49px; } }
@media (max-width: 375px) {
  .footer { gap: 4px; padding-inline: 5px; }
  .footer button { padding-inline: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .flash { background: #9bf6ff45; }
  .unit.target { animation: none; outline: 2px solid #f74c4c; }
}
.exchange-mark {
  position: absolute;
  top: 5px;
  right: 4px;
  padding: 2px 5px;
  background: #193a46;
  border: 1px solid #5bdff4;
  border-radius: 4px;
  font-size: .7rem;
}

.story-navigation { display: flex; align-items: center; gap: .4rem; margin-top: .55rem; }
#storyRematch { border: 1px solid #a28a62; border-radius: 4px; padding: .48em .8em; background: #232a37; }

/* The supplied card crops include counters along the outside edges. */
.art-frame { position: relative; display: block; overflow: hidden; width: 100%; min-height: 0; }
.unit .art-frame { flex: 1; }
.handcard .art-frame { height: 66%; }
.unit .art-frame .art, .handcard .art-frame .art {
  position: absolute; width: 100%; height: 100%; left: 0; top: 0;
  object-fit: cover; object-position: center 35%;
}
#storyRival.speaking img { filter: brightness(1) drop-shadow(3px 8px 11px #080a12); }
.reward-frame { display: block; position: relative; overflow: hidden; width: 125px; height: 115px; margin: 0 auto; border: 1px solid #bda373; border-radius: 8px; }
.reward-frame img { position: absolute; width: 100%; height: 100%; left: 0; top: 0; object-fit: cover; object-position: center 35%; border: 0; }

/* Card selection, payment preview, and battlefield gestures. */
#app { user-select: none; }
#allyRow, #allyRow .unit-slot { touch-action: none; }
#hand { touch-action: pan-x; }
#hand.hand-browsing {
  position: relative;
  margin-top: -18px;
  padding-top: 26px;
  scroll-snap-type: none;
  touch-action: none;
}
#hand.hand-browsing .handcard.active {
  z-index: 2;
  transform: translateY(-13px) scale(1.09);
}
.handcard .art { -webkit-user-drag: none; }
.hero-head.eligible { outline: 2px solid #e7bb70; outline-offset: -2px; cursor: pointer; }
#app .hand-label { height: 32px; }
#manaPreview {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 0 8px;
  border: 1px solid #5298a5;
  border-radius: 4px;
  background: #0e222d;
  color: #dbf8ff;
  white-space: nowrap;
}
#manaPreviewCost { color: #accbd3; font-size: 10px; }
#manaPreviewValue { color: #b9f8ff; font: 850 21px/1.05 system-ui, sans-serif; }
#manaPreview.short { border-color: #ab6f52; background: #2b1b16; color: #ffd5bb; }
#manaPreview.short strong, #manaPreview.short small { color: #ffd5bb; }
#app.mana-previewing .bottom { background: #050810; }
#app.mana-previewing .footer { background: #07090f; border-top-color: #4d4235; }
#app.mana-previewing .footer .primary { filter: brightness(.77); }
#app.mana-previewing #hand .handcard:not(.mana-card) {
  filter: brightness(.39) saturate(.65);
}
#app.mana-previewing #handTitle, #app.mana-previewing #handCount { color: #adb3c0; }
#handCount { margin-left: 8px; white-space: nowrap; }
#handTitle { white-space: nowrap; }
#gems { display: inline-flex; gap: 1px; }
.gem.reserved {
  background: linear-gradient(145deg,#fff,#bffaff 38%,#27dafa 73%,#fff8cf);
  animation: gem-charge .75s ease-in-out infinite alternate;
}
@keyframes gem-charge {
  to { opacity: .6; transform: translateY(-1px); }
}
.handcard.mana-card { filter: none; outline-color: #91f6ff; }
.mana-card .crystal {
  color: #fff;
  background: linear-gradient(145deg,#fffabf 3%,#69f5ff 34%,#168ccc 64%,#d3fcff);
  text-shadow: 0 1px 3px #061c38, 0 0 5px #061c38;
  animation: cost-charge .6s ease-in-out infinite alternate;
}
@keyframes cost-charge {
  to { transform: scale(1.13); filter: brightness(1.24); }
}
.unit.selected {
  outline-color: #ffe274;
  box-shadow: 0 0 14px #f8cb628f, inset 0 0 0 1px #f8cb62;
  transform: translateY(-3px);
}
.eligible.drop-focus {
  outline: 3px solid #acf8ff;
  box-shadow: inset 0 0 18px #33d1f95e, 0 0 12px #69efff9e;
}
.handcard.drag-source { opacity: .24; }
.handcard.card-ghost {
  position: fixed;
  z-index: 14;
  margin: 0;
  pointer-events: none;
  outline: 2px solid #8cf4ff;
  box-shadow: 0 10px 25px #000c, 0 0 15px #58e8fc80;
  will-change: transform;
  animation: card-lift .21s ease-out both;
}
@keyframes card-lift {
  0% { rotate: y -30deg; scale: .94; }
  100% { rotate: y 0deg; scale: 1.07; }
}
#manaFlow {
  position: absolute;
  inset: 0;
  z-index: 15;
  overflow: hidden;
  pointer-events: none;
}
.mana-ray {
  position: absolute;
  height: 2px;
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #84edff99, #b9f8ff6e 55%, #e9fbffbb);
  box-shadow: 0 0 5px #61dbfb;
}
.mana-ray::after {
  content: '';
  position: absolute;
  inset: -2px 0;
  background: linear-gradient(90deg, transparent 36%, #3ad6ff66 44%, #efffff 48%, transparent 56%) 100% 0 / 235% 100%;
  animation: mana-current .74s var(--delay) linear infinite;
}
@keyframes mana-current {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}
#app:has(.overlay:not(.hidden)) #manaFlow { visibility: hidden; }
#modal.card-inspect-overlay { position: fixed; }
.inspect-art {
  width: fit-content;
  max-width: min(100%, 300px);
  position: relative;
  overflow: hidden;
  margin: 0 auto;
  padding: 8px;
  border: 1px solid #d6b77e;
  border-radius: 7px;
  background: #111823;
}
.inspect-art > img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(49dvh, 380px);
  margin: 0 auto;
  object-fit: contain;
}
.inspect-meta span { color: #9debff; }

/* Hold the impact and the result long enough to read between attacks. */
.parry-impact {
  position: absolute;
  inset: 0;
  z-index: 17;
  pointer-events: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  animation: impact-wash .5s ease-out both;
}
.parry-burst { position: absolute; left: 50%; top: 44%; }
.parry-ring {
  position: absolute;
  width: 230px;
  aspect-ratio: 1;
  margin: -115px 0 0 -115px;
  border-radius: 50%;
  border: 3px solid #e9ffff;
  box-shadow: 0 0 22px #61e4ff, inset 0 0 20px #61e4ff;
  animation: impact-ring .54s ease-out both;
}
.parry-slash {
  position: absolute;
  width: min(85vw, 390px);
  height: 24px;
  left: 0;
  border-radius: 50%;
  background: radial-gradient(ellipse, #fff 0 17%, #cffdff 22%, #76e9ffbb 43%, transparent 71%);
  --slash-angle: -32deg;
  animation: impact-slash .46s ease-out both;
}
.parry-slash.reverse { --slash-angle: 24deg; animation-delay: 36ms; }
.parry-spark {
  position: absolute;
  height: 2px;
  width: 26px;
  border-radius: 50%;
  background: linear-gradient(90deg, transparent, #dcfaff 75%, #fff3b7);
  box-shadow: 0 0 9px #83e9ff;
  animation: impact-spark .57s var(--delay) ease-out both;
}
.parry-result {
  position: absolute;
  top: 45%;
  transform: translateY(-50%);
  display: grid;
  gap: 4px;
  min-width: min(76%, 280px);
  padding: 13px 20px 15px;
  text-align: center;
  color: #edfeff;
  background: linear-gradient(90deg, #102430ed, #153742f5, #102430ed);
  border-block: 1px solid #93ecff;
  box-shadow: 0 0 25px #50cdff65;
  animation: impact-result 1.08s both;
}
.parry-result strong { font-size: clamp(20px, 6vw, 30px); text-shadow: 0 0 12px #65d3ff; }
.parry-result span { font: 800 13px system-ui, sans-serif; color: #fff2b8; }
@keyframes impact-wash { from { background: #c7f7ff79; } to { background: #54ccff00; } }
@keyframes impact-ring { from { transform: scale(.18); opacity: 1; } to { transform: scale(1.45); opacity: 0; } }
@keyframes impact-slash {
  from { transform: translate(-50%,-50%) rotate(var(--slash-angle)) scale(.1,1.85); opacity: 1; }
  35% { opacity: 1; }
  to { transform: translate(-50%,-50%) rotate(var(--slash-angle)) scale(1.12,.18); opacity: 0; }
}
@keyframes impact-spark {
  from { transform: rotate(var(--angle)) translateX(16px) scaleX(.25); opacity: 1; }
  to { transform: rotate(var(--angle)) translateX(var(--distance)) scaleX(1.1); opacity: 0; }
}
@keyframes impact-result {
  0% { opacity: 0; scale: .92; }
  12%, 83% { opacity: 1; scale: 1; }
  100% { opacity: 0; }
}
@media (max-width: 375px) {
  #gems { display: inline-flex; gap: 0; }
  #gems .gem { width: clamp(5px, 2vw, 8px); height: 12px; }
  .mana { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .gem.reserved, .mana-card .crystal, .handcard.card-ghost, .mana-ray::after,
  .parry-impact, .parry-result { animation: none; }
  .parry-burst { display: none; }
}

.parry-buttons {
  flex-direction: column;
  gap: 5px;
}
.parry-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 0;
  padding: 5px 9px;
  background: #101f2d;
  border-color: #738392;
  touch-action: none;
  user-select: none;
}
.parry-btn.cue-active { border-color: #75c9dc; background: #142b3b; }
.parry-btn.in-window { border-color: #ffe089; background: #3e3021; }
.parry-lane-label { flex: 0 0 3em; font-size: clamp(13px, 3.6vw, 17px); white-space: nowrap; text-align: left; }
.parry-progress {
  flex: 1;
  position: relative;
  height: clamp(15px, 3vh, 24px);
  overflow: hidden;
  background: #080d16;
  border: 1px solid #53606c;
  border-radius: 4px;
}
.parry-band {
  position: absolute;
  inset-block: 0;
  background: #95712e;
  border-inline: 2px solid #ffe58f;
  box-shadow: 0 0 9px #f3c66c80;
}
.parry-btn:not(.cue-active) .parry-band { opacity: .5; }
.in-window .parry-band { background: #efc464; border-color: #fff4ca; }
.parry-hit-line {
  position: absolute;
  left: 82%;
  inset-block: 0;
  width: 1px;
  background: #fff1bfaa;
}
.parry-marker {
  position: absolute;
  inset-block: 0;
  width: 4px;
  transform: translateX(-50%);
  background: #eaffff;
  box-shadow: 0 0 8px 2px #4deeff, -5px 0 9px 2px #4deeffa3;
  border-radius: 2px;
}
.in-window .parry-marker:not(.upcoming-marker) { background: #fff; box-shadow: 0 0 7px 2px #fff4c4; }
.parry-marker.upcoming-marker {
  width: 3px;
  opacity: .84;
  background: #95dcee;
  box-shadow: 0 0 7px #4deeff, -6px 0 6px #4deeff90;
}
.parry-warning { font-weight: 750; color: #ffe4a4; }

#openParryPractice { margin-top: .85rem; background: #152330; }
#parryPractice {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 14px;
  background: linear-gradient(160deg,#20313c,#111b27 54%, #18232d);
  border-inline: 1px solid #998057;
}
.practice-header h1 { margin: 1rem 0 .55rem; font-size: clamp(20px, 6vw, 26px); color: #f5ddab; }
.practice-header p, #practiceResult { margin: 8px 0; font: 14px/1.55 system-ui, sans-serif; }
.practice-options {
  display: grid;
  gap: 10px;
  margin: 18px 0 12px;
}
.practice-options fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
}
.practice-options label { display: grid; gap: 5px; min-width: 0; font: 13px system-ui, sans-serif; color: #e9d8b7; }
.practice-options select {
  width: 100%;
  min-height: 40px;
  padding: 5px;
  color: #f5eee0;
  background: #101923;
  border: 1px solid #827456;
  border-radius: 5px;
  font: inherit;
}
#practiceStage {
  position: relative;
  background: #111821;
  border: 1px solid #8d7958;
  border-radius: 7px;
  overflow: hidden;
}
#practiceStage:empty { display: none; }
#practiceStage .parry-area { height: 163px; }
#practiceStage .parry-btn { min-height: 55px; }
#practiceResult {
  min-height: 22px;
  color: #ffdf9b;
  text-align: center;
}

#parryHint.cue-miss { color: #ffbd9f; }

.parry-cue-spark {
  position: absolute;
  z-index: 18;
  pointer-events: none;
}
.parry-cue-spark::before {
  content: '';
  position: absolute;
  inset: clamp(-53px, -12vw, -28px);
  border-radius: 50%;
  background: radial-gradient(circle, #fff8d6 0%, #ffce5e9e 20%, #f9b93400 68%);
  border: 1px solid #ffe092a0;
  box-shadow: 0 0 15px #ffca635c, inset 0 0 13px #ffce6359;
  animation: parry-cue-glow .36s ease-out both;
}
.parry-cue-spark::after {
  content: '';
  position: absolute;
  right: -20px;
  top: -10px;
  width: min(72vw, 310px);
  height: 20px;
  border-radius: 50%;
  transform-origin: 92% 50%;
  background: radial-gradient(ellipse at 65% 50%, #fff5c2 0%, #ffe293 19%, #ffa52d80 46%, transparent 72%);
  animation: parry-cue-slash .34s ease-out both;
}
.parry-cue-spark i {
  position: absolute;
  width: clamp(12px, 5vw, 24px);
  height: 3px;
  border-radius: 50%;
  background: linear-gradient(90deg, #ffcf6080, #ffe59a 80%, #fff9d8);
  box-shadow: 0 0 7px #ffc85d;
  animation: parry-cue-ray .36s ease-out both;
}
@keyframes parry-cue-glow {
  from { opacity: 1; transform: scale(.28); }
  40% { opacity: .9; }
  to { opacity: 0; transform: scale(1.45); }
}
@keyframes parry-cue-slash {
  from { opacity: 1; transform: rotate(-21deg) scale(.28, 1.35); }
  35% { opacity: .95; transform: rotate(-21deg) scale(.96, 1); }
  to { opacity: 0; transform: rotate(-21deg) scale(1.02, .22); }
}
@keyframes parry-cue-ray {
  from { opacity: 1; transform: rotate(var(--angle)) translateX(10px) scaleX(.55); }
  36% { opacity: .95; }
  to { opacity: 0; transform: rotate(var(--angle)) translateX(var(--reach)) scaleX(.8); }
}
@media (prefers-reduced-motion: reduce) {
  .parry-cue-spark::before { animation: none; inset: -22px; }
  .parry-cue-spark::after, .parry-cue-spark i { display: none; }
}

#attackTrail {
  position: absolute;
  inset: 0;
  z-index: 7;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.incoming-damage {
  position: absolute;
  z-index: 16;
  pointer-events: none;
  display: grid;
  place-items: center;
}
.incoming-damage strong {
  position: absolute;
  color: #ff474f;
  white-space: nowrap;
  font: 950 clamp(45px, 15vw, 66px)/1 system-ui, sans-serif;
  -webkit-text-stroke: 1px #ffd6c4;
  text-shadow: 0 2px 1px #39080b, 0 0 14px #f22637;
  animation: damage-number .68s ease-out both;
}
.incoming-damage i {
  position: absolute;
  width: 98px;
  height: 64px;
  border: 2px solid #ff9b78;
  border-radius: 50%;
  background: radial-gradient(ellipse,#ffc18b9e, #f1343938 51%, transparent 69%);
  box-shadow: 0 0 16px #ff503c8c;
  animation: damage-burst .48s ease-out both;
}
.hero-head.damage-hit .leader-portrait { animation: damage-portrait .38s ease-out both; }
.hero-head.damage-hit .bar { box-shadow: 0 0 12px #ff4846; border-color: #ff9b7e; }
.hero-head.damage-hit #php { color: #ff8886; }
@keyframes damage-number {
  0% { transform: translateY(-6px) scale(.8); opacity: .78; }
  16% { transform: translateY(-18px) scale(1.13); opacity: 1; }
  67% { transform: translateY(-29px) scale(1); opacity: 1; }
  100% { transform: translateY(-37px) scale(.96); opacity: 0; }
}
@keyframes damage-burst {
  from { transform: rotate(-20deg) scale(.26); opacity: 1; }
  to { transform: rotate(-20deg) scale(1.5); opacity: 0; }
}
@keyframes damage-portrait {
  0%, 30% { filter: sepia(.7) saturate(2.5) brightness(1.45) drop-shadow(0 0 10px #ff5a47); }
  100% { filter: drop-shadow(0 6px 10px #000); }
}
@media (prefers-reduced-motion: reduce) {
  .incoming-damage strong, .incoming-damage i, .hero-head.damage-hit .leader-portrait { animation: none; }
  .incoming-damage strong { transform: translateY(-26px); }
}

.unit.striking { outline: 2px solid #ffd38e; outline-offset: -2px; box-shadow: 0 0 12px #f6b66480; }
.numbers .heart { color: #f3ded0; }
.unit.damaged .numbers .heart { color: #ff575c; text-shadow: 0 0 6px #ff222a66; }
.stat-value { display: inline-block; color: #fff; text-shadow: none; }
.stat-value.stat-up { color: #8cf8a3; }
.stat-value.stat-down { color: #ff858a; }
.stat-value.stat-pulse { animation: stat-pulse 290ms var(--stat-delay) ease-out both; }
@keyframes stat-pulse {
  30% { transform: scale(1.22); text-shadow: 0 0 7px currentColor; }
}
.unit.exhausted.damaged { filter: none; }
.unit.exhausted.damaged .art, .unit.exhausted.damaged .label { filter: grayscale(.8) brightness(.65); }
.unit-damage strong { font-size: clamp(26px, 8vw, 42px); }
.unit-damage i { width: 58px; height: 52px; }
.enemy-head.damage-hit .leader-portrait { animation: damage-portrait .38s ease-out both; }
.enemy-head.damage-hit .bar { box-shadow: 0 0 12px #ff4846; border-color: #ff9b7e; }
.enemy-head.damage-hit #ehp { color: #ff8886; }
@media (prefers-reduced-motion: reduce) {
  .enemy-head.damage-hit .leader-portrait { animation: none; }
}

.recovery-effect strong {
  color: #63ee88;
  -webkit-text-stroke-color: #e1ffdb;
  text-shadow: 0 2px 1px #052b16, 0 0 14px #28da60;
}
.recovery-effect i {
  border-color: #aaffaf;
  background: radial-gradient(ellipse, #dbffafcf, #53ed8d66 45%, transparent 70%);
  box-shadow: 0 0 18px #4bff9885, inset 0 0 12px #8cffb575;
  animation: recovery-burst .62s ease-out both;
}
.recovery-effect i::before, .recovery-effect i::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 23%, #caffd2 0 2px, transparent 3px),
    radial-gradient(circle at 77% 14%, #eaffcd 0 2px, transparent 3px),
    radial-gradient(circle at 66% 70%, #89ffa9 0 2px, transparent 3px),
    radial-gradient(circle at 16% 84%, #a0fcb2 0 2px, transparent 3px);
}
.recovery-effect i::after { transform: rotate(43deg); }
.recovery-hit .leader-portrait { animation: recovery-portrait .55s ease-out both; }
.recovery-hit .bar { box-shadow: 0 0 12px #44ea79; border-color: #a7ffad; }
.recovery-hit .hptitle { color: #a5ffb8; }
@keyframes recovery-burst {
  from { transform: translateY(9px) scale(.4); opacity: .85; }
  40% { opacity: 1; }
  to { transform: translateY(-23px) scale(1.4); opacity: 0; }
}
@keyframes recovery-portrait {
  0%, 25% { filter: brightness(1.28) drop-shadow(0 0 12px #6aff9e); }
  to { filter: drop-shadow(0 6px 10px #000); }
}
@media (prefers-reduced-motion: reduce) {
  .recovery-effect i, .recovery-hit .leader-portrait { animation: none; }
}

.bar { position: relative; }
.bar > .health-overflow {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, #228d53, #7dfb9a);
  box-shadow: inset -1px 0 #d0ffdd;
}

#enemyAttackButton {
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
}
#enemyAttackButton:disabled { cursor: default; }
.enemy-head .head-info { pointer-events: none; }
.enemy-head .statline { gap: clamp(3px, 1.4vw, 7px); white-space: nowrap; }
.pile-counts { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; }
.pile-marker {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 3px;
  min-width: 30px;
  min-height: 26px;
  padding: 1px 4px;
  color: #f5e6c9;
  background: #121921;
  border: 1px solid #6d6355;
  border-radius: 4px;
  font: 700 11px/1 system-ui,sans-serif;
  pointer-events: auto;
  user-select: none;
  -webkit-touch-callout: none;
}
.pile-marker:disabled { opacity: .65; cursor: default; }
.pile-marker:active { border-color: #f1cd86; }
.pile-icon { position: relative; width: 10px; height: 12px; color: #edc98c; }
.pile-icon.stack::before, .pile-icon.stack::after {
  content: '';
  position: absolute;
  inset: 0 2px 2px 0;
  border: 1px solid currentColor;
  border-radius: 1.5px;
}
.pile-icon.stack::after { transform: translate(2px, 2px); background: #273243; }
.handcard.draw-pending { visibility: hidden; }
.draw-flight {
  position: absolute;
  z-index: 15;
  width: 34px;
  aspect-ratio: 3 / 4;
  border: 1px solid #ebc689;
  border-radius: 4px;
  background: #203144 url('assets/ui-crest_flower.png') center / 57% auto no-repeat;
  box-shadow: inset 0 0 0 2px #101c2e, 0 0 9px #e8be81a6;
  pointer-events: none;
}
.draw-flight.draw-enemy {
  background-color: #35252b;
  background-image: url('assets/ui-crest_tomoe.png');
}
.grave-flight {
  position: absolute;
  z-index: 13;
  overflow: hidden;
  border: 1px solid #d6a579;
  border-radius: 6px;
  background: #281924;
  box-shadow: 0 0 12px #ff96605e, 0 4px 12px #000a;
  pointer-events: none;
}
.grave-flight img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pile-icon.grave {
  width: 9px;
  height: 10px;
  margin: 1px;
  border: 1px solid currentColor;
  border-radius: 6px 6px 1px 1px;
  background: #2a2935;
}
.pile-icon.grave::before, .pile-icon.grave::after {
  content: '';
  position: absolute;
  background: currentColor;
}
.pile-icon.grave::before { left: 3px; top: 2px; width: 1px; height: 5px; }
.pile-icon.grave::after { left: 2px; top: 4px; width: 3px; height: 1px; }
#manaCount, .mana > span:first-child { white-space: nowrap; }

.pile-lightbox {
  padding: 0;
  width: min(94vw, 510px);
  max-height: 84dvh;
  overflow: auto;
  overscroll-behavior: contain;
  background: #151c27;
  color: var(--ink);
  border: 1px solid #a78c60;
  border-radius: 8px;
  box-shadow: 0 12px 42px #0009;
  color-scheme: dark;
}
.pile-lightbox::backdrop { background: #04060cc2; }
.pile-dialog-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 4px 9px 4px 12px;
  background: #212936;
  border-bottom: 1px solid #a78c60;
}
.pile-dialog-header h2 { font-size: clamp(15px, 4.2vw, 20px); color: #ffe0a5; margin: 0; }
.pile-close {
  flex: 0 0 37px;
  height: 36px;
  border: 0;
  border-radius: 4px;
  background: #121820;
  color: #f9e2bc;
  font: 25px/1 system-ui, sans-serif;
}
.pile-card-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(3px, 1vw, 6px);
  padding: 9px;
}
.pile-mini-card[aria-pressed="true"] {
  outline: 3px solid var(--cyan, #46dff4);
  outline-offset: -3px;
  filter: brightness(1.25);
}
.pile-mini-card {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(22px, auto);
  min-width: 0;
  aspect-ratio: .68;
  padding: 0;
  overflow: hidden;
  border: 1px solid #897050;
  border-radius: 4px;
  background: #111923;
  touch-action: pan-y;
  user-select: none;
  -webkit-touch-callout: none;
}
.pile-mini-art { position: relative; overflow: hidden; }
.pile-mini-art img {
  position: absolute;
  left: -19%;
  top: -30%;
  width: 138%;
  height: 144%;
  object-fit: cover;
  pointer-events: none;
}
.pile-mini-cost {
  position: absolute;
  top: 1px;
  left: 1px;
  min-width: 14px;
  padding: 1px 3px;
  background: #166690;
  border: 1px solid #6bddf1;
  border-radius: 4px;
  color: #fff;
  font: 750 10px/1.15 system-ui,sans-serif;
}
.pile-mini-name {
  display: -webkit-box;
  overflow: hidden;
  margin: auto 0;
  padding: 1px 2px;
  font: 650 clamp(8px, 2.3vw, 11px)/1.15 system-ui,sans-serif;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
.pile-empty { padding: 0 12px 4px; text-align: center; }
.pile-card-detail { width: min(87vw, 390px); }
#pileCardContents { padding: 14px 12px 3px; text-align: center; }

.keyword-button {
  padding: 0 2px;
  color: #f8d89c;
  background: transparent;
  border: 0;
  line-height: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.keyword-button[aria-expanded="true"] { color: #fff1cb; }
.card-rules { position: relative; }
.keyword-explanations {
  position: absolute;
  inset: 100% 0 auto;
  z-index: 2;
  pointer-events: none;
}
.card-rules:has(.keyword-button[data-pinned]) .keyword-explanations { position: static; }
.keyword-explanation {
  max-width: 32ch;
  margin: 4px auto 7px;
  padding: 6px 9px;
  text-align: left;
  font: 13px/1.5 system-ui,sans-serif;
  background: #20293a;
  color: #f8edda;
  border-left: 2px solid #e4b86b;
}

.hero-head.casting .leader-portrait { filter: brightness(1.2) drop-shadow(0 0 10px #58d7ff); }

@font-face {
  font-family: 'Yuji Boku';
  src: url('assets/yuji-boku-turn.woff') format('woff');
  font-display: swap;
}
.turn-banner {
  position: absolute;
  z-index: 14;
  top: 36%;
  left: 1%;
  right: 1%;
  min-height: 120px;
  display: grid;
  place-items: center;
  pointer-events: none;
  transform: translateY(-50%);
  color: #edf6ee;
}
.turn-ink {
  position: absolute;
  inset: 2px 0;
  background:
    repeating-linear-gradient(176deg, transparent 0 5px, #9aa08a1a 5px 6px, transparent 7px 10px),
    linear-gradient(174deg, #121514 7%, #0a0e13 44%, #1a2427 76%, #131719 94%);
  clip-path: polygon(1% 28%, 7% 18%, 4% 15%, 22% 13%, 13% 9%, 47% 8%, 68% 4%, 93% 4%, 90% 9%,
    100% 10%, 96% 18%, 100% 22%, 97% 39%, 100% 59%, 97% 67%, 100% 76%, 92% 82%, 95% 86%,
    59% 94%, 34% 93%, 27% 99%, 5% 96%, 9% 91%, 1% 86%, 4% 74%, 0 66%, 4% 53%, 0 45%);
  transform-origin: left center;
  animation: turn-ink-sweep .68s ease-out both;
}
.battle-quote {
  position: absolute;
  z-index: 15;
  max-width: 80%;
  padding: 8px 12px 9px;
  pointer-events: none;
  color: #eef3ea;
  background: linear-gradient(174deg, #171a17f2, #0c0f0df5);
  border: 1px solid #cfd6bd55;
  box-shadow: 0 6px 18px #0009;
  animation: battle-quote-in .28s ease-out both;
}
.battle-quote .quote-name {
  display: block;
  font-size: 11px;
  letter-spacing: .18em;
  opacity: .75;
}
.battle-quote p { margin: 2px 0 0; font-size: 15px; line-height: 1.55; }
.battle-quote.quote-player { left: 4%; bottom: 33%; border-left: 3px solid #7fc4bd; }
.battle-quote.quote-enemy { right: 4%; top: 15%; border-right: 3px solid #c46a5a; color: #f6e3d3; }
@keyframes battle-quote-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.enemy-turn-banner { color: #f4ddc5; }
.enemy-turn-banner .turn-ink {
  transform-origin: right center;
  background:
    repeating-linear-gradient(178deg, transparent 0 5px, #b5a08221 5px 6px, transparent 7px 10px),
    linear-gradient(174deg, #211618 7%, #100d13 44%, #302126 76%, #171619 94%);
}
.turn-caption {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 1px;
  text-shadow: 0 2px 3px #030608;
  animation: turn-caption-reveal .68s ease-out both;
}
.turn-caption strong, .turn-caption span {
  font-family: 'Yuji Boku', 'Hiragino Mincho ProN', 'Yu Mincho', 'Noto Serif CJK JP', serif;
  font-weight: 400;
  line-height: 1.08;
}
.turn-caption strong { font-size: clamp(32px, 11vw, 56px); letter-spacing: .16em; padding-left: .16em; }
.turn-caption span { font-size: clamp(16px, 5vw, 22px); letter-spacing: .12em; color: #f2cf86; }
@keyframes turn-ink-sweep {
  0% { transform: scaleX(.035) scaleY(.7); opacity: 0; }
  26% { transform: scaleX(1) scaleY(1); opacity: .96; }
  79% { opacity: .96; }
  100% { transform: scaleX(1) scaleY(1); opacity: 0; }
}
@keyframes turn-caption-reveal {
  0% { opacity: 0; transform: translateY(5px); }
  24%, 77% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .turn-ink, .turn-caption { animation: none; }
}

.unit.block-ghost {
  position: fixed;
  z-index: 14;
  pointer-events: none;
  opacity: .86;
  outline: 2px solid #ffe274;
  outline-offset: -1px;
  box-shadow: 0 6px 16px #000a, 0 0 10px #ffcf737d;
}

/* Supplied Bakumatsu interface artwork. */
.art-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.turn-banner { min-height: 142px; }
.turn-ink, .enemy-turn-banner .turn-ink {
  inset: 8% 1% 10%;
  background: url('assets/ui-ink_swash.png') center / 100% 100% no-repeat;
  clip-path: none;
  opacity: .5;
  mix-blend-mode: screen;
}
.turn-banner::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: -14% 1% -6%;
  background: url('assets/ui-turn_flash_blue.png') center / auto 90% no-repeat;
  mix-blend-mode: screen;
  animation: turn-flash-art .68s ease-out both;
}
.enemy-turn-banner::after { background-image: url('assets/ui-turn_flash_red.png'); }
.turn-caption { width: 100%; gap: 0; }
.turn-title-art {
  display: block;
  width: min(100%, 471px);
  height: clamp(100px, 29vw, 137px);
  object-fit: contain;
  filter: drop-shadow(0 3px 7px #000);
}
.turn-caption span {
  margin-top: -5px;
  padding: 2px 12px 5px;
  background: radial-gradient(ellipse,#101116ef 30%, #0d0f15bc 61%, transparent 75%);
}
@keyframes turn-flash-art {
  0% { opacity: 0; transform: scale(.7); }
  34% { opacity: .58; }
  80%, 100% { opacity: 0; transform: scale(1.25); }
}

.story-title p { display: flex; align-items: center; gap: 7px; }
.story-title p::before {
  content: '';
  width: 22px;
  height: 22px;
  background: url('assets/ui-crest_diamond.png') center / contain no-repeat;
}
.story-text {
  border: 9px solid transparent;
  border-image: url('assets/ui-dialogue_paper.png') 17 21 fill stretch;
  background: none;
  padding: .35rem .6rem;
}
.story-text strong.hero-name {
  display: inline-block;
  width: 85px;
  height: 29px;
  background: url('assets/ui-name_hero.png') left center / contain no-repeat;
  color: transparent;
}
.hero-head::after, .enemy-head::after {
  content: '';
  position: absolute;
  pointer-events: none;
  top: 9%;
  left: 2%;
  width: 19px;
  height: 19px;
  background: url('assets/ui-crest_flower.png') center / contain no-repeat;
  opacity: .8;
}
.enemy-head::after { background-image: url('assets/ui-crest_tomoe.png'); }

.perm.perm-empty {
  background: url('assets/ui-permanent_socket.png') center / auto 100% no-repeat;
  border-color: transparent;
}
.unit-states {
  position: absolute;
  z-index: 3;
  top: 3px;
  right: 3px;
  display: flex;
  gap: 1px;
  pointer-events: none;
}
.unit-states img {
  width: clamp(16px, 5vw, 23px);
  height: clamp(16px, 5vw, 23px);
  object-fit: contain;
  border-radius: 4px;
  background: #101923bf;
  filter: drop-shadow(0 1px 2px #000);
}
.unit.exhausted { filter: none; }
.unit.exhausted .art, .unit.exhausted .label { filter: grayscale(.8) brightness(.55); }
.unit .numbers {
  background: linear-gradient(#14141970, #0d1119bc),
    url('assets/ui-stat_plate_blank.png') center / 100% 100% no-repeat;
}
[data-kind="unit"] { --card-frame: url('assets/ui-unit_frame.png'); }
[data-kind="spell"] { --card-frame: url('assets/ui-spell_frame.png'); }
[data-kind="permanent"] { --card-frame: url('assets/ui-permanent_frame.png'); }
.handcard[data-kind]::after, .pile-mini-card[data-kind]::after, .unit[data-kind]::after,
.inspect-art[data-kind]::after, .reward-frame[data-kind]::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border: var(--card-edge-size, 5px) solid transparent;
  border-image: var(--card-frame) 16 stretch;
}
.pile-mini-card, .unit[data-kind] { --card-edge-size: 4px; }
.inspect-art, .reward-frame { --card-edge-size: 8px; }
.pile-mini-cost, .exchange-mark { z-index: 2; }

.gem, .gem.reserved {
  clip-path: none;
  background: url('assets/ui-crystal_blue.png') center / contain no-repeat;
}
.crystal, .mana-card .crystal {
  clip-path: none;
  background: url('assets/ui-crystal_blue_wide.png') center / contain no-repeat;
  text-shadow: 0 1px 2px #071525, 0 -1px 3px #071525, 1px 0 2px #071525;
}
.gem.reserved, .mana-card .crystal { filter: drop-shadow(0 0 4px #6cecff) brightness(1.15); }

.parry-burst::after {
  content: '';
  position: absolute;
  width: min(66vw, 280px);
  height: min(66vw, 280px);
  background: url('assets/ui-parry_impact.png') center / contain no-repeat;
  mix-blend-mode: screen;
  animation: supplied-parry .49s ease-out both;
}
.damage-effect i::after {
  content: '';
  position: absolute;
  inset: -65% -45%;
  background: url('assets/ui-hit_slash.png') center / contain no-repeat;
  mix-blend-mode: screen;
}
@keyframes supplied-parry {
  from { opacity: .7; transform: translate(-50%, -50%) scale(.35); }
  32% { opacity: 1; transform: translate(-50%, -50%) scale(.86); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(1.18); }
}

.reward-display {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding-bottom: 1px;
}
.reward-display::before {
  content: '';
  position: absolute;
  inset: 25px 0 6px;
  z-index: -1;
  background: url('assets/ui-reward_ring.png') center / min(100%, 200px) 100% no-repeat;
  animation: reward-ring-appear .65s ease-out both;
}
.reward-friendship, .reward-earned { width: min(70%, 190px); height: auto; }
.reward-earned { width: min(60%, 150px); }
.reward-display .reward-frame { width: 101px; height: 129px; margin: 1px 0; }
.reward-display .reward-frame img { width: 140%; height: 145%; left: -20%; top: -29%; }
@keyframes reward-ring-appear {
  from { opacity: .25; transform: scale(.86); }
  to { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .turn-banner::after, .parry-burst::after { display: none; }
  .reward-display::before { animation: none; }
}

.card-tags { color: #b5d6dc; }
.card-flavor {
  margin: 12px 0;
  padding: 9px 0 0;
  border-top: 1px solid #987b4c;
  text-align: left;
  color: #d6c9b1;
}
.card-flavor h3 { margin: 0 0 4px; font-size: .78rem; }
.dialog .card-flavor p, .pile-card-detail .card-flavor p {
  margin: 0;
  font: .75rem/1.7 system-ui,sans-serif;
  overflow-wrap: anywhere;
}

.vanish-effect {
  position: absolute;
  z-index: 16;
  min-width: 54px;
  pointer-events: none;
  color: #f3d9ff;
  font: 800 clamp(16px, 5vw, 23px)/1 system-ui, sans-serif;
  text-align: center;
  text-shadow: 0 0 9px #d666ff, 0 1px 2px #180b35;
  transform: translate(-50%, -50%);
  animation: vanish-mark .68s ease-out both;
}
.vanish-effect::before {
  content: '';
  position: absolute;
  inset: -19px -7px;
  z-index: -1;
  border: 1px solid #dfacffb5;
  border-radius: 50%;
  background: radial-gradient(ellipse, #a765e680 15%, #54278470 50%, transparent 74%);
  box-shadow: 0 0 11px #bb72fa65;
}
@keyframes vanish-mark {
  0% { opacity: .64; transform: translate(-50%, -43%) scale(.7); }
  23%, 66% { opacity: 1; transform: translate(-50%, -55%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -78%) scale(.8); }
}
@media (prefers-reduced-motion: reduce) {
  .vanish-effect { animation: none; }
}

.story-practice-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .85rem; }
.story-practice-actions #openParryPractice, #openKeywordPractice { margin: 0; background: #152330; }
#keywordPractice {
  min-height: 100dvh;
  max-width: 520px;
  margin-inline: auto;
  padding: 20px 14px;
  background: linear-gradient(160deg,#20313c,#111b27 54%, #18232d);
  border-inline: 1px solid #998057;
}
#keywordRule, #keywordHint { margin: 0; padding: 9px 10px; font: 14px/1.55 system-ui,sans-serif; }
#keywordRule { border-left: 2px solid #d7ad63; background: #263343; }
#keywordHint { color: #efdbaf; }
.exercise-tools {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 13;
  display: flex;
  gap: 3px;
}
.exercise-tools button { padding: 5px; font-size: 11px; border-color: #aa8c5c; background: #111e2de8; }
.unit.warded { box-shadow: inset 0 0 11px #76e8ff86, 0 0 9px #62d5ff85; border-color: #95e8f6; }
.barrier-effect {
  position: absolute;
  z-index: 16;
  transform: translate(-50%,-50%);
  pointer-events: none;
  border: 1px solid #9aefff;
  border-radius: 14px;
  padding: 4px 9px;
  background: #173c56;
  color: #caffff;
  font: bold 13px system-ui,sans-serif;
  white-space: nowrap;
  box-shadow: 0 0 12px #78d8ff;
}

/* The supplied illustration is shared by both counters. */
.stat-orbs {
  position: absolute;
  right: 3px;
  bottom: 2px;
  z-index: 5;
  display: flex;
  gap: 2px;
  pointer-events: none;
}
.stat-orb {
  --orb-glow: #a9ff72;
  position: relative;
  display: grid;
  direction: ltr;
  place-items: center;
  width: clamp(15px, 4.7vw, 21px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: url('assets/stat-orbs.jpg') 17.6% 18% / 312.2% 103.9% no-repeat;
  box-shadow: 0 1px 3px #000c;
  color: white;
  font: 900 clamp(9px, 2.8vw, 13px)/1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 2px #000, 1px 0 #000, -1px 0 #000, 0 -1px #000;
}
.orb-blue {
  --orb-glow: #68cbff;
  background: url('assets/stat-orb-blue.jpg') 45.5% 45.3% / 124% 122.6% no-repeat;
}
.orb-red { --orb-glow: #ff7758; background-position: 81.2% 18%; }
.orb-number { font-weight: inherit; white-space: nowrap; -webkit-text-stroke: .35px #100c0c; }
.perm .stat-orbs { top: 2px; bottom: auto; }
.inspect-art .stat-orbs { top: 7px; right: 7px; bottom: auto; gap: 3px; }
.inspect-art .stat-orb {
  width: 44px;
  font-size: 17px;
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.inspect-art .stat-orb:focus-visible {
  outline: 2px solid #fff0b1;
  outline-offset: 2px;
}
.modifier-detail {
  margin: 8px 0;
  padding: 8px 10px;
  background: #141e29;
  border: 1px solid #6c604c;
  border-radius: 6px;
  text-align: left;
  font: 13px/1.5 system-ui, sans-serif;
}
.modifier-detail h3 { margin: 0 0 4px; font-size: 14px; color: #f5d9a1; }
.modifier-detail ul { margin: 0; padding-left: 18px; }
.modifier-detail li + li { margin-top: 4px; }
.modifier-detail li span { display: block; color: #d4e2eb; }

.stat-orb:is(.orb-gain, .orb-release, .orb-consume, .orb-zero) {
  animation: var(--orb-animation) 330ms var(--orb-delay) ease-out both;
}
.orb-gain { --orb-animation: orb-bounce; }
.orb-red.orb-gain { --orb-animation: orb-shake; }
.orb-release { --orb-animation: orb-drain; }
.orb-consume { --orb-animation: orb-spend; }
.orb-zero { --orb-animation: orb-collapse; pointer-events: none; }
.stat-orb:is(.orb-gain, .orb-release, .orb-consume) .orb-number {
  animation: orb-number-pop 330ms var(--orb-delay) ease-out both;
}
.orb-release::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid var(--orb-glow);
  border-radius: inherit;
  animation: orb-light-out 330ms var(--orb-delay) ease-out both;
}
.orb-particles { position: absolute; inset: 0; pointer-events: none; }
.orb-particles b {
  position: absolute;
  top: 46%;
  left: 46%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #efffc5;
  box-shadow: 0 0 7px 2px #9bff54;
  animation: orb-particle 330ms var(--orb-delay) ease-in-out both;
}
.orb-particles b:nth-child(1) { --x: -13px; --y: 1px; }
.orb-particles b:nth-child(2) { --x: -5px; --y: -13px; }
.orb-particles b:nth-child(3) { --x: 10px; --y: -8px; }
.orb-particles b:nth-child(4) { --x: 13px; --y: 7px; }
.orb-particles b:nth-child(5) { --x: 2px; --y: 14px; }

@keyframes orb-bounce {
  0%, 100% { transform: none; }
  32% { transform: translateY(-2px) scale(1.13); box-shadow: 0 0 9px 2px var(--orb-glow); }
  68% { transform: translateY(1px) scale(.95); }
}
@keyframes orb-shake {
  0%, 100% { transform: none; }
  24% { transform: translateX(-2px); box-shadow: 0 0 8px 2px var(--orb-glow); }
  45% { transform: translateX(2px); }
  65% { transform: translateX(-1px); }
}
@keyframes orb-drain {
  20% { filter: brightness(1.22); }
  63% { filter: brightness(.76); }
}
@keyframes orb-spend {
  27% { box-shadow: 0 0 8px 2px var(--orb-glow); }
  58% { transform: scale(.88); }
}
@keyframes orb-collapse {
  0%, 25% { opacity: 1; }
  100% { transform: scale(.25); opacity: 0; visibility: hidden; }
}
@keyframes orb-number-pop {
  0%, 100% { transform: scale(1); }
  29% { transform: scale(1.23); }
}
@keyframes orb-light-out {
  0% { opacity: .9; }
  100% { transform: scale(1.36); opacity: 0; }
}
@keyframes orb-particle {
  0% { opacity: 0; }
  35% { transform: translate(var(--x), var(--y)); opacity: 1; }
  78% { opacity: .95; }
  100% { transform: translate(-22px, 24px) scale(.15); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .stat-value.stat-pulse,
  .stat-orb:is(.orb-gain, .orb-release, .orb-consume, .orb-zero),
  .stat-orb:is(.orb-gain, .orb-release, .orb-consume) .orb-number { animation: none; }
  .stat-orb.orb-zero, .orb-particles, .orb-release::after { display: none; }
}
.modifier-exercise-tools {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  flex: none;
  gap: 3px;
  padding: 2px 6px;
}
.modifier-exercise-tools .secondary { min-height: 32px; padding: 3px; font-size: 11px; }

.card-library {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px;
  background: #101823;
}
.library-controls, .custom-deck { margin: 10px 0; }
.library-controls label { display: block; }
#cardSearch {
  width: 100%;
  display: block;
  margin: 6px 0;
  padding: 9px;
  border: 1px solid #9d8257;
  border-radius: 5px;
  background: #1d2733;
  color: inherit;
  font: inherit;
}
.library-controls p, .custom-deck p { margin: 6px 0; color: #dfcfb6; font-size: 13px; }
.card-results, #customDeckCards { list-style: none; padding: 0; }
.card-results {
  max-height: 43dvh;
  overflow: auto;
  border: 1px solid #665940;
  border-radius: 5px;
  margin: 0;
}
.card-results li, #customDeckCards li {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-bottom: 1px solid #5d5039;
}
.library-card-info {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 5px 0;
  border: 0;
  background: transparent;
}
.library-card-info small { display: block; color: #d2ba92; margin-top: 3px; }
.custom-deck { padding: 7px; border: 1px solid #665940; border-radius: 5px; }
#customDeckCards { max-height: 28dvh; overflow: auto; margin: 0; }
.library-actions { display: flex; justify-content: space-between; gap: 6px; }
#libraryCardContents { padding: 12px; }
.grave-recovery-options { max-height: 43dvh; overflow: auto; }

#enemyHandViewer { appearance:none; padding:0; border:0; background:none; color:inherit; font:inherit; cursor:pointer; }
#enemyHandViewer:focus-visible { outline:1px solid #eed095; outline-offset:3px; }
.handcard.affordable:not(.active) { box-shadow:0 0 8px #e6be6666; }
.handcard.awakened, .pile-mini-card[data-playable="true"] { box-shadow:0 0 9px #efc464; }
.is-presenting :is(.footer,#allyRow,#enemyRow,#allyPerms,#enemyPerms,#hand,.pile-marker,#enemyHandViewer) { pointer-events:none; }
.ability-presentation {
  position:absolute; z-index:30; margin:0; left:50%; top:47%; transform:translate(-50%,-50%);
  width:min(31vw,132px); pointer-events:none; color:#fff4cd; text-align:center;
}
.ability-presentation img {
  display:block; width:100%; height:auto; aspect-ratio:3/4; object-fit:cover;
  border:1px solid #efcf8b; border-radius:6px; box-shadow:0 0 22px #efc464ad,0 8px 22px #000;
}
.card-use-presentation img { object-fit:contain; background:#161714; }
.ability-presentation figcaption {
  background:#18191ae8; border:1px solid #a98854; padding:.35em .55em; border-radius:3px; font-size:.74rem;
}
#parry[data-color="red"] { --parry-band-color:#f39379; }
#parry[data-color="purple"] { --parry-band-color:#d4a0ee; }
#parry[data-color="blue"] { --parry-band-color:#83cadf; }
#parry[data-color="yellow"] { --parry-band-color:#efcf70; }
#parry[data-color="silver"] { --parry-band-color:#e6e8ec; }
#parry[data-color]:not([data-color="practice"]) .parry-band {
  background:color-mix(in srgb,var(--parry-band-color) 65%,transparent);
  border-color:var(--parry-band-color);
}
#parry[data-color]:not([data-color="practice"]) .in-window .parry-band { background:var(--parry-band-color); }
.combat-count { position:absolute; right:3px; top:2px; border-radius:3px; background:#211b16dd; color:#fff4cd; padding:1px 3px; font-size:.62rem; z-index:2; }
.unit.untargetable::before { content:'対象外'; position:absolute; right:2px; top:2px; padding:2px 3px; z-index:2; background:#231e19db; color:#e9dbbc; font-size:.57rem; }
.ability-presentation[data-side="enemy"] { top:43%; }
.ability-presentation[data-side="player"] { top:53%; }
.battle-history { max-height:48dvh; overflow:auto; padding-left:1.8em; text-align:left; font-size:.8rem; line-height:1.7; }

#worldMenu:not([hidden]) {
  position:fixed; inset:0; max-width:640px; margin:auto;
  display:flex; flex-direction:column; min-height:0; color:#f0e5cd;
  background:radial-gradient(ellipse at 50% 10%,#403222,#201a16 65%,#151211);
}
.world-header { display:flex; align-items:center; justify-content:space-between; gap:1rem;
  padding:calc(env(safe-area-inset-top) + .7rem) 1rem .7rem; border-bottom:1px solid #806c47; }
.world-header > div { display:flex; flex-direction:column; gap:.25rem; }
#worldMoney { color:#efcc80; }
#worldContent { overflow:auto; flex:1; padding:.75rem 1rem 1rem; outline:none; }
#worldContent h1 { font-size:1.45rem; margin:.35rem 0 1rem; }
#worldContent h2 { font-size:1.05rem; }
#worldContent section { border:1px solid #6d5c3d; background:#251d16; border-radius:6px; padding:.75rem; margin:.75rem 0; }
#worldContent p { line-height:1.65; margin:.7rem 0; }
#worldMenu button { min-height:44px; }
#worldMenu select, .world-search input { min-height:42px; font:inherit; }
#worldMenu [aria-pressed="true"] { border-color:#edc77b; background:#513c27; }
#worldNotice { margin:0; padding-inline:1rem; color:#ffd991; }
#worldNotice:not(:empty) { padding-block:.5rem; }
#worldTabs { display:grid; grid-template-columns:repeat(4,1fr); gap:.3rem; padding:.45rem .55rem calc(.45rem + env(safe-area-inset-bottom));
  background:#211a14; border-top:1px solid #806c47; }
#worldTabs button { color:#f0e5cd; font:inherit; background:#30251b; border:1px solid #66512f; border-radius:4px; }
.world-chart { position:relative; min-height:195px; border:1px solid #a88c52; border-radius:7px;
  background:radial-gradient(ellipse at 76% 15%,#69513566,#251b11b0),url('assets/ui-dialogue_paper.png') center/cover; margin-bottom:1rem; }
.world-pin { position:absolute; left:var(--x); top:var(--y); transform:translate(-50%,-50%); }
.world-list { display:grid; gap:.5rem; }
.world-list article { display:flex; gap:.55rem; justify-content:space-between; align-items:center; padding:.4rem .55rem;
  border-bottom:1px solid #665237; background:#2b2118; }
.world-list article > div { flex:1; min-width:0; }
.world-list small { display:block; margin:.25rem 0; color:#d2bd99; overflow-wrap:anywhere; }
.world-thumb { width:42px; height:54px; object-fit:contain; background:#211a14; border:1px solid #8a7148; border-radius:4px; }
.world-search { display:grid; gap:.4rem; margin:.7rem 0; }
