:root {
  color-scheme: dark;
  --bg: #151516;
  --panel: #222327;
  --panel-strong: #2e3036;
  --ink: #f5f0e8;
  --muted: #b8b2aa;
  --line: #454852;
  --accent: #e24b3b;
  --accent-2: #38a5ad;
  --gold: #e2b457;
  --danger: #ec5d64;
  --tile: #333843;
  --tile-active: #4a3d36;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, rgba(47,55,66,.42), rgba(21,21,22,.94)), var(--bg);
  color: var(--ink);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; }
.app-shell {
  width: min(100vw, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: rgba(19,20,22,.84);
}
.app-page {
  min-height: 0;
  overflow: auto;
}
.battle-page {
  display: block;
  position: relative;
  height: 100%;
  background: #b9dce9;
  color: #202226;
  overflow: hidden;
}
.battle-page .top-bar,
.battle-page .match-strip {
  display: none;
}
.battle-page .top-bar {
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
}
.battle-page .top-bar .leader,
.battle-page .top-bar .leader-metrics {
  display: none;
}
.battle-page .top-bar .back-button {
  display: none;
}
.home-page,
.menu-page {
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 14px;
}
.skyscraper-home {
  padding: 8px;
  gap: 8px;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background:
    radial-gradient(circle at 18% 20%, rgba(255,255,255,.55), transparent 18%),
    linear-gradient(180deg, #8ed2ee 0%, #c9eef9 42%, #a7d176 43%, #54964a 100%);
  color: #202226;
  overflow: hidden;
}
.skyscraper-home > .hub-header,
.skyscraper-home > .player-banner,
.skyscraper-home > .hub-actions,
.skyscraper-home > .home-grid {
  display: none;
}
.home-resource-strip {
  display: grid;
  grid-template-columns: .88fr 1fr 1fr;
  gap: 6px;
  position: relative;
  z-index: 3;
}
.home-resource-strip > div {
  min-height: 42px;
  padding: 5px;
  border: 1px solid #b9c7cf;
  border-radius: 4px;
  background: rgba(255,255,255,.95);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.22);
}
.home-resource-strip strong {
  min-width: 30px;
  min-height: 30px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: #d94f48;
  color: white;
  font-size: .72rem;
  font-weight: 900;
}
.home-resource-strip div:nth-child(2) strong {
  background: #20aeca;
}
.home-resource-strip div:nth-child(3) strong {
  background: #e0b94e;
  color: #5e4610;
}
.home-resource-strip span {
  min-width: 0;
  padding: 4px 7px;
  border-radius: 3px;
  background: #57585c;
  color: white;
  text-align: right;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-resource-strip button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 3px;
  background: #20b96d;
  color: white;
  font-size: 1.15rem;
  font-weight: 900;
}
.home-level span {
  text-align: left;
}
.home-tower-scene {
  position: relative;
  min-height: 0;
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 6px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.55), transparent 9%),
    radial-gradient(circle at 80% 28%, rgba(255,255,255,.42), transparent 12%),
    linear-gradient(180deg, rgba(94,167,208,.48), rgba(255,255,255,.2) 45%, rgba(66,122,59,.5));
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.2);
}
.home-settings {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: rgba(0,0,0,.45);
  color: white;
  font-weight: 900;
}
.home-logo {
  position: absolute;
  top: 18px;
  left: 16px;
  z-index: 4;
  display: grid;
  gap: 2px;
  color: white;
  text-shadow: 0 2px 3px rgba(0,0,0,.45);
}
.home-logo span {
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
}
.home-logo strong {
  font-size: 2.6rem;
  line-height: .94;
  color: #fff5d9;
}
.tower-core {
  position: absolute;
  left: 50%;
  bottom: -20px;
  width: min(50%, 250px);
  height: 84%;
  transform: translateX(-50%);
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  gap: 4px;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.34));
}
.tower-core span {
  border: 2px solid rgba(255,255,255,.85);
  background: linear-gradient(180deg, rgba(111,129,149,.9), rgba(79,91,109,.92));
  transform: skewX(-4deg);
}
.tower-core span:nth-child(2n) {
  margin: 0 12px;
}
.tower-core span:first-child {
  border-radius: 18px 18px 3px 3px;
  background: linear-gradient(180deg, #f3d86e, #6c7485);
}
.floor-card {
  position: absolute;
  left: 14px;
  bottom: 96px;
  z-index: 4;
  width: 150px;
  padding: 10px;
  border-radius: 4px;
  background: rgba(0,0,0,.66);
  color: white;
  box-shadow: 0 2px 7px rgba(0,0,0,.28);
}
.floor-card span,
.floor-card em {
  display: block;
  color: #dceff6;
  font-size: .72rem;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}
.floor-card strong {
  display: block;
  margin: 2px 0;
  color: #fff5d9;
  font-size: 1.45rem;
}
.home-battle-button {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 4;
  width: min(76%, 320px);
  min-height: 68px;
  transform: translateX(-50%);
  border: 0;
  border-radius: 6px;
  background: linear-gradient(180deg, #ff9c20, #ef6b11);
  color: white;
  box-shadow: 0 4px 0 #9c3d0c, 0 7px 12px rgba(0,0,0,.25);
  text-shadow: 0 2px rgba(0,0,0,.35);
  font-size: 2.15rem;
  font-weight: 900;
  text-transform: uppercase;
}
.home-action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.home-action-row button,
.home-menu-grid button {
  min-height: 58px;
  border: 1px solid #b9c7cf;
  border-radius: 4px;
  background: rgba(255,255,255,.96);
  color: #202226;
  box-shadow: 0 2px 4px rgba(0,0,0,.16);
  font-weight: 900;
}
.home-action-row button {
  display: grid;
  align-content: center;
  gap: 2px;
}
.home-action-row span {
  color: #76828a;
  font-size: .72rem;
}
.home-menu-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.home-menu-grid button {
  min-height: 44px;
  font-size: .76rem;
}
.menu-page[data-page="deck"] {
  padding: 8px;
  gap: 0;
  background: #d9edf5;
  color: #222;
}
.hub-header,
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.hub-header h1,
.page-header h1 {
  margin: 0;
  font-size: 2rem;
}
.icon-button,
.back-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  font-weight: 900;
}
.icon-button {
  width: 42px;
}
.back-button {
  padding: 0 10px;
}
.player-banner,
.empty-panel,
.deck-summary,
.collection-panel {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.deck-resource-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.deck-resource-strip > div {
  min-height: 42px;
  padding: 6px;
  border: 1px solid #c6d7df;
  border-radius: 4px;
  background: #f8fbfd;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.deck-resource-strip strong {
  min-width: 28px;
  min-height: 28px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: #d74b46;
  color: white;
  font-size: .72rem;
  font-weight: 900;
}
.deck-resource-strip div:nth-child(2) strong {
  background: #23a9c2;
}
.deck-resource-strip div:nth-child(3) strong {
  background: #e0b94e;
  color: #5e4610;
}
.deck-resource-strip span {
  min-width: 0;
  padding: 4px 8px;
  border-radius: 3px;
  background: #57585c;
  color: white;
  text-align: right;
  font-weight: 900;
}
.deck-resource-strip button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 3px;
  background: #20b96d;
  color: white;
  font-size: 1.2rem;
  font-weight: 900;
}
.deck-tabs {
  display: grid;
  grid-template-columns: 1.35fr repeat(4, 1fr);
  align-items: end;
}
.deck-tabs button {
  min-height: 48px;
  border: 1px solid #c9d7de;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #f3f6f8;
  color: #555;
  font-size: 1.3rem;
  font-weight: 900;
}
.deck-tabs button.is-active {
  min-height: 56px;
  background: white;
  color: #222;
}
.deck-builder-board {
  padding: 10px 8px;
  border: 1px solid #c7d5dc;
  background: white;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.16);
}
.deck-side-stats {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  text-align: center;
}
.deck-side-stats strong {
  font-size: .9rem;
  line-height: 1.05;
}
.deck-side-stats span {
  color: #209fc0;
  font-weight: 900;
}
.deck-side-stats span:nth-of-type(3) {
  color: #df4f64;
}
.training-button {
  width: 72px;
  min-height: 72px;
  border: 0;
  border-radius: 4px;
  background: #43a7ee;
  color: white;
  font-size: .82rem;
  font-weight: 900;
}
.small-action {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(226,180,87,.5);
  border-radius: 8px;
  background: transparent;
  color: var(--gold);
  font-weight: 900;
}
.deck-slots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}
.deck-slot {
  aspect-ratio: .78;
  min-height: 0;
  padding: 3px;
  border: 2px solid #aeb9bf;
  border-radius: 3px;
  background: #f8f8f8;
  color: #222;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 2px;
  text-align: left;
  cursor: pointer;
}
.deck-slot strong {
  min-height: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: .62rem;
  line-height: 1.02;
  text-align: center;
}
.deck-slot.is-empty {
  border-style: dashed;
  color: #9ba5aa;
}
.empty-slot-index {
  margin: auto;
  color: #8f9aa1;
  font-weight: 900;
}
.collection-panel {
  margin-top: 10px;
  display: grid;
  gap: 10px;
  padding: 10px 8px;
  border: 1px solid #c7d5dc;
  border-radius: 3px;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,.16);
}
.collection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.collection-head strong {
  font-size: 1.35rem;
}
.collection-head button {
  min-height: 34px;
  min-width: 132px;
  border: 0;
  border-radius: 3px;
  background: #858585;
  color: white;
  font-size: 1rem;
  font-weight: 900;
}
.deck-collection {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
}
.collection-card {
  position: relative;
  aspect-ratio: .78;
  min-height: 0;
  padding: 3px;
  border: 2px solid #94b7c7;
  border-radius: 3px;
  background: #f8f8f8;
  color: #222;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 2px;
  text-align: left;
  cursor: pointer;
}
.collection-card strong {
  min-height: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: .6rem;
  line-height: 1.02;
  text-align: center;
}
.collection-card.is-in-deck {
  border-color: #d8c05d;
  opacity: .68;
}
.collection-card.is-locked {
  background: #b9bdc2;
  color: #5f656a;
  filter: grayscale(1);
  cursor: not-allowed;
}
.collection-card.is-locked strong,
.collection-card.is-locked .mini-stats,
.collection-card.is-locked small {
  color: #50555a;
}
.mini-stats {
  display: flex;
  justify-content: space-between;
  gap: 3px;
  font-size: .95rem;
  line-height: 1;
  font-weight: 900;
}
.mini-stats b:first-child {
  color: #2395cc;
  text-shadow: 1px 1px white;
}
.mini-stats b:last-child {
  color: #de4b57;
  text-shadow: 1px 1px white;
}
.upgrade-mark {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #20b96d;
  color: white;
  font-size: .64rem;
  font-weight: 900;
  box-shadow: 0 1px 3px rgba(0,0,0,.28);
}
.collection-pager {
  display: grid;
  grid-template-columns: 70px 1fr 70px;
  align-items: center;
  justify-items: center;
}
.collection-pager button {
  border: 0;
  background: transparent;
  color: #3f9cde;
  font-size: 3rem;
  line-height: 1;
  font-weight: 900;
}
.collection-pager button:disabled {
  opacity: .28;
}
.collection-pager span {
  color: #222;
  font-size: 1.15rem;
  font-weight: 900;
}
.deck-slot .card-cost,
.collection-card .card-cost {
  width: 26px;
  height: 22px;
  border-radius: 2px;
  background: #26a7c5;
  color: white;
  font-size: .9rem;
  box-shadow: inset 0 -2px rgba(0,0,0,.18);
}
.deck-slot .card-art,
.collection-card .card-art {
  min-height: 0;
  border-radius: 2px;
  background: linear-gradient(135deg, #f2c25a, #de6756);
}
.deck-slot:nth-child(4n + 2) .card-art,
.collection-card:nth-child(5n + 2) .card-art {
  background: linear-gradient(135deg, #55b8e5, #2a829f);
}
.deck-slot:nth-child(4n + 3) .card-art,
.collection-card:nth-child(5n + 3) .card-art {
  background: linear-gradient(135deg, #86d27a, #3b9b65);
}
.deck-slot:nth-child(4n + 4) .card-art,
.collection-card:nth-child(5n + 4) .card-art {
  background: linear-gradient(135deg, #e8d979, #c39d36);
}
.deck-slot:nth-child(4n + 5) .card-art,
.collection-card:nth-child(5n + 5) .card-art {
  background: linear-gradient(135deg, #a67ad5, #5f4692);
}
.shop-wallet {
  display: flex;
  gap: 8px;
}
.shop-wallet span {
  flex: 1;
  padding: 10px;
  border: 1px solid rgba(226,180,87,.35);
  border-radius: 8px;
  background: var(--panel);
  color: var(--gold);
  font-weight: 900;
  text-align: center;
}
.shop-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.shop-tabs button {
  min-height: 42px;
  border: 0;
  background: var(--panel);
  color: var(--muted);
  font-weight: 900;
}
.shop-tabs button.is-active {
  background: var(--panel-strong);
  color: var(--gold);
}
.pack-list,
.currency-shop-grid {
  display: grid;
  gap: 10px;
}
.pack-card {
  min-height: 116px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 82px;
  gap: 10px;
  align-items: stretch;
}
.pack-art {
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--gold));
  color: #171717;
  font-size: .72rem;
  font-weight: 900;
  text-transform: uppercase;
}
.pack-card.union .pack-art,
.pack-card.vault .pack-art {
  background: linear-gradient(145deg, #7060c8, #38a5ad);
  color: var(--ink);
}
.pack-copy {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 5px;
}
.pack-copy strong {
  font-size: 1rem;
}
.pack-copy p {
  margin: 0;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.25;
}
.pack-buy {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: .78rem;
  font-weight: 900;
}
.pack-buy:disabled {
  background: #666;
  color: #d8d8d8;
}
.currency-shop-grid button {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  display: grid;
  align-content: center;
  gap: 6px;
}
.currency-shop-grid span {
  color: var(--muted);
  font-size: .76rem;
}
.pack-modal {
  width: min(92vw, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}
.pack-modal::backdrop {
  background: rgba(0,0,0,.72);
}
.pack-stage {
  display: grid;
  gap: 12px;
  text-align: center;
}
.pack-stage h1 {
  margin: 0;
}
.pack-visual {
  min-height: 144px;
  border: 1px solid rgba(226,180,87,.45);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(226,75,59,.82), rgba(226,180,87,.72));
  color: #171717;
  font-size: 1.4rem;
  font-weight: 900;
  transform-origin: center;
}
.pack-visual.is-open {
  animation: pack-pop 420ms cubic-bezier(.2,.8,.2,1);
}
.pack-rewards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.reward-card {
  min-height: 92px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17191d;
  color: var(--muted);
  display: grid;
  align-content: space-between;
  gap: 4px;
}
.reward-card.is-revealed {
  background: var(--panel-strong);
  color: var(--ink);
  border-color: var(--gold);
  animation: reward-flip 260ms ease-out;
}
.reward-card span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #171717;
  font-size: .72rem;
  font-weight: 900;
}
.reward-card strong {
  overflow-wrap: anywhere;
  font-size: .76rem;
}
.reward-card em {
  color: var(--muted);
  font-size: .68rem;
  font-style: normal;
}
@keyframes pack-pop {
  0% { transform: scale(1); filter: brightness(1); }
  45% { transform: scale(1.06) rotate(-1deg); filter: brightness(1.25); }
  100% { transform: scale(1); filter: brightness(1); }
}
@keyframes reward-flip {
  0% { transform: rotateY(80deg) scale(.96); opacity: .2; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}
.currency-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  color: var(--gold);
  font-size: .78rem;
  font-weight: 900;
}
.currency-row span {
  padding: 6px 8px;
  border: 1px solid rgba(226,180,87,.35);
  border-radius: 6px;
}
.hub-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
}
.battle-entry,
.hub-tile,
.home-grid button {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  text-align: left;
  font-weight: 900;
  cursor: pointer;
}
.battle-entry {
  grid-row: span 2;
  padding: 14px;
  background: linear-gradient(160deg, rgba(226,75,59,.92), rgba(226,180,87,.84));
  color: #171717;
}
.battle-entry strong {
  display: block;
  font-size: 2rem;
}
.hub-tile {
  padding: 12px;
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.home-grid button {
  min-height: 72px;
  padding: 12px;
}
.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  background: #17191d;
}
.bottom-nav button {
  min-height: 54px;
  border: 0;
  border-right: 1px solid rgba(255,255,255,.06);
  background: transparent;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 900;
  cursor: pointer;
}
.bottom-nav button.is-active {
  color: var(--gold);
  background: rgba(226,180,87,.08);
}
.battle-start-panel {
  position: absolute;
  inset: 0;
  z-index: 8;
  padding: 24px;
  display: grid;
  align-content: center;
  gap: 18px;
  background: linear-gradient(180deg, rgba(226,241,247,.96), rgba(185,220,233,.96));
  text-align: center;
}
.battle-start-panel h1 {
  margin: 4px 0;
  color: #1f2b35;
  font-size: 2.8rem;
}
.battle-start-panel p {
  margin: 0;
  color: #56636d;
  font-weight: 800;
}
.battle-start-panel .primary-action {
  background: #43a7ee;
}
.top-bar, .match-strip, .bottom-panel { padding: 8px 10px; }
.top-bar, .match-strip, .player-status, .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.top-bar {
  background: #f8fbfd;
  border-bottom: 1px solid #c5d7e0;
  color: #202226;
  box-shadow: 0 2px 4px rgba(0,0,0,.12);
}
.top-bar .back-button {
  flex: 0 0 auto;
}
.top-bar .leader-opponent {
  flex: 1;
  justify-content: center;
  padding-right: 54px;
}
.leader { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; }
.leader-portrait {
  width: 54px;
  height: 54px;
  border: 2px solid rgba(255,255,255,.24);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  color: #171717;
  font-size: .72rem;
  font-weight: 900;
}
.leader-combat-stats {
  position: absolute;
  left: 30px;
  bottom: -8px;
  display: flex;
  align-items: end;
  gap: 6px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}
.leader-combat-stats span,
.leader-combat-stats b {
  font-size: 1.08rem;
  text-shadow: 1px 1px white, -1px -1px white, 0 2px rgba(0,0,0,.18);
}
.leader-combat-stats span {
  color: #1b8fd0;
}
.leader-combat-stats b {
  color: #e14e62;
}
.leader-opponent .leader-portrait { background: linear-gradient(135deg, var(--accent-2), #86d2e9); }
.leader-copy { min-width: 0; }
.top-bar .leader-copy {
  max-width: 170px;
}
.bottom-panel .leader-copy {
  max-width: 185px;
  padding-left: 18px;
}
.leader-copy strong, .match-strip strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eyebrow, .label, .panel-head span {
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: 0;
}
.leader-metrics, .resource-block { display: grid; justify-items: end; }
.health { color: var(--danger); font-size: 1.4rem; font-weight: 900; }
.match-strip {
  background: #dceff6;
  border-bottom: 1px solid #b7cbd5;
  color: #202226;
}
.phase-pill {
  min-width: 116px;
  padding: 7px 10px;
  border: 1px solid #58a9d8;
  border-radius: 4px;
  background: #43a7ee;
  color: white;
  text-align: center;
  font-weight: 900;
}
.battlefield {
  position: relative;
  display: grid;
  height: 100%;
  grid-template-rows: minmax(0, var(--battle-board-height)) 24px minmax(0, var(--battle-board-height));
  align-content: center;
  gap: 4px;
  padding: 78px 10px 154px;
  --battle-board-height: min(25dvh, 238px);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,.7), transparent 30%, rgba(255,255,255,.55)),
    repeating-linear-gradient(90deg, rgba(255,255,255,.22) 0 1px, transparent 1px 84px),
    #b9dce9;
}
.field-leader {
  position: absolute;
  left: 50%;
  z-index: 4;
  width: 78px;
  height: 70px;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  border: 4px solid #e8e8e8;
  border-radius: 16px 16px 7px 7px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.field-leader-opponent {
  top: 8px;
}
.field-leader-player {
  bottom: 166px;
}
.field-leader .leader-portrait {
  width: 58px;
  height: 58px;
  border: 0;
}
.field-leader .leader-combat-stats {
  left: 6px;
  right: 6px;
  bottom: -12px;
  justify-content: space-between;
  gap: 0;
}
.field-leader .leader-combat-stats span,
.field-leader .leader-combat-stats b {
  font-size: 1.25rem;
}
.battle-detail-flyout {
  position: absolute;
  left: 0;
  right: auto;
  top: calc(50% - 94px);
  bottom: auto;
  z-index: 12;
  width: min(52%, 300px);
  min-height: 72px;
  padding: 10px 12px;
  border-radius: 0 5px 5px 0;
  background: rgba(0,0,0,.76);
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.phase-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 8;
  transform: translate(-50%, -50%);
  color: #ffd34e;
  font-size: clamp(2.4rem, 11vw, 4.6rem);
  font-weight: 900;
  line-height: .9;
  white-space: nowrap;
  text-shadow:
    3px 3px 0 #24150a,
    -2px -2px 0 #24150a,
    0 4px 10px rgba(0,0,0,.5);
  animation: phase-banner-pop 700ms cubic-bezier(.2,.75,.2,1);
}
.phase-banner span {
  font-size: 1.25em;
}
@keyframes phase-banner-pop {
  0% { transform: translate(-50%, -50%) scale(.85); opacity: 0; }
  22% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.battle-detail-flyout strong {
  display: block;
  margin-bottom: 5px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,.22);
  font-size: .9rem;
}
.battle-detail-flyout p {
  margin: 0;
  font-size: .78rem;
  line-height: 1.22;
}
.battlefield::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(67,167,238,.18), transparent 42%, rgba(226,75,59,.14));
  pointer-events: none;
}
.board {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  width: min(80%, 400px);
  height: 100%;
  justify-self: center;
  column-gap: 7px;
  row-gap: 0;
}
.tile {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  border: 2px solid rgba(255,255,255,.75);
  border-radius: 5px;
  background: rgba(255,255,255,.48);
  box-shadow: inset 0 0 0 1px rgba(82,113,131,.18), 0 1px 2px rgba(0,0,0,.14);
  display: grid;
  place-items: stretch;
  overflow: hidden;
}
.tile.can-place { border-color: #43a7ee; background: rgba(67,167,238,.22); cursor: pointer; }
.lane-divider {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 4px;
  align-items: center;
}
.turn-chip {
  height: 34px;
  padding: 3px 5px;
  background: rgba(0,0,0,.55);
  color: white;
  display: grid;
  align-content: center;
  text-shadow: 1px 1px rgba(0,0,0,.7);
}
.turn-chip b,
.turn-chip em {
  display: block;
  font-size: .7rem;
  line-height: 1;
  font-style: normal;
  font-weight: 900;
}
.battle-timer-bar {
  height: 8px;
  border: 1px solid rgba(0,0,0,.55);
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.24);
}
.battle-timer-bar > span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #ffffff, #f2f7f9);
  box-shadow: inset 0 -1px rgba(0,0,0,.15);
  transition: width 120ms linear;
}
.unit {
  position: relative;
  padding: 6px 7px 5px;
  display: grid;
  align-content: end;
  gap: 2px;
  width: 100%;
  min-height: 100%;
  background: transparent;
}
.unit.is-attacking {
  position: relative;
  z-index: 4;
}
.unit.is-attacking-player,
.unit.is-attacking-enemy {
  animation: targeted-attack 420ms cubic-bezier(.2,.75,.2,1);
}
.unit.enemy { border-top: 4px solid #43a7ee; }
.unit.player { border-bottom: 4px solid #ef534a; }
.unit-name {
  display: none;
}
.unit-art {
  min-height: 54px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
}
.enemy .unit-art { background: linear-gradient(135deg, var(--accent-2), #86d2e9); }
.unit-stats {
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 12px;
  display: flex;
  justify-content: space-between;
  color: #202226;
  font-size: 1.05rem;
  line-height: 1;
  font-weight: 900;
  text-shadow: 1px 1px white, -1px -1px white;
}
.gauge { height: 5px; border-radius: 999px; background: rgba(0,0,0,.12); overflow: hidden; }
.gauge > span { display: block; height: 100%; background: #43a7ee; }

@keyframes targeted-attack {
  0% { transform: translate(0, 0) scale(1); filter: brightness(1); }
  46% { transform: translate(var(--attack-x, 0), var(--attack-y, -18px)) scale(1.06); filter: brightness(1.28); }
  100% { transform: translate(0, 0) scale(1); filter: brightness(1); }
}

.unit.is-hit,
.leader-portrait.is-hit {
  animation: hit-flash 340ms cubic-bezier(.2,.8,.2,1);
}

.unit.is-hit-from-player,
.leader-portrait.is-hit-from-player {
  --hit-y: -10px;
}

.unit.is-hit-from-enemy,
.leader-portrait.is-hit-from-enemy {
  --hit-y: 10px;
}

@keyframes hit-flash {
  0% { transform: translateY(0); filter: brightness(1); }
  26% { transform: translateY(var(--hit-y, 8px)); filter: brightness(1.8); }
  48% { transform: translateY(calc(var(--hit-y, 8px) * -0.35)); filter: brightness(1.15); }
  100% { transform: translateY(0); filter: brightness(1); }
}
.bottom-panel {
  position: relative;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  min-height: 132px;
  background: #f8fbfd;
  border-top: 1px solid #c5d7e0;
  color: #202226;
  display: grid;
  align-content: start;
  gap: 4px;
  box-shadow: 0 -2px 4px rgba(0,0,0,.12);
  overflow: visible;
}
.player-status {
  display: none;
  visibility: hidden;
  height: 0;
  overflow: hidden;
}
.bottom-panel .leader {
  flex: 1;
  padding-right: 8px;
}
.bottom-panel .leader-portrait,
.bottom-panel .leader-combat-stats {
  display: none;
}
.bottom-panel .leader-copy {
  padding-left: 0;
}
.bottom-panel .leader-combat-stats {
  left: 26px;
  bottom: -5px;
}
.mana-block {
  min-width: 64px;
}
.bottom-panel:has(.choice-panel:not(.is-hidden):not(.is-collapsed)) {
  min-height: 132px;
  padding-top: 0;
}
.bottom-panel:has(.choice-panel.is-collapsed) {
  padding-top: 8px;
}
.mana-block span:first-child { color: var(--gold); font-weight: 900; }
.battle-page .card-inspect {
  display: none;
}
.card-inspect {
  min-height: 96px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  padding: 8px;
  border: 1px solid #cbd5dc;
  border-radius: 5px;
  background: white;
  color: #202226;
}
.card-inspect.spell .inspect-art {
  background: linear-gradient(135deg, #7060c8, #d36aae);
}
.inspect-art {
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
}
.inspect-main {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 5px;
}
.inspect-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.inspect-title-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inspect-cost {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--gold);
  color: #171717;
  font-weight: 900;
}
.inspect-stats {
  color: var(--gold);
  font-size: .72rem;
  font-weight: 900;
  text-transform: uppercase;
}
.card-inspect p {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.25;
}
.inspect-action {
  min-width: 78px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font-size: .76rem;
  font-weight: 900;
  cursor: pointer;
}
.inspect-action:disabled {
  background: #666;
  color: #d8d8d8;
  cursor: not-allowed;
}
.choice-panel, .hand-panel { position: relative; display: grid; gap: 8px; }
.hand-panel {
  padding-top: 2px;
}
.hand-panel .panel-head {
  display: none;
}
.choice-toggle {
  position: absolute;
  right: 4px;
  top: -58px;
  z-index: 14;
  width: 46px;
  height: 42px;
  border: 1px solid #d3dde3;
  border-radius: 4px;
  background: white;
  color: #9ba5aa;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 900;
  box-shadow: 0 1px 4px rgba(0,0,0,.16);
}
.choice-panel:not(.is-hidden) {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  max-height: min(52vh, 460px);
  overflow: visible;
  padding: 12px 40px 24px;
  background: #eef7fb;
  box-shadow: 0 -2px 8px rgba(0,0,0,.18);
}
.battle-start-panel:not(.is-hidden) ~ .bottom-panel #choice-panel,
.battle-start-panel:not(.is-hidden) ~ .bottom-panel #hand-panel {
  display: none;
}
.battle-start-panel:not(.is-hidden) ~ .bottom-panel {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.choice-panel.is-collapsed {
  position: static;
  height: 0;
  min-height: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}
.choice-panel.is-collapsed .panel-head,
.choice-panel.is-collapsed .card-row,
.choice-panel.is-collapsed .primary-action,
.choice-panel.is-collapsed .skyscraper-mana-row,
.choice-panel.is-collapsed .choice-selected-slots {
  display: none;
}
.choice-panel .panel-head {
  display: none;
}
.choice-panel.is-collapsed .choice-toggle {
  display: grid;
}
.choice-panel.is-collapsed .choice-toggle {
  top: -58px;
  right: -4px;
}
.skyscraper-mana-row {
  display: grid;
  grid-template-columns: auto minmax(0, max-content);
  justify-content: center;
  align-items: center;
  gap: 8px;
}
.hand-mana-row {
  margin-bottom: 2px;
}
.skyscraper-mana-row strong {
  color: #1aa5b0;
  font-size: 1.2rem;
  font-weight: 900;
  text-shadow: 1px 1px white;
}
.mana-dots {
  display: flex;
  gap: 4px;
}
.mana-dots span {
  width: 17px;
  height: 17px;
  border: 2px solid #dfe5e8;
  border-radius: 50%;
  background: white;
}
.mana-dots span.is-available {
  border-color: #1aa5b0;
  background: #1bb5c0;
}
.mana-dots span.is-used {
  border-color: #1aa5b0;
  background: #1bb5c0;
}
.choice-selected-slots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 78px));
  justify-content: center;
  gap: 8px;
}
.selection-slot {
  aspect-ratio: .78;
  min-height: 0;
  border: 2px solid #d6d6d6;
  border-radius: 4px;
  background: #ededed;
  padding: 4px;
}
.selection-slot.is-filled {
  border-color: #e9dc59;
  background: white;
}
.card-row { display: grid; grid-template-columns: repeat(4, minmax(0, 78px)); justify-content: center; gap: 8px; }
#choice-cards { grid-template-columns: repeat(4, minmax(0, 78px)); }
#hand-cards { grid-template-columns: repeat(4, minmax(0, 84px)); }
.card {
  position: relative;
  aspect-ratio: .78;
  min-height: 0;
  padding: 4px;
  border: 2px solid #94b7c7;
  border-radius: 4px;
  background: #f8f8f8;
  color: #202226;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 2px;
  text-align: left;
  cursor: pointer;
}
.card.is-selected {
  outline: 2px solid #43a7ee;
  border-color: #43a7ee;
  background: #ffffff;
  transform: translateY(-6px);
  box-shadow: 0 8px 18px rgba(0,0,0,.26);
}
.card.is-selected::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 12px;
  height: 12px;
  padding: 0;
  border-radius: 50%;
  background: #43a7ee;
  color: white;
  font-size: .58rem;
  font-weight: 900;
  text-transform: uppercase;
}
.card.is-unavailable { opacity: .48; }
.card.is-unavailable,
.card[data-faction-blocked="true"] {
  filter: grayscale(1);
  background: #d6dde1;
  cursor: not-allowed;
}
.card[data-faction-blocked="true"]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 3px;
  background: rgba(80,80,80,.34);
}
.card[data-faction-blocked="true"]::after {
  content: "LOCK";
  position: absolute;
  inset: auto 6px 6px;
  z-index: 3;
  padding: 3px 0;
  border-radius: 3px;
  background: rgba(0,0,0,.55);
  color: white;
  text-align: center;
  font-size: .58rem;
  font-weight: 900;
}
.card-cost {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  display: grid;
  place-items: center;
  background: #26a7c5;
  color: white;
  font-weight: 900;
}
.card-art { border-radius: 5px; background: linear-gradient(135deg, var(--accent), var(--gold)); }
.card.spell .card-art { background: linear-gradient(135deg, #7060c8, #d36aae); }
.card-name { display: none; }
.card-text {
  display: flex;
  justify-content: space-between;
  color: #58656d;
  font-size: .9rem;
  line-height: 1;
  font-weight: 900;
}
.selection-slot .card-cost {
  width: 24px;
  height: 22px;
  border-radius: 3px;
  background: #26a7c5;
  color: white;
}
.selection-slot .card-art {
  min-height: 0;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
}
.selection-slot .card-name {
  display: none;
}
.selection-slot .card-text {
  display: flex;
  justify-content: space-between;
  color: #58656d;
  font-size: .9rem;
  line-height: 1;
  font-weight: 900;
}
.primary-action {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 900;
  cursor: pointer;
}
.primary-action:disabled { background: #666; cursor: not-allowed; }
.is-hidden { display: none; }
.result-modal {
  width: min(90vw, 360px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}
.result-modal::backdrop { background: rgba(0,0,0,.62); }
.result-modal h1 { margin: 0 0 8px; }
.card-detail-modal {
  width: min(94vw, 460px);
  min-height: min(82vh, 720px);
  padding: 0;
  border: 1px solid #cfd6dc;
  border-radius: 3px;
  background: white;
  color: #222;
}
.card-detail-modal::backdrop {
  background: rgba(0,0,0,.62);
}
.card-detail-shell {
  min-height: min(82vh, 720px);
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
}
.card-detail-shell header {
  min-height: 54px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  border-bottom: 1px solid #e4e4e4;
}
.card-detail-shell header button {
  width: 32px;
  height: 32px;
  margin-left: 12px;
  border: 0;
  border-radius: 2px;
  background: #ef534a;
  color: white;
  font-size: 1.3rem;
  font-weight: 900;
}
.card-detail-shell header strong {
  grid-column: 2;
  text-align: center;
  font-size: 1.25rem;
}
.card-detail-body {
  min-height: 320px;
  padding: 28px 26px 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 124px;
  gap: 18px;
}
.detail-art {
  align-self: center;
  height: 220px;
  border-radius: 12px;
  background: linear-gradient(145deg, #e9b56a, #76a6df);
  clip-path: polygon(50% 0, 86% 18%, 100% 58%, 73% 100%, 27% 100%, 0 58%, 14% 18%);
}
.detail-meta {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 8px;
  text-align: center;
}
.detail-meta strong {
  margin-top: 8px;
  font-size: 1.12rem;
  line-height: 1.05;
}
.detail-meta span {
  color: #333;
  font-size: 1rem;
}
.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid transparent;
}
.detail-stats div {
  min-height: 68px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  border-right: 1px solid #dedede;
}
.detail-stats div:last-child {
  border-right: 0;
}
.detail-stats strong {
  font-size: 1.05rem;
}
.detail-stats span {
  font-size: 1.1rem;
  font-weight: 900;
}
#detail-cost { color: #12a9b6; }
#detail-power { color: #2395cc; }
#detail-hp { color: #df4f64; }
.detail-ability {
  padding: 0 18px 18px;
  text-align: center;
}
.detail-ability strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.12rem;
}
.detail-ability p {
  margin: 0;
  color: #333;
  font-size: 1rem;
  line-height: 1.3;
  text-align: left;
}
.card-detail-shell > .primary-action {
  width: calc(100% - 32px);
  margin: 0 16px 16px;
  background: #43a7ee;
}
@media (min-width: 720px) {
  body { display: grid; place-items: center; padding: 18px; }
  .app-shell { min-height: 860px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
}
@media (max-width: 380px) {
  .top-bar, .match-strip, .bottom-panel { padding: 10px; }
  .pack-card { grid-template-columns: 64px minmax(0, 1fr); }
  .pack-buy { grid-column: 1 / -1; min-height: 38px; }
  .pack-rewards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-inspect { grid-template-columns: 48px minmax(0, 1fr); }
  .inspect-action { grid-column: 1 / -1; min-height: 36px; }
  .card { min-height: 104px; padding: 6px; }
  .card-text { display: flex; }
  .choice-selected-slots,
  .card-row,
  #choice-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
