:root {
  color-scheme: dark;
  font-family: Geist, Inter, "Segoe UI", sans-serif;
  color: #e9f0f7;
  background: #0c1518;
  --muted: #aebfc0;
  --surface: #111e22;
  --line: #b7cbcb2d;
  --aqua: #87dfcc;
  --violet: #e5b6a3;
  --rift-gold: #edcb91;
  --rift-serif: Cinzel, Georgia, serif;
  --mini-card: clamp(48px, 5vw, 88px);
  --hand-card: clamp(68px, 6.65vw, 113px);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; color: inherit; }
button:not(:disabled), summary { cursor: pointer; }
button:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--aqua);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

.practice-home {
  min-height: 100dvh;
  padding: 0 max(18px, calc((100vw - 1160px) / 2)) 48px;
  background:
    linear-gradient(180deg, #0a141626, #0a1416c9 430px, #0a1416 720px),
    url("riftbound-stage.webp") center top / max(100%, 900px) auto no-repeat,
    #0a1416;
}
.practice-home-header, .practice-home-brand, .practice-nav { display: flex; align-items: center; gap: 10px; }
.practice-home-header { justify-content: space-between; flex-wrap: wrap; min-height: 72px; padding: 10px 0; border-bottom: 1px solid #eac69043; }
.practice-home-brand > strong { font: 700 23px/1 var(--rift-serif); color: #f3dfb8; }
.practice-home-brand > span:last-child { padding-left: 10px; border-left: 1px solid #eac69056; color: #b7c5c4; font-size: 12px; }
.practice-nav { flex-wrap: wrap; gap: 6px; }
.practice-nav .btn { border-color: transparent; background: #152023bd; }
.practice-nav .btn:not(:disabled):hover { border-color: #f0ca896b; background: #273137; }
.practice-home-mark { display: grid; flex: 0 0 36px; width: 36px; height: 36px; place-items: center; }
.practice-home-mark::before, .brand-mark::before {
  content: "";
  width: 58%;
  aspect-ratio: 1;
  transform: rotate(45deg);
  border: 1px solid #edca8b;
  background: linear-gradient(135deg, #e6b96c99, #1e716f78 48%, #0d3439 50%, #c3944b77);
  box-shadow: inset 0 0 0 3px #12282d, 0 0 18px #d4ac653d;
}
.practice-home-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .85fr); min-height: 365px; align-items: center; gap: clamp(22px, 5vw, 72px); padding: 38px 0; }
.practice-home-copy h1 { margin: 0; max-width: 13ch; color: #faead0; font-family: var(--rift-serif); font-size: clamp(2.65rem, 5.5vw, 5rem); font-weight: 700; letter-spacing: -.055em; line-height: .99; text-shadow: 0 5px 20px #060c0de0; }
.practice-home-copy p { margin: 18px 0; max-width: 43ch; color: #cad7d5; line-height: 1.6; }
.practice-home-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.practice-home-actions .btn { min-height: 44px; padding-inline: 17px; }
.practice-home-actions .btn--primary { border-color: #ffdfa5; background: linear-gradient(125deg, #f6dca7, #c68b4c); color: #211a13; }
.practice-home-actions .btn--primary:not(:disabled):hover { background: #ffe0a5; color: #211a13; }
.practice-home-copy .practice-home-coverage { margin-bottom: 0; color: #9cadbd; font-size: 12px; }
.practice-home-art { display: flex; justify-content: center; align-items: center; min-width: 0; padding: 26px 14px; background: radial-gradient(ellipse, #3b84796b, transparent 70%); }
.practice-home-art:empty { display: none; }
.practice-home-art img { display: block; width: min(31%, 162px); height: auto; aspect-ratio: 5 / 7; object-fit: contain; border-radius: 6%; box-shadow: 0 0 0 1px #dfbd89a0, 0 22px 35px #050c0ddd; }
.practice-home-art img + img { margin-left: -2.2%; }
.practice-home-art img:first-child { transform: translateY(8px) rotate(-9deg); }
.practice-home-art img:nth-child(2) { position: relative; z-index: 1; transform: translateY(-8px); }
.practice-home-art img:last-child { transform: translateY(8px) rotate(9deg); }
.practice-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 24px; }
.practice-mode {
  display: grid; gap: 7px; align-content: start; padding: 15px 17px; min-width: 0; text-align: left;
  border: 1px solid #e5bd7448; border-radius: 5px; background: linear-gradient(145deg, #1c3437, #102023 82%); color: #c9d9d6;
}
.practice-mode:hover { border-color: #edca8bbe; background: #233b3c; }
.practice-mode > strong { display: flex; justify-content: space-between; gap: 8px; color: #faecd1; font: 700 17px/1.2 var(--rift-serif); }
.practice-mode strong span { color: var(--rift-gold); }
.practice-mode > span { font-size: 13px; line-height: 1.45; }
.practice-tournaments { padding-top: 24px; border-top: 1px solid var(--line); }
.practice-section-title { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.practice-tournaments h2 { margin: 0; color: #f2dfb8; font: 700 23px/1.15 var(--rift-serif); }
.practice-tournaments > p { margin: 0 0 14px; color: #afc3d2; font-size: 13px; }
.practice-tournaments ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.practice-tournaments li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; padding: 12px; border: 1px solid #a8cfe326; border-inline-start: 2px solid #d6ab6e80; border-radius: 5px; background: #112125; }
.practice-tournaments li strong, .practice-tournaments li small { display: block; overflow-wrap: anywhere; }
.practice-tournaments li strong { color: #edf5fc; font-size: 13px; }
.practice-tournaments li small { margin-top: 4px; color: #adbed0; font-size: 11px; }
.practice-tournaments li .btn { flex: none; }
.setup-tournament-link { color: #a7ebdc; font-size: 12px; text-underline-offset: 2px; }
.setup-native { display: grid; gap: 5px; }
.setup-selection {
  display: flex; gap: 12px; align-items: center; padding: 8px; min-height: 92px;
  border: 1px solid color-mix(in srgb, var(--seat-accent), transparent 70%); border-radius: 6px;
  background: linear-gradient(115deg, color-mix(in srgb, var(--seat-accent), #101b20 88%), #10191e 60%);
}
.setup-deck-art {
  display: grid; place-items: center; flex: 0 0 53px; width: 53px; aspect-ratio: 5 / 7;
  border-radius: 5px; overflow: hidden; background: #243346; color: var(--seat-accent); font-size: 25px;
}
.setup-deck-art img { width: 100%; height: 100%; object-fit: cover; }
.setup-deck-info { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.setup-deck-info span { color: var(--seat-accent); font-size: 11px; }
.setup-deck-info strong { font-size: 16px; }
.setup-deck-info small { color: #bccadb; }
.setup-choice-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.setup-import { padding-top: 8px; border-top: 1px solid var(--line); }
.setup-import summary { margin-bottom: 4px; color: #c8d8e6; font-size: 13px; font-weight: 650; }
.setup-import[open] summary { margin-bottom: 10px; }
.setup-import textarea { margin-bottom: 8px; }
.bot-update { display: none; }
#difficulty-hint { color: #b9cbdc; font-size: 11px; font-weight: 400; line-height: 1.35; }
.practice-utility { width: min(650px, calc(100vw - 24px)); padding: clamp(14px, 3vw, 24px); overflow: auto; }
.utility-heading, .utility-actions, .utility-rule-topics { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.utility-heading { justify-content: space-between; margin-bottom: 12px; }
.utility-heading h2 { margin: 0; font-size: clamp(1.2rem, 4vw, 1.6rem); }
.utility-intro, .utility-rule-sources { color: #b5c7d7; line-height: 1.5; }
.utility-form, .utility-field, .utility-rule-results { display: grid; gap: 9px; min-width: 0; }
.utility-field { color: #cfdfed; font-size: 13px; font-weight: 700; }
.utility-field input { min-height: 42px; width: 100%; padding: 7px 10px; border: 1px solid #58758c; border-radius: 6px; background: #0d1826; color: #eef7ff; font: inherit; font-size: 16px; font-weight: 400; }
.utility-field input:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }
.utility-form > .btn { justify-self: start; }
.utility-status:empty { display: none; }
.utility-status { margin: 3px 0; color: var(--aqua); }
.utility-rule-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; margin-bottom: 12px; }
.utility-rule-search .btn { min-height: 42px; }
.utility-rule-topics, .utility-rule-context:not(:empty) { margin-bottom: 14px; }
.utility-rule-context > h3 { margin: 0 0 7px; font-size: 13px; color: var(--aqua); }
.utility-rule { min-width: 0; padding: 11px; border: 1px solid #58758c62; border-radius: 7px; background: #0f1927; overflow-wrap: anywhere; }
.utility-rule h3 { margin: 0 0 4px; font-size: 15px; }
.utility-rule p { margin: 0 0 5px; color: #c4d4e2; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.utility-rule a, .utility-rule small, .utility-rule-sources { color: #b5e7de; font-size: 12px; }
.utility-rule-sources a { color: inherit; }
.showdown-actions--choices { max-height: 144px; overflow: auto; }
.field-facedown {
  --hidden-rim: #95ddf1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 3px;
}
.field-facedown[data-seat="opponent"] { --hidden-rim: #e0b9fa; }
.field-hidden-label {
  padding: 2px 4px;
  border: 1px solid color-mix(in srgb, var(--hidden-rim), transparent 48%);
  border-radius: 4px;
  color: var(--hidden-rim);
  background: #101928;
  font-size: 10px;
  font-weight: 700;
}
.field-facedown .field-hidden-card {
  --face-width: clamp(28px, 3vw, 48px);
  flex: none;
  width: var(--face-width);
  border: 1px solid var(--hidden-rim);
}
.field-hidden-card.game-card { opacity: .76; }
.field-hidden-card.game-card:hover, .field-hidden-card.game-card:focus-visible { opacity: 1; }
.sideboard-setup { display: grid; gap: 10px; margin: 10px 0; }
.sideboard-setup label { display: grid; min-width: 0; gap: 4px; color: #cbd6e1; font-size: 12px; font-weight: 700; }
.sideboard-setup select { width: 100%; min-height: 38px; padding: 5px; border: 1px solid #7b9eb75c; border-radius: 6px; color: #edf4fa; background: #151f30; font: inherit; }
.sideboard-swaps { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: 7px; }
.sideboard-swaps .btn { min-height: 38px; }
.sideboard-setup p { margin: 0; color: #d0e0ed; font-size: 12px; }
.sideboard-setup > .btn { justify-self: start; }

@media (max-width: 700px) {
  .practice-home-hero { grid-template-columns: 1fr; min-height: 0; gap: 18px; padding: 36px 0 26px; }
  .practice-home-art { padding: 5px 12px 15px; }
  .practice-home-art img { width: min(28%, 110px); }
  .practice-tournaments ul { grid-template-columns: 1fr; }
  .practice-modes { grid-template-columns: 1fr; }
  .sideboard-swaps { grid-template-columns: minmax(0, 1fr); }
  .sideboard-setup select { font-size: 16px; }
}

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: clamp(178px, 14vw, 222px) minmax(0, 1fr);
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
  padding: 15px 11px 10px;
  border-right: 1px solid #c8a76d58;
  background: linear-gradient(180deg, #151e20, #0e181c 66%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f3dfb8;
  font: 700 20px/1.1 var(--rift-serif);
  letter-spacing: -.02em;
}
.brand > :first-child {
  display: grid;
  flex: 0 0 32px;
  min-height: 32px;
  place-items: center;
}
.brand small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-family: Geist, Inter, "Segoe UI", sans-serif;
  font-weight: 570;
  letter-spacing: .015em;
}
.room-caption {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.scoreboard { display: grid; gap: 6px; }
.player {
  --player-accent: var(--aqua);
  display: flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: #ffffff03;
}
.player[data-seat="opponent"] { --player-accent: var(--violet); }
.player[data-active="true"] {
  border-color: color-mix(in srgb, var(--player-accent), transparent 61%);
  box-shadow: inset 2px 0 0 var(--player-accent), inset 0 0 16px #08111358;
  background: color-mix(in srgb, var(--player-accent), #101a1e 89%);
}
.avatar {
  display: grid;
  flex: 0 0 26px;
  height: 26px;
  place-items: center;
  border: 1px solid #d5b2f543;
  border-radius: 50%;
  background: #d5b2f51a;
  color: var(--violet);
  font-size: 12px;
  font-weight: 750;
}
.player:last-child .avatar { border-color: #7fe8d743; background: #7fe8d71a; color: var(--aqua); }
.player-copy { display: grid; min-width: 0; flex: 1; gap: 2px; }
.player-copy > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-copy strong { font-size: 12px; }
.player-copy small { color: var(--muted); font-size: 10px; }
.player[data-active="true"] .player-copy small:last-child { color: var(--player-accent); font-weight: 740; }
.player-copy .player-deck { color: #c8d5e4; font-weight: 650; }
.player-score { display: none; }
.player-tag {
  color: var(--aqua);
  font-size: 10px;
  font-weight: 740;
  line-height: 1.25;
}
.match-notice {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.history {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}
.history summary {
  padding: 12px 0;
  color: #e0c497;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.history summary span {
  margin-left: 4px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0;
}
.log {
  min-height: 0;
  max-height: calc(100dvh - 285px);
  margin: 0;
  padding: 0 4px 0 0;
  overflow: auto;
  scrollbar-width: thin;
  list-style: none;
}
.log li {
  display: grid;
  gap: 2px;
  padding: 6px 3px;
  border-top: 1px solid #ffffff0b;
  overflow-wrap: anywhere;
  color: #cbdad8;
  font-size: 12px;
  line-height: 1.45;
}
.log small { color: var(--aqua); font-size: 10px; font-weight: 740; }
.log li[data-seat="opponent"] small { color: var(--violet); }
.log li:not([data-kind="turn"], :first-child) small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.log li[data-kind="draw"] { border-inline-start: 2px solid var(--aqua); padding-inline-start: 7px; }
.log li[data-kind="draw"][data-seat="opponent"] { border-inline-start-color: var(--violet); }
.log li[data-kind="turn"] { margin-block-start: 5px; padding: 7px 6px; border-block-start-color: #c5a47057; background: #d5b38414; color: #f4dfb8; font-weight: 730; }
.log-filters { display: flex; flex-wrap: wrap; gap: 4px; padding: 5px 0; }
.log-filters .btn { min-height: 29px; padding: 3px 7px; font-size: 11px; }
.log-filters [aria-pressed="true"] { color: var(--aqua); border-color: #7fe8d766; background: #7fe8d714; }
.draw-summary {
  margin: 0 0 6px; padding: 7px; border: 1px solid #7fe8d740; border-radius: 6px;
  color: #d2f6ee; background: #17302c; font-size: 11px; line-height: 1.4; white-space: pre-line; overflow-wrap: anywhere;
}
.sidebar-footer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; margin-top: auto; padding-top: 8px; }
.sidebar-footer .btn { min-height: 30px; padding: 4px 5px; font-size: 10px; }
#motion-toggle[aria-pressed="true"] { border-color: #e3ba7969; color: #f2d49d; }
@media (min-width: 701px) {
  .history { overflow: hidden; }
  .history[open]::details-content { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
  .history[open] .log { flex: 1; }
}
#mode[aria-pressed="true"] { border-color: var(--aqua); background: #224347; }

.table {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(200px, 1fr) auto auto;
  min-width: 0;
  min-height: 100dvh;
  gap: 8px;
  padding: 9px 11px;
  isolation: isolate;
  background:
    linear-gradient(180deg, #37223121, #11192012 48%, #06292817),
    url("riftbound-stage.webp") center / cover,
    linear-gradient(170deg, #3b303e, #192d34 65%, #143038);
}

.seat { display: grid; min-width: 0; gap: 2px; }
.seat--opponent { --seat-color: var(--violet); --seat-surface: #5b3b4561; }
.seat--you { --seat-color: var(--aqua); --seat-surface: #18404667; }
.hand-row, .resource-row, .zone {
  min-width: 0;
  border: 1px solid #cbcec234;
  border-radius: 4px;
  background: #0b171d70;
}
.hand-row {
  display: grid;
  grid-template-columns: minmax(54px, auto) minmax(0, 1fr) auto;
  min-height: 58px;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
}
.hand-label, .zone-label, .resource-count {
  color: #c7d3e2;
  font-size: 10px;
  font-weight: 740;
  letter-spacing: .055em;
  line-height: 1.3;
}
.hand-label { display: grid; gap: 5px; justify-items: start; }
.seat :is(.hand-label > span:first-child, .base-zone .zone-label) { color: var(--seat-color); }
.seat .hand-row, .seat .resource-row { border-inline-start: 2px solid color-mix(in srgb, var(--seat-color), transparent 44%); }
.seat .base-zone { border-inline-start-width: 2px; }
.seat .base-zone:not(.is-legal, .is-drop-hover) { border-inline-start-color: color-mix(in srgb, var(--seat-color), transparent 44%); }
.table[data-turn="you"] .seat--you .hand-row,
.table[data-turn="opponent"] .seat--opponent .hand-row {
  border-color: color-mix(in srgb, var(--seat-color), transparent 56%);
  border-inline-start-color: var(--seat-color);
  background-color: color-mix(in srgb, var(--seat-color), #101b2b 90%);
}
#hide-hand { min-height: 28px; max-width: 100%; padding: 3px 5px; font-size: 10px; line-height: 1.2; }
#hide-hand[aria-pressed="true"] { border-color: #7fe8d76d; color: var(--aqua); }
.hand {
  display: flex;
  min-width: 0;
  justify-content: safe center;
  gap: 5px;
  padding: 4px;
  overflow: auto hidden;
  scrollbar-width: thin;
}
.hand > * { flex: 0 0 var(--hand-card); min-width: 0; }
.hand--hidden { gap: 5px; }
.hand--hidden > * { flex-basis: calc(var(--mini-card) * .69); }
.hand--hidden:not(:has(.game-card)) { padding-inline: 14px; }
.hand--hidden .card-back + .card-back { margin-inline-start: -11px; }
.card-back, .deck-stack {
  --sleeve: #0b3950;
  --sleeve-rim: #b69d67;
  display: grid;
  place-items: center;
  border: 1px solid var(--sleeve-rim);
  border-radius: 5px;
  box-shadow: 2px 2px 0 #0e121c, 3px 3px 0 #5c553d;
  background:
    var(--card-back, linear-gradient(45deg, transparent 48%, #b69d6780 49% 50%, transparent 51%)) center / cover,
    linear-gradient(135deg, transparent 48%, #b69d6780 49% 50%, transparent 51%),
    radial-gradient(circle, #c7a56644, transparent 62%), var(--sleeve);
}
.card-back { aspect-ratio: 5 / 7; max-height: 67px; color: #e5cb8d; }
.field-facedown .field-hidden-card.field-hidden-inspect {
  padding: 0;
  color: #fff;
  font-size: .67rem;
  font-weight: 700;
  text-shadow: 0 1px 4px #000, 0 0 8px #000;
  cursor: pointer;
}
.deck-stack {
  position: relative;
  width: 37px;
  min-height: 43px;
  padding: 2px;
  color: #fff;
  font-size: 13px;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
}
.deck-stack span { font-size: 8px; font-weight: 680; line-height: 1; }
.deck-stack strong { line-height: 1; }
.deck-stack--rune { --sleeve: #252e41; --sleeve-rim: #aeb9c9; }
.deck-stack:not(:disabled):hover { border-color: var(--seat-color); }

.resource-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  min-height: 49px;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: var(--seat-surface);
}
.points {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  min-width: 60px;
  place-items: center;
  column-gap: 5px;
  color: var(--seat-color);
  font-size: 26px;
  font-weight: 760;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.points > div { grid-column: 1; grid-row: 1; white-space: nowrap; }
.points > div span { margin-left: 2px; color: #c7d3e2; font-size: 11px; }
.points small { grid-column: 1; grid-row: 2; color: #c7d3e2; font-size: 9px; font-weight: 720; letter-spacing: .07em; text-transform: uppercase; }
.point-button {
  grid-column: 2;
  grid-row: 1 / 3;
  width: 23px;
  height: 23px;
  padding: 0;
  border: 1px solid #ffffff2e;
  border-radius: 5px;
  background: #101a296e;
  color: var(--seat-color);
  font-size: 16px;
  line-height: 1;
}
.point-button:not(:disabled):hover { border-color: var(--seat-color); }
.point-button:disabled { opacity: .45; }
.resource-count {
  padding: 5px 7px;
  border: 1px solid #ffffff18;
  border-radius: 4px;
  background: #0d181f80;
  white-space: nowrap;
}
.runes { display: flex; gap: 4px; min-width: 0; padding: 3px 3px 4px; overflow: auto hidden; scrollbar-width: thin; }
.rune {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: clamp(24px, 2.8vw, 32px);
  aspect-ratio: 5 / 7;
  place-items: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--domain, #9db3d1) 65%, #1e2739);
  border-radius: 4px;
  color: #f3f6fd;
  background: linear-gradient(145deg, var(--domain, #9db3d1), #152036 83%);
  box-shadow: 0 2px 5px #05081370, inset 0 0 0 2px #ffffff22;
  font-size: 13px;
  font-weight: 750;
  transition: transform .13s ease, opacity .13s ease;
}
.rune:has(.rune-image) { overflow: hidden; background: #10151b; }
.rune-image, .card-image, .field-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.rune[aria-pressed="true"], .rune[data-exhausted="true"] { transform: scale(.84) rotate(14deg); opacity: .66; }
[data-domain="ember"] { --domain: #e46762; }
[data-domain="tide"] { --domain: #56a5db; }
[data-domain="veil"] { --domain: #a27adb; }
[data-domain="sun"] { --domain: #d4a855; }
[data-domain="fury"] { --domain: #c75a50; }
[data-domain="calm"] { --domain: #6fa586; }
[data-domain="mind"] { --domain: #56a5db; }
[data-domain="body"] { --domain: #da945a; }
[data-domain="chaos"] { --domain: #a27adb; }
[data-domain="order"] { --domain: #c8ab67; }

.zone {
  transition: border-color .15s ease, background-color .15s ease;
}
.destination { position: relative; }
.destination.is-legal {
  border-color: #95f7df;
  background-color: #31706570;
  box-shadow: inset 0 0 0 1px #8df9dc55;
  cursor: pointer;
}
.destination.is-drop-hover {
  border-color: #c9fff2;
  background-color: #57a98a8a;
  box-shadow: inset 0 0 0 2px #b0ffea, 0 0 15px #83ffe149;
}
.destination-cue {
  position: absolute;
  z-index: 2;
  right: 6px;
  bottom: 6px;
  max-width: calc(100% - 12px);
  min-height: 30px;
  padding: 3px 8px;
  border: 1px solid #b0f5e4;
  border-radius: 6px;
  color: #e7fff8;
  background: #123731;
  box-shadow: 0 2px 7px #051214a3;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.destination-cue:hover, .is-drop-hover > .destination-cue { color: #102a25; background: #bbffea; }
.base-zone {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: stretch;
  gap: 9px;
  padding: 4px 8px;
  background: var(--seat-surface);
}
.legend-slot {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px 3px 2px;
  border-right: 1px solid #ffffff1c;
}
.legend-slot .game-card { width: calc(var(--mini-card) * .83); }
.zone-content {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-width: 0;
  align-items: center;
  gap: 5px;
}
.zone-content .zone-label { grid-area: 1 / 1; align-self: start; padding-block-start: 4px; }
.zone-content .zone-cards { grid-area: 1 / 2; }
.zone-label { display: flex; min-height: 15px; justify-content: space-between; gap: 5px; }
.zone-cards {
  display: flex;
  min-width: 0;
  min-height: 0;
  align-items: center;
  gap: 5px;
  padding: 4px;
  overflow: auto hidden;
  scrollbar-width: thin;
}
.zone-cards > * { flex: 0 0 auto; }
.zone-cards:empty { min-height: 22px; }

.midboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(62px, .2fr);
  gap: 8px;
  min-height: 0;
}
@media (min-width: 701px) {
  .midboard[data-field-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(58px, .22fr); }
  .midboard[data-many-fields] { grid-auto-rows: minmax(148px, 1fr); }
  .midboard[data-many-fields] > .chain { grid-column: 3; grid-row: 1 / span var(--battlefield-rows); }
}
@media (max-width: 700px) {
  .midboard[data-field-count="3"] > [data-zone="center"] { grid-column: 1 / -1; }
}
.battlefield, .chain {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  padding: 8px 10px;
}
.battlefield {
  --field-owner: #c9d7d4;
  grid-template-areas: "field-head" "field-body" "showdown";
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(180deg, #704c5351, #25242b20 49.7%, #1c534b2b 50.3%, #26726937),
    #0b141961;
}
.battlefield[data-control="you"] { --field-owner: var(--aqua); }
.battlefield[data-control="opponent"] { --field-owner: var(--violet); }
.battlefield[data-control="contested"] { --field-owner: #ffd193; }
.battlefield[data-control] .field-emblem {
  border-color: color-mix(in srgb, var(--field-owner), transparent 24%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--field-owner), transparent 73%), 0 3px 8px #03091372;
}
.battlefield > .zone-label { grid-area: field-head; align-items: baseline; gap: 5px 10px; flex-wrap: wrap; }
.battlefield [data-field-title] { color: #f7e7cf; font-family: var(--rift-serif); font-size: clamp(14px, 1.25vw, 18px); font-weight: 700; letter-spacing: -.016em; }
.battlefield > .zone-label > span:not(:empty) {
  padding: 1px 0;
  color: var(--field-owner);
  line-height: 1.18;
  letter-spacing: 0;
  text-align: end;
}
.field-layout {
  grid-area: field-body;
  display: grid;
  grid-template-columns: minmax(92px, .82fr) minmax(0, 1.18fr);
  min-width: 0;
  align-items: center;
  gap: 10px;
}
.field-showdown {
  grid-area: showdown;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  align-content: center;
  gap: 3px 8px;
  padding: 7px 9px;
  border: 1px solid #eab97992;
  border-radius: 5px;
  color: #fff2dc;
  background: linear-gradient(100deg, #3e2e2e, #232427);
  box-shadow: 0 4px 12px #07081359;
  overflow-wrap: anywhere;
}
.battlefield:not(.is-legal, .is-drop-hover):has(> .field-showdown:not([hidden])) { border-color: #f3c587b8; box-shadow: inset 0 0 22px #dba35e12; }
.showdown-title { grid-column: 1; margin: 0; color: #ffda9f; font: 700 14px/1.22 var(--rift-serif); }
.showdown-status { grid-column: 1; margin: 0; color: #f1dfd9; font-size: 11px; line-height: 1.35; }
.showdown-actions { grid-area: 1 / 2 / span 2; display: flex; flex-wrap: wrap; align-self: center; justify-content: end; gap: 5px; }
.showdown-actions--choices { grid-area: 3 / 1 / auto / -1; justify-content: start; }
.showdown-actions:empty { display: none; }
.showdown-actions .btn { max-width: 100%; min-height: 34px; padding: 4px 7px; font-size: 11px; line-height: 1.2; }
.showdown-actions .btn--primary { border-color: #ffe4b8; color: #291e29; background: linear-gradient(145deg, #f6d9a4, #d79859); }
.showdown-actions .btn--primary:not(:disabled):hover { border-color: #fff2da; color: #251a24; background: #ffdcab; }
.field-emblem {
  position: relative;
  display: grid;
  min-height: 68px;
  align-content: end;
  gap: 4px;
  padding: 10px 7px;
  overflow: hidden;
  border: 1px solid #8bddce52;
  border-radius: 5px;
  color: #e9fffb;
  background: linear-gradient(150deg, #263b49, #111a23);
  box-shadow: 0 3px 8px #03091372;
}
.field-emblem:has(.field-image) {
  width: 100%;
  max-width: 218px;
  min-height: 0;
  aspect-ratio: 1039 / 744;
  padding: 0;
  align-content: stretch;
  background: #12171b;
}
.field-emblem .field-image { min-width: 0; min-height: 0; }
.field-emblem .game-card { width: 100%; }
.battlefield:nth-child(2):not([data-control]) .field-emblem {
  border-color: #d3a9ec69;
}
.field-emblem small { color: #d1e3e8; font-size: 9px; }
.field-emblem strong { font-size: clamp(12px, 1.1vw, 16px); line-height: 1.15; overflow-wrap: anywhere; }
.field-units { display: grid; grid-template-rows: 1fr 1fr; min-height: 100%; min-width: 0; gap: 4px; }
.field-units .zone-cards[data-seat] {
  --lane-color: var(--aqua);
  border: 1px solid color-mix(in srgb, var(--lane-color), transparent 82%);
  border-inline-start: 2px solid color-mix(in srgb, var(--lane-color), transparent 53%);
  border-radius: 4px;
  background-color: color-mix(in srgb, var(--lane-color), transparent 94%);
}
.field-units .zone-cards[data-seat="opponent"] { --lane-color: var(--violet); }
.field-units .zone-cards[data-seat]:empty::before {
  color: var(--lane-color);
  font-size: 9px;
  font-weight: 670;
  opacity: .76;
  white-space: nowrap;
}
.field-units .zone-cards[data-seat="opponent"]:empty::before { content: "Opponent"; }
.field-units .zone-cards[data-seat="you"]:empty::before { content: "You"; }
.field-units .field-facedown:not([hidden]) { align-self: end; }
@media (min-width: 901px) {
  @supports (grid-template-rows: subgrid) {
    .midboard:not([data-many-fields]) { grid-template-rows: auto minmax(0, 1fr) auto; grid-auto-flow: column; }
    .midboard:not([data-many-fields]) > .battlefield { grid-row: span 3; grid-template-rows: subgrid; }
    .midboard:not([data-many-fields]) > .chain { grid-row: span 3; }
  }
}
.chain {
  position: relative;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #111f25a9;
  border-style: dashed;
  border-color: #d3daf331;
}
.chain .zone-cards { align-content: start; }
.table[data-phase="priority"] .chain {
  border-style: solid;
  border-color: #92d8cf9e;
  background: #172d32e6;
}
.table[data-phase="priority"] .chain > .zone-label { color: #b6e4ff; }
.chain-empty {
  position: absolute;
  inset: 50% 4px auto;
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 0;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
  text-align: center;
  pointer-events: none;
}
.chain-empty span { color: #bbc0df; font-size: 19px; }
.chain .btn { grid-row: 3; }

.game-card {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  min-width: 0;
  --face-width: var(--mini-card);
  width: var(--face-width);
  aspect-ratio: 744 / 1039;
  gap: 0;
  padding: 3px 3px 4px;
  border: 1px solid color-mix(in srgb, var(--domain, #b3bed5) 63%, #1b2334);
  border-radius: 6px;
  color: #f2f7fa;
  background: #101721;
  box-shadow: 0 3px 8px #07091690, inset 0 0 0 1px #ffffff10;
  text-align: left;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.game-card:has(> :is(.card-image, .field-image)) {
  grid-template-rows: minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
  border-color: #080b10;
  background: #101115;
}
.game-card[data-orientation="landscape"] { aspect-ratio: 1039 / 744; }
.game-card > :is(.card-image, .field-image) { min-height: 0; border-radius: inherit; }
.game-card:has(> :is(.card-image, .field-image)) > :is(.card-name, .card-kind, .card-cost) { display: none; }
.game-card[data-playable="true"] { border-color: #7fe8d7b8; box-shadow: 0 0 0 1px #7fe8d747, 0 3px 8px #07091690; }
.table:not([data-phase="mulligan"]) .seat--you .hand .game-card[data-playable="true"]:not([data-pick="true"], .is-target, .is-drop-hover) {
  --playable-rim: #efd09c;
  border-color: var(--playable-rim);
  box-shadow: 0 0 0 1px var(--playable-rim), 0 3px 8px #07091690;
}
.table:not([data-phase="mulligan"]) .seat--you .hand .game-card[data-playable="true"][data-kind="spell"] { --playable-rim: #91cdec; }
.table:not([data-phase="mulligan"]) .seat--you .hand .game-card[data-playable="false"]:not(:hover, :focus-visible) { filter: brightness(.78) saturate(.88); }
.game-card[data-pick="true"] { border-color: #b5e9ff; box-shadow: 0 0 0 2px #b5e9ff; }
.card-fallback {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 4px;
  color: #e2eaf4;
  font-size: clamp(9px, 1.1vw, 12px);
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}
.game-card:not(:disabled):hover, .game-card[aria-pressed="true"] {
  z-index: 2;
  border-color: var(--aqua);
  box-shadow: 0 0 0 1px var(--aqua), 0 4px 12px #050b15af;
}
.game-card[aria-pressed="true"] { transform: translateY(-3px); }
.game-card[data-exhausted="true"]:has(.card-image) {
  width: calc(var(--face-width) * 1.29);
  aspect-ratio: 1039 / 744;
  filter: saturate(.84) brightness(.85);
}
.game-card[data-exhausted="true"] .card-image {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 71.6%;
  height: 139.7%;
  transform: translate(-50%, -50%) rotate(90deg);
}
.game-card[data-exhausted="true"]:hover { filter: none; }
.game-card[draggable="true"] { cursor: grab; }
.game-card[draggable="true"]:active, .game-card.is-dragging { cursor: grabbing; }
.game-card.is-dragging { opacity: .55; }
.game-card.is-target, .game-card.is-target:hover {
  z-index: 2;
  border-color: #ffd49c;
  box-shadow: 0 0 0 2px #ffd49c, 0 0 12px #f6bc7480;
}
.game-card.is-drop-hover, .game-card.is-drop-hover:hover {
  border-color: #fff0cd;
  box-shadow: 0 0 0 2px #fff0cd, 0 0 15px #f6bc74bd;
}
.table .game-card[data-pick="true"] {
  border-color: #d5fbff;
  box-shadow: 0 0 0 2px #d5fbff, 0 3px 12px #061520a9;
}
.table .game-card[data-group-eligible="true"]:not([data-pick="true"]) {
  outline: 1px dashed var(--aqua);
  outline-offset: 1px;
}
.table .game-card[data-card-activity], .table .deck-stack[data-card-activity] {
  outline: 1px solid color-mix(in srgb, var(--seat-color, var(--aqua)), transparent 19%);
  outline-offset: 1px;
}
.game-card[data-card-activity="draw"] { animation: board-card-drawn .3s ease-out both; }
.game-card:is([data-card-activity="play"], [data-card-activity="move"]) { animation: board-card-placed .22s ease-out both; }
.deck-stack[data-card-activity="draw"] { animation: board-draw-pulse .4s ease-out; }
@keyframes board-card-drawn {
  from { translate: 9px 3px; opacity: .52; }
  to { translate: none; opacity: 1; }
}
@keyframes board-card-placed {
  from { translate: 0 3px; opacity: .66; }
  to { translate: none; opacity: 1; }
}
@keyframes board-draw-pulse {
  from { box-shadow: 0 0 0 4px color-mix(in srgb, var(--seat-color, var(--aqua)), transparent 55%); }
  to { box-shadow: 2px 2px 0 #0e121c, 3px 3px 0 #5c553d; }
}
.game-card.touch-drag-card {
  position: fixed;
  z-index: 12;
  margin: 0;
  opacity: .9;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.card-art {
  position: relative;
  display: block;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #ffffff2a;
  border-radius: 3px;
  background-color: var(--card-dark, #273848);
  background-image:
    linear-gradient(180deg, #0308100a, #09101726),
    var(--card-image, radial-gradient(ellipse at 67% 27%, var(--card-light, #71bfd1), transparent 61%)),
    linear-gradient(137deg, var(--card-dark, #273848), var(--card-light, #71bfd1) 49%, var(--card-dark, #273848) 51%);
  background-size: cover;
  background-position: center;
}
.card-name, .card-kind {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-name { margin-top: 2px; font-size: 9px; line-height: 1.13; font-weight: 750; }
.card-kind { color: #b9c7d9; font-size: 7px; line-height: 1.25; }
.card-cost, .card-might, .card-damage {
  position: absolute;
  top: 4px;
  min-width: 14px;
  padding: 1px 2px;
  border: 1px solid #ffffff55;
  border-radius: 3px;
  color: #fff;
  background: #0d1524d9;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
}
.card-might { right: 4px; }
.game-card:has(.card-image) .card-might { inset: auto 2px 2px auto; }
.card-damage {
  inset: auto auto 2px 2px;
  border-color: #ff8c93;
  color: #fff5f3;
  background: #8d2732;
  font-size: clamp(8px, .74vw, 11px);
  white-space: nowrap;
}
.card-cost { left: 4px; }
.hand .game-card { --face-width: var(--hand-card); }
.hand .card-name { font-size: 10px; }
.hand .card-kind { font-size: 8px; }

.pilot-dock {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 254px);
  grid-template-areas: "hand controls" "feedback feedback";
  min-width: 0;
  align-items: stretch;
  gap: 0 9px;
  padding: 5px 9px max(5px, env(safe-area-inset-bottom));
  border: 1px solid #a7d4c45c;
  border-block-start-color: #d7af6f97;
  border-radius: 5px;
  background: linear-gradient(153deg, #1a3033, #0c1e25 68%);
  box-shadow: 0 6px 22px #060e14aa;
}
.pilot-dock .hand-row { grid-area: hand; padding: 0; border: 0; background: transparent; }
.pilot-dock .hand-label > span:first-child { color: var(--aqua); }
.pilot-dock .draw-summary { grid-area: feedback; margin: 4px 0 0; padding: 4px 6px; border: 0; border-inline-start: 2px solid var(--aqua); border-radius: 0; background: #0b211b80; }
.pilot-dock .hand { padding-inline: 6px; }
.controls {
  grid-area: controls;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: 5px;
  min-width: 0;
  padding: 5px 0 5px 8px;
  border-inline-start: 1px solid #c5a47042;
}
.turn-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 6px;
  color: var(--aqua);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.25;
}
.turn-status small { color: var(--muted); font-size: 10px; white-space: nowrap; }
.turn-status strong { font-family: var(--rift-serif); font-size: 14px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.table[data-turn="opponent"] .turn-status { color: var(--violet); }
.table:is([data-phase="priority"], [data-phase="showdown"], [data-phase="effect"]) .turn-status { color: var(--aqua); }
.table[data-phase="turn-start"] .pilot-dock { border-color: #ebc789ab; background: linear-gradient(130deg, #2b342e, #162c30 70%); }
.table[data-phase="turn-start"] .turn-status { color: var(--rift-gold); }
.table[data-phase="turn-start"] #end-turn { border-color: #ffdb9c; background: var(--rift-gold); color: #242016; }
.table[data-phase="turn-start"] #end-turn:not(:disabled):hover { background: #ffe0a5; }
.selection-actions, .turn-actions { display: flex; min-width: 0; flex-wrap: wrap; align-items: center; gap: 5px; }
.turn-actions .btn--primary { flex: 1 1 auto; }
.selection-actions {
  max-height: min(22dvh, 148px);
  padding: 3px 2px;
  overflow: auto;
  color: var(--muted);
  font-size: 12px;
  scrollbar-width: thin;
}
.selection-actions:empty { display: none; }
.setup-hint { flex: 1 0 100%; margin: 0 0 2px; color: #d1e3ed; font-size: 12px; line-height: 1.35; }
.placement-hint { color: #d1e3ed; font-size: 12px; }
.card-actions-menu { min-width: 0; }
.card-actions-menu > summary.btn { display: list-item; width: max-content; list-style-position: inside; }
.card-actions-menu[open] { flex: 1 0 100%; }
.card-actions-list { display: flex; flex-wrap: wrap; gap: 5px; padding-top: 5px; }
.action-choice { min-width: 0; max-width: 100%; line-height: 1.25; text-align: start; overflow-wrap: anywhere; }
.turn-actions { justify-content: flex-end; }
.btn {
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid #b4c4bf4e;
  border-radius: 5px;
  color: #e7f2f8;
  background: #203339;
  font-size: 12px;
  font-weight: 700;
}
.btn:not(:disabled):hover { border-color: var(--aqua); background: #30535c; }
.btn:disabled { opacity: .55; }
.btn--primary { border-color: #9df3de; color: #122628; background: linear-gradient(140deg, #a5efdc, #76cbb9); }
.btn--primary:not(:disabled):hover { border-color: #c7fff5; color: #0e2024; background: #acfae9; }

.card-dialog {
  width: min(480px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 16px;
  overflow: auto;
  border: 1px solid #b79b6b9b;
  border-radius: 8px;
  color: #edf5f1;
  background: linear-gradient(150deg, #233338, #101e24 63%);
  box-shadow: 0 18px 80px #02080ce3;
}
.card-dialog::backdrop { background: #030a0db8; }
#card-dialog { width: min(646px, calc(100% - 24px)); padding: clamp(14px, 3vw, 25px); }
.placement-dialog h2 { margin: 0 0 8px; }
.placement-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.placement-actions .btn { max-width: 100%; }
.dialog-body { display: grid; grid-template-columns: minmax(92px, auto) minmax(0, 1fr); align-items: start; gap: clamp(12px, 3vw, 22px); }
.dialog-body .game-card { --face-width: clamp(128px, 26vw, 235px); }
#inspected-card .game-card { box-shadow: 0 0 0 1px #ddba7c6e, 0 8px 23px #080f14cc; }
.dialog-details { min-width: 0; overflow-wrap: anywhere; }
.dialog-details :is(h2, p) { margin: 0 0 10px; }
.dialog-details h2 { color: #f5e0b7; font: 700 clamp(21px, 3.4vw, 30px)/1.13 var(--rift-serif); }
.dialog-details p { color: #d3e0db; font-size: 14px; line-height: 1.55; white-space: pre-line; }
#inspected-kind { color: var(--aqua); font-size: 12px; font-weight: 750; }
#inspected-text { white-space: pre-wrap; }
#inspected-text:not(:empty) { padding-block-start: 12px; border-top: 1px solid #ba9d6e50; }
.card-rule-glyph {
  display: inline-block;
  inline-size: 1.08em;
  block-size: 1.08em;
  margin-inline: .08em;
  object-fit: contain;
  vertical-align: -.17em;
}
.card-rule-arrow { margin-inline: .15em; color: #afc5df; font-weight: 800; }
.card-rule-keyword { color: #f8e7c7; font-weight: 750; }
.card-dialog form { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.dialog-close { min-width: 35px; padding: 0; font-size: 20px; }
.card-hover-preview {
  position: fixed;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: min(clamp(232px, 19vw, 280px), calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  gap: 8px;
  color: #f6f6fa;
  pointer-events: none;
}
.card-hover-preview[data-orientation="landscape"] {
  width: min(clamp(282px, 25vw, 350px), calc(100vw - 16px));
}
.card-hover-art {
  flex: 0 1 auto;
  min-height: 0;
  aspect-ratio: 744 / 1039;
  max-height: 59dvh;
  filter: drop-shadow(0 10px 16px #04070bb0);
}
.card-hover-preview[data-orientation="landscape"] .card-hover-art { aspect-ratio: 1039 / 744; }
.card-hover-art:has(.card-fallback) { display: none; }
.card-hover-art .hover-image {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: contain;
}
.card-hover-info {
  flex: 0 0 auto;
  max-height: 67dvh;
  padding: 13px 14px;
  overflow: hidden;
  overflow-wrap: anywhere;
  border: 1px solid #4d56646b;
  border-radius: 10px;
  background: #16191f;
  box-shadow: 0 8px 18px #04070b70;
  font-size: 13px;
  line-height: 1.45;
}
.card-hover-name { display: block; font-size: 16px; line-height: 1.2; }
.card-hover-meta { display: flex; align-items: center; gap: 5px; margin-top: 3px; color: #b1b9c7; font-size: 12px; }
.card-hover-meta .card-rule-glyph { flex: none; margin: 0; }
.card-hover-neutral { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #a7adba; }
.card-hover-rules { margin: 9px 0 0; white-space: pre-wrap; }
.card-hover-reason { margin: 9px 0 0; color: #ffd2a1; font-size: 12px; }

.deck-setup {
  width: min(880px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  padding: clamp(16px, 3vw, 28px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #b89b6b91;
  border-radius: 9px;
  color: #edf4fa;
  background: linear-gradient(140deg, #243636, #122227 54%);
  box-shadow: 0 24px 80px #020611cc;
}
.deck-setup::backdrop { background: #060d11c7; }
.setup-heading { margin-bottom: 18px; }
.setup-heading h1 { margin: 0; color: #f7e0b2; font: 700 clamp(24px, 4.5vw, 34px)/1.12 var(--rift-serif); letter-spacing: -.026em; }
.setup-heading p { margin: 7px 0 0; max-width: 65ch; color: var(--muted); font-size: 13px; line-height: 1.45; }
.setup-match-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid #c9a9704d;
  border-radius: 6px;
  background: #112024b0;
}
.setup-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.setup-seat {
  --seat-accent: var(--aqua);
  display: grid;
  min-width: 0;
  margin: 0;
  padding: 14px;
  gap: 9px;
  border: 1px solid color-mix(in srgb, var(--seat-accent), transparent 66%);
  border-radius: 6px;
  background: color-mix(in srgb, var(--seat-accent), #0e1d22 94%);
}
.setup-seat + .setup-seat { --seat-accent: var(--violet); }
.setup-seat legend { padding: 0 6px; color: var(--seat-accent); font: 700 16px/1.2 var(--rift-serif); }
:is(.setup-seat, .setup-match-options) label { display: grid; min-width: 0; gap: 6px; font-size: 12px; font-weight: 700; }
.setup-match-options label { align-content: start; }
:is(.setup-seat, .setup-match-options) :is(select, textarea) {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #a3c4c06a;
  border-radius: 5px;
  color: #ecf4fb;
  background: #0d1c21;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}
:is(.setup-seat, .setup-match-options) :is(select, textarea):focus-visible { outline: 2px solid var(--seat-accent, var(--aqua)); outline-offset: 2px; }
:is(.setup-seat, .setup-match-options) select { min-height: 41px; }
.setup-seat textarea { min-height: 152px; resize: vertical; font-family: ui-monospace, Consolas, monospace; }
.setup-seat textarea::placeholder { color: #91a3b9; }
.setup-seat-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 7px 10px; }
.setup-seat .setup-file { flex: 1 1 152px; min-width: 0; gap: 3px; color: #c3d4e5; font-size: 11px; }
.setup-file input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0;
  overflow: hidden;
  color: var(--muted);
  font: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.setup-file input::file-selector-button {
  min-height: 34px;
  margin-inline-end: 6px;
  padding: 5px 8px;
  border: 1px solid #758eaa48;
  border-radius: 6px;
  color: #e7f2f8;
  background: #243345;
  font: inherit;
  cursor: pointer;
}
.setup-file input:focus-visible { outline: 2px solid var(--seat-accent); outline-offset: 2px; }
.setup-summary { margin: 0; color: #c3d4e5; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.setup-summary:empty, .setup-error:empty { display: none; }
.setup-error {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #b85d6a7a;
  border-radius: 6px;
  color: #ffd1d6;
  background: #321d2a;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
:is(ul, ol).setup-error, .setup-error :is(ul, ol) { padding-left: 25px; }
.setup-supported { margin-top: 13px; color: #c8d5e4; font-size: 12px; line-height: 1.5; }
.setup-supported summary { width: fit-content; padding-block: 5px; font-weight: 700; }
.setup-supported :is(pre, code) { color: #e5eafa; font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.setup-supported pre { margin: 6px 0 0; padding: 8px 10px; border-radius: 5px; background: #0e1624; white-space: pre-wrap; }
.setup-card-list { display: flex; flex-wrap: wrap; gap: 5px; }
.setup-card-list span {
  padding: 3px 7px;
  border: 1px solid #647eaa53;
  border-radius: 5px;
  background: #111927;
  overflow-wrap: anywhere;
}
.setup-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 16px; }
.setup-actions .btn { min-height: 40px; padding-inline: 14px; }
.setup-status { flex: 1 1 140px; min-width: 0; margin: 0; color: #c3d4e5; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.setup-status:empty { display: none; }
.setup-status a { color: var(--aqua); }

.game-setup { width: min(740px, calc(100% - 28px)); }
.dice-board { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dice-seat {
  display: grid;
  min-width: 0;
  place-items: center;
  gap: 8px;
  padding: 12px 10px;
  border: 1px solid #647eaa53;
  border-radius: 9px;
  color: #d2deed;
  background: #101827a8;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
}
.die {
  display: grid;
  width: clamp(44px, 14vw, 66px);
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid #7fe8d779;
  border-radius: 11px;
  color: var(--aqua);
  background: linear-gradient(150deg, #2b4a51, #152a39);
  font-size: clamp(24px, 6.5vw, 34px);
  font-weight: 780;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  box-shadow: inset 0 1px 0 #d6ffff27, 0 3px 7px #080c16a8;
}
.dice-seat + .dice-seat .die { border-color: #d5b2f579; color: var(--violet); background: linear-gradient(150deg, #473b59, #292337); }
.die[data-rolling="true"] { animation: dice-roll .35s ease-out; }
@keyframes dice-roll {
  from { transform: translateY(-5px) rotate(-12deg); }
  60% { transform: translateY(1px) rotate(4deg); }
  to { transform: none; }
}
.initiative-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.initiative-actions .btn { min-height: 40px; }
.field-picks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  gap: 9px;
  margin-top: 12px;
}
.field-pick {
  display: grid;
  align-content: start;
  min-width: 0;
  gap: 7px;
  padding: 7px;
  border: 1px solid #647eaa75;
  border-radius: 8px;
  color: #edf4fa;
  background: #101827;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  text-align: left;
  overflow-wrap: anywhere;
}
.field-pick img { display: block; width: 100%; aspect-ratio: 1039 / 744; border-radius: 4px; object-fit: contain; background: #0d131e; }
.field-pick:is(:hover, [aria-pressed="true"]) { border-color: var(--aqua); background: #1a3440; }
.series-score {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  margin: 8px 0 0;
  color: #cedce9;
  font-size: 12px;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.sidebar .series-score { margin: -7px 0 9px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 176px minmax(0, 1fr); }
  .sidebar { padding: 12px 9px; }
  .table { padding: 6px; }
  .midboard { grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(56px, .21fr); }
  .field-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .field-emblem { min-height: 45px; padding: 5px; }
  .pilot-dock { grid-template-columns: minmax(0, 1fr) minmax(156px, 192px); }
}

@media (min-width: 701px) and (max-height: 850px) {
  :root {
    --mini-card: clamp(42px, 4vw, 54px);
    --hand-card: clamp(56px, 5.5vw, 74px);
  }
  .table { grid-template-rows: auto minmax(170px, 1fr) auto auto; padding: 6px; }
  .hand-row { min-height: 56px; }
  .card-back { max-height: 55px; }
  .resource-row { min-height: 49px; }
  .rune { width: min(2.8vw, 29px); }
}

@media (min-width: 701px) and (851px <= height <= 950px) {
  :root {
    --mini-card: clamp(48px, 4.5vw, 72px);
    --hand-card: clamp(63px, 5.9vw, 92px);
  }
}

@media (max-width: 700px) {
  :root { --mini-card: clamp(43px, 10vw, 59px); --hand-card: clamp(54px, 14vw, 79px); }
  .app { display: block; }
  .sidebar {
    position: static; display: grid; grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand format" "players players" "notice notice" "history history" "footer footer";
    gap: 3px 6px; height: auto; padding: 8px; border-right: 0; border-bottom: 1px solid #bd9a6359;
  }
  .sidebar .brand { grid-area: brand; gap: 6px; font-size: 16px; }
  .sidebar .brand > :first-child { flex-basis: 25px; min-height: 25px; border-radius: 5px; }
  .sidebar .brand small { font-size: 8px; }
  .scoreboard { grid-area: players; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-format { grid-area: format; align-self: center; text-align: right; }
  .room-caption { justify-content: end; margin: 0; font-size: 10px; }
  .sidebar .series-score { margin: 0; }
  .sidebar .match-notice { grid-area: notice; margin: 0; font-size: 9px; }
  .history { grid-area: history; margin-top: 2px; }
  .history summary { padding: 5px 0 0; }
  .log { max-height: 105px; margin-top: 5px; }
  .log li { padding: 5px 2px; }
  .sidebar-footer { grid-area: footer; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 2px 0 0; padding: 0; }
  .sidebar-footer .btn { min-height: 33px; }
  .table { grid-template-rows: auto auto auto auto; min-height: auto; }
  .midboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .midboard > .chain:not(:has(#chain > *)) { display: none; }
  .chain { grid-column: 1 / -1; }
  .chain .zone-cards:empty { min-height: 3px; }
  .chain-empty { inset: 9px 10px auto auto; display: block; transform: none; }
  .chain-empty span { margin-right: 4px; font-size: 10px; }
  .battlefield {
    grid-template-areas: "field-head" "field-art" "showdown" "field-lanes";
    grid-template-rows: auto auto auto minmax(0, 1fr);
    padding: 6px;
  }
  .battlefield > .zone-label { min-height: 30px; gap: 1px 4px; }
  .field-layout { display: contents; }
  .field-emblem { grid-area: field-art; }
  .field-emblem:has(.field-image) { width: min(100%, 126px); justify-self: center; }
  .field-units { grid-area: field-lanes; gap: 3px; }
  .field-units .zone-cards:empty { min-height: 31px; }
  .field-showdown { grid-template-columns: minmax(0, 1fr); scroll-margin-block-end: 166px; }
  .showdown-actions, .showdown-actions--choices { grid-area: auto; justify-content: start; }
  .showdown-actions .btn { flex: 1 1 auto; min-height: 36px; }
  .destination-cue { min-height: 36px; }
  .hand-row { grid-template-columns: minmax(38px, auto) minmax(0, 1fr) auto; gap: 4px; padding: 4px; }
  .hand-label { max-width: 56px; }
  .pilot-dock { grid-template-columns: minmax(0, 1fr); grid-template-areas: "hand" "controls" "feedback"; padding: 4px 6px max(4px, env(safe-area-inset-bottom)); }
  .pilot-dock .hand { padding-block: 3px; }
  .pilot-dock .draw-summary { margin-top: 2px; font-size: 10px; }
  .controls { grid-template-columns: minmax(0, 1fr) auto; gap: 3px 6px; padding: 3px 0 0; border-inline-start: 0; border-top: 1px solid #b4ddcc33; }
  .controls .turn-status { grid-area: 1 / 1; }
  .controls .turn-actions { grid-area: 1 / 2; justify-content: end; }
  .controls .selection-actions { grid-column: 1 / -1; }
  .turn-actions .btn { min-height: 38px; }
  #hide-hand { min-height: 32px; }
  .resource-row { gap: 5px; padding: 4px; }
  .hand .card-name { font-size: 8px; }
  .hand .card-kind { font-size: 7px; }
  .points { min-width: 53px; font-size: 18px; }
  .point-button { width: 20px; height: 20px; }
  .resource-count { padding: 4px; }
  .deck-stack { width: 32px; min-height: 38px; }
  .deck-setup { width: calc(100% - 16px); max-height: calc(100dvh - 16px); }
  .setup-options { grid-template-columns: 1fr; }
  .setup-seat { padding: 12px; }
  :is(.setup-seat, .setup-match-options) :is(select, textarea) { font-size: 16px; }
  .setup-seat textarea { min-height: 108px; }
  .setup-actions { position: sticky; bottom: -16px; padding: 7px 0; background: #122227; }
  .game-setup { width: calc(100% - 16px); }
  .setup-match-options { gap: 8px; }
  .field-picks { grid-template-columns: repeat(auto-fit, minmax(min(104px, 100%), 1fr)); }
}

@media (max-width: 480px) {
  #card-dialog .dialog-body { grid-template-columns: minmax(0, 1fr); }
  #inspected-card { justify-self: center; }
  #inspected-card .game-card { --face-width: min(52vw, 192px); }
  .practice-home-header { min-height: 64px; }
  .practice-home-brand > strong { font-size: 20px; }
  .practice-home-copy h1 { font-size: clamp(2.55rem, 10vw, 3.4rem); }
}

@media (any-pointer: coarse) {
  .table :is(button, summary) { touch-action: manipulation; }
  .game-card[data-pick="true"][draggable="true"] { touch-action: none; }
}

@media (prefers-reduced-motion: reduce) {
  .game-card, .rune, .zone { transition: none; }
  .game-card[data-card-activity], .deck-stack[data-card-activity] { animation: none; }
  .die[data-rolling="true"] { animation: none; }
}
