:root {
  color-scheme: dark;
  --bg: #0b0a08;
  --panel: rgba(18, 18, 16, 0.82);
  --panel-strong: rgba(33, 31, 27, 0.94);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f3efe6;
  --muted: #a9a093;
  --gold: #d8a84f;
  --red: #d65b57;
  --green: #4bb174;
  --violet: #8d7cf6;
  --cyan: #55b8c7;
  --shadow: rgba(0, 0, 0, 0.38);
  --void: #8d7cf6;
  --void-glow: rgba(141, 124, 246, 0.45);
  --rival-glow: rgba(214, 91, 87, 0.42);
  --player-glow: rgba(75, 177, 116, 0.42);
  --font-display: "Chakra Petch", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  height: 100vh;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(216, 168, 79, 0.72);
  background: rgba(216, 168, 79, 0.13);
}

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

button.primary {
  border-color: rgba(216, 168, 79, 0.86);
  background: linear-gradient(135deg, #b98234, #d8a84f);
  color: #16110a;
}

button.wide {
  width: 100%;
}

#gl-board {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  height: 100vh;
  padding: 12px;
  background:
    radial-gradient(circle at 20% 10%, rgba(216, 168, 79, 0.1), transparent 25%),
    linear-gradient(180deg, rgba(6, 6, 5, 0.2), rgba(6, 6, 5, 0.78));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 12, 10, 0.74);
  box-shadow: 0 18px 48px var(--shadow);
  backdrop-filter: blur(14px);
}

.eyebrow,
.label {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 1px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.4vw, 2.3rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: linear-gradient(120deg, var(--gold) 0%, #f0d9a6 42%, var(--void) 120%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(68px, 1fr));
  gap: 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.help-button {
  min-width: 118px;
  border-color: rgba(85, 184, 199, 0.58);
  background: rgba(85, 184, 199, 0.12);
}

.status-strip div {
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
}

.status-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 1.15rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(700px, 1fr) minmax(300px, 340px);
  gap: 14px;
  height: calc(100vh - 24px);
  max-width: 1520px;
  margin: 0 auto;
}

.rail-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  box-shadow: 0 18px 48px var(--shadow);
  backdrop-filter: blur(14px);
}

.rail-hero {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.mode-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mode-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-options button.active {
  border-color: rgba(216, 168, 79, 0.86);
  background: rgba(216, 168, 79, 0.13);
}

.operator-strip {
  display: grid;
  gap: 10px;
  align-items: stretch;
}

.operator-copy {
  min-width: 170px;
  padding: 8px 10px;
}

.operator-copy strong {
  display: block;
  margin-top: 4px;
}

.operator-choice-row {
  display: grid;
  gap: 6px;
}

.operator-choice-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.operator-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.operator-option {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 68px;
  padding: 10px;
  text-align: left;
}

.operator-option.active {
  border-color: rgba(216, 168, 79, 0.86);
  background: rgba(216, 168, 79, 0.13);
}

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

.operator-option span {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
}

.operator-option .risk-line {
  color: #e0b8b5;
}

.play-surface,
.side-panel {
  min-width: 0;
}

.play-surface {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(150px, 23vh);
  gap: 12px;
  height: 100%;
  padding: 12px;
  border: 1px solid rgba(216, 168, 79, 0.22);
  border-radius: 14px;
  background:
    radial-gradient(120% 80% at 50% 0%, var(--rival-glow), transparent 38%),
    radial-gradient(120% 80% at 50% 100%, var(--player-glow), transparent 38%),
    radial-gradient(80% 60% at 50% 50%, rgba(141, 124, 246, 0.08), transparent 70%),
    linear-gradient(180deg, rgba(10, 10, 9, 0.72), rgba(6, 7, 9, 0.86));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    inset 0 0 120px rgba(0, 0, 0, 0.55),
    0 30px 80px var(--shadow);
  overflow: hidden;
}

.battlefield-head,
.hand-row,
.panel-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 48px var(--shadow);
  backdrop-filter: blur(14px);
}

.battlefield-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 92px;
  padding: 12px 14px;
  background:
    linear-gradient(135deg, rgba(214, 91, 87, 0.14), transparent 42%),
    var(--panel);
}

.battlefield-head strong {
  display: block;
  margin-top: 3px;
}

.arena-hero,
.hand-head {
  position: relative;
}

.hero-player {
  min-width: 0;
}

.hero-player strong {
  display: block;
  overflow-wrap: anywhere;
}

.hero-line {
  max-width: 620px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.32;
}

.hero-meta {
  flex-shrink: 0;
  min-width: 150px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.055);
}

.hero-meta strong {
  display: block;
  margin-top: 3px;
  font-size: 0.9rem;
}

.resource-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(76px, 1fr));
  gap: 6px;
  width: 100%;
  margin-top: 8px;
}

.resource-chip {
  display: grid;
  gap: 2px;
  min-height: 42px;
  border: 1px solid rgba(85, 184, 199, 0.34);
  border-radius: 7px;
  padding: 6px 7px;
  background: rgba(85, 184, 199, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.resource-chip.reserve {
  border-color: rgba(216, 168, 79, 0.42);
  background: rgba(216, 168, 79, 0.1);
}

.resource-chip span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 900;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.resource-chip strong {
  margin: 0;
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1;
}

.resource-up {
  animation: resourceGain 760ms ease-out;
}

.resource-down {
  animation: resourceLoss 760ms ease-out;
}

@keyframes resourceGain {
  0% {
    border-color: rgba(75, 177, 116, 0.95);
    background: rgba(75, 177, 116, 0.24);
    transform: translateY(-1px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes resourceLoss {
  0% {
    border-color: rgba(214, 91, 87, 0.95);
    background: rgba(214, 91, 87, 0.22);
    transform: translateY(1px);
  }
  100% {
    transform: translateY(0);
  }
}

.opponent-row {
  display: grid;
  justify-items: end;
  gap: 4px;
  text-align: right;
}

.queue-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.coach-output {
  display: grid;
  gap: 6px;
}

.coach-output strong {
  display: block;
  margin-top: 2px;
  font-size: 1rem;
}

.coach-output p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.board-intro {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(85, 184, 199, 0.3);
  border-radius: 8px;
  background: rgba(8, 28, 31, 0.7);
  box-shadow: 0 18px 48px var(--shadow);
  backdrop-filter: blur(14px);
}

.board-intro strong {
  display: block;
}

.board-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

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

.lane {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(214, 91, 87, 0.07), transparent 24%, transparent 76%, rgba(75, 177, 116, 0.07)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)),
    rgba(13, 14, 12, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025);
  transition:
    border-color 180ms ease,
    box-shadow 220ms ease,
    transform 180ms ease;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  padding: 0;
  overflow: hidden;
}

.lane:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(216, 168, 79, 0.5);
  background:
    linear-gradient(180deg, rgba(214, 91, 87, 0.09), transparent 24%, transparent 76%, rgba(75, 177, 116, 0.09)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)),
    rgba(13, 14, 12, 0.76);
}

.lane.contested {
  border-color: rgba(141, 124, 246, 0.5);
  box-shadow:
    inset 0 0 0 1px rgba(141, 124, 246, 0.22),
    0 0 26px -6px var(--void-glow);
}

.lane.selected {
  border-color: rgba(216, 168, 79, 0.86);
  box-shadow:
    inset 0 0 0 1px rgba(216, 168, 79, 0.4),
    0 0 30px -6px rgba(216, 168, 79, 0.5);
}

.lane-head,
.lane-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 11px;
  background: rgba(255, 255, 255, 0.04);
}

.lane-head {
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.lane-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.lane-head h2 span {
  display: block;
  margin-bottom: 2px;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.lane-scoreboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(58px, 1fr));
  gap: 6px;
  min-width: 126px;
}

.score-card,
.tag {
  min-width: 34px;
  border-radius: 7px;
  padding: 5px 7px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 900;
  text-align: center;
}

.score-card {
  display: grid;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition:
    border-color 200ms ease,
    background 200ms ease,
    box-shadow 200ms ease;
}

.score-card span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.56rem;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.score-card strong {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1;
}

.score-card.leading {
  box-shadow: 0 0 16px -4px currentColor;
}

.score-card.rival-score.leading {
  border-color: var(--red);
  background: rgba(214, 91, 87, 0.14);
}

.score-card.player-score.leading {
  border-color: var(--green);
  background: rgba(75, 177, 116, 0.14);
}

.tag {
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.player-score strong {
  color: var(--green);
}

.rival-score strong {
  color: var(--red);
}

.lane-cards {
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  gap: 7px;
  padding: 9px;
  min-height: 0;
}

.lane-zone {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 5px;
  min-height: 0;
  overflow: hidden;
}

.zone-label {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.rival-zone .zone-label {
  color: rgba(224, 158, 155, 0.85);
}

.player-zone .zone-label {
  color: rgba(150, 214, 178, 0.9);
}

.side-stack {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  align-content: start;
  gap: 6px;
  min-height: 0;
  overflow: hidden;
}

.side-stack.bravo {
  align-content: end;
}

/* Center seam: the "no man's land" reveal line between the two territories. */
.lane-seam {
  position: relative;
  display: grid;
  place-items: center;
  height: 1px;
  margin: 1px 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.16), transparent);
}

.lane.contested .lane-seam {
  background: linear-gradient(90deg, transparent, var(--void-glow), transparent);
}

.lane-seam-tag {
  padding: 1px 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(10, 11, 13, 0.92);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.lane.you-lead .lane-seam-tag {
  color: var(--green);
  border-color: rgba(75, 177, 116, 0.4);
}

.lane.rival-lead .lane-seam-tag {
  color: var(--red);
  border-color: rgba(214, 91, 87, 0.4);
}

.card {
  min-height: 74px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 7px;
  padding: 7px;
  background: var(--panel-strong);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.card.alpha {
  border-color: rgba(75, 177, 116, 0.45);
}

.card.bravo {
  border-color: rgba(214, 91, 87, 0.45);
}

.card.selected {
  border-color: rgba(216, 168, 79, 0.9);
  background: rgba(54, 43, 25, 0.96);
}

.card.queued {
  border-style: dashed;
  cursor: pointer;
}

.card.queued:hover,
.card.queued:focus-visible {
  border-color: rgba(216, 168, 79, 0.9);
  box-shadow: 0 0 0 2px rgba(216, 168, 79, 0.18), 0 12px 30px rgba(0, 0, 0, 0.3);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 7px 0 6px;
}

.card-art {
  display: block;
  width: 100%;
  height: 56px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  object-fit: cover;
  object-position: center 18%;
  background: rgba(0, 0, 0, 0.28);
}

.lane .card {
  position: relative;
  min-height: 0;
  padding: 5px 6px 6px;
  border-radius: 9px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.34);
}

.lane .card-art {
  display: block;
  height: 34px;
  margin-bottom: 4px;
  border-radius: 5px;
}

.lane .card-text {
  display: none;
}

.lane .card-top {
  margin: 0;
}

.lane .card-name {
  display: -webkit-box;
  font-size: 0.72rem;
  line-height: 1.12;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* On the board, collapse the badge row to a single power token in the corner. */
.lane .card-badges {
  position: absolute;
  top: 4px;
  right: 4px;
  display: block;
  grid-template-columns: none;
  margin: 0;
}

.lane .card-badge {
  display: none;
}

.lane .card-badge:nth-child(2) {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border: 1px solid rgba(216, 168, 79, 0.55);
  border-radius: 7px;
  background: rgba(20, 16, 9, 0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.lane .card-badge:nth-child(2) span {
  display: none;
}

.lane .card-badge:nth-child(2) strong {
  margin: 0;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 700;
}

.lane .card.enter {
  animation: cardReveal 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cardReveal {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.9) rotateX(35deg);
    filter: brightness(1.7);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotateX(0);
    filter: brightness(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lane .card.enter {
    animation: none;
  }
}

.card-name {
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.15;
}

.card-meta {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.card-badges {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 7px;
}

.card-badge {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  padding: 4px 5px;
  background: rgba(255, 255, 255, 0.055);
}

.card-badge span,
.card-badge strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-badge span {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 900;
  text-transform: uppercase;
}

.card-badge strong {
  margin-top: 1px;
  font-size: 0.72rem;
}

.card-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.25;
}

.card-preview-template {
  display: none;
}

.card-preview-panel {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  width: min(286px, calc(100vw - 28px));
  border: 1px solid rgba(216, 168, 79, 0.42);
  border-radius: 8px;
  padding: 10px;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(216, 168, 79, 0.13), transparent 46%),
    rgba(17, 20, 22, 0.98);
  box-shadow: 0 22px 58px rgba(0, 0, 0, 0.48);
  opacity: 0;
}

.card-preview-panel.visible {
  opacity: 1;
}

.card-preview-art {
  display: block;
  width: 100%;
  aspect-ratio: 1003 / 1568;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  object-fit: contain;
  object-position: center;
  background: rgba(0, 0, 0, 0.28);
}

.card-preview-copy {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.card-preview-copy h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.1;
}

.card-preview-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.card-preview-stat {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.card-preview-stat span,
.card-preview-stat strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-preview-stat span {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 900;
  text-transform: uppercase;
}

.card-preview-stat strong {
  margin-top: 2px;
  font-size: 0.82rem;
}

.card-preview-copy p {
  margin: 0;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.35;
}

.hand-row {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  padding: 12px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(75, 177, 116, 0.13), transparent 42%),
    var(--panel);
}

.hand-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.actions {
  display: flex;
  gap: 8px;
}

.raise-status {
  display: grid;
  gap: 3px;
  max-width: none;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.raise-pill {
  justify-self: start;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.raise-pill.ready,
.raise-pill.armed {
  background: rgba(75, 177, 116, 0.18);
  color: var(--green);
}

.raise-pill.risky {
  background: rgba(214, 91, 87, 0.16);
  color: var(--red);
}

.raise-pill.building,
.raise-pill.locked {
  color: var(--gold);
}

.hand {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.hand .card {
  min-height: 0;
  cursor: pointer;
}

.hand .card-art {
  height: 64px;
}

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

.side-panel {
  display: grid;
  align-content: start;
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow: auto;
}

.panel-block {
  padding: 12px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 900;
}

.advanced-panel summary {
  cursor: pointer;
  font-weight: 900;
}

.advanced-panel summary::marker {
  color: var(--gold);
}

.advanced-panel[open] summary {
  margin-bottom: 12px;
}

.utility-section {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.utility-section + .utility-section {
  margin-top: 14px;
}

.result-text {
  min-height: 48px;
  margin-bottom: 10px;
  color: var(--muted);
  line-height: 1.35;
}

.post-game {
  display: grid;
  gap: 7px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.lab-output {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.diagnostics-export {
  max-height: 220px;
  margin: 10px 0 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.diagnostics-export:empty {
  display: none;
}

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

.metric {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
}

.market-list,
.log {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.log-block {
  max-height: 220px;
  overflow: hidden;
}

.log {
  max-height: 160px;
  overflow: auto;
}

.rail-note {
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.log li + li,
.market-list li + li {
  margin-top: 6px;
}

.onboarding-panel {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(8px);
}

.onboarding-panel[hidden] {
  display: none;
}

.onboarding-card {
  width: min(100%, 680px);
  max-height: min(720px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid rgba(216, 168, 79, 0.44);
  border-radius: 8px;
  padding: 18px;
  background: rgba(16, 15, 13, 0.97);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.58);
}

.onboarding-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.onboarding-head h2 {
  margin: 2px 0 0;
  font-size: 1.8rem;
  letter-spacing: 0;
}

.onboarding-steps {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.onboarding-step {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.onboarding-step > span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(216, 168, 79, 0.16);
  color: var(--gold);
  font-weight: 900;
}

.onboarding-step h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.onboarding-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.42;
}

.deck-browser-panel {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  padding: 18px;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(10px);
}

.deck-browser-panel[hidden] {
  display: none;
}

.deck-browser-page {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(100%, 1180px);
  max-height: calc(100vh - 36px);
  justify-self: center;
  border: 1px solid rgba(216, 168, 79, 0.44);
  border-radius: 8px;
  background: rgba(16, 15, 13, 0.97);
  box-shadow: 0 30px 88px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.deck-browser-head,
.deck-browser-intro,
.deck-browser-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.deck-browser-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(216, 168, 79, 0.12), transparent 44%),
    rgba(255, 255, 255, 0.035);
}

.deck-browser-head h2 {
  margin: 2px 0 0;
  font-size: 1.75rem;
  letter-spacing: 0;
}

.deck-browser-body {
  min-height: 0;
  overflow: auto;
  padding: 16px 18px 18px;
}

.deck-browser-intro {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: -16px -18px 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 15, 13, 0.96);
}

.deck-browser-intro p,
.deck-browser-section-head p {
  margin: 2px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.deck-browser-search {
  display: grid;
  gap: 5px;
  width: min(100%, 360px);
}

.deck-browser-search span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
}

.deck-browser-search input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  padding: 10px 11px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  font: inherit;
}

.deck-browser-search input:focus {
  outline: 2px solid rgba(216, 168, 79, 0.42);
  outline-offset: 2px;
}

.deck-browser-sections {
  display: grid;
  gap: 18px;
}

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

.deck-browser-section[hidden] {
  display: none;
}

.deck-browser-section-head {
  align-items: end;
}

.deck-browser-section-title {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0;
}

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

.deck-browser-card {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 9px;
  background:
    linear-gradient(135deg, rgba(85, 184, 199, 0.08), transparent 38%),
    var(--panel-strong);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.26);
}

.deck-browser-card[hidden] {
  display: none;
}

.deck-browser-card .card-preview-art {
  aspect-ratio: 1003 / 1568;
}

.deck-browser-card .card-preview-copy h3 {
  font-size: 1rem;
}

@media (max-width: 980px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  #app {
    height: auto;
    min-height: 100vh;
    padding: 12px;
  }

  .topbar,
  .topbar-actions,
  .hand-head,
  .battlefield-head,
  .mode-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .raise-status {
    max-width: none;
  }

  .status-strip {
    width: 100%;
  }

  .help-button {
    width: 100%;
  }

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

  .play-surface,
  .side-panel {
    height: auto;
    overflow: visible;
  }

  .hand-row {
    grid-template-rows: auto auto;
    overflow: visible;
  }

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

  .lanes {
    grid-template-columns: 1fr;
  }

  .lane {
    min-height: 340px;
  }

  .hand {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    min-height: 120px;
    overflow: visible;
  }

  .hand .card-art {
    height: 110px;
  }

  .deck-browser-intro,
  .deck-browser-head,
  .deck-browser-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .deck-browser-search {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .status-strip,
  .metric-grid,
  .operator-options {
    grid-template-columns: 1fr;
  }

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

  .hand {
    grid-template-columns: 1fr;
  }

  .deck-browser-panel {
    padding: 10px;
  }

  .deck-browser-page {
    max-height: calc(100vh - 20px);
  }

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