:root {
  --bg: #1b1712;
  --panel: #2a241c;
  --panel-2: #352d22;
  --ink: #efe6d2;
  --muted: #a8997c;
  --gold: #d9a441;
  --red: #c4483a;
  --blue: #4f8cc9;
  --card: #f1e5c8;
  --card-ink: #2a2015;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: linear-gradient(rgba(15, 12, 9, 0.38), rgba(15, 12, 9, 0.78)),
    url('/img/backgrounds/kingdom/castle-road.webp') center / cover no-repeat;
  background-color: var(--bg);
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--gold);
  background: var(--panel-2);
  color: var(--ink);
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 8px;
  touch-action: manipulation;
}
button:disabled { opacity: 0.4; cursor: default; }
button:not(:disabled):active { background: var(--gold); color: var(--card-ink); }
button.danger { border-color: var(--red); background: var(--red); color: var(--ink); }
button.secondary { border-color: #6b5636; background: transparent; color: var(--muted); }
button.secondary:not(:disabled):active { background: var(--red); border-color: var(--red); color: var(--ink); }

#status-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 6px 12px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}
#status-bar:has(#status:empty) { display: none; }
body:has(#status:empty) #board { min-height: 100dvh; }

#board {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 1100px;
  min-height: calc(100dvh - 28px);
  margin: 0 auto;
  padding: 0 12px 16px;
  position: relative;
}

.side { display: flex; flex-direction: column; gap: 8px; }
#battlefield {
  --img-w: max(100vw, 1950px);
  --img-h: calc(var(--img-w) * 719 / 2000);
  --wall: 0.561;
  --sink: 14px;
  --img-top: calc(120px - var(--sink) - var(--wall) * var(--img-h));
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  gap: 8px;
  margin-inline: calc(50% - 50vw);
  padding: 40px calc(50vw - 50%) 12px;
  background:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
    linear-gradient(#080808, transparent) no-repeat center top var(--img-top) / 100% 160px,
    #080808 var(--battle-bg, url('/img/ui/dungeon.png')) no-repeat center top var(--img-top) / var(--img-w) auto;
}
#controls { padding-bottom: 52px; display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
#controls .actions { display: flex; gap: 8px; margin-left: auto; }

.pile-row {
  display: flex;
  align-items: center;
  gap: 8px 12px;
  flex-wrap: wrap;
}
.label { font-weight: bold; color: var(--gold); }
.piles { color: var(--muted); font-size: 12px; }
.piles .pile {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--gold);
  font-size: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
#pile-viewer .modal { width: min(100%, 720px); }
#pile-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px 10px; padding-top: 10px; overflow-y: auto; }
#pile-cards .card { cursor: default; }
.pile-empty { color: var(--muted); }
.piles .pile:not(:disabled):hover, .piles .pile:not(:disabled):active { background: none; color: var(--ink); }
.energy { display: inline-flex; gap: 4px; }
.pip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--gold);
}
.pip.full { background: var(--gold); box-shadow: 0 0 6px var(--gold); }


.champions {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding-bottom: 50px;
}
.champion .plate {
  position: absolute;
  top: 100%;
  left: 6px;
  right: 6px;
  padding-top: 4px;
}

.champion {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: 180px;
  padding: 8px 6px 0;
  border-radius: 10px;
  border: 2px solid transparent;
  text-align: center;
  transition: transform 0.15s, border-color 0.15s, opacity 0.3s;
  touch-action: manipulation;
}
.champion .figure {
  position: relative;
  height: 70px;
  aspect-ratio: 512 / 509;
  margin: 0 auto;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.5));
}
.champion .figure::before {
  content: '';
  position: absolute;
  inset: auto 8% -5px;
  height: 14px;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.75), transparent);
}
.champion .figure.enemy { scale: -1 1; }
.champion .sprite {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 100%;
  animation: idle 2.4s ease-in-out var(--idle-delay, 0s) infinite;
}
.champion .pose {
  position: absolute;
  bottom: 0;
  opacity: 0;
}
.champion .pose.attack { left: -5%; height: 100%; }
.champion .pose.cast { left: 3%; height: 135.4%; }
.champion .pose.hurt { left: -5%; height: 110.8%; }
.champion .pose.idle-pose { left: 0; height: 100%; }
.champion.dead .sprite { animation: none; }
@keyframes idle {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  50% { transform: translateY(-1px) scale(0.99, 1.03); }
}

.champion[class*='act-'] { z-index: 2; }
.champion[class*='act-'] .sprite { animation: hide-while-acting 0.6s steps(1); }
.champion.act-attack .figure { animation: lunge 0.6s ease-in-out; }
.champion.act-attack .pose.attack { animation: show-while-acting 0.6s steps(1); }
.champion.act-cast .figure { animation: rally 0.6s ease-in-out; }
.champion.act-cast .pose.cast { animation: show-while-acting 0.6s steps(1); }
@keyframes lunge {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateX(-8px); }
  45%, 75% { transform: translateX(28px); }
}
@keyframes rally {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(0.96, 0.92); }
  45%, 75% { transform: scale(1.06); }
}
@keyframes hide-while-acting {
  0%, 85% { opacity: 1; }
  40% { opacity: 0; }
}
@keyframes show-while-acting {
  0%, 85% { opacity: 0; }
  40% { opacity: 1; }
}

.champion.hit .figure { animation: knockback 0.5s ease-out; }
.champion.hit .sprite { animation: hide-while-hurt 0.5s steps(1); }
.champion.hit .pose.hurt { animation: show-hurt 0.5s steps(1), flash 0.5s ease-out; }
@keyframes knockback {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-16px) rotate(-4deg); }
  60% { transform: translateX(-10px); }
}
@keyframes hide-while-hurt {
  0% { opacity: 0; }
  70% { opacity: 1; }
}
@keyframes show-hurt {
  0% { opacity: 1; }
  70% { opacity: 0; }
}
@keyframes flash {
  0% { filter: brightness(2) sepia(1) saturate(6) hue-rotate(-20deg); }
  40% { filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  .champion .sprite, .champion .figure { animation: none !important; }
}
.champion .name {
  font-size: 12px;
  margin-bottom: 6px;
  text-shadow: 0 1px 3px black;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hp-bar {
  position: relative;
  height: 16px;
  background: #3a2020;
  border-radius: 4px;
  overflow: hidden;
}
.hp-fill { height: 100%; background: var(--red); transition: width 0.3s; }
.hp-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: bold;
  line-height: 1;
  color: white;
  text-shadow: 0 1px 2px black;
}
.block {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--blue);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: bold;
}
.intent {
  position: absolute;
  top: -24px;
  left: 50%;
  translate: -50% 0;
  z-index: 2;
  padding: 2px 8px;
  border: 1px solid #b33a3a;
  border-radius: 10px;
  background: rgba(20, 14, 10, 0.85);
  color: white;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
}
.statuses {
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
}
.status {
  padding: 1px 6px;
  border: 1px solid #555;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
  text-shadow: 0 1px 2px black;
}
.bleed {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px 1px 5px;
  border: 1px solid #7a2a22;
  border-radius: 9px;
  background: #2a1714;
  font-size: 12px;
  z-index: 1;
  font-weight: bold;
  color: #ff8a7a;
  text-shadow: 0 1px 2px black;
}
.bleed::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #d8352a;
  box-shadow: 0 0 4px #ff4a3a;
}
.champion.dead { opacity: 0.35; filter: grayscale(1); }
.champion.caster {
  --champion-glow: 255, 244, 205;
}
.champion .figure::after {
  content: '';
  position: absolute;
  inset: -20% -30% -12%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(closest-side,
    rgba(var(--champion-glow, 255, 200, 80), 0.85),
    rgba(var(--champion-glow, 255, 200, 80), 0.45) 55%, transparent);
  opacity: 0;
  transition: opacity 150ms ease;
}
.champion:is(.caster, .targetable) .figure::after { opacity: 1; }
.champion.caster::before {
  content: 'Juega';
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--card-ink);
  font-size: 11px;
  font-weight: bold;
  z-index: 1;
}
.champion.targetable { cursor: pointer; }
.champion.targetable:hover .figure::after { opacity: 1; filter: brightness(1.25); }

.card .range { display: flex; justify-content: center; gap: 6px; }
.card .dots { display: flex; gap: 2px; }
.card .dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid #8a6a3a;
}
.card .dots.from i.on { background: #8a6a3a; }
.card .dots.enemy i.on { background: var(--red); border-color: var(--red); }
.card .dots.ally i.on { background: var(--blue); border-color: var(--blue); }
.card .dots.all { padding: 1px 2px; border-radius: 6px; background: rgba(196, 72, 58, 0.25); }
.champion.caster.targetable { --champion-glow: 255, 225, 140; }

.float {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  font-size: 22px;
  font-weight: bold;
  white-space: nowrap;
  pointer-events: none;
  animation: rise 1s forwards;
  text-shadow: 0 2px 4px black;
}
.float.damage { color: #ff6b5b; }
.float.heal { color: #8fe08a; }
.float.block { color: #8cc0f2; }
@keyframes rise {
  from { opacity: 1; margin-top: 0; }
  to { opacity: 0; margin-top: -40px; }
}

#turn-banner {
  position: absolute;
  inset: 8px 0 auto;
  z-index: 1;
  font-size: 20px;
  text-align: center;
  color: var(--gold);
  text-shadow: 0 2px 4px black;
  pointer-events: none;
}

#hand {
  display: flex;
  justify-content: safe center;
  gap: 8px;
  padding: 16px 4px 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
}

.card {
  position: relative;
  flex: 0 0 auto;
  width: 150px;
  height: 225px;
  padding: 10px 11px 12px;
  border-radius: 8px;
  background: url('/img/ui/card-frame.png') center / 100% 100% no-repeat;
  color: var(--card-ink);
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-snap-align: center;
  touch-action: manipulation;
  user-select: none;
  container-type: inline-size;
}
.card .cost {
  position: absolute;
  top: 1%;
  left: 1%;
  width: 22%;
  height: auto;
  aspect-ratio: 1;
  background: url('/img/ui/card-cost-v2.png') center / contain no-repeat;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(14px, 12cqw, 25px);
  line-height: 1;
  color: #100c06;
  z-index: 2;
}
.card:has(.card-class--warrior) { background-image: url('/img/ui/card-frame-warrior-v2.png'); }
.card:has(.card-class--cleric) { background-image: url('/img/ui/card-frame-cleric-v2.png'); }
.card:has(.card-class--mage) { background-image: url('/img/ui/card-frame-mage-v2.png'); }
.card:has(.card-class--bard) { background-image: url('/img/ui/card-frame-bard-v2.png'); }
.card:has(.card-class--assassin) { background-image: url('/img/ui/card-frame-assassin-v2.png'); }
.card .card-class { position: absolute; top: 20%; right: 11%; z-index: 1; max-width: 75%; padding: 2px 4px; border-radius: 2px; background: #211b15e8; color: #f4e5c7; font-size: clamp(8px, 5cqw, 10px); line-height: 1.1; }
.card .card-class--cleric { background: #eee2c6; color: #46361c; }
.card .card-class--mage { background: #3b254b; }
.card .card-class--bard { background: #263721; }
.card .card-class--assassin { background: #2b222d; }
/* Card composition: parchment title, illustration, stats, rules. */
.card .title {
  position: absolute;
  top: 7%; left: 10%; right: 10%; height: 8%;
  margin: 0;
  display: grid; place-items: center;
  font-weight: bold;
  font-size: min(var(--title-size, 13px), 95cqw / var(--len));
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.card .card-art {
  position: absolute;
  top: 18%; left: 9%; right: 9%; height: 44%;
  overflow: hidden;
  background: #201b16;
  border: 1px solid #5a4832;
  box-shadow: inset 0 2px 8px #0009;
}
.card-art img { width: 100%; height: 100%; object-fit: cover; }
.card .card-effects {
  position: absolute;
  top: 57%; left: 5%; right: 5%; min-height: 13%;
  display: flex; align-items: center; justify-content: space-between; gap: 2px;
  z-index: 1;
}
.card-effect {
  position: relative;
  display: inline-flex; align-items: center; gap: 1px;
  width: 47%;
  min-width: 0;
  min-height: 24cqw;
  justify-content: center;
  padding: 3px 4px;
  background: url('/img/ui/card-stat-frame.png') center / 100% 100% no-repeat;
  color: #f4e5c7;
  line-height: 1;
}
.card-effect.block { margin-left: auto; }
.card-effect img { width: 19cqw; height: 19cqw; max-width: 38px; max-height: 38px; object-fit: contain; flex-shrink: 0; }
.card-effect b { font-size: clamp(17px, 15cqw, 30px); font-weight: 900; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px #000; }
.card-effect small { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); padding: 1px 2px; background: #45171e; color: #fff; font-size: 7px; }
.card .card-description {
  position: absolute;
  top: 70%; left: 10%; right: 10%; bottom: 9%;
  display: flex; flex-direction: column; justify-content: center; gap: 3px;
}
.card .text { font-size: clamp(9px, 5.5cqw, 12px); text-align: center; line-height: 1.15; }
.card .keywords { font-size: 10px; font-weight: bold; text-align: center; color: #7a4a14; }
.keyword-tip {
  position: fixed;
  z-index: 1000;
  max-width: 200px;
  padding: 8px 10px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: rgba(20, 16, 12, 0.95);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.3;
  display: grid;
  gap: 6px;
  pointer-events: none;
}
.keyword-tip b { color: var(--gold); }
.keyword-tip[hidden] { display: none; }
.card .owner { position: absolute; bottom: 5%; left: 10%; right: 10%; font-size: 10px; color: #7a6a50; text-align: center; }
.card.selected { transform: translateY(-10px); filter: drop-shadow(0 0 8px var(--gold)); }
.card.unplayable { opacity: 0.5; cursor: default; }

#log {
  list-style: none;
  margin: 0;
  padding: 8px 12px;
  max-height: 120px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
}
#log li:last-child { color: var(--ink); }

#overlay {
  position: fixed;
  inset: 0;
  padding: 16px;
  display: grid;
  place-items: center;
}
#overlay[hidden], #feedback[hidden], #pile-viewer[hidden], #board[hidden], #toast[hidden], #login[hidden], #roster[hidden], #barracks[hidden], #tavern[hidden], #locked[hidden], #tip[hidden], #building[hidden], #lobby[hidden], #kingdom[hidden], #mission[hidden], #missions[hidden], #player-body[hidden], #arena-button[hidden] { display: none; }
.dialog {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}

#toast {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  z-index: 450;
  background: var(--red);
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  text-align: center;
}
#toast.ok { background: #4a8a4f; }

@media (hover: hover) {
  button:not(:disabled):hover { background: var(--gold); color: var(--card-ink); }
  button.secondary:not(:disabled):hover { background: var(--red); border-color: var(--red); color: var(--ink); }
  .champion.targetable:hover { transform: translateY(-4px); }
  .card.playable:hover { transform: translateY(-10px); filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.5)); }
}

#lobby {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - 40px);
  padding: 16px;
}
#lobby h2 { margin-top: 0; color: var(--gold); }
#lobby p { color: var(--muted); }
#lobby a { color: var(--gold); }
#login {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - 40px);
  padding: 16px;
}
#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-form input {
  font: inherit;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #4a3f30;
  background: var(--bg);
  color: var(--ink);
}
#login-form .actions { display: flex; gap: 8px; }
#login-form .actions button { flex: 1; }
.error { color: var(--red); min-height: 1.2em; margin: 0; font-size: 14px; }

#kingdom {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr clamp(340px, 26vw, 420px);
}
#kingdom-view {
  position: relative;
  overflow: hidden;
  container: kingdom / size;
  background: linear-gradient(rgba(15, 12, 9, 0.4), rgba(15, 12, 9, 0.7)),
    url('/img/backgrounds/kingdom/castle-road.webp') center / cover no-repeat;
}
#barracks-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: calc(16px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) 12px;
  border-left: 2px solid var(--gold);
  background: var(--panel);
}
#barracks-main .portrait-frame { width: 72px; height: 72px; }
#barracks-list .name { padding-right: 24px; }
@media (max-width: 800px) {
  #kingdom { grid-template-columns: 1fr; grid-template-rows: 1fr 42dvh; }
  #barracks-main { border-left: none; border-top: 2px solid var(--gold); padding-top: 12px; }
}
#kingdom-ribbon {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  left: calc(16px + env(safe-area-inset-left));
  z-index: 150;
  max-width: calc(100% - 32px);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
}
.ribbon {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 30px;
  background: linear-gradient(#f6ecd2, var(--card) 45%, #d8c69c);
  color: var(--card-ink);
  clip-path: polygon(0 0, 100% 0, calc(100% - 16px) 50%, 100% 100%, 0 100%, 16px 50%);
}
.ribbon h2 { margin: 0; font-size: 22px; white-space: nowrap; }
#kingdom-name {
  min-height: 0;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font-weight: inherit;
  cursor: text;
}
#kingdom-name:not(:disabled):hover, #kingdom-name:not(:disabled):active { background: none; color: inherit; text-decoration: underline dotted; }
.name-input {
  max-width: 100%;
  padding: 0 6px;
  border: 1px solid #a88a55;
  border-radius: 4px;
  background: #fffaf0;
  color: var(--card-ink);
  font: inherit;
}
.editable { cursor: text; }
.editable:hover { text-decoration: underline dotted; }
#kingdom-user { color: #7a6544; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#kingdom-logout {
  min-height: 0;
  padding: 0 2px;
  border: none;
  background: none;
  color: var(--red);
  font-size: 20px;
  font-weight: bold;
  line-height: 1;
}
#kingdom-logout:not(:disabled):hover, #kingdom-logout:not(:disabled):active { background: none; color: #8f2a1f; }
.admin-page main { width: min(100% - 32px, 960px); margin: 0 auto; padding: 24px 0 48px; display: flex; flex-direction: column; gap: 16px; }
.admin-head { display: flex; align-items: baseline; gap: 12px; }
.admin-cards-page .admin-head { flex-wrap: wrap; }
.admin-card-tools { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.admin-card-tools label { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.admin-card-tools input { width: 100%; min-width: 0; }
.admin-card-tools select { width: 100%; min-width: 0; min-height: 44px; padding: 8px 12px; border: 1px solid #6b5636; border-radius: 6px; background: var(--panel); color: var(--ink); font: inherit; }
.admin-card-tools label { min-width: min(100%, 200px); }
.admin-card-catalog { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 28px 16px; }
.admin-card-entry { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.admin-card-entry .card { width: 210px; height: 315px; padding: 18px; cursor: default; }

.admin-card-entry .card .title { --title-size: 17px; }
.admin-card-entry .card:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.admin-card-entry code { overflow-wrap: anywhere; color: var(--gold); }
.admin-head h1 { margin: 0; color: var(--gold); }
.admin-head #admin-refresh { margin-left: auto; min-height: 36px; padding: 4px 12px; }
.admin-page a { color: var(--gold); }
#admin-hint { margin: 0; color: var(--muted); }
.admin-page h2 { margin: 8px 0 0; color: var(--gold); font-size: 18px; }
#player-body { display: flex; flex-direction: column; gap: 12px; }
#player-flags { margin: 0; padding-left: 20px; font-family: monospace; display: flex; flex-direction: column; gap: 4px; }
#player-flags li { display: flex; align-items: center; gap: 8px; }
.flag-remove { min-height: 0; padding: 0 6px; font-size: 12px; line-height: 20px; }
#player-flag-form { display: flex; gap: 8px; }
#player-flag-input { flex: 0 1 240px; padding: 6px 8px; font-family: monospace; }
#player-error:empty { display: none; }
.wins-input { width: 64px; padding: 2px 4px; text-align: right; }
#player-no-flags, #player-no-runs { margin: 0; color: var(--muted); }
#player-runs { display: flex; flex-direction: column; gap: 12px; }
.player-run { padding: 12px; border: 1px solid rgba(107, 86, 54, 0.6); border-radius: 10px; }
.player-run h3 { margin: 0 0 8px; font-size: 16px; }
.player-run ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.player-run p { margin: 2px 0 0; }
.player-run .run-log { color: var(--muted); font-size: 14px; }
.mission-status { padding: 2px 8px; border-radius: 8px; font-size: 13px; border: 1px solid var(--muted); }
.mission-status.cumplida { border-color: var(--gold); color: var(--gold); }
.mission-status.en-curso { border-color: #5fbf5f; color: #5fbf5f; }
.mission-status.bloqueada { opacity: 0.6; }
.admin-table { min-width: 0; overflow: auto; }
.admin-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { color: var(--muted); font-weight: normal; text-align: left; white-space: nowrap; padding: 6px 8px; border-bottom: 1px solid #6b5636; }
.admin-table td { padding: 8px; border-bottom: 1px solid rgba(107, 86, 54, 0.4); white-space: nowrap; }
.admin-table .num, .admin-table th.num { text-align: right; }
.role { margin-left: 4px; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: bold; color: var(--card-ink); background: var(--gold); }
.role.special { background: #9b6bd6; color: var(--ink); }
.presence::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #6b6152; }
.presence.online::before { background: #5fbf5f; }
.presence.match::before { background: var(--gold); }
.presence.offline { color: var(--muted); }
#kingdom-map {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100cqw, calc(100cqh * 1672 / 940));
  aspect-ratio: 1672 / 940;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at 50% 60%, #6f9a4c, #4f7a3a 55%, #2f4f26) center / cover;
}
@container kingdom (max-aspect-ratio: 1/1) {
  #kingdom-map { width: 100cqw; }
}
.building {
  position: absolute;
  transform: translate(-50%, -70%);
  min-height: 0;
  padding: 0;
  border: none;
  background: none;
}
.building:not(:disabled):hover, .building:not(:disabled):active { background: none; color: inherit; }
.building { pointer-events: none; }
.building-hit {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: auto;
  clip-path: polygon(50% 100%, 2% 76%, 8% 30%, 50% 8%, 92% 30%, 98% 76%);
}
.building img, .building-silhouette {
  display: block;
  width: 100%;
  position: relative;
}
.building-silhouette {
  aspect-ratio: 1;
  background: var(--panel-2);
  clip-path: polygon(50% 8%, 90% 45%, 80% 45%, 80% 92%, 20% 92%, 20% 45%, 10% 45%);
}
.building::before {
  content: '';
  position: absolute;
  inset: -15% -15% -5%;
  background: radial-gradient(closest-side, rgba(255, 225, 140, 1), rgba(255, 200, 80, 0.7) 55%, transparent);
  opacity: 0;
  transition: opacity 150ms ease;
}
.building:hover::before, .building:focus-visible::before { opacity: 1; }
.building-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translate(-50%, -40%);
  padding: 2px 10px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: rgba(27, 23, 18, 0.85);
  font-size: clamp(12px, 1.2vw, 16px);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}
.building:hover .building-label, .building:focus-visible .building-label { opacity: 1; }
#arena-button {
  position: absolute;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 100;
  width: clamp(64px, 9cqw, 128px);
  min-height: 0;
  padding: 0;
  border: none;
  background: none;
  transition: transform 150ms ease, filter 150ms ease;
}
#arena-button img { display: block; width: 100%; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6)); }
#arena-button:not(:disabled):hover, #arena-button:not(:disabled):active { background: none; color: var(--ink); }
#arena-button:hover, #arena-button:focus-visible { transform: scale(1.08); filter: brightness(1.15); }
#arena-button:hover .building-label, #arena-button:focus-visible .building-label { opacity: 1; }
#arena-button .building-label { top: auto; bottom: 100%; transform: translate(-50%, -4px); }

#roster, #barracks, #tavern, #locked, #tip, #building, #missions, #pile-viewer, #feedback {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal {
  width: min(100%, 520px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 2px solid var(--gold);
  border-radius: 12px;
  background: var(--panel);
}
#tavern {
  background: linear-gradient(rgba(15, 10, 6, 0.25), rgba(15, 10, 6, 0.65)),
    var(--bg) url('/img/backgrounds/interiors/tavern.webp') center / cover no-repeat;
}
#missions {
  background: linear-gradient(rgba(9, 16, 12, 0.35), rgba(9, 16, 12, 0.7)),
    var(--bg) url('/img/backgrounds/missions/forest-trail.webp') center / cover no-repeat;
}
.roster-head { display: flex; align-items: center; gap: 12px; }
.roster-head h2 { margin: 0; color: var(--gold); }
#roster-hint, #barracks-hint, #tavern-hint, #locked-hint, #missions-hint, #pile-hint { margin: 0; color: var(--muted); }
#roster-notice:empty, #barracks-notice:empty, #tavern-notice:empty, #missions-notice:empty { display: none; }
#roster-list, #barracks-list, #tavern-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.recruit {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  min-height: 0;
  padding: 0 12px 0 0;
  border: 2px solid #4a3f30;
  border-radius: 10px;
  background: var(--panel-2);
  text-align: left;
  overflow: hidden;
}
.recruit:not(:disabled):hover, .recruit:not(:disabled):active { background: var(--panel-2); color: var(--ink); border-color: var(--muted); }
.recruit .portrait { position: relative; flex-shrink: 0; }
.recruit .portrait-frame {
  display: block;
  width: 88px;
  height: 88px;
  overflow: hidden;
  background: var(--bg);
}
.recruit .portrait-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.recruit .portrait-img.zoomed {
  object-fit: cover;
  object-position: 50% 0;
  transform: scale(2.2);
  transform-origin: 50% 8%;
}
.gear {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap-reverse;
  gap: 2px;
}
.gear-item {
  width: 20px;
  height: 20px;
  padding: 1px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 3px;
  background: rgba(20, 16, 12, 0.85);
  cursor: help;
}
.gear-item .item-icon.fallback { font-size: 12px; }
.card-tip {
  position: fixed;
  z-index: 1000;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  overflow: hidden;
  gap: 10px;
  padding: 8px;
  pointer-events: none;
}
.card-tip[hidden] { display: none; }
.card-tip .card { width: min(170px, calc((100vw - 42px) / 2), calc((100dvh - 32px) * 2 / 3)); height: auto; aspect-ratio: 2 / 3; padding: 14px 14px 15px; cursor: default; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.7)); }
.card-tip .card .title { --title-size: 13px; }

.champion > .gear { left: auto; right: 4px; top: 4px; bottom: auto; flex-direction: column; }
.recruit .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.recruit .name { font-size: 16px; }
.recruit .stamina { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.recruit .pips { display: flex; gap: 3px; }
.recruit .pips i { width: 10px; height: 10px; border-radius: 2px; border: 1px solid var(--gold); }
.recruit .pips i.on { background: var(--gold); }
.recruit .stats { font-size: 13px; color: var(--muted); }
.recruit.selected, .recruit.selected:not(:disabled):hover { border-color: var(--gold); box-shadow: 0 0 10px var(--gold); }
.recruit.ko { filter: grayscale(1); opacity: 0.6; }
.recruit .ko-label { font-size: 12px; color: var(--red); }
.recruit { position: relative; }
.recruit .slot:empty { display: none; }
.recruit .slot {
  position: absolute;
  z-index: 3;
  top: 6px;
  left: 6px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: var(--card-ink);
  font-size: 13px;
  font-weight: bold;
}
#play { flex-shrink: 0; }
#locked .modal { width: min(100%, 360px); text-align: center; }
.building-upgrade { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 8px; }
.building-level { font-weight: bold; color: var(--gold); }
.building-requirements { flex: 1; opacity: 0.8; }
.locked-message { margin: 8px 0 0; color: var(--red); font-size: 20px; font-weight: bold; }
.recruit .hire { align-self: center; flex-shrink: 0; min-height: 36px; padding: 4px 12px; }
.recruit .dismiss {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  width: 28px;
  height: 28px;
  min-height: 0;
  padding: 4px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
}
.recruit .dismiss svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.recruit .dismiss:not(:disabled):hover, .recruit .dismiss:not(:disabled):active, .recruit .dismiss:focus-visible { background: var(--red); color: var(--ink); }
.recruit.selectable { cursor: pointer; }
.recruit.selectable:hover, .recruit.selectable:focus-visible { border-color: var(--gold); }
#barracks-detail { overflow-y: auto; }
.recruit.selectable.selected { border-color: var(--gold); box-shadow: 0 0 10px var(--gold); }
#barracks-champion { flex-shrink: 0; }
.slot-line { display: grid; grid-template-columns: 7.5em auto; align-items: center; justify-content: center; gap: 12px; }
.slot-title { margin: 0; color: var(--gold); font-size: 16px; }
.slot-row { display: grid; grid-template-columns: repeat(4, 64px); justify-content: center; gap: 12px; padding: 12px 4px 24px; }
.ability-cell.filled { cursor: help; }
.ability-cell.locked { border-style: dashed; }
.ability-level {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 10px;
  background: var(--gold);
  color: var(--card-ink);
  font-size: 12px;
  font-weight: bold;
  line-height: 20px;
  text-align: center;
}
.inventory { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.inventory h3 { align-self: stretch; margin: 4px 0 0; color: var(--gold); font-size: 16px; }
.inv-cell {
  position: relative;
  z-index: 1;
  width: 64px;
  height: 64px;
  min-height: 0;
  padding: 4px;
  display: grid;
  place-items: center;
  justify-self: center;
  border: 2px solid #6b5636;
  border-radius: 6px;
  background: linear-gradient(145deg, #2b241b, #16120d);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 220, 150, 0.12);
}
.inv-cell.filled { border-color: var(--gold); }
.inv-cell:not(:disabled):not([aria-disabled]):hover, .inv-cell:focus-visible {
  border-color: #ffd98a;
  background: linear-gradient(145deg, #3a3024, #1d1812);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.6), 0 0 10px rgba(255, 200, 80, 0.5);
}
.inv-cell:disabled, .inv-cell[aria-disabled] { opacity: 1; cursor: default; }
.item-icon { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7)); }
.item-icon.fallback, .item-icon.ghost { display: grid; place-items: center; font-size: 30px; line-height: 1; }
.item-icon.fallback { filter: grayscale(1) sepia(0.7) brightness(0.9) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7)); }
.item-icon.ghost { opacity: 0.25; filter: grayscale(1); }
.cell-label {
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.bag { display: grid; grid-template-columns: repeat(6, 64px); gap: 6px; }
@media (max-width: 480px) {
  .bag { grid-template-columns: repeat(4, 64px); }
  .slot-line { grid-template-columns: auto; gap: 4px; }
}

@media (min-width: 720px) {
  #status-bar { font-size: 14px; padding: 8px 16px; }
  #board { gap: 12px; padding: 0 16px 16px; min-height: calc(100dvh - 36px); }
  .piles { font-size: 14px; }
  .pip { width: 16px; height: 16px; }
  #battlefield {
    --ground: 72px;
    flex-direction: row;
    align-items: flex-end;
    gap: 24px;
    padding-top: 56px;
    padding-bottom: var(--ground);
    --img-bottom: calc(var(--ground) + var(--sink) - (1 - var(--wall)) * var(--img-h));
    background-position: center, center bottom calc(var(--img-bottom) + var(--img-h) - 160px), center bottom var(--img-bottom);
  }
  .side { flex: 1; min-width: 0; }
  .side.enemy .pile-row { justify-content: flex-end; }
  #your-champions { flex-direction: row-reverse; }
  .champions { gap: 8px; margin-top: 8px; padding-bottom: 0; }
  .champion { flex: 0 1 120px; padding: 8px 6px 0; }
  .champion .figure { height: 90px; }
  .champion .name { font-size: 14px; }
  .hp-bar { height: 18px; }
  .hp-text { font-size: 12px; }
  #turn-banner { font-size: 28px; }
  #hand { gap: 10px; padding-top: 20px; }
  .card { width: 160px; height: 240px; padding: 14px 14px 15px; }
  .card .title { --title-size: 13px; }

  .card .owner { font-size: 11px; }
  .card.selected { transform: translateY(-16px); }
  #log { max-height: 140px; font-size: 13px; }
}
#version {
  position: fixed;
  right: calc(8px + env(safe-area-inset-right));
  bottom: calc(4px + env(safe-area-inset-bottom));
  z-index: 300;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
  pointer-events: none;
}
.ticket-form { display: flex; flex-direction: column; gap: 10px; }
.ticket-field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 14px; }
.ticket-form input, .ticket-form select, .ticket-form textarea, .tickets-filters select, .ticket-status-select {
  font: inherit;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid #6b5636;
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 40px;
}
.ticket-form textarea { resize: vertical; }
.ticket-form button[type="submit"] { align-self: flex-end; }

.tickets-page main { width: min(100% - 32px, 760px); margin: 0 auto; padding: 24px 0 48px; display: flex; flex-direction: column; gap: 16px; }
.tickets-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tickets-head h1 { margin: 0; color: var(--gold); }
.tickets-page a { color: var(--gold); }
#tickets-new { padding: 16px; border: 2px solid var(--gold); border-radius: 12px; background: var(--panel); }
#tickets-new h2 { margin: 0 0 12px; font-size: 18px; }
.tickets-login { margin: 0; }
.tickets-filters { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); }
.tickets-filters label { display: flex; align-items: center; gap: 6px; }
#tickets-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ticket { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid #6b5636; border-radius: 10px; background: var(--panel); }
.ticket > button { align-self: flex-start; }
.ticket-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ticket-title { margin: 0; font-size: 17px; flex: 1 1 200px; overflow-wrap: anywhere; }
.ticket-type, .ticket-status { padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: bold; }
.ticket-type { color: var(--card-ink); background: var(--card); }
.ticket-status { color: #fff; background: #6f665a; }
.ticket-status.status-analyzed { background: var(--blue); }
.ticket-status.status-in_progress { background: var(--gold); color: var(--card-ink); }
.ticket-status.status-done { background: #4a8a4f; }
.ticket-status.status-cancelled { background: #7a3a33; }
.ticket-meta { margin: 0; color: var(--muted); font-size: 13px; }
.ticket-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
#tickets-version { text-align: center; color: var(--muted); font-size: 12px; padding-bottom: 16px; }

#feedback { z-index: 400; }
#feedback .modal { width: min(100%, 560px); }
#feedback-all { align-self: flex-start; color: var(--gold); }
#feedback-button {
  position: fixed;
  left: calc(16px + env(safe-area-inset-left));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 350;
  min-height: 36px;
  padding: 4px 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

#kingdom-gold { color: #7a6544; white-space: nowrap; }

#missions .modal { width: min(100%, 900px); }
#missions-active:empty { display: none; }
#missions-active { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#missions-active p { margin: 0; }
#missions-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
#missions-browse, #missions-detail { min-height: 0; overflow-y: auto; }
#missions-list, #missions-done { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin-top: 8px; }
#missions-done-title { margin: 16px 0 0; }
.mission-tile { min-height: 56px; padding: 8px 12px; text-align: left; border: 1px solid var(--muted); border-radius: 10px; }
.mission-tile.selected { border-color: var(--gold); outline: 2px solid var(--gold); }
.mission-done { opacity: 0.7; border-style: dashed; }
#missions-detail { padding: 12px; border: 1px solid var(--muted); border-radius: 10px; }
#missions-detail:empty { display: none; }
#missions-detail h3 { margin: 0 0 8px; }
#missions-detail p { margin: 0 0 12px; white-space: pre-line; }
.mission-where { color: var(--muted); font-style: italic; }
@media (max-width: 640px) {
  #missions-body { grid-template-columns: 1fr; overflow-y: auto; }
  #missions-browse, #missions-detail { overflow-y: visible; }
}

#mission {
  --accent: var(--gold);
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.6)),
    var(--bg) url('/img/backgrounds/missions/forest-trail.webp') center / cover no-repeat;
}
.mission-head, .mission-foot { background: rgba(0, 0, 0, 0.55); }
.mission-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 2px solid var(--accent); }
.mission-heading { flex: 1; min-width: 0; text-align: center; }
#mission-title { margin: 0; color: var(--accent); }
#mission-step, #mission-bag { margin: 0; color: var(--muted); }
#mission button { border-color: var(--accent); }
#mission button.secondary { border-color: var(--accent); }
#mission button:not(:disabled):active { background: var(--accent); }
#mission button.secondary:not(:disabled):active { background: var(--red); }
#mission-home, #mission-mute { min-height: 36px; padding: 4px 12px; }
#mission-stage { display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.mission-panel { width: min(100%, 560px); padding: 20px; display: flex; flex-direction: column; gap: 12px; border: 2px solid var(--accent); border-radius: 12px; background: rgba(26, 21, 15, 0.88); }
.mission-panel h3 { margin: 0; color: var(--accent); }
.mission-panel p { margin: 0; white-space: pre-line; }
.mission-panel p:empty { display: none; }
.mission-panel--illustrated {
  width: min(100%, 980px);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 32px);
  align-items: start;
}
.mission-story-content { display: flex; flex-direction: column; gap: 16px; min-width: 0; line-height: 1.55; }
.mission-story-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
@media (max-width: 640px) {
  .mission-panel--illustrated { grid-template-columns: 1fr; }
  .mission-story-image { aspect-ratio: 16 / 9; object-position: center 35%; }
}
.mission-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.mission-options button { min-width: 140px; padding: 16px; font-size: 16px; }
.mission-choices { display: grid; gap: 8px; }
.mission-testimony { width: 100%; box-sizing: border-box; font: inherit; padding: 8px; resize: vertical; }
#mission-panel blockquote { margin: 8px 0; font-style: italic; }
.mission-log { margin: 0; padding-left: 20px; color: var(--muted); }
.mission-foot { display: flex; align-items: center; gap: 12px; padding: 10px 16px 18px 128px; border-top: 2px solid var(--accent); }
#mission-team { flex: 1; min-width: 0; display: flex; gap: 12px; overflow-x: auto; }
#mission-abandon { flex-shrink: 0; min-height: 36px; padding: 4px 16px; }
#mission-abandon[hidden] { display: block; visibility: hidden; }
.mission-champion { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.mission-champion.dead { opacity: 0.45; }
.mission-champion .portrait-frame { width: 44px; height: 44px; flex-shrink: 0; overflow: hidden; border-radius: 50%; }
.mission-champion .portrait-img { width: 100%; height: 100%; object-fit: cover; }
.mission-champion .hp { color: var(--muted); font-size: 14px; white-space: nowrap; }
@media (max-width: 640px) {
  .mission-head { flex-wrap: wrap; }
  .mission-heading { order: -1; flex-basis: 100%; }
  .mission-foot { flex-wrap: wrap; padding: 8px 16px 18px; }
  #mission-team { flex-basis: 100%; flex-wrap: wrap; overflow-x: visible; }
  #mission-abandon { margin-left: auto; }
  .mission-champion { flex-basis: calc(50% - 6px); min-width: 0; }
  .mission-champion .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (hover: hover) {
  #mission button:not(:disabled):hover { background: var(--accent); }
  #mission button.secondary:not(:disabled):hover { background: var(--red); }
}

#tip { z-index: 2000; }
.tip-never { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
