/* Shared design tokens: see "Design system" in AGENTS.md. */
:root {
  --jd-edge: color-mix(in srgb, var(--foreground) 28%, transparent);
  --jd-line: var(--border);
  --jd-surface: color-mix(in srgb, var(--foreground) 4%, var(--background));
  --jd-radius: var(--radius-large);
  --jd-control: 2rem;
  --jd-magic: #4a8dff;
  --jd-magic-2: #9b6bff;
  --jd-magic-3: #ff6bc6;
}
/* JustDraft: small overrides on top of Oat. */
[x-cloak] {
  display: none !important;
}

body {
  min-height: 100vh;
}

.jd-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) 88%, transparent);
  backdrop-filter: blur(10px);
}

.jd-brand {
  font-size: var(--text-4);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--foreground);
  text-decoration: none;
}
.jd-brand span {
  color: var(--muted-foreground);
}
.jd-spacer {
  flex: 1;
}
.jd-hint {
  color: var(--muted-foreground);
  font-size: var(--text-7);
}

main.container {
  max-width: 1200px;
  padding-bottom: var(--space-16);
}

/* Small uppercase label: one style for every section label. */
.jd-kicker,
.jd-deck-group-head,
.jd-subhead h5,
.jd-builder-stats h5,
.jd-seat-label,
.jd-outlook-title,
.jd-group-head {
  color: var(--muted-foreground);
  font-size: var(--text-8);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Setup */
/* One gap between a screen's top-level blocks; blocks carry no outer margin of their own. */
.jd-setup,
.jd-draft-inner,
.jd-results-wrap > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}
.jd-setup > *,
.jd-draft-inner > *,
.jd-results-wrap > div > * {
  margin: 0;
}
.jd-setup {
  max-width: 780px;
  margin-inline: auto;
  padding-block: var(--space-6);
}
.jd-kicker {
  margin: 0;
}
.jd-hero h1 {
  margin: var(--space-2) 0 var(--space-3);
  font-size: clamp(2rem, 6vw, 3.2rem);
  letter-spacing: -0.04em;
}
.jd-lede {
  max-width: 56ch;
  margin: 0;
  font-size: var(--text-4);
  color: var(--muted-foreground);
}
.jd-input-card {
  padding: var(--space-4);
}
.jd-import-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.jd-import-row input {
  flex: 1;
}
.jd-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-3);
  font-size: var(--text-7);
  color: var(--muted-foreground);
}
.jd-meta strong {
  color: var(--foreground);
}
.jd-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
.jd-settings label {
  margin: 0;
  font-size: var(--text-7);
  color: var(--muted-foreground);
}
.jd-settings input {
  margin-top: var(--space-1);
}
.jd-auto {
  margin-left: var(--space-1);
  font-size: var(--text-8);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}
.jd-start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}
.jd-start button {
  min-width: 160px;
}
.jd-progress {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--space-3);
  min-width: 200px;
}
.jd-progress progress {
  flex: 1;
}

/* Draft */
.jd-draft-inner {
  padding-block: var(--space-3);
}
.jd-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.jd-actions button {
  padding-block: var(--space-2);
  padding-inline: var(--space-4);
  font-size: var(--text-7);
}
.jd-table {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 22rem);
  align-items: start;
  gap: var(--space-8);
}
.jd-board {
  display: grid;
  grid-template-columns: 34px repeat(3, minmax(0, 1fr));
  grid-template-rows: 34px repeat(3, auto);
  width: 100%;
  max-width: 880px;
  margin-inline: auto;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--jd-edge);
  border-radius: var(--radius-large);
  background: color-mix(in srgb, var(--foreground) 5%, var(--background));
}
.jd-line-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--jd-edge);
  border-radius: var(--radius-small);
  background: color-mix(in srgb, var(--foreground) 9%, transparent);
  color: var(--foreground);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s,
    border-color 0.12s;
}
/* Your turn: a soft haze breathes around the grid and the status text takes the accent color. */
.jd-board {
  transition:
    border-color 0.3s,
    box-shadow 0.3s;
}
@property --jd-spin {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
.jd-board.jd-your-turn {
  position: relative;
  border-color: color-mix(in srgb, var(--jd-magic) 40%, var(--jd-edge));
}
/* Three lights, blue, purple and pink, orbit the grid, lighting only its border. */
.jd-board.jd-your-turn::before {
  content: "";
  position: absolute;
  inset: -1px;
  padding: 5px;
  border-radius: inherit;
  background: conic-gradient(
    from var(--jd-spin),
    transparent,
    var(--jd-magic) 10%,
    transparent 30%,
    var(--jd-magic-2) 44%,
    transparent 63%,
    var(--jd-magic-3) 78%,
    transparent
  );
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
  animation: jd-spin 14s linear infinite;
}
@keyframes jd-spin {
  to {
    --jd-spin: 360deg;
  }
}
@media (prefers-reduced-motion: reduce) {
  .jd-board.jd-your-turn::before {
    animation: none;
  }
}
.jd-your-turn-text {
  color: var(--jd-magic);
}
.jd-your-turn .jd-line-btn:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}
.jd-line-btn:hover:not(:disabled),
.jd-line-btn.jd-hot {
  border-style: solid;
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}
.jd-line-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.jd-cell {
  position: relative;
  aspect-ratio: 488 / 680;
  overflow: hidden;
  border: 1px solid var(--jd-edge);
  border-radius: var(--radius-medium);
  background: var(--muted);
  transition: opacity 0.2s;
}
.jd-cell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* A new card is dealt out from the middle of the grid, one cell after another. */
.jd-deal {
  animation: jd-deal 280ms cubic-bezier(0.2, 0.8, 0.3, 1) backwards;
  animation-delay: calc(var(--i) * 35ms);
}
@keyframes jd-deal {
  from {
    opacity: 0;
    transform: translate(
        calc((1 - var(--c)) * 100%),
        calc((1 - var(--r)) * 100%)
      )
      scale(0.5) rotate(-8deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .jd-deal {
    animation: none;
  }
}
.jd-cell.jd-hl {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
}
.jd-cell-empty {
  opacity: 0.3;
  border-style: dashed;
}
.jd-cell-empty.jd-hl {
  opacity: 0.4;
}
.jd-round-over .jd-cell:not(.jd-cell-empty) {
  opacity: 0.55;
}
.jd-card-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  font-size: var(--text-8);
  line-height: 1.3;
  text-align: center;
  color: var(--muted-foreground);
}

/* Pools */
.jd-pool {
  position: sticky;
  top: 64px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.jd-player {
  padding: var(--space-3);
  border: 1px solid var(--jd-line);
  border-radius: var(--jd-radius);
  background: var(--card);
}
.jd-player.jd-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.jd-player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.jd-player-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}
.jd-you {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--muted-foreground);
  font-size: var(--text-8);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.jd-mini {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-1);
  max-height: 260px;
  overflow: auto;
  overscroll-behavior: contain;
}
.jd-mini img {
  display: block;
  width: 100%;
  border-radius: var(--radius-small);
}
.jd-mini-full {
  grid-template-columns: repeat(5, 1fr);
  max-height: none;
  margin-top: var(--space-4);
}

/* Results */
.jd-results-wrap {
  padding-block: var(--space-3) var(--space-5);
}
.jd-results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
}
.jd-results-head h1 {
  margin: 0;
  font-size: var(--text-4);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.jd-results-head .jd-hint {
  margin: 0;
}
.jd-roster-chip {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-1);
  max-width: 16rem;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--text-7);
}
.jd-roster-chip > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.jd-roster-count {
  color: var(--muted-foreground);
  font-size: var(--text-8);
  white-space: nowrap;
}
.jd-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: var(--space-5);
}
.jd-results-stacked {
  grid-template-columns: 1fr;
}
.jd-result {
  padding: var(--space-4);
}
.jd-result-wide {
  grid-column: 1 / -1;
}
.jd-result h2 {
  margin: 0;
  font-size: var(--text-3);
}

/* In-app 40-card deck builder */
.jd-builder {
  --jd-card-overlap: 38%;
  margin-top: var(--space-3);
}
.jd-builder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.jd-builder-actions button {
  min-height: var(--jd-control);
}
.jd-builder-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--jd-line);
  border-radius: var(--jd-radius);
  background: var(--jd-surface);
}
.jd-builder-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}
.jd-builder-counts {
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.jd-legality {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--background);
  font-size: var(--text-7);
  line-height: 1.2;
}
.jd-legality-label {
  font-weight: 700;
}
.jd-legality-why {
  color: var(--muted-foreground);
}
.jd-legality.jd-legal {
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
  background: color-mix(in srgb, var(--success) 10%, transparent);
}
.jd-legality.jd-legal .jd-legality-label {
  color: var(--success);
}
.jd-legality.jd-illegal {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}
.jd-legality.jd-illegal .jd-legality-label {
  color: var(--danger);
}
.jd-builder-view {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}
.jd-groupby {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--text-7);
}
.jd-groupby select {
  width: auto;
  min-height: var(--jd-control);
  margin: 0;
  padding-block: var(--space-1);
  font-size: var(--text-7);
}
.jd-view-toggle {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-medium);
}
.jd-view-toggle button {
  min-height: var(--jd-control);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--foreground);
}
.jd-view-toggle button + button {
  border-left: 1px solid var(--border);
}
.jd-view-toggle button:hover {
  background: var(--accent);
}
.jd-view-toggle .jd-active {
  background: var(--primary);
  color: var(--primary-foreground);
}
.jd-builder-notices {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-4);
  margin-top: var(--space-2);
}
.jd-builder-notices .jd-hint {
  margin: 0;
}
.jd-builder-layout {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.jd-builder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: var(--space-4);
}
.jd-deck-section {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--jd-line);
  border-radius: var(--jd-radius);
  background: var(--background);
}
.jd-deck-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--jd-line);
  background: var(--jd-surface);
}
.jd-deck-section-head h4 {
  margin: 0;
  font-size: var(--text-6);
}
.jd-deck-section-head .badge {
  flex: none;
}
.jd-deck-section-body {
  padding-bottom: var(--space-3);
}
.jd-empty {
  margin: 0;
  padding: var(--space-4) var(--space-4) 0;
  color: var(--muted-foreground);
  font-size: var(--text-7);
}
.jd-card-groups {
  display: flex;
  flex-direction: column;
}
.jd-deck-group + .jd-deck-group,
.jd-card-group + .jd-card-group {
  border-top: 1px solid var(--border);
}
.jd-deck-group-head {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--jd-surface);
}
.jd-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0 var(--space-2);
  padding: var(--space-3) var(--space-4) 0;
  overflow: hidden;
}
.jd-card-tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 63 / 88;
  margin-bottom: calc(-1 * var(--jd-card-overlap));
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-medium);
  background: var(--muted);
  cursor: pointer;
}
.jd-card-tile:hover,
.jd-card-tile:focus-visible {
  z-index: 2;
}
.jd-card-tile img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: inherit;
}
.jd-card-tile:hover {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.jd-card-tile:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.jd-card-tile:disabled {
  cursor: not-allowed;
}
.jd-card-tile:disabled .jd-card-action {
  opacity: 0.35;
}
.jd-card-count,
.jd-card-action {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgb(0 0 0 / 0.72);
  color: #fff;
  font-weight: 700;
  line-height: 1;
}
.jd-card-count {
  top: var(--space-1);
  right: var(--space-1);
  min-width: 1.25rem;
  height: 1.25rem;
  padding-inline: var(--space-1);
  font-size: var(--text-8);
}
.jd-card-action {
  top: 50%;
  left: 50%;
  width: 2rem;
  height: 2rem;
  transform: translate(-50%, -50%);
  font-size: var(--text-5);
  opacity: 0;
  transition: opacity 0.12s;
}
.jd-card-tile:hover .jd-card-action,
.jd-card-tile:focus-visible .jd-card-action {
  opacity: 1;
}
.jd-card-tile .jd-card-fallback {
  position: static;
  aspect-ratio: 63 / 88;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: inherit;
  background: var(--card);
  font-size: var(--text-8);
  line-height: 1.3;
}
.jd-deck-list {
  overflow: visible;
  border: 0;
  border-radius: 0;
}
.jd-deck-row {
  position: relative;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) 8rem var(--jd-control);
  align-items: center;
  gap: var(--space-2);
  height: 2.25rem;
  padding: 0 var(--space-4);
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-7);
}
.jd-deck-row:hover {
  background: var(--jd-surface);
}
.jd-deck-list .jd-deck-art {
  display: none;
}
.jd-deck-row:last-child {
  border-bottom: 0;
}
.jd-deck-art {
  position: absolute;
  inset-block: 0;
  right: calc(var(--jd-control) + var(--space-2));
  width: 45%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 28%;
  opacity: 0.45;
  mask-image: linear-gradient(
    to right,
    transparent,
    black 55%,
    black 85%,
    transparent
  );
  pointer-events: none;
}
.jd-deck-row > :not(.jd-deck-art) {
  position: relative;
}
.jd-deck-count {
  text-align: right;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}
.jd-deck-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.jd-deck-meta {
  overflow: hidden;
  max-width: 8rem;
  padding-inline: var(--space-1);
  border-radius: var(--radius-small);
  background: var(--jd-surface);
  color: var(--muted-foreground);
  font-size: var(--text-8);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.jd-deck-btn {
  width: var(--jd-control);
  height: 1.75rem;
  padding: 0;
  font-size: var(--text-5);
  line-height: 1;
}
.jd-subhead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  margin: var(--space-4) var(--space-4) var(--space-2);
}
.jd-subhead h5 {
  margin: 0;
}
.jd-subhead button {
  min-height: 1.75rem;
  padding-block: var(--space-1);
}
.jd-basics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  padding: 0 var(--space-4);
}
.jd-basic-row {
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr) 2rem 1.75rem 1.75rem;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-medium);
  font-size: var(--text-7);
}
.jd-basic-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.jd-builder-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
.jd-builder-stats h5 {
  margin: 0 0 var(--space-2);
}
.jd-builder-stats .jd-colors {
  margin: 0 0 var(--space-5);
}
.jd-colors {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-block: var(--space-3);
}
.jd-color-row {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr) 1.5rem;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-7);
}
.jd-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  font-size: var(--text-8);
  font-weight: 700;
}
.jd-pip-W {
  background: #f7f0d5;
  color: #5b4a12;
}
.jd-pip-U {
  background: #cfe7f7;
  color: #123a57;
}
.jd-pip-B {
  background: #3a3a3a;
  color: #f0f0f0;
}
.jd-pip-R {
  background: #f6d3c8;
  color: #6b1f10;
}
.jd-pip-G {
  background: #d4ead1;
  color: #1f4a1c;
}
.jd-pip-C {
  background: var(--muted);
  color: var(--muted-foreground);
}
.jd-bar {
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--muted);
}
.jd-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--primary);
}
.jd-fill-W {
  background: #c9b458;
}
.jd-fill-U {
  background: #4a90c4;
}
.jd-fill-B {
  background: #555;
}
.jd-fill-R {
  background: #c4553f;
}
.jd-fill-G {
  background: #4f8a46;
}
.jd-fill-C {
  background: #8a8a8a;
}
.jd-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.jd-curve {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  height: 6rem;
  margin: var(--space-3) 0 var(--space-4);
  padding-top: var(--space-2);
}
.jd-curve-col {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: var(--space-1);
}
.jd-bar-v {
  width: 100%;
  max-width: 28px;
  min-height: 2px;
  border-radius: var(--radius-medium) var(--radius-medium) 0 0;
  background: var(--primary);
}
.jd-curve-n,
.jd-curve-label {
  color: var(--muted-foreground);
  font-size: var(--text-8);
  font-variant-numeric: tabular-nums;
}
.jd-decklist-label {
  display: block;
  margin-top: var(--space-4);
  color: var(--muted-foreground);
  font-size: var(--text-7);
  font-weight: 600;
}
.jd-decklist-label .jd-hint {
  margin-left: var(--space-1);
  font-weight: 400;
}
textarea.jd-decklist {
  width: 100%;
  min-height: 12rem;
  font-family: var(--font-mono);
  font-size: var(--text-8);
  line-height: 1.5;
  resize: vertical;
  white-space: pre;
}

details {
  margin-top: var(--space-3);
}

/* Toast */
.jd-toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  z-index: 50;
  max-width: calc(100vw - 2rem);
  padding: var(--space-2) var(--space-4);
  transform: translateX(-50%);
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: var(--text-7);
  text-align: center;
  box-shadow: var(--shadow-medium);
}

@media (min-width: 1400px) {
  .jd-builder-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(300px, 0.72fr);
  }
  .jd-builder-grid {
    display: contents;
  }
  .jd-builder-stats {
    grid-template-columns: 1fr;
    gap: var(--space-5);
    padding-top: 0;
    padding-left: var(--space-5);
    border-top: 0;
    border-left: 1px solid var(--border);
  }
}

@media (max-width: 900px) {
  .jd-table {
    grid-template-columns: 1fr;
  }
  .jd-pool {
    position: static;
    flex-direction: row;
    overflow-x: auto;
  }
  .jd-pool .jd-player {
    flex: 1;
    min-width: 220px;
  }
  .jd-mini {
    max-height: 150px;
  }
  .jd-builder-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .jd-builder-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .jd-builder-actions button {
    width: 100%;
  }
  .jd-builder-actions button:first-child {
    grid-column: 1 / -1;
  }
  .jd-builder-toolbar {
    align-items: stretch;
  }
  .jd-builder-view {
    justify-content: space-between;
    width: 100%;
  }
  .jd-builder-stats {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }
}

@media (max-width: 640px) {
  .jd-settings {
    grid-template-columns: 1fr 1fr;
  }
  .jd-results {
    grid-template-columns: 1fr;
  }
  .jd-board {
    grid-template-columns: 26px repeat(3, minmax(0, 1fr));
    gap: var(--space-1);
  }
}

.jd-footer {
  margin-top: var(--space-10);
  padding-block: var(--space-6) var(--space-10);
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: var(--text-8);
}
.jd-footer p {
  max-width: 80ch;
  margin: 0 0 var(--space-2);
}
.jd-footer p:last-child {
  margin-bottom: 0;
}
.jd-footer a {
  color: inherit;
  text-decoration: underline;
}

/* Shared sessions */
.jd-conn {
  font-size: var(--text-8);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.jd-conn-live {
  background: var(--success);
  color: var(--success-foreground);
}
.jd-invite {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--primary);
  border-radius: var(--jd-radius);
  background: var(--faint);
}
.jd-invite-text {
  display: flex;
  flex: 1 1 220px;
  flex-direction: column;
  gap: var(--space-1);
}
.jd-invite-link {
  flex: 1 1 260px;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--text-8);
}
.jd-invite button {
  flex: 0 0 auto;
}

/* Seat picker */
.jd-seats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.jd-seat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-medium);
  background: var(--card);
  color: var(--foreground);
  text-align: left;
  cursor: pointer;
}
.jd-seat:hover:not(:disabled) {
  border-color: var(--primary);
}
.jd-seat:disabled {
  opacity: 1;
  cursor: default;
}
.jd-seat-taken {
  background: var(--faint);
  color: var(--muted-foreground);
}
.jd-seat strong {
  font-size: var(--text-4);
}
.jd-seat-actions {
  margin-top: var(--space-3);
}
@media (max-width: 560px) {
  .jd-seats {
    grid-template-columns: 1fr;
  }
  .jd-basics {
    grid-template-columns: 1fr;
  }
  .jd-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  }
  .jd-deck-row {
    grid-template-columns: 1.5rem minmax(0, 1fr) var(--jd-control);
  }
  .jd-deck-meta {
    display: none;
  }
}

.jd-rejoin {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.jd-outlook {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  font-size: var(--text-7);
}
.jd-analysis {
  container-type: inline-size;
}
.jd-outlook-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  padding-top: var(--space-3);
}
.jd-outlook-head,
.jd-outlook summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  cursor: pointer;
  font-weight: 600;
}
.jd-outlook-head {
  cursor: default;
}
.jd-outlook > .jd-decklist {
  display: block;
  margin-top: var(--space-3);
}
.jd-outlook-title {
  margin: 0 0 var(--space-2);
}
.jd-outlook-foot {
  margin: 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.jd-outlook-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.jd-outlook-rows li {
  display: grid;
  grid-template-columns: 9.5em 1fr 3em;
  align-items: center;
  gap: var(--space-2);
}
.jd-outlook-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.jd-outlook-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted-foreground);
}
.jd-outlook-rows li.jd-met .jd-bar-fill {
  background: var(--success, #2e8b57);
}
.jd-bar-v.jd-met {
  background: var(--success, #2e8b57);
}
.jd-outlook-rows li.jd-met .jd-outlook-count {
  color: var(--success, #2e8b57);
  font-weight: 600;
}
.jd-outlook-curve {
  height: 64px;
  margin: 0;
}
.jd-preview {
  position: fixed;
  z-index: 100;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.45);
  pointer-events: none;
}
.jd-preview img {
  display: block;
  width: 100%;
  border-radius: 14px;
}
.jd-pool-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-height: 340px;
  overflow: auto;
  overscroll-behavior: contain;
}
.jd-pick {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 26px;
  padding: 0 var(--space-2) 0 var(--space-1);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--card);
  font-size: var(--text-7);
}
.jd-pick-art {
  position: absolute;
  top: 0;
  right: 0;
  width: 60%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 28%; /* faces sit above the middle of most card art */
  opacity: 0.6;
  mask-image: linear-gradient(to right, transparent, black 70%);
}
.jd-pick > :not(.jd-pick-art) {
  position: relative;
}
.jd-pick-cost {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: var(--text-8);
  font-weight: 700;
}
.jd-pip-M {
  background: #ecd9a0;
  color: #5b4a12;
}
.jd-pick-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.jd-pick-pips {
  display: flex;
  flex: none;
  gap: var(--space-1);
}
.jd-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.25);
}
.jd-pick-count {
  flex: none;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: var(--text-8);
  font-weight: 700;
}
.jd-pool-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.jd-group-head {
  display: flex;
  justify-content: space-between;
  margin: var(--space-2) var(--space-1) 0;
}
/* Round, whose turn it is, and the buttons all live in the sticky top bar, so the grid starts high. */
.jd-head-turn {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-6);
  font-weight: 600;
}
.jd-head-actions {
  display: flex;
  gap: var(--space-2);
}
.jd-head-btn {
  min-height: 0;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-7);
}
@media (max-width: 640px) {
  .jd-topbar {
    flex-wrap: wrap;
  }
  .jd-head-turn {
    order: 5;
    flex-basis: 100%;
    white-space: normal;
  }
}
/* The draft screen uses the whole width: a wide board in the middle, a fixed-width pool beside it. */
main.container.jd-wide {
  max-width: 1760px;
}
@container (min-width: 480px) {
  .jd-analysis .jd-outlook-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4) var(--space-5);
  }
  .jd-outlook-foot {
    grid-column: 1 / -1;
  }
}
.jd-others {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.jd-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 0;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--jd-edge);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--foreground);
  font-size: var(--text-7);
}
.jd-chip.jd-open {
  background: var(--muted);
}
.jd-chip:disabled {
  cursor: default;
  opacity: 0.7;
}
.jd-chip.jd-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.jd-seat-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.jd-seat-bot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--text-7);
}
.jd-recent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.jd-chip-group {
  display: inline-flex;
  align-items: center;
}
.jd-chip-group .jd-chip {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.jd-chip-x {
  min-height: 0;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--jd-edge);
  border-left: 0;
  border-radius: 0 99px 99px 0;
  background: transparent;
  color: var(--muted-foreground);
  font-size: var(--text-7);
}
