@import "./card-badges.css";
@import "./scrollbars.css";

:root {
  color-scheme: dark;
  --background: #071b3c;
  --panel: #183c71;
  --panel-raised: #244e87;
  --border: #416799;
  --text: #fff8e6;
  --muted: #b1c6e5;
  --gold: #ffd27a;
  --cyan: #72e6f4;
  --coral: #ff9c9a;
  --purple: #e2a2ff;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  height: 100%;
}
body {
  margin: 0;
  height: 100svh;
  height: 100dvh;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  color: var(--text);
  font:
    14px/1.45 "Trebuchet MS",
    ui-rounded,
    system-ui,
    sans-serif;
  background:
    radial-gradient(ellipse at 50% 15%, #29599377, transparent 65%),
    repeating-conic-gradient(#ffffff03 0 25%, transparent 0 50%) 0 0 / 44px 44px,
    #091f43;
}
button,
input,
select {
  font: inherit;
}
button,
select,
summary {
  cursor: pointer;
}
button {
  color: var(--text);
  background: linear-gradient(#365f97, #234779);
  border: 1px solid #5882b7;
  border-bottom: 3px solid #0a254c;
  border-radius: 9px;
  padding: 9px 13px;
  font-weight: 800;
  text-shadow: 0 1px 2px #0007;
  box-shadow:
    inset 0 1px #ffffff20,
    0 2px 3px #0002;
  transition:
    filter 0.15s,
    transform 0.15s,
    box-shadow 0.15s;
  touch-action: manipulation;
}
button:hover:enabled {
  filter: brightness(1.13);
}
button:active:enabled {
  transform: translateY(2px);
  box-shadow: inset 0 1px #ffffff10;
}
button:disabled {
  opacity: 0.42;
  cursor: default;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
a {
  color: inherit;
  text-decoration: none;
}
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: min(1100px, 100%);
  margin: auto;
  padding: 5px 24px;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 950;
  letter-spacing: -0.7px;
  line-height: 1;
  text-shadow: 0 2px #0008;
}
.brand b {
  color: var(--gold);
}
.brand small {
  display: block;
  margin-top: 4px;
  font-size: 7px;
  letter-spacing: 2.8px;
  font-weight: 700;
  color: #a7bddc;
}
.brand-mark {
  color: var(--gold);
  font-size: 36px;
  line-height: 1;
  filter: drop-shadow(0 3px #613a0a);
}
.header-actions {
  display: flex;
  gap: 7px;
}
.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 19px;
  border-radius: 10px;
}
.icon-button[aria-pressed="true"] {
  border-color: var(--gold);
  color: var(--gold);
}
.studio-toggle,
#close-studio {
  display: none;
}
main {
  min-height: 0;
  padding: 0 18px 12px;
}
.game-layout {
  height: 100%;
  display: grid;
  grid-template-columns: auto 285px;
  justify-content: center;
  gap: 24px;
  min-height: 0;
}
.arena-column {
  --hand-card-height: clamp(100px, 14svh, 140px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows:
    40px 20px minmax(0, 1fr) calc(var(--hand-card-height) + 81px)
    34px;
  width: clamp(330px, calc((100svh - 320px) * 0.75), 500px);
  min-height: 0;
}
.deck-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 8px 4px;
}
.deck-toolbar > div:first-child {
  min-width: 0;
}
.deck-toolbar strong,
#deck-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deck-toolbar strong {
  display: block;
  font-size: 10px;
  letter-spacing: 1.6px;
  color: #e6efff;
}
#deck-summary {
  color: var(--muted);
  display: block;
  font-size: 9px;
  margin-top: 2px;
}
.deck-toolbar button {
  padding: 6px 13px;
  color: var(--gold);
  font-size: 11px;
}
.deck-toolbar button span {
  margin-left: 8px;
}
.deck-toolbar-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}
.arena-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 9px 5px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #b2c6e3;
}
.arena-topline > span:last-child {
  font-size: 7px;
  letter-spacing: 0.3px;
  color: #8fa9ce;
}
.status-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin: 0 5px 1px 0;
  border-radius: 50%;
  background: #8be5be;
  box-shadow: 0 0 7px #80f4b955;
}
.battle-stage {
  min-height: 0;
  display: grid;
  grid-template-rows: 36px minmax(0, 1fr);
  overflow: hidden;
  border: 3px solid #799dc0;
  border-radius: 15px 15px 0 0;
  box-shadow:
    0 0 0 2px #0a1934,
    0 0 0 5px #31527e,
    0 15px 40px #0004;
  background: #0d2c52;
}
.player-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  background: linear-gradient(#2b5080, #173662);
  position: relative;
  z-index: 2;
  border-bottom: 2px solid #0b2548;
}
.player-identity {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}
.player-identity strong {
  display: block;
  font-size: 11px;
  line-height: 1.1;
}
.player-identity small {
  display: block;
  font-size: 6px;
  letter-spacing: 1px;
  margin-top: 2px;
  color: #c2aec8;
}
.player-emblem {
  color: #ffc780;
  font-size: 23px;
  line-height: 1;
  text-shadow: 0 2px #602d20;
}
.match-clock {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #b7c4d933;
  border-radius: 7px;
  padding: 2px 5px;
  background: #10294766;
}
.match-clock strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 2px #0007;
}
.match-clock span {
  font-size: 8px;
  line-height: 1.1;
  max-width: 35px;
  color: #b7c4d9;
  font-weight: 800;
}
.tower-score {
  font-size: 16px;
  font-weight: 900;
  color: var(--gold);
  min-width: 34px;
  text-align: right;
}
.board-container {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
  background: radial-gradient(ellipse at 50% 10%, #43769a, #173f62 80%);
  overflow: hidden;
}
.board-container:before,
.board-container:after {
  content: "";
  position: absolute;
  inset: 0 auto 0 8px;
  width: 2px;
  background: linear-gradient(transparent, #8bbcc855, transparent);
}
.board-container:after {
  left: auto;
  right: 8px;
}
.arena-surface {
  position: relative;
  width: min(100cqw, calc(100cqh * 3 / 4));
  height: min(100cqh, calc(100cqw * 4 / 3));
  overflow: hidden;
  box-shadow: 0 0 25px #0005;
}
#arena {
  display: block;
  width: 100%;
  height: 100%;
  outline-offset: -3px;
  touch-action: none;
}
.battle-overlay {
  z-index: 4;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  overflow: auto;
  background: linear-gradient(#071c4588, #071c45ed 45%, #071c45b8);
  backdrop-filter: blur(2px);
  z-index: 4;
}
.overlay-crown {
  color: var(--gold);
  font-size: clamp(40px, 6vh, 70px);
  line-height: 1.2;
  text-shadow:
    0 4px #854d0c,
    0 8px 30px #0004;
  animation: crown-float 3s ease-in-out infinite;
}
.eyebrow {
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--gold);
}
.battle-overlay .eyebrow {
  margin-top: 13px;
  font-size: 7px;
}
.battle-overlay h2 {
  margin: 12px 0;
  font-size: clamp(29px, 4.4vh, 48px);
  line-height: 0.98;
  letter-spacing: -1.6px;
  text-shadow:
    0 3px #061831,
    0 6px 12px #0005;
}
.battle-overlay p {
  font-size: 11px;
  max-width: 220px;
  color: #d0e0f5;
  margin: 0 0 22px;
  line-height: 1.6;
}
.gold-button {
  color: #502a09;
  background: linear-gradient(#ffe5a0, #ffbd4f);
  border: 1px solid #ffeab9;
  border-bottom: 5px solid #a46620;
  border-radius: 10px;
  padding: 12px 20px;
  font-weight: 950;
  text-shadow: 0 1px #fff5;
  box-shadow:
    inset 0 2px #fff8,
    0 4px 0 #482a0e55,
    0 8px 20px #0003;
}
.gold-button > span {
  margin-left: 24px;
}
.battle-overlay small {
  color: #a9bedc;
  font-size: 8px;
  margin-top: 12px;
}
.battle-banner {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #fff3c0;
  padding: 16px;
  text-align: center;
  font-size: clamp(24px, 5vh, 48px);
  font-weight: 950;
  line-height: 1;
  text-shadow:
    0 5px #805021,
    0 9px #091c38,
    0 0 40px #ffc96e66;
  background: radial-gradient(ellipse, #0b285b25, transparent 65%);
  animation: arena-announcement 280ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
body[data-phase="countdown"] .battle-banner {
  font-size: clamp(50px, 12vh, 120px);
}
body[data-phase="finished"] .battle-banner {
  display: none;
}
@keyframes arena-announcement {
  from {
    opacity: 0;
    transform: scale(0.82);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.battle-banner small {
  display: block;
  font-size: 12px;
  letter-spacing: 2px;
}
.arena-toast {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: max-content;
  max-width: calc(100% - 24px);
  text-align: center;
  overflow-wrap: anywhere;
  color: #fff5d7;
  background: #102c5066;
  border: 1px solid #d9a95533;
  border-radius: 6px;
  font-size: 10px;
  line-height: 1.35;
  padding: 4px 7px;
  text-shadow: 0 1px 2px #000;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition:
    opacity 0.16s,
    transform 0.16s;
  pointer-events: none;
  z-index: 8;
}
.arena-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.hand-panel {
  padding: 7px 10px 9px;
  border: 3px solid #6f90b7;
  border-top: 2px solid #e2cfa0;
  border-radius: 0 0 14px 14px;
  background: linear-gradient(#365b8c, #173a6b 20%, #102c55);
  box-shadow:
    0 0 0 2px #0a1934,
    0 0 0 5px #31527e,
    0 12px 25px #0003;
  position: relative;
  z-index: 3;
}
.hand-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  height: 24px;
  font-size: 7px;
  letter-spacing: 1px;
  font-weight: 900;
  color: #d8e7ff;
}
.hand-heading small {
  display: none;
}
.hand-crowns {
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0;
  margin-right: 5px;
}
.next-card {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 6px;
  color: #b6c7e4;
  letter-spacing: 0.5px;
  line-height: 1.1;
}
.next-card-art {
  display: grid;
  place-items: center;
  width: 21px;
  height: 28px;
  position: relative;
}
.next-card-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: absolute;
}
.next-card-art:has(img:not([hidden])) > span {
  visibility: hidden;
}
.next-card b {
  display: block;
  font-size: 7px;
  max-width: 78px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
  color: #d4c5ef;
  letter-spacing: 0;
}
#hand {
  touch-action: none;
}
.hand {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  height: var(--hand-card-height);
}
.hand-card {
  position: relative;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 2px solid #a7bfd6;
  border-bottom: 4px solid #36567a;
  border-radius: 8px;
  background: radial-gradient(
    ellipse at 50% 35%,
    color-mix(in srgb, var(--card-color) 60%, #31517a),
    #274779 80%
  );
  box-shadow:
    inset 0 1px #fff5,
    0 4px #061b3599;
  transform-origin: 50% 100%;
  transition:
    transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1.3),
    filter 0.15s,
    border-color 0.15s;
  overflow: visible;
}
.hand-card .card-portrait {
  position: absolute;
  inset: -6px 0 auto;
  width: 100%;
  height: calc(100% - 11px);
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 3px 2px #0005);
  transition: transform 0.16s;
}
.hand-card.selected {
  transform: translateY(-7px) scale(1.035);
  border-color: #fff1ab;
  box-shadow:
    0 0 0 2px #eab75b,
    0 5px #664422,
    0 0 17px #ffcc7050;
  z-index: 2;
}
.hand-card.selected .card-portrait {
  transform: translateY(-2px);
}
.hand-card.new-card {
  animation: card-deal 0.2s cubic-bezier(0.2, 0.8, 0.2, 1.2);
}
body.is-dragging .hand-card.selected {
  opacity: 0.4;
  transform: translateY(-12px) rotate(-3deg);
}
.hand-panel.played .elixir-track {
  animation: elixir-spend 0.25s ease-out;
}
.hand-card.unaffordable {
  filter: grayscale(1);
}
.hand-card.has-art .card-emblem {
  display: none;
}
.hand-card.has-art {
  width: min(100%, calc(var(--hand-card-height) * 0.75));
  justify-self: center;
  border: 0;
  background: transparent;
  box-shadow: 0 4px 8px #061b3599;
}
.hand-card.has-art .card-portrait {
  inset: 0;
  height: 100%;
  filter: none;
}
.hand-card.has-art.selected {
  box-shadow:
    0 0 0 2px #ffe09b,
    0 0 17px #ffcc7050;
}
.hand-card.has-art.selected .card-portrait {
  transform: none;
}
.hand-card.has-art .card-title,
.hand-card.has-art .card-subtitle {
  display: none;
}
.card-emblem {
  position: absolute;
  inset: 4px 5px 16px;
  display: grid;
  place-items: center;
  font-size: 29px;
  font-weight: 900;
  color: var(--card-color);
  text-shadow: 0 3px #0a1934;
}
.card-cost {
  position: absolute;
  top: -8px;
  left: -7px;
  width: 25px;
  height: 29px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 13px;
  font-weight: 950;
  text-shadow: 0 2px #642080;
  background: linear-gradient(140deg, #f7c4ff, #b65ce0 55%, #7f35b6);
  clip-path: polygon(50% 0, 100% 27%, 100% 78%, 50% 100%, 0 78%, 0 27%);
  z-index: 3;
  filter: drop-shadow(0 2px #39276a);
}
.card-hotkey {
  position: absolute;
  top: 3px;
  right: 4px;
  display: grid;
  place-items: center;
  min-width: 13px;
  height: 14px;
  color: #e2ecff;
  background: #10294d99;
  border-radius: 3px;
  font-size: 8px;
}
.card-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 0 0 5px 5px;
  padding: 3px 2px 2px;
  background: linear-gradient(#102a4cbb, #0b203fe8);
  font-size: 8px;
  font-weight: 950;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff5dd;
}
.card-subtitle {
  display: none;
}
.elixir-row {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  margin-top: 7px;
}
.elixir-gem {
  color: #e9b0ff;
  font-size: 22px;
  text-shadow: 0 2px #76318a;
}
.elixir-track {
  position: relative;
  flex: 1;
  min-width: 15px;
  height: 16px;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid #e6bd54;
  background: #171439;
  box-shadow: inset 0 2px 3px #0008;
}
.elixir-track:after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(10% - 1px),
    #49330fbb calc(10% - 1px),
    #49330fbb 10%
  );
}
#elixir-fill {
  width: 50%;
  height: 100%;
  background: linear-gradient(#fff0a6, #f5c542 65%, #cb8b19);
  box-shadow: 0 0 10px #da98ff66;
  transition: width 0.05s linear;
}
.elixir-caption {
  display: none;
}
.ability-button {
  display: flex;
  gap: 4px;
  justify-content: space-between;
  color: #ffdfa0;
  border-color: #8f752f;
  border-bottom-color: #67480c;
  border-radius: 6px;
  background: linear-gradient(#645c34, #443e2a);
  padding: 4px 6px;
  font-size: 8px;
  height: 25px;
}
.ability-button > b {
  color: #ecc1ff;
  font-size: 8px;
}
.ability-button:not(:disabled) {
  animation: ability-glow 2s ease-in-out infinite;
}
.playback-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  padding-top: 5px;
}
.bot-choice {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 135px;
  min-width: 0;
  max-width: 180px;
  font-size: 8px;
  color: var(--gold);
}
.bot-choice select {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  width: 100%;
}
.playback-controls button,
.playback-controls select {
  padding: 4px 10px;
  border-radius: 6px;
  background: #153769;
  border: 1px solid #3a5e8d;
  border-bottom: 2px solid #071c3d;
  color: #c4d5ed;
  font-size: 9px;
  font-weight: 800;
  height: 27px;
}
.sidebar {
  min-height: 0;
  overflow-y: auto;
  padding: 8px 8px 12px;
  scrollbar-width: thin;
  scrollbar-color: #4a6b97 transparent;
}
.studio-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 12px;
}
.studio-heading .eyebrow {
  color: #8badd6;
  font-size: 7px;
}
.selected-panel {
  padding: 16px;
  border: 1px solid #5a80ac;
  border-bottom: 3px solid #0a234d;
  border-radius: 13px;
  background: linear-gradient(135deg, #2b5086, #183766);
  box-shadow:
    inset 0 1px #ffffff1a,
    0 8px 15px #0002;
}
.panel-topline,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.panel-topline .eyebrow {
  font-size: 7px;
}
.cost-badge {
  font-size: 13px;
  font-weight: 900;
  color: var(--purple);
}
.character-preview {
  height: 252px;
  position: relative;
  margin: 12px 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(
    ellipse at 50% 60%,
    color-mix(in srgb, var(--character-color) 25%, transparent),
    transparent 65%
  );
}
.selected-portrait {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 5px #0004);
}
.preview-orbit {
  position: absolute;
  width: 135px;
  height: 135px;
  border: 1px solid #d8ba7055;
  border-radius: 50%;
}
.preview-star {
  position: absolute;
  right: 28px;
  top: 14px;
  font-size: 25px;
  color: var(--character-color);
}
.placeholder-portrait {
  width: 85px;
  height: 100px;
  display: grid;
  place-items: center;
  color: var(--character-color);
  border: 3px solid currentColor;
  border-radius: 30px 30px 18px 18px;
  background: #153563;
  font-size: 30px;
  font-weight: 900;
  transform: rotate(-5deg);
}
.character-preview.has-art .placeholder-portrait {
  display: none;
}
.character-preview.has-art {
  background: none;
}
.character-preview.has-art .preview-orbit,
.character-preview.has-art .preview-star,
.character-preview.has-art .art-label {
  display: none;
}
.art-label {
  position: absolute;
  bottom: 1px;
  font-size: 6px;
  letter-spacing: 1.4px;
  color: #9bb5d6;
  opacity: 0.65;
}
.character-class {
  font-size: 7px;
  letter-spacing: 1.2px;
  font-weight: 900;
  color: var(--gold);
}
.selected-panel h2 {
  font-size: 24px;
  letter-spacing: -0.8px;
  line-height: 1.05;
  margin: 6px 0 10px;
  text-shadow: 0 2px #0a234d;
}
.selected-panel > p {
  font-size: 10px;
  color: #c0d0e7;
  line-height: 1.65;
  margin: 0 0 12px;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  border-top: 1px solid #42638d;
  padding-top: 10px;
  margin-top: 12px;
}
.stat-grid span {
  font-size: 7px;
  text-transform: uppercase;
  color: #90add2;
}
.stat-grid strong {
  display: block;
  font-size: 15px;
  font-weight: 900;
  color: #f0f4ff;
  margin-top: 3px;
}
.selected-panel .personality-note {
  color: var(--gold);
  font-size: 11px;
  margin-top: -3px;
}
.collection-personality {
  display: block;
  padding: 0 10px;
  margin: 0 0 6px;
  color: #d6e9ff;
  font-size: 10px;
}
.selected-panel .ability-note {
  font-size: 8px;
  color: #97afcf;
  margin: 12px 0 0;
}
.journal-panel,
.replay-panel {
  padding: 18px 4px 0;
}
.panel-heading h2 {
  margin: 0;
  font-size: 13px;
}
.panel-heading > span {
  font-size: 8px;
  color: #9fb5d6;
  letter-spacing: 0.5px;
}
#battle-journal {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#battle-journal li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9px;
  color: #b5c9e5;
}
#battle-journal time {
  font-size: 8px;
  color: #7f9bc2;
  font-variant-numeric: tabular-nums;
}
.journal-team {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--cyan);
}
.journal-team.enemy {
  background: var(--coral);
}
.journal-empty {
  color: #87a5ce !important;
}
.record-icon {
  color: var(--coral) !important;
}
.replay-panel {
  border-top: 1px solid #2e4e79;
  margin-top: 18px;
}
.replay-panel > p {
  font-size: 10px;
  color: #95b1d4;
  margin: 8px 0 12px;
}
.replay-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.replay-buttons button,
.watch-button {
  font-size: 9px;
  padding: 8px;
}
.watch-button {
  width: 100%;
  margin-top: 7px;
}
.seek-controls {
  margin-top: 14px;
}
.seek-controls label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 9px;
  color: #c2d1e8;
}
.seek-controls input {
  width: 100%;
  accent-color: var(--gold);
}
.seek-controls p {
  font-size: 8px;
  color: var(--muted);
}
.battle-settings {
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid #2e4e79;
}
.battle-settings summary {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #a9c1df;
}
.battle-settings label {
  display: block;
  font-size: 9px;
  margin: 12px 0 5px;
  color: var(--muted);
}
.seed-row {
  display: flex;
  gap: 7px;
}
.seed-row input {
  min-width: 0;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid #476b9b;
  border-radius: 5px;
  background: #0c2a53;
  color: var(--text);
  font-size: 11px;
}
.seed-row button {
  padding: 6px 10px;
  font-size: 10px;
}
.battle-settings p {
  font-size: 9px;
  color: #8fa9cd;
  line-height: 1.6;
  margin: 9px 0;
}
.fingerprint-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 8px;
  color: #89a6ce;
}
.fingerprint-row code {
  color: var(--gold);
}
.battle-settings .settings-note {
  font-size: 8px;
  color: #7594bf;
}
.help-panel {
  position: fixed;
  z-index: 20;
  top: 64px;
  right: max(18px, calc((100vw - 1060px) / 2));
  width: min(370px, calc(100vw - 30px));
  padding: 18px;
  border: 1px solid #7b9cca;
  border-radius: 13px;
  background: #153967f5;
  box-shadow: 0 15px 50px #0007;
  max-height: calc(
    100dvh - 90px - env(safe-area-inset-top) - env(safe-area-inset-bottom)
  );
  overflow-y: auto;
}
.help-panel p {
  font-size: 11px;
  color: #bbd0ed;
  line-height: 1.6;
  margin: 0 0 14px;
}
.help-panel strong {
  display: block;
  color: #fff3d4;
  font-size: 13px;
  margin-bottom: 4px;
}
.help-panel button {
  display: block;
  margin-left: auto;
  font-size: 11px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
body.is-focused .game-layout {
  grid-template-columns: minmax(0, 620px);
  justify-items: center;
}
body.is-focused .sidebar {
  display: none;
}
body.is-focused .arena-column {
  width: min(100%, 620px);
  grid-template-rows: minmax(0, 1fr) calc(var(--hand-card-height) + 81px) 48px;
}
body.is-focused .deck-toolbar,
body.is-focused .arena-topline,
body.is-focused #studio-button {
  display: none;
}
.deck-dialog {
  width: min(1000px, calc(100% - 28px));
  max-height: calc(
    100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom)
  );
  padding: 0;
  color: var(--text);
  border: 2px solid #7a9dc8;
  border-bottom: 5px solid #1e3b65;
  border-radius: 17px;
  background: linear-gradient(145deg, #214578, #102e59);
  box-shadow:
    0 25px 100px #000a,
    inset 0 2px #ffffff20;
}
.deck-dialog::backdrop {
  background: #05142de0;
  backdrop-filter: blur(5px);
}
.saved-games-dialog {
  width: min(620px, calc(100% - 24px));
  max-height: calc(
    100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)
  );
  padding: 20px;
  color: var(--text);
  border: 2px solid #7a9dc8;
  border-radius: 17px;
  background: linear-gradient(145deg, #214578, #102e59);
  box-shadow: 0 25px 100px #000a;
}
.saved-games-dialog::backdrop {
  background: #05142de0;
  backdrop-filter: blur(5px);
}
.saved-games-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.saved-games-heading h2 {
  margin: 0 0 6px;
  font-size: 25px;
  line-height: 1.1;
}
.saved-games-heading p,
#saved-games-status {
  color: var(--muted);
  font-size: 12px;
}
.saved-games-heading p {
  margin: 0;
}
#saved-games-status {
  margin: 16px 0 0;
}
#saved-games-status:empty,
.game-save-status:empty {
  display: none;
}
#saved-games-status.is-error,
.game-save-status.is-error,
.game-save-status[data-state="error"] {
  color: var(--coral);
}
#saved-games-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}
.saved-game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid #6581a866;
}
.saved-game:first-child {
  border-top: 0;
}
.saved-game time,
.saved-game span {
  display: block;
  overflow-wrap: anywhere;
}
.saved-game time {
  font-size: 13px;
  color: var(--text);
}
.saved-game span {
  margin-top: 4px;
  font-size: 12px;
  color: var(--gold);
}
.saved-game button {
  white-space: nowrap;
  padding: 7px 11px;
}
.game-save-status {
  font-size: 12px;
}
.deck-dialog-heading {
  padding: 22px 24px 0;
}
.deck-dialog-heading h2 {
  font-size: 32px;
  line-height: 1;
  margin: 8px 0 10px;
  letter-spacing: -1px;
  text-shadow: 0 3px #0b234a;
}
.deck-dialog-heading p {
  font-size: 12px;
  color: #b5cbe9;
  margin: 0 0 16px;
}
.deck-selected-list {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 7px;
  padding: 0 24px;
}
.deck-slot {
  position: relative;
  aspect-ratio: 3 / 4;
  min-width: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 2px solid #a6bedd;
  border-bottom: 4px solid #2c4976;
  background: #102b51;
  overflow: hidden;
}
.deck-slot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.deck-slot .deck-slot-remove {
  position: absolute;
  right: 3px;
  top: 0;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px #000;
}
.deck-slot:has(img) {
  font-size: 0;
  border: 0;
  background: transparent;
}
.deck-slot.empty {
  border: 1px dashed #6b8ebc;
  color: #688bb8;
  font-size: 20px;
  box-shadow: none;
  background: #0e2b5333;
}
.deck-picker-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 13px 24px;
}
.deck-picker-controls p {
  font-size: 12px;
  color: var(--gold);
  margin: 0;
  font-weight: 800;
}
.deck-picker-controls button {
  font-size: 11px;
  padding: 8px 12px;
  white-space: nowrap;
}
.collection-tools {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 24px 16px;
}
.collection-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  border: 1px solid #5b80ae;
  border-radius: 7px;
  padding: 7px 10px;
  background: #0d2a51;
  color: #91b1d9;
}
.collection-search input {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 11px;
}
.collection-search input::placeholder {
  color: #83a0c5;
}
.collection-filters {
  display: flex;
  gap: 5px;
}
.collection-filters button {
  padding: 6px 10px;
  font-size: 10px;
}
.collection-filters button[aria-pressed="true"] {
  color: #53300e;
  background: linear-gradient(#ffe5a1, #f3c05d);
  border-color: #ffe5a1;
  border-bottom-color: #9c6b29;
  text-shadow: none;
}
.collection-search-status {
  padding: 20px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.deck-card-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding: 0 24px 20px;
}
.collection-card {
  position: relative;
  min-width: 0;
  padding: 0 0 11px;
  text-align: left;
  overflow: hidden;
  border: 2px solid #6b8fbd;
  border-bottom: 4px solid #2a4a73;
  background: linear-gradient(135deg, #2d527f, #163760);
  border-radius: 10px;
}
.collection-card.selected {
  border-color: #ffe09b;
  border-bottom-color: #bd8c34;
  box-shadow:
    0 0 0 1px #ffc454,
    0 4px 8px #0003;
  background: linear-gradient(140deg, #5e614d, #283d55);
}
.collection-card.selected:after {
  content: "✓";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: #ffd77b;
  color: #5c3a14;
  border-radius: 50%;
  box-shadow: 0 2px #92652a;
  font-size: 14px;
  font-weight: 950;
}
.collection-portrait {
  position: relative;
  display: grid;
  place-items: center;
  height: 125px;
  background: radial-gradient(
    ellipse at 50% 55%,
    color-mix(in srgb, var(--card-color) 45%, transparent),
    transparent 75%
  );
}
.collection-portrait > span {
  font-size: 40px;
  color: var(--card-color);
  font-weight: 900;
}
.collection-portrait img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.collection-portrait:has(img) > span {
  visibility: hidden;
}
.collection-card.has-art {
  padding: 0;
  border: 0;
  background: transparent;
}
.collection-card.has-art .collection-portrait {
  height: auto;
  aspect-ratio: 3 / 4;
  background: none;
}
.collection-card.has-art
  > :not(.collection-portrait):not(.collection-traits):not(.card-badges):not(
    .collection-cost
  ) {
  display: none;
}
.collection-card.has-art .collection-traits {
  padding: 6px 5px;
  margin: 0;
  border-radius: 0 0 7px 7px;
  background: #102e59;
}
.collection-card.has-art.selected {
  box-shadow:
    0 0 0 2px #ffe09b,
    0 4px 8px #0003;
}
.collection-cost {
  position: absolute;
  top: 6px;
  right: 6px;
  color: #f5d4ff;
  background: linear-gradient(#9254b6, #642e8f);
  border: 1px solid #d9acfb;
  border-bottom: 3px solid #40215d;
  border-radius: 5px;
  padding: 2px 5px;
  font-size: 11px;
  font-weight: 900;
}
.collection-card strong,
.collection-role,
.collection-description {
  display: block;
  padding: 0 9px;
}
.collection-card strong {
  font-size: 12px;
  line-height: 1.1;
  margin-top: 6px;
}
.collection-role {
  font-size: 9px;
  color: var(--gold);
  margin: 5px 0 6px;
}
.collection-traits {
  display: block;
  padding: 0 9px;
  margin-bottom: 6px;
  font-size: 9px;
  line-height: 1.4;
  color: #b8f1ea;
}
.deck-coverage {
  margin: 0 24px 10px;
  color: var(--gold);
  font-size: 12px;
}
.deck-coverage:empty {
  display: none;
}
.collection-description {
  font-size: 9px;
  color: #b0c3de;
  line-height: 1.45;
}
.deck-dialog-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 13px 24px;
  background: #102e59f5;
  border-top: 1px solid #6581a8;
  backdrop-filter: blur(5px);
}
.deck-dialog-actions .gold-button {
  min-width: 0;
  padding: 9px 18px;
  font-size: 13px;
}
.deck-dialog-actions .gold-button > span {
  margin-left: 20px;
}
@keyframes card-deal {
  from {
    transform: translateY(16px) scale(0.86);
    opacity: 0;
  }
}
@keyframes elixir-spend {
  from {
    filter: brightness(1.8);
    box-shadow: 0 0 12px #eab6ff;
  }
}
@keyframes crown-float {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }
  50% {
    transform: translateY(-5px) rotate(4deg);
  }
}
@keyframes ability-glow {
  0%,
  100% {
    box-shadow: 0 0 0 1px #c4a13933;
  }
  50% {
    box-shadow: 0 0 12px #fdd96b66;
  }
}
@media (max-width: 780px) {
  body {
    grid-template-rows: 52px minmax(0, 1fr);
  }
  .site-header {
    padding: 4px 13px;
  }
  .brand {
    font-size: 18px;
    gap: 7px;
  }
  .brand-mark {
    font-size: 31px;
  }
  .brand small {
    font-size: 6px;
    letter-spacing: 2px;
  }
  .header-actions {
    gap: 5px;
  }
  .icon-button {
    width: 44px;
    height: 44px;
    font-size: 17px;
  }
  .studio-toggle {
    display: grid;
  }
  main {
    padding: 0 8px 6px;
  }
  .game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }
  .arena-column {
    --hand-card-height: clamp(64px, 13dvh, 110px);
    width: min(100%, 410px);
    grid-template-rows:
      44px 17px minmax(0, 1fr) calc(var(--hand-card-height) + 93px)
      48px;
  }
  .deck-toolbar {
    padding: 0 5px 4px;
  }
  .deck-toolbar strong {
    font-size: 8px;
    letter-spacing: 1px;
  }
  #deck-summary {
    font-size: 8px;
  }
  .deck-toolbar button {
    font-size: 10px;
    padding: 5px 10px;
  }
  .arena-topline {
    font-size: 7px;
    padding-left: 5px;
    padding-right: 5px;
  }
  .arena-topline > span:last-child {
    font-size: 6px;
  }
  .battle-stage {
    grid-template-rows: 32px minmax(0, 1fr);
    border-width: 2px;
    border-radius: 12px 12px 0 0;
    box-shadow:
      0 0 0 1px #0a1934,
      0 0 0 3px #31527e;
  }
  .player-strip {
    padding: 3px 8px;
  }
  .player-identity strong {
    font-size: 10px;
  }
  .player-identity small {
    font-size: 5px;
  }
  .player-emblem {
    font-size: 19px;
  }
  .match-clock strong {
    font-size: 16px;
  }
  .match-clock span {
    font-size: 8px;
  }
  .tower-score {
    font-size: 14px;
  }
  .hand-panel {
    padding: 6px 9px 7px;
    border-width: 2px;
    border-top-width: 2px;
    box-shadow:
      0 0 0 1px #0a1934,
      0 0 0 3px #31527e;
  }
  .hand-heading {
    height: 24px;
    margin-bottom: 6px;
  }
  .hand {
    gap: 7px;
  }
  .card-title {
    font-size: 8px;
  }
  .card-hotkey {
    font-size: 6px;
  }
  .card-cost {
    width: 22px;
    height: 26px;
    font-size: 12px;
    top: -7px;
    left: -6px;
  }
  .elixir-row {
    height: 44px;
    margin-top: 5px;
  }
  .elixir-track {
    height: 12px;
  }
  .ability-button {
    font-size: 7px;
    height: 44px;
    padding: 4px 5px;
  }
  .ability-button > b {
    font-size: 7px;
  }
  .playback-controls {
    padding-top: 4px;
    gap: 6px;
  }
  .playback-controls button,
  .playback-controls select {
    height: 44px;
    padding: 3px 9px;
    font-size: 8px;
  }
  .sidebar {
    display: none;
    position: fixed;
    z-index: 15;
    inset: 54px 8px 8px;
    width: auto;
    padding: 14px;
    background: #102e59fa;
    border: 2px solid #6489b7;
    border-radius: 13px;
    box-shadow: 0 15px 70px #000b;
  }
  body.show-studio .sidebar {
    display: block;
  }
  body.show-studio #close-studio {
    display: grid;
  }
  .studio-heading {
    margin-bottom: 12px;
  }
  .studio-heading .eyebrow {
    font-size: 9px;
    color: var(--gold);
  }
  .selected-panel {
    display: grid;
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 0 14px;
  }
  .panel-topline {
    grid-column: 1 / -1;
    margin-bottom: 8px;
  }
  .character-preview {
    grid-column: 1;
    grid-row: 2 / 7;
    height: 135px;
    margin: 0;
  }
  .character-class,
  .selected-panel h2,
  .selected-panel > p,
  .stat-grid {
    grid-column: 2;
  }
  .selected-panel h2 {
    font-size: 22px;
  }
  .stat-grid {
    padding-top: 7px;
    margin-top: 7px;
  }
  .selected-panel .ability-note {
    grid-column: 1 / -1;
  }
  .deck-dialog {
    width: calc(100% - 16px);
    max-height: calc(
      100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)
    );
    border-radius: 12px;
  }
  .deck-dialog-heading {
    padding: 18px 15px 0;
  }
  .deck-dialog-heading h2 {
    font-size: 26px;
  }
  .deck-dialog-heading p {
    font-size: 10px;
    margin-bottom: 12px;
  }
  .deck-selected-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 0 15px;
    gap: 4px;
  }
  .deck-slot {
    border-radius: 5px;
  }
  .deck-slot .deck-slot-remove {
    font-size: 9px;
    right: 2px;
  }
  .deck-picker-controls {
    padding: 10px 15px;
    gap: 5px;
  }
  .deck-picker-controls p {
    font-size: 10px;
  }
  .deck-picker-controls button {
    padding: 7px 9px;
    font-size: 10px;
  }
  .collection-tools {
    display: block;
    padding: 0 15px 12px;
  }
  .collection-search {
    margin-bottom: 9px;
  }
  .collection-filters {
    gap: 6px;
  }
  .collection-filters button {
    flex: 1;
    font-size: 10px;
  }
  .deck-card-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 0 15px 15px;
  }
  .collection-portrait {
    height: 90px;
  }
  .collection-card strong {
    font-size: 10px;
    padding: 0 7px;
  }
  .collection-role {
    font-size: 7px;
    padding: 0 7px;
  }
  .collection-description {
    display: none;
  }
  .collection-cost {
    font-size: 9px;
    padding: 2px 4px;
    right: 4px;
    top: 4px;
  }
  .collection-card.selected:after {
    width: 17px;
    height: 17px;
    font-size: 11px;
    left: 4px;
    top: 4px;
  }
  .deck-dialog-actions {
    padding: 10px 15px;
  }
  .deck-dialog-actions button {
    font-size: 12px;
  }
  .battle-overlay {
    padding: 15px;
  }
  .battle-overlay p {
    font-size: 10px;
    max-width: 200px;
    margin-bottom: 18px;
  }
  .battle-overlay .gold-button {
    font-size: 13px;
    padding: 10px 15px;
  }
}
@media (max-width: 360px) {
  .brand {
    font-size: 16px;
  }
  .brand small {
    letter-spacing: 1.2px;
  }
  .header-actions {
    gap: 3px;
  }
  .icon-button {
    width: 44px;
    height: 44px;
  }
  .deck-selected-list {
    gap: 3px;
    padding: 0 10px;
  }
  .deck-slot {
    min-height: 0;
  }
  .deck-card-list {
    padding: 0 10px 12px;
    gap: 6px;
  }
  .deck-dialog-actions .gold-button {
    padding: 9px 13px;
  }
}
@media (max-height: 580px) and (min-width: 480px) and (orientation: landscape) {
  body {
    grid-template-rows: 52px minmax(0, 1fr);
  }
  main {
    padding: 0 8px 5px;
  }
  .site-header {
    padding-top: 2px;
    padding-bottom: 2px;
  }
  .brand-mark {
    font-size: 27px;
  }
  .brand small {
    display: none;
  }
  .game-layout {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }
  .arena-column,
  body.is-focused .arena-column {
    width: min(100%, calc((100dvh - 90px) * 0.75 + 270px));
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    grid-template-rows: 44px minmax(0, 1fr) 48px;
    gap: 0 8px;
  }
  .deck-toolbar {
    grid-column: 1 / -1;
  }
  .arena-topline {
    display: none;
  }
  .battle-stage {
    grid-column: 1;
    grid-row: 2 / 4;
    border-radius: 11px;
  }
  .hand-panel {
    grid-column: 2;
    grid-row: 2;
    border-radius: 11px;
    padding: 8px 10px;
  }
  .hand-heading {
    margin-bottom: 8px;
  }
  .hand {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    height: calc(100% - 90px);
    gap: 6px;
  }
  .hand-card.has-art {
    width: 100%;
    min-height: 0;
  }
  .elixir-row {
    flex-wrap: wrap;
    margin-top: 8px;
    gap: 3px;
  }
  .ability-button {
    width: 100%;
    height: 44px;
    margin-top: 1px;
  }
  .playback-controls {
    grid-column: 2;
    grid-row: 3;
    gap: 3px;
    flex-wrap: nowrap;
  }
  .playback-controls button,
  .playback-controls select {
    font-size: 9px;
    padding: 3px 4px;
    height: 44px;
  }
  .sidebar {
    display: none;
  }
  .studio-toggle {
    display: grid;
  }
  body.show-studio .sidebar {
    display: block;
    position: fixed;
    inset: 45px 8px 8px;
    z-index: 15;
    background: #102e59fa;
    border: 2px solid #6489b7;
    border-radius: 13px;
  }
  body.show-studio #close-studio {
    display: grid;
  }
  .battle-overlay .overlay-crown {
    font-size: 28px;
  }
  .battle-overlay h2 {
    font-size: 25px;
  }
  .battle-overlay p {
    font-size: 8px;
    margin-bottom: 10px;
  }
  .battle-overlay .eyebrow {
    font-size: 6px;
    margin-top: 4px;
  }
  .battle-overlay small {
    font-size: 6px;
    margin-top: 8px;
  }
}
.battle-overlay[data-result] {
  background: #0b203bed;
  overflow: auto;
}
.battle-overlay[data-result] h2 {
  font-size: clamp(32px, 5vw, 50px);
  line-height: 1.1;
  color: var(--gold);
  letter-spacing: -0.8px;
}
.battle-overlay[data-result="defeat"] h2 {
  color: #ffb59d;
}
.battle-overlay[data-result] p {
  font-size: 13px;
  max-width: 250px;
  margin-bottom: 16px;
}
.battle-overlay[data-result] .eyebrow {
  font-size: 9px;
}
.battle-overlay[data-result] .overlay-crown {
  font-size: 32px;
  animation: none;
}
.battle-overlay[data-result] #overlay-note {
  order: 2;
}
.result-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  padding: 8px 12px;
  min-height: 40px;
  border: 1px solid #d6bb7e;
  border-radius: 8px;
  background: #112e50;
  color: #ffe2a0;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.battle-overlay[data-result] h2:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 5px;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 420px) {
  .deck-card-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Touch layouts keep controls usable while the board retains its 3:4 ratio. */
@media (max-width: 780px) {
  .brand small,
  .brand-mark {
    display: none;
  }
  .brand {
    font-size: 14px;
    min-width: 0;
  }
  .site-header {
    padding-inline: 6px;
    gap: 4px;
  }
  .header-actions {
    gap: 2px;
  }
  .deck-toolbar button,
  .collection-filters button,
  .deck-picker-controls button {
    min-height: 44px;
  }
  .deck-toolbar strong {
    display: none;
  }
  .deck-toolbar {
    gap: 4px;
  }
  .deck-toolbar button {
    padding-inline: 7px;
  }
  body.is-focused .arena-column {
    grid-template-rows: minmax(0, 1fr) calc(var(--hand-card-height) + 93px) 48px;
  }
  .sidebar {
    top: calc(54px + env(safe-area-inset-top));
    bottom: calc(8px + env(safe-area-inset-bottom));
  }
  input,
  select,
  .playback-controls select {
    font-size: 16px;
  }
}
@media (max-height: 580px) and (min-width: 480px) and (orientation: landscape) {
  body.is-focused .arena-column {
    grid-template-rows: 0 minmax(0, 1fr) 48px;
  }
  .hand-panel {
    min-height: 0;
  }
  .elixir-row {
    height: 58px;
    margin-top: 4px;
  }
  .hand-heading {
    height: 18px;
    margin-bottom: 4px;
  }
  .hand {
    height: calc(100% - 84px);
  }
  .playback-controls .bot-choice {
    flex-basis: 70px;
    max-width: 90px;
  }
  .battle-overlay {
    justify-content: safe center;
    padding: 8px;
  }
  .battle-overlay .overlay-crown,
  .battle-overlay > .eyebrow,
  .battle-overlay > p,
  .battle-overlay > small {
    display: none;
  }
}

@media (max-width: 420px) {
  .brand {
    font-size: 11px;
    max-width: 66px;
    line-height: 1.25;
  }
}
@media (pointer: coarse) {
  .icon-button {
    width: 44px;
    height: 44px;
  }
  #sound-settings .audio-controls summary {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .audio-controls-body label {
    min-height: 44px;
  }
}

@media (max-height: 380px) and (min-width: 480px) and (orientation: landscape) {
  .hand {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
  }
}

.tiebreak-cue {
  position: absolute;
  z-index: 7;
  top: 42px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 5px 8px;
  border-radius: 6px;
  background: #102c5066;
  color: #fff5d7;
  font:
    600 11px/1.35 system-ui,
    sans-serif;
  text-align: center;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

/* Shared resource badge: the shape sits behind the readable numeral. */
.star-power,
.card-cost,
.collection-cost,
.cost-badge {
  position: relative;
  display: inline-grid;
  place-items: center;
  isolation: isolate;
  box-sizing: border-box;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  padding: 2px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  clip-path: none;
  color: #30200a;
  font:
    900 14px/1 system-ui,
    sans-serif;
  text-shadow: none;
  filter: drop-shadow(0 1px 1px #0009);
}
.star-power::before,
.card-cost::before,
.collection-cost::before,
.cost-badge::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(145deg, #fff3a9, #f5c542 55%, #d79218);
  clip-path: polygon(
    50% 0%,
    64% 32%,
    100% 36%,
    73% 60%,
    82% 96%,
    50% 78%,
    18% 96%,
    27% 60%,
    0% 36%,
    36% 32%
  );
}
.hand-card .card-cost {
  position: absolute;
  top: 1px;
  left: 1px;
  z-index: 3;
}
.collection-cost {
  position: absolute;
  top: 4px;
  right: 4px;
}
.elixir-row {
  min-height: 36px;
}
.collection-cost {
  right: auto;
  left: 0;
  top: 12px;
  width: 34%;
  height: auto;
  aspect-ratio: 1;
  font-size: clamp(14px, 3vw, 22px);
}

/* Keep dialog gestures inside their own scroll surface. */
.deck-dialog,
.saved-games-dialog {
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
}

/* Reuse the same crowned promo logo in local practice. */
.brand-wordmark {
  display: block;
  width: 92px;
  height: auto;
}
@media (max-width: 700px) {
  .brand-wordmark {
    width: 80px;
  }
}
