:root {
  color-scheme: dark;
  --bg: #0f1114;
  --surface: #171b20;
  --surface-2: #20262d;
  --surface-3: #29313a;
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.25);
  --text: #f4f0e8;
  --muted: #aeb5be;
  --gold: #d8b764;
  --green: #81c784;
  --red: #df746b;
  --blue: #75abd5;
  --card: #eee3c8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 18% 18%, rgba(117, 171, 213, 0.16), transparent 26%),
    radial-gradient(circle at 82% 10%, rgba(216, 183, 100, 0.16), transparent 28%),
    linear-gradient(135deg, #111417, #1b2026 45%, #0d0f12);
}

button,
input,
select {
  font: inherit;
}

button {
  max-width: 100%;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 14px;
  color: var(--text);
  background: #252c35;
  cursor: pointer;
}

button:hover {
  border-color: var(--gold);
}

button:disabled,
button:disabled:hover {
  opacity: 0.55;
  border-color: var(--line);
  cursor: not-allowed;
}

input,
select {
  min-width: 0;
  max-width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--text);
  background: #101419;
}

.hidden {
  display: none !important;
}

.app {
  min-height: 100vh;
}

.loading-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-landing {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(320px, 420px);
  gap: 28px;
  align-items: center;
}

.auth-brand {
  display: grid;
  gap: 18px;
}

.auth-brand p:last-child {
  max-width: 560px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.auth-card {
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: rgba(23, 27, 32, 0.9);
  box-shadow: 0 24px 52px rgba(0, 0, 0, 0.32);
}

.auth-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.auth-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-mode-toggle button.active {
  border-color: var(--gold);
  background: rgba(216, 183, 100, 0.16);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-form input,
.auth-form button {
  width: 100%;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup.large {
  align-self: end;
}

.brand-lockup strong {
  display: block;
  font-size: 17px;
}

.brand-lockup small {
  display: block;
  color: var(--muted);
}

.vault-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(216, 183, 100, 0.9);
  border-radius: 50%;
  background:
    conic-gradient(from 90deg, rgba(216, 183, 100, 0.2), rgba(117, 171, 213, 0.24), rgba(129, 199, 132, 0.2), rgba(216, 183, 100, 0.2)),
    #15191e;
  box-shadow: 0 0 34px rgba(216, 183, 100, 0.18);
}

.vault-mark span {
  width: 22px;
  height: 28px;
  border: 2px solid var(--gold);
  border-top: 0;
  border-radius: 0 0 5px 5px;
  position: relative;
}

.vault-mark span::before {
  content: "";
  position: absolute;
  left: 3px;
  top: -14px;
  width: 12px;
  height: 14px;
  border: 2px solid var(--gold);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
}

.large .vault-mark {
  width: 82px;
  height: 82px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 42px;
}

h2 {
  margin-bottom: 0;
  font-size: 28px;
}

h3 {
  margin-bottom: 10px;
  font-size: 18px;
}

.loading-panel {
  width: min(420px, calc(100vw - 32px));
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(15, 18, 22, 0.76);
}

.loading-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.loading-bar span {
  display: block;
  width: 22%;
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
  transition: width 250ms ease;
}

.loading-panel p {
  margin: 12px 0 0;
  color: var(--muted);
}

.home-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
}

.sidebar {
  padding: 20px;
  border-right: 1px solid var(--line);
  background: rgba(12, 15, 18, 0.82);
}

.nav-tabs {
  display: grid;
  gap: 8px;
  margin: 28px 0;
}

.nav-button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
}

.nav-button.active {
  border-color: var(--gold);
  background: rgba(216, 183, 100, 0.12);
}

.ai-view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.ai-view-tabs button {
  background: transparent;
}

.ai-view-tabs button.active {
  border-color: var(--gold);
  background: rgba(216, 183, 100, 0.12);
}

.sync-card,
.profile-hero,
.metric-panel,
.deck-list-panel,
.deck-editor-panel,
.card-browser-panel,
.play-panel,
.admin-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 32, 0.88);
}

.sync-card {
  padding: 14px;
}

.sync-card span,
.metric-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.sync-card strong,
.metric-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.sync-card p {
  color: var(--muted);
  line-height: 1.4;
}

.sync-card button {
  width: 100%;
}

.content {
  min-width: 0;
  padding: 20px;
}

.content-header,
.match-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.player-input {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) repeat(3, minmax(120px, 1fr));
  gap: 14px;
}

.profile-hero {
  display: flex;
  gap: 18px;
  padding: 22px;
}

.profile-hero p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  max-width: 520px;
}

.profile-avatar {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 8px;
  font-weight: 900;
  font-size: 24px;
  background: rgba(216, 183, 100, 0.14);
}

.metric-panel {
  padding: 18px;
}

.account-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(23, 27, 32, 0.88);
}

.account-panel p {
  color: var(--muted);
}

.account-panel button {
  min-width: 120px;
}

.deck-builder {
  display: grid;
  grid-template-columns: minmax(170px, 210px) minmax(0, 1fr) minmax(260px, 320px);
  gap: 14px;
  min-height: calc(100vh - 130px);
}

.deck-list-panel,
.deck-editor-panel,
.card-browser-panel,
.play-panel,
.admin-panel {
  min-width: 0;
  padding: 14px;
}

.panel-header,
.deck-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-header h3 {
  margin: 0;
}

.deck-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.search-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #07090b;
}

.search-shell input,
.search-shell button {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.search-shell input {
  height: 40px;
  font-style: italic;
}

.search-shell button {
  height: 40px;
  color: var(--muted);
  font-weight: 900;
}

.color-filter {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.mana-filter {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  color: #14171a;
  font-weight: 900;
  text-align: center;
  border-color: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 -3px 7px rgba(0, 0, 0, 0.24);
}

.mana-filter.white {
  background: #f2ead0;
}

.mana-filter.blue {
  background: #7fb2d9;
}

.mana-filter.black {
  color: #f3efe5;
  background: #2e3037;
}

.mana-filter.red {
  background: #dc796f;
}

.mana-filter.green {
  background: #8bcf86;
}

.mana-filter.colorless {
  background: #c4c0b4;
}

.mana-filter.active {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.filter-summary {
  min-height: 18px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.advanced-filters {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background: rgba(4, 7, 9, 0.62);
}

.filter-section {
  display: grid;
  gap: 7px;
  margin-bottom: 10px;
}

.filter-section span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.filter-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.filter-section button,
.cmc-filter button {
  height: 32px;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
}

.cmc-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cmc-filter button {
  width: 38px;
  border-radius: 50%;
  padding: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
}

.filter-section button.active,
.cmc-filter button.active {
  border-color: var(--gold);
  background: rgba(216, 183, 100, 0.16);
}

.deck-list,
.deck-cards,
.card-results {
  display: grid;
  gap: 8px;
  align-content: start;
  overflow: auto;
}

.deck-list,
.deck-cards {
  max-height: calc(100vh - 210px);
}

.card-results {
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  max-height: calc(100vh - 232px);
}

.deck-row,
.deck-card-row,
.search-row {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.04);
}

.library-card {
  min-height: 214px;
  display: grid;
  grid-template-rows: 142px minmax(52px, auto) 32px;
  border: 1px solid rgba(0, 0, 0, 0.55);
  border-radius: 8px;
  overflow: hidden;
  color: #17120d;
  background: var(--card);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.26);
}

.library-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
}

.library-card-art {
  background:
    linear-gradient(135deg, rgba(117, 171, 213, 0.76), rgba(129, 199, 132, 0.54)),
    #6f7468;
  background-size: cover;
  background-position: center;
}

.library-card-body {
  padding: 7px;
}

.library-card strong,
.modal-card strong {
  display: block;
  font-size: 12px;
  line-height: 1.16;
}

.library-card span,
.modal-card span {
  display: block;
  margin-top: 3px;
  color: #584c39;
  font-size: 10px;
  font-weight: 700;
}

.library-card button {
  height: 32px;
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 0;
  color: #17120d;
  background: rgba(216, 183, 100, 0.34);
}

.deck-row {
  cursor: pointer;
}

.deck-row.active {
  border-color: var(--gold);
}

.deck-row strong,
.deck-card-row strong,
.search-row strong {
  display: block;
}

.deck-row span,
.deck-card-row span,
.search-row span {
  color: var(--muted);
  font-size: 12px;
}

.deck-editor-header input {
  flex: 1 1 180px;
}

.deck-actions {
  display: flex;
  flex: 1 1 auto;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.deck-actions button {
  flex: 1 1 82px;
}

.deck-validity {
  margin-bottom: 10px;
  color: var(--muted);
}

.deck-validity.valid {
  color: #bde8b6;
}

.deck-zone-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.deck-zone-toggle button.active {
  border-color: var(--gold);
  background: rgba(216, 183, 100, 0.16);
}

#expand-deck-button {
  width: 100%;
  margin-bottom: 10px;
}

.arena-deck-panel .deck-cards {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.search-row p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.play-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.play-panel {
  min-height: 180px;
}

.play-panel p {
  color: var(--muted);
  line-height: 1.45;
}

.mode-panel button {
  width: 100%;
  margin-top: 22px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 14px;
  align-items: start;
}

.admin-panel {
  display: grid;
  gap: 12px;
}

.admin-input {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-actions button {
  flex: 1 1 150px;
}

.admin-filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.admin-filter-row label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-filter-row select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  color: var(--text);
  background: rgba(7, 12, 18, 0.76);
}

.training-progress {
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.training-progress > div {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #5ba9db, #67e8f9);
  transition: width 180ms ease;
}

.admin-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 250px);
  overflow: auto;
}

.admin-report-review {
  display: grid;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h3 {
  margin: 0;
  font-size: 14px;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.admin-row strong,
.admin-row span {
  display: block;
}

.admin-row span {
  color: var(--muted);
  font-size: 12px;
}

.admin-row ul {
  grid-column: 1 / -1;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.admin-status {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  text-transform: uppercase;
  font-size: 11px !important;
  font-weight: 900;
}

.admin-row.supported .admin-status {
  color: #c8efc2;
  border-color: rgba(129, 199, 132, 0.55);
}

.admin-row.unsupported .admin-status {
  color: #f3d892;
  border-color: rgba(216, 183, 100, 0.55);
}

.admin-row.invalid .admin-status {
  color: #f2b4ae;
  border-color: rgba(223, 116, 107, 0.55);
}

.admin-row.bug .admin-status {
  color: #f2b4ae;
  border-color: rgba(223, 116, 107, 0.55);
}

.admin-row.bug.critical {
  border-color: rgba(223, 116, 107, 0.5);
  background: rgba(223, 116, 107, 0.08);
}

.admin-row.bug.selected {
  border-color: rgba(242, 180, 174, 0.75);
  background: rgba(223, 116, 107, 0.12);
}

.admin-row.improvement .admin-status {
  color: #9ed8ff;
  border-color: rgba(91, 169, 219, 0.55);
}

.admin-row.improvement.critical {
  border-color: rgba(91, 169, 219, 0.5);
  background: rgba(91, 169, 219, 0.08);
}

.admin-row.learning .admin-status {
  color: #c7d2fe;
  border-color: rgba(129, 140, 248, 0.55);
}

.admin-row.learning.finished {
  border-color: rgba(103, 232, 249, 0.35);
}

.admin-row.learning.bounded {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.07);
}

.admin-row.learning.selected {
  border-color: rgba(103, 232, 249, 0.7);
  background: rgba(103, 232, 249, 0.08);
}

.admin-row.issue .admin-status {
  color: #f9d38b;
  border-color: rgba(245, 158, 11, 0.55);
}

.admin-row.issue.high {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.07);
}

.admin-output {
  min-height: 320px;
  max-height: calc(100vh - 330px);
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: #dbe4ed;
  background: rgba(4, 7, 9, 0.72);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.admin-output.compact {
  min-height: 180px;
  max-height: 360px;
}

.match-shell {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) 176px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(216, 183, 100, 0.07), transparent 58%),
    #090b0d;
}

.match-topbar {
  margin: 0;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #101419;
}

.match-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.match-top-actions button {
  white-space: nowrap;
}

#concede-button {
  border-color: rgba(223, 116, 107, 0.55);
  color: #f2b4ae;
}

#concede-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.match-intro {
  position: absolute;
  inset: 58px 0 176px;
  z-index: 12;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 16px;
  padding: clamp(14px, 2vw, 24px);
  background:
    linear-gradient(180deg, rgba(13, 16, 19, 0.94), rgba(13, 16, 19, 0.86)),
    linear-gradient(90deg, rgba(216, 183, 100, 0.08), rgba(117, 171, 213, 0.08));
  backdrop-filter: blur(6px);
}

.issue-panel textarea {
  width: 100%;
  min-height: min(34vh, 280px);
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  background: #07090b;
  font: 14px/1.45 inherit;
}

.issue-panel {
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1fr) auto auto;
  gap: 12px;
  width: min(680px, 94vw);
  max-height: min(720px, 92vh);
}

.issue-panel #submit-issue-button {
  width: 100%;
}

.match-result-banner {
  position: absolute;
  z-index: 18;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  border: 1px solid rgba(103, 232, 249, 0.4);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(10, 14, 18, 0.94);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.34);
}

.match-intro-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.match-intro.peek-battlefield {
  pointer-events: none;
  background: transparent;
  backdrop-filter: none;
}

.match-intro.peek-battlefield .match-intro-top {
  pointer-events: auto;
}

.match-intro.peek-battlefield .match-intro-copy,
.match-intro.peek-battlefield .opening-hand,
.match-intro.peek-battlefield .mulligan-actions {
  display: none;
}

.match-intro-top strong {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.match-intro-top button {
  height: 38px;
  border-color: var(--line-strong);
  border-radius: 7px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.04);
}

.match-intro-copy {
  align-self: start;
  text-align: center;
}

.match-intro-copy h2 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1.05;
}

.match-intro-copy p {
  margin: 0 auto;
  max-width: 720px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.opening-hand {
  align-self: center;
  display: grid;
  grid-template-columns: repeat(7, minmax(96px, 152px));
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1vw, 14px);
  min-width: 0;
  overflow-x: auto;
  padding: 12px;
}

.opening-card {
  position: relative;
  aspect-ratio: 0.715;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.56);
  border-radius: 8px;
  background: #090b0e;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.34);
}

.opening-card strong {
  display: none;
}

.opening-card.bottoming-card {
  cursor: pointer;
  outline: 2px solid rgba(216, 183, 100, 0.86);
  outline-offset: 3px;
}

.opening-card.bottoming-card:hover {
  transform: translateY(-5px);
  border-color: var(--gold);
}

.opening-card.selected-bottom-card {
  outline: 4px solid var(--blue);
  outline-offset: 4px;
  transform: translateY(-8px);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.22),
    0 18px 34px rgba(117, 171, 213, 0.34);
}

.mulligan-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.mulligan-actions button {
  min-width: 148px;
  height: 42px;
  border-radius: 7px;
  font-size: 15px;
  font-weight: 800;
}

#mulligan-button {
  border-color: rgba(117, 171, 213, 0.58);
  background: rgba(117, 171, 213, 0.18);
  box-shadow: none;
}

#keep-hand-button {
  border-color: rgba(216, 183, 100, 0.72);
  background: rgba(216, 183, 100, 0.2);
  box-shadow: none;
}

.status-pill {
  min-width: 86px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
}

.status-pill.online {
  color: #d8f6d0;
  border-color: rgba(129, 199, 132, 0.6);
}

.game-table {
  display: grid;
  grid-template-columns: minmax(68px, 86px) minmax(0, 1fr) minmax(132px, 170px);
  min-height: 0;
  height: calc(100vh - 234px);
  background: #0c0f12;
}

.left-rail,
.right-rail {
  padding: 10px 8px;
  border-right: 1px solid var(--line);
  background: rgba(7, 9, 11, 0.82);
}

.right-rail {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.zone-counter,
.zone-box {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
  background: rgba(23, 27, 32, 0.54);
}

.zone-counter span,
.zone-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.zone-counter strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.icon-action {
  width: 100%;
  margin-bottom: 7px;
}

.next-action {
  border-color: rgba(216, 183, 100, 0.72);
  color: var(--text);
  background: rgba(216, 183, 100, 0.16);
  box-shadow: none;
}

.playmat {
  position: relative;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) 46px minmax(0, 1fr) 48px;
  gap: 8px;
  width: min(100%, 1380px);
  height: calc(100vh - 252px);
  min-height: 560px;
  justify-self: center;
  align-self: center;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(216, 183, 100, 0.34) calc(50% - 1px), rgba(216, 183, 100, 0.34) calc(50% + 1px), transparent calc(50% + 1px)),
    radial-gradient(ellipse at 50% 50%, rgba(117, 171, 213, 0.08), transparent 34%),
    #11181a;
  box-shadow: inset 0 0 42px rgba(0, 0, 0, 0.36);
}

.playmat::before {
  content: "";
  position: absolute;
  inset: 50% 14px auto;
  height: 1px;
  background: rgba(255, 255, 255, 0.13);
  pointer-events: none;
}

.player-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(10, 12, 15, 0.62);
}

.player-name {
  font-size: 18px;
  font-weight: 750;
}

.player-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat {
  min-width: 52px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.stat strong {
  display: block;
  color: var(--text);
}

.battlefield-row {
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.026);
}

.opponent-zone {
  align-content: end;
}

.player-zone {
  align-content: start;
}

.zone-label {
  margin-bottom: 6px;
}

.zone {
  min-height: 0;
  height: calc(100% - 20px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  overflow-x: auto;
}

.zone.drop-ready,
.player-zone.drop-ready {
  outline: 2px solid var(--gold);
  outline-offset: -3px;
  background: rgba(216, 183, 100, 0.08);
}

.battlefield-lane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.battlefield-lane > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.battlefield-lane-cards {
  min-width: 0;
  min-height: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
}

.center-line {
  display: grid;
  grid-template-columns: minmax(130px, 190px) minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
}

.stack-zone,
.target-hint {
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  padding: 8px;
  background: rgba(5, 7, 9, 0.42);
}

.target-hint {
  display: flex;
  align-items: center;
  color: var(--muted);
  line-height: 1.35;
}

.mini-zone {
  display: grid;
  gap: 6px;
  max-height: 108px;
  overflow: auto;
}

.side-zone {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.event-panel {
  min-height: 0;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: rgba(5, 7, 9, 0.48);
}

.event-log {
  display: grid;
  gap: 5px;
  max-height: 168px;
  overflow: auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.event-log div:first-child {
  color: var(--text);
  font-weight: 750;
}

.zone-icon-button {
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 900;
}

.zone-icon-button span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-align: left;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.zone-icon-button strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  min-height: 22px;
  margin-left: 6px;
  border-radius: 999px;
  color: #10151a;
  background: var(--gold);
}

.zone-icon-button.active-stack {
  border-color: rgba(246, 207, 132, 0.7);
  background: rgba(246, 207, 132, 0.14);
}

.stack-panel {
  grid-template-columns: 1fr;
}

.stack-button {
  width: 100%;
}

.mini-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.hand-dock {
  border-top: 1px solid var(--line);
  padding: 8px 18px 12px;
  background: rgba(9, 10, 12, 0.94);
}

.hand {
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-height: 164px;
  overflow-x: auto;
  justify-content: center;
}

.hand,
.zone,
.deck-list,
.deck-cards,
.card-results,
.mini-zone,
.deck-modal-cards {
  scrollbar-width: thin;
}

.card {
  position: relative;
  flex: 0 0 112px;
  width: 112px;
  aspect-ratio: 0.715;
  border: 1px solid rgba(0, 0, 0, 0.7);
  border-radius: 7px;
  padding: 0;
  background: #090b0e;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.32);
  overflow: hidden;
}

.hand-card {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.hand-card.not-playable-card {
  cursor: default;
  filter: grayscale(0.45) brightness(0.74);
  opacity: 0.62;
}

.hand-card.playable-card {
  border-color: rgba(216, 183, 100, 0.82);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.32), 0 0 0 1px rgba(216, 183, 100, 0.36);
}

.hand-card:active {
  cursor: grabbing;
}

.dragging-source {
  opacity: 0.42;
}

.drag-ghost {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  opacity: 0.92;
  transform: rotate(-2deg);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.42);
}

.card:hover {
  transform: translateY(-5px);
  border-color: var(--gold);
}

.card.selected {
  outline: 3px solid var(--gold);
}

.card.targetable {
  outline: 3px solid var(--red);
}

.card.actionable-card {
  border-color: rgba(117, 171, 213, 0.9);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.32), 0 0 0 1px rgba(117, 171, 213, 0.36);
}

.card.tapped {
  transform: rotate(90deg);
  opacity: 0.78;
  transform-origin: 50% 50%;
}

.own-permanent:not(.tapped) {
  cursor: pointer;
}

.card.summoning-sick {
  border-color: rgba(117, 171, 213, 0.85);
}

.card.summoning-sick::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(117, 171, 213, 0.18), transparent 42%);
}

.status-chip {
  position: absolute;
  left: 5px;
  bottom: 5px;
  z-index: 2;
  border: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 4px;
  padding: 2px 5px;
  color: #111;
  background: rgba(245, 239, 220, 0.92);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.attack-chip {
  left: auto;
  right: 5px;
  color: #f6efe0;
  background: rgba(172, 74, 55, 0.94);
}

.keyword-chip-row {
  position: absolute;
  left: 5px;
  right: 5px;
  top: 5px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  pointer-events: none;
}

.keyword-chip {
  position: static;
  color: #f6efe0;
  background: rgba(45, 67, 84, 0.95);
  border-color: rgba(117, 171, 213, 0.75);
  font-size: 9px;
}

.card-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.68);
}

.card-preview-panel {
  position: relative;
  width: min(500px, calc(100vw - 48px), calc((100vh - 48px) * 0.715));
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border-radius: 18px;
}

.card-preview-panel img,
.card-preview-missing {
  display: block;
  width: 100%;
  max-height: calc(100vh - 48px);
  object-fit: contain;
  border-radius: 18px;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.62);
}

.card-preview-panel .preview-readable {
  left: 7%;
  right: 7%;
  bottom: 8%;
  gap: 7px;
  min-height: 31%;
  max-height: 48%;
  padding: 16px;
  border-radius: 8px;
}

.card-preview-panel .preview-readable strong {
  font-size: 23px;
  line-height: 1.1;
}

.card-preview-panel .preview-readable span,
.card-preview-panel .preview-readable em {
  font-size: 15px;
}

.card-preview-panel .preview-readable p {
  font-size: 17px;
  line-height: 1.35;
  -webkit-line-clamp: 8;
}

.card-preview-missing {
  min-height: 560px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: #11161b;
}

.card-preview-close {
  position: absolute;
  top: -12px;
  right: -12px;
  z-index: 2;
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--text);
  background: #151a20;
}

.pending-choice-overlay {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 8, 11, 0.82);
  backdrop-filter: blur(10px);
}

.pending-choice-panel {
  width: min(980px, 100%);
  max-height: min(760px, 92vh);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
  padding: 18px;
  border: 1px solid rgba(246, 207, 132, 0.28);
  border-radius: 8px;
  background: rgba(14, 18, 21, 0.96);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.pending-choice-header h3 {
  margin: 2px 0 0;
  font-size: 1.1rem;
}

.pending-choice-header p:not(.eyebrow) {
  margin: 6px 0 0;
  color: var(--muted);
}

.pending-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

.pending-choice-panel.visual-card-choice {
  width: min(1100px, 100%);
  height: min(860px, 94vh);
  max-height: min(900px, 94vh);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.visual-card-choice .pending-choice-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 260px));
  justify-content: center;
  align-items: start;
}

.pending-choice-card {
  display: grid;
  height: auto;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.pending-choice-card:hover {
  border-color: rgba(246, 207, 132, 0.72);
  background: rgba(246, 207, 132, 0.12);
}

.pending-choice-card.selected-choice {
  border-color: rgba(110, 215, 176, 0.9);
  box-shadow: 0 0 0 2px rgba(110, 215, 176, 0.22);
}

.pending-choice-card.disabled-choice {
  opacity: 0.42;
  cursor: not-allowed;
}

.pending-choice-card img {
  width: 100%;
  aspect-ratio: 63 / 88;
  object-fit: contain;
  border-radius: 6px;
  background: #07090b;
}

.pending-choice-card span {
  display: grid;
  place-items: center;
  aspect-ratio: 63 / 88;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.82rem;
  text-align: center;
}

.pending-choice-card strong {
  font-size: 0.82rem;
  line-height: 1.2;
}

.pending-choice-actions,
.pending-type-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.pending-type-button,
#pending-choice-submit {
  border: 1px solid rgba(246, 207, 132, 0.4);
  border-radius: 8px;
  padding: 10px 14px;
  background: rgba(246, 207, 132, 0.14);
  color: var(--text);
  cursor: pointer;
}

.pending-type-button:hover,
#pending-choice-submit:hover {
  background: rgba(246, 207, 132, 0.24);
}

.game-choice-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 8, 11, 0.68);
  backdrop-filter: blur(6px);
}

.game-choice-panel {
  width: min(680px, 100%);
  display: grid;
  gap: 12px;
  border: 1px solid rgba(246, 207, 132, 0.28);
  border-radius: 8px;
  padding: 14px;
  background: rgba(14, 18, 21, 0.97);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.48);
}

.compact-choice .game-choice-panel {
  width: min(360px, 100%);
}

.mana-symbol-choice .game-choice-panel {
  width: min(430px, 100%);
}

.mana-symbol-choice .game-choice-options {
  grid-template-columns: repeat(5, 54px);
  justify-content: center;
  overflow: visible;
}

.mana-symbol-choice .game-choice-option {
  display: grid;
  place-items: center;
  width: 54px;
  min-height: 54px;
  padding: 0;
  border-radius: 50%;
}

.choice-mana-pip {
  display: grid !important;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(0, 0, 0, 0.62);
  border-radius: 50%;
  color: #111;
  font-size: 20px !important;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.choice-mana-pip.mana-W { background: #f4efcf; }
.choice-mana-pip.mana-U { background: #8fc8e8; }
.choice-mana-pip.mana-B { color: #f2eee6; background: #343038; }
.choice-mana-pip.mana-R { background: #e68c78; }
.choice-mana-pip.mana-G { background: #86bc8a; }

.game-choice-header h3 {
  margin: 2px 0 0;
  font-size: 1rem;
}

.game-choice-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  max-height: min(420px, 56vh);
  overflow: auto;
}

.game-choice-option,
.game-choice-actions button {
  min-height: 62px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 7px;
  padding: 9px 11px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.game-choice-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  text-align: left;
}

.game-choice-option strong,
.game-choice-option span:not(.choice-thumb) {
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.choice-thumb {
  grid-row: span 2;
  width: 42px;
  aspect-ratio: 0.715;
  overflow: hidden;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.28);
}

.choice-thumb .card-image,
.stack-card-thumb .card-image {
  width: 100%;
  height: 100%;
}

.game-choice-option:hover,
.game-choice-actions button:hover {
  border-color: rgba(246, 207, 132, 0.68);
  background: rgba(246, 207, 132, 0.14);
}

.game-choice-option.selected-choice {
  border-color: rgba(110, 215, 176, 0.9);
  background: rgba(110, 215, 176, 0.14);
}

.game-choice-option strong,
.game-choice-option span {
  display: block;
}

.game-choice-option span {
  color: var(--muted);
  font-size: 11px;
}

.game-choice-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.game-choice-confirm {
  border-color: rgba(110, 215, 176, 0.55) !important;
  background: rgba(110, 215, 176, 0.12) !important;
}

.game-choice-confirm:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.card-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-readable {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 7%;
  z-index: 1;
  display: grid;
  gap: 2px;
  min-height: 31%;
  max-height: 45%;
  border: 1px solid rgba(0, 0, 0, 0.72);
  border-radius: 5px;
  padding: 5px;
  color: #101418;
  background: #f3ead2;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.38) inset,
    0 6px 14px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.card-readable strong,
.card-readable span,
.card-readable p,
.card-readable em {
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-readable strong {
  font-size: 10px;
  line-height: 1.05;
  white-space: nowrap;
}

.card-readable span {
  font-size: 8px;
  line-height: 1.1;
  white-space: nowrap;
}

.card-readable p {
  display: -webkit-box;
  margin: 0;
  font-size: 8px;
  line-height: 1.15;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.card-readable em {
  justify-self: end;
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
}

.battlefield-zone .card {
  flex-basis: clamp(136px, 10vw, 178px);
  width: clamp(96px, 7.2vw, 128px);
  margin-inline: 4px;
}

.card-missing {
  display: grid;
  place-items: center;
  padding: 8px;
  color: var(--text);
  text-align: center;
  font-size: 11px;
  background: linear-gradient(135deg, rgba(117, 171, 213, 0.22), rgba(216, 183, 100, 0.16));
}

.empty-zone {
  color: rgba(255, 255, 255, 0.42);
  font-size: 13px;
}

.deck-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(0, 0, 0, 0.72);
}

.deck-modal-panel {
  width: min(1120px, 94vw);
  max-height: 88vh;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  background: #11161b;
  overflow: hidden;
}

.import-panel textarea {
  width: 100%;
  min-height: 340px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  background: #07090b;
  font: 14px/1.45 Consolas, "Courier New", monospace;
}

.import-panel #apply-import-button {
  width: 100%;
}

.deck-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.deck-modal-cards {
  display: grid;
  gap: 18px;
  max-height: calc(88vh - 120px);
  overflow: auto;
}

.deck-modal-section {
  display: grid;
  gap: 10px;
}

.deck-modal-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.deck-modal-section-header h3 {
  margin: 0;
}

.deck-modal-section-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.deck-modal-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(134px, 1fr));
  gap: 12px;
}

.modal-card {
  min-height: 200px;
  display: grid;
  grid-template-rows: 142px auto auto;
  border-radius: 8px;
  overflow: hidden;
  color: #17120d;
  background: var(--card);
}

.modal-card strong,
.modal-card span {
  padding: 0 8px;
}

.zone-modal-panel {
  width: min(900px, 94vw);
}

.zone-modal-panel .deck-modal-header {
  align-items: end;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.modal-subtitle {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

#zone-modal-sort {
  min-width: 136px;
  height: 36px;
}

.zone-browser-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 10px;
}

.zone-modal-card {
  position: relative;
  min-height: 190px;
}

.zone-card-count {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 8px;
  border-radius: 999px;
  padding: 3px 7px;
  color: #0e1418;
  font-size: 12px;
  font-weight: 900;
  background: var(--gold);
}

.stack-modal {
  position: fixed;
  inset: 0;
  z-index: 12;
  pointer-events: none;
}

.stack-modal-panel {
  position: fixed;
  right: 24px;
  top: 96px;
  width: min(380px, calc(100vw - 32px));
  max-height: min(520px, calc(100vh - 128px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 14px;
  overflow: hidden;
  pointer-events: auto;
  background: #11161b;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
}

.stack-modal-header {
  cursor: move;
}

.stack-modal-list {
  display: grid;
  gap: 8px;
  max-height: 390px;
  overflow: auto;
}

.stack-modal-item {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.stack-modal-item.top-stack-item {
  border-color: rgba(246, 207, 132, 0.72);
  background: rgba(246, 207, 132, 0.1);
}

.stack-modal-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stack-modal-item em {
  align-self: start;
  border-radius: 999px;
  padding: 3px 7px;
  color: #0e1418;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
  background: var(--gold);
}

.stack-card-thumb {
  width: 54px;
  aspect-ratio: 0.715;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.32);
  font-weight: 900;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: min(560px, calc(100vw - 32px));
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text);
  background: #151a20;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.36);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1180px) {
  .home-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .deck-builder {
    grid-template-columns: 180px minmax(0, 1fr);
  }

  .arena-deck-panel {
    grid-column: 1 / -1;
  }

  .arena-deck-panel .deck-cards {
    max-height: 260px;
  }

  .deck-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #advanced-filter-button {
    width: 120px;
  }
}

@media (max-width: 980px) {
  .home-shell {
    display: block;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-tabs {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    margin: 18px 0;
  }

  .dashboard-grid,
  .account-panel,
  .play-grid,
  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .deck-builder {
    grid-template-columns: minmax(0, 1fr);
  }

  .deck-list {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    max-height: 190px;
  }

  .card-results {
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    max-height: none;
  }

  .game-table {
    grid-template-columns: 1fr;
    height: auto;
  }

  .match-intro {
    inset: 0;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }

  .opening-hand {
    grid-template-columns: repeat(7, minmax(92px, 132px));
    justify-content: flex-start;
  }

  .left-rail,
  .right-rail {
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .left-rail {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }

  .zone-counter,
  .zone-box,
  .icon-action {
    margin-bottom: 0;
  }

  .match-shell {
    grid-template-rows: auto auto auto;
  }
}

@media (max-width: 700px) {
  .content,
  .sidebar {
    padding: 12px;
  }

  .content-header,
  .match-topbar,
  .profile-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-lockup.large {
    align-self: center;
    text-align: center;
    flex-direction: column;
  }

  .auth-screen {
    align-items: start;
    padding: 18px;
  }

  .auth-landing {
    grid-template-columns: 1fr;
  }

  .nav-tabs,
  .dashboard-grid,
  .account-panel,
  .play-grid,
  .admin-grid,
  .admin-filter-row,
  .deck-toolbar {
    grid-template-columns: 1fr;
  }

  .sync-card {
    display: none;
  }

  .deck-editor-header {
    display: grid;
    grid-template-columns: 1fr;
  }

  .deck-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: clamp(28px, 9vw, 36px);
  }

  h2 {
    font-size: 24px;
  }

  .filter-columns,
  .center-line,
  .left-rail {
    grid-template-columns: 1fr;
  }

  .filter-section button,
  .cmc-filter button {
    min-height: 40px;
  }

  .library-card {
    grid-template-rows: 118px minmax(58px, auto) 36px;
    min-height: 196px;
  }

  .card-results {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  }

  .playmat {
    width: 100%;
    height: auto;
    min-height: 620px;
    grid-template-rows: auto minmax(190px, 1fr) auto minmax(190px, 1fr) auto;
  }

  .battlefield-lane {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .battlefield-lane-cards {
    min-height: 92px;
  }

  .player-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .hand {
    min-height: 132px;
    justify-content: flex-start;
  }

  .deck-modal {
    padding: 10px;
  }

  .deck-modal-panel {
    width: 100%;
    max-height: 94vh;
    padding: 12px;
  }

  .deck-modal-header {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .match-intro {
    padding: 14px;
  }

  .match-intro-top {
    align-items: stretch;
    flex-direction: column;
  }

  .mulligan-actions button {
    flex: 1 1 140px;
  }
}

@media (max-width: 430px) {
  .content,
  .sidebar,
  .playmat,
  .left-rail,
  .right-rail,
  .hand-dock {
    padding: 10px;
  }

  .mana-filter {
    width: 38px;
    height: 38px;
  }

  .deck-zone-toggle,
  .deck-actions {
    grid-template-columns: 1fr;
  }

  .card-results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Simple MTGO-style battlefield */
.match-shell {
  grid-template-rows: 52px minmax(0, 1fr) 32px 172px;
  background: #08090b;
}

.match-topbar {
  padding: 8px 12px;
  background: #0e1115;
}

.match-topbar h2 {
  font-size: 20px;
}

.game-table {
  grid-template-columns: 164px minmax(0, 1fr) 178px;
  height: auto;
  min-height: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #111418;
}

.left-rail,
.right-rail {
  padding: 7px;
  background: #0b0d10;
}

.left-rail {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 7px;
}

.zone-counter,
.zone-box {
  margin: 0;
  border-radius: 3px;
  background: #161a1f;
}

.zone-counter strong {
  font-size: 18px;
}

.icon-action {
  height: 34px;
  margin: 0;
  border-radius: 4px;
}

.playmat {
  width: 100%;
  height: 100%;
  min-height: 0;
  align-self: stretch;
  justify-self: stretch;
  grid-template-rows: 42px minmax(0, 1fr) 34px minmax(0, 1fr) 42px;
  gap: 0;
  padding: 0;
  border: 1px solid #4d5660;
  border-radius: 0;
  background: #2f363d;
  box-shadow: none;
}

.playmat::before {
  inset: 50% 0 auto;
  background: #89919a;
}

.player-panel {
  border-radius: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  padding: 5px 8px;
  background: #151a20;
}

.player-panel.self {
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom: 0;
}

.player-panel.active-turn {
  background: #202a30;
  box-shadow: inset 4px 0 0 var(--gold);
}

.player-panel.has-priority .player-name::after {
  content: " priority";
  margin-left: 8px;
  color: var(--gold);
  font-size: 11px;
  text-transform: uppercase;
}

.player-name {
  font-size: 14px;
}

.player-stats {
  gap: 5px;
}

.stat {
  min-width: 44px;
  border-radius: 3px;
  padding: 2px 5px;
  background: #0f1317;
}

.stat span {
  font-size: 9px;
}

.stat strong {
  font-size: 14px;
}

.battlefield-row {
  border-radius: 0;
  padding: 6px;
  background: #3a424a;
}

.opponent-zone {
  background: #303740;
}

.player-zone {
  background: #b7c0c8;
}

.player-zone .zone-label,
.player-zone .battlefield-lane > span {
  color: rgba(0, 0, 0, 0.62);
}

.zone {
  height: calc(100% - 16px);
  gap: 5px;
}

.battlefield-lane {
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 5px;
}

.battlefield-lane-cards {
  gap: 7px;
}

.center-line {
  grid-template-columns: minmax(130px, 190px) minmax(0, 1fr);
  gap: 0;
  border-top: 1px solid #6e7680;
  border-bottom: 1px solid #6e7680;
  background: #111418;
}

.stack-zone,
.target-hint {
  border: 0;
  border-radius: 0;
  background: #15191e;
}

.target-hint {
  color: #cbd2d9;
}

.right-rail {
  display: grid;
  grid-template-rows: minmax(72px, auto) minmax(72px, auto) minmax(0, 1fr);
  gap: 7px;
}

.mini-zone {
  max-height: 92px;
}

.turn-strip {
  display: grid;
  grid-template-columns: 164px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  color: #dfe5ea;
  background: #0c0e11;
}

.turn-strip > strong {
  padding: 0 8px;
  font-size: 12px;
  white-space: nowrap;
}

.turn-steps {
  display: grid;
  grid-template-columns: repeat(12, minmax(58px, 1fr));
  height: 100%;
  min-width: 0;
  overflow-x: auto;
}

.turn-steps span {
  display: grid;
  place-items: center;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  color: #9da6ae;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.turn-steps span.active {
  color: #fff;
  background: rgba(216, 183, 100, 0.22);
  box-shadow: inset 0 0 0 1px var(--gold);
}

.hand-dock {
  padding: 6px 12px;
  background: #0b0d10;
}

.hand {
  min-height: 140px;
  justify-content: flex-start;
}

.card {
  flex-basis: 112px;
  width: 112px;
  border-radius: 4px;
}

.battlefield-zone .card {
  flex-basis: clamp(92px, 6.5vw, 116px);
  width: clamp(92px, 6.5vw, 116px);
}

.player-zone.drop-ready,
.zone.drop-ready {
  outline: 3px solid var(--gold);
  outline-offset: -4px;
  background: #c7d0d8;
}

@media (max-width: 980px) {
  .match-shell {
    grid-template-rows: auto minmax(620px, 1fr) auto auto;
    overflow: auto;
  }

  .game-table {
    grid-template-columns: 1fr;
  }

  .left-rail {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .right-rail {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto;
  }

  .turn-strip {
    grid-template-columns: 1fr;
  }

  .turn-strip > strong {
    padding: 5px 8px;
  }
}

@media (max-width: 700px) {
  .playmat {
    min-height: 560px;
    grid-template-rows: auto minmax(180px, 1fr) auto minmax(180px, 1fr) auto;
  }

  .battlefield-lane {
    grid-template-columns: 1fr;
  }

  .left-rail,
  .right-rail {
    grid-template-columns: 1fr 1fr;
  }
}

/* Cleaner board flow */
.match-shell {
  grid-template-rows: 44px minmax(0, 1fr) 32px 166px;
}

.match-topbar {
  min-height: 0;
}

.match-topbar .eyebrow,
.match-topbar h2 {
  display: none;
}

.game-table {
  grid-template-columns: 178px minmax(0, 1fr) 104px;
}

.left-rail {
  grid-template-rows: auto minmax(58px, auto) minmax(58px, auto) minmax(80px, 1fr) auto;
}

.right-rail {
  display: grid;
  grid-template-rows: 1fr;
  gap: 7px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.controls-rail {
  align-items: end;
}

.playmat {
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
}

.playmat::before {
  z-index: 1;
}

.battlefield-row {
  position: relative;
  padding: 10px;
}

.battlefield-row::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.opponent-zone::before {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), transparent 45%);
}

.player-zone::before {
  background: linear-gradient(0deg, rgba(255, 255, 255, 0.18), transparent 45%);
}

.zone {
  position: relative;
  z-index: 2;
  height: 100%;
  grid-template-rows: minmax(0, 1fr) minmax(0, 0.72fr);
  overflow: hidden;
}

.battlefield-lane {
  grid-template-columns: minmax(0, 1fr);
}

.battlefield-lane > span,
.battlefield-row > .zone-label,
.empty-zone {
  display: none;
}

.battlefield-lane-cards {
  min-height: 0;
  align-items: center;
  overflow-x: auto;
  padding: 2px;
}

.opponent-zone .battlefield-lane:first-child .battlefield-lane-cards {
  align-items: start;
}

.player-zone .battlefield-lane:first-child .battlefield-lane-cards {
  align-items: end;
}

.player-panel {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 8px;
  background: #12161b;
}

.player-panel.self {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.player-panel.active-turn {
  box-shadow: inset 4px 0 0 var(--gold), 0 0 0 1px rgba(216, 183, 100, 0.3);
}

.player-panel.has-priority {
  border-color: var(--gold);
}

.player-panel.targetable-player {
  cursor: crosshair;
  border-color: var(--red);
  box-shadow: inset 4px 0 0 var(--red), 0 0 0 1px rgba(172, 74, 55, 0.45);
}

.player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat {
  min-width: 0;
  display: grid;
  gap: 2px;
  text-align: left;
}

.life-stat {
  grid-column: span 2;
  text-align: center;
  border-color: rgba(216, 183, 100, 0.35);
}

.life-stat strong {
  font-size: 28px;
  line-height: 1;
}

.mana-stat {
  grid-column: span 2;
}

.mana-stat strong {
  min-height: 22px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px;
}

.mana-stat em {
  color: var(--muted);
  font-style: normal;
}

.mana-pip {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #111;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.28);
}

.mana-W { background: #f1e9cc; }
.mana-U { background: #77afd8; }
.mana-B { color: #f5f0e8; background: #2a2b30; }
.mana-R { background: #dc7567; }
.mana-G { background: #7bc477; }
.mana-C { background: #bdb8ab; }

.side-zone,
.stack-panel {
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 7px;
  background: #15191e;
}

.stack-panel {
  overflow: hidden;
}

.stack-list {
  display: grid;
  gap: 5px;
}

.mini-zone {
  max-height: 76px;
}

.mini-card {
  border-radius: 3px;
  padding: 4px 5px;
  font-size: 11px;
}

.action-dock {
  display: grid;
  gap: 7px;
  align-self: end;
  min-height: 88px;
}

.action-dock .icon-action {
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0 8px;
}

.turn-strip {
  grid-template-columns: 178px minmax(0, 1fr) 104px;
}

.turn-strip::after {
  content: "";
}

.turn-steps {
  grid-template-columns: repeat(12, minmax(64px, 1fr));
}

.hand {
  min-height: 134px;
}

.card {
  flex-basis: 108px;
  width: 108px;
}

.battlefield-zone .card {
  flex-basis: clamp(90px, 6.2vw, 112px);
  width: clamp(90px, 6.2vw, 112px);
}

.target-hint,
.center-line,
.stack-zone {
  display: none;
}

@media (max-width: 980px) {
  .game-table,
  .turn-strip {
    grid-template-columns: 1fr;
  }

  .left-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
  }

  .right-rail {
    grid-template-columns: 1fr;
  }
}

/* Polished match left rail */
.game-table {
  grid-template-columns: minmax(204px, 224px) minmax(0, 1fr) 104px;
}

.turn-strip {
  grid-template-columns: minmax(204px, 224px) minmax(0, 1fr) 104px;
}

.left-rail {
  gap: 9px;
  grid-template-rows: auto auto auto auto auto;
  min-width: 0;
}

.player-panel {
  gap: 8px;
  padding: 9px;
}

.player-name {
  min-width: 0;
  font-size: 13px;
  font-weight: 900;
}

.player-state-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.player-state-row span {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.player-panel.active-turn .player-state-row span:first-child,
.player-panel.has-priority .player-state-row span:last-child {
  color: #10151a;
  background: var(--gold);
  border-color: var(--gold);
}

.player-stats {
  gap: 6px;
}

.stat {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.side-zone {
  grid-template-columns: 1fr;
  gap: 7px;
  padding: 8px;
}

.zone-icon-button {
  min-height: 38px;
  border-radius: 6px;
}

.zone-icon-button span {
  overflow: visible;
  text-overflow: clip;
}

.stack-panel {
  min-height: 56px;
}

@media (max-width: 980px) {
  .game-table,
  .turn-strip {
    grid-template-columns: 1fr;
  }

  .left-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
  }
}

/* Fixed-height match viewport and readable opening hand */
body:has(.match-shell:not(.hidden)) {
  overflow: hidden;
}

.match-shell:not(.hidden) {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: minmax(44px, auto) minmax(0, 1fr) minmax(28px, auto) clamp(112px, 19vh, 164px);
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.match-shell:not(.hidden) .match-topbar,
.match-shell:not(.hidden) .turn-strip,
.match-shell:not(.hidden) .hand-dock {
  min-height: 0;
}

.match-shell:not(.hidden) .game-table {
  height: auto;
  min-height: 0;
  overflow: hidden;
}

.match-shell:not(.hidden) .playmat {
  height: 100%;
  min-height: 0;
}

.match-shell:not(.hidden) .left-rail,
.match-shell:not(.hidden) .right-rail,
.match-shell:not(.hidden) .battlefield-lane-cards,
.match-shell:not(.hidden) .hand {
  min-height: 0;
  overflow: auto;
}

.match-shell:not(.hidden) .hand-dock {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.match-shell:not(.hidden) .hand {
  align-content: start;
  min-height: 0;
  max-height: 100%;
  padding-bottom: 6px;
}

.match-shell:not(.hidden) .hand .card {
  flex-basis: clamp(76px, 8.2vw, 112px);
  width: clamp(76px, 8.2vw, 112px);
}

.match-shell:not(.hidden) .action-dock .icon-action {
  min-height: clamp(32px, 5vh, 40px);
  height: clamp(32px, 5vh, 40px);
}

.match-intro:not(.hidden) {
  overflow: hidden;
}

.match-intro:not(.hidden) .opening-hand {
  grid-template-columns: repeat(7, minmax(112px, 1fr));
  align-items: center;
  width: min(100%, 1320px);
  max-height: min(62dvh, 640px);
  overflow-x: auto;
  overflow-y: hidden;
}

.opening-card {
  display: block;
  min-width: 0;
}

.opening-card-readable {
  gap: 2px;
  min-height: 31%;
  max-height: 45%;
  padding: 6px;
}

.opening-card-readable strong {
  display: block;
  font-size: 12px;
  line-height: 1.15;
}

.opening-card-readable span,
.opening-card-readable em {
  color: #44505a;
  font-size: 10px;
  font-style: normal;
  line-height: 1.2;
}

.card-readable em small {
  color: var(--gold);
  font-size: 10px;
  font-style: normal;
}

.opening-card-readable p {
  margin: 0;
  font-size: 10px;
  line-height: 1.25;
  -webkit-line-clamp: 6;
}

.opening-card:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 4px;
}

.match-intro:not(.hidden) ~ .hand-dock {
  opacity: 0.22;
  pointer-events: none;
}

@media (max-height: 760px) {
  .match-shell:not(.hidden) {
    grid-template-rows: minmax(40px, auto) minmax(0, 1fr) minmax(26px, auto) clamp(96px, 17vh, 132px);
  }

  .match-topbar {
    padding-block: 5px;
  }

  .player-panel,
  .side-zone {
    padding: 6px;
  }

  .match-intro-copy p {
    display: none;
  }

  .match-intro:not(.hidden) .opening-hand {
    grid-template-columns: repeat(7, minmax(104px, 1fr));
    max-height: 58dvh;
  }
}

@media (max-width: 760px) {
  .match-shell:not(.hidden) {
    grid-template-rows: auto minmax(0, 1fr) auto clamp(102px, 20vh, 150px);
  }

  .match-intro:not(.hidden) .opening-hand {
    grid-template-columns: repeat(7, minmax(150px, 68vw));
    justify-content: start;
  }

  .visual-card-choice .pending-choice-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 190px));
  }
}
