:root {
  color-scheme: dark;
  --mobile-bg: #05070d;
  --mobile-panel: rgba(14, 22, 36, 0.94);
  --mobile-panel-strong: #111a2a;
  --mobile-line: rgba(108, 210, 255, 0.28);
  --mobile-line-strong: rgba(108, 210, 255, 0.58);
  --mobile-text: #eef7ff;
  --mobile-muted: #9eb2c5;
  --mobile-cyan: #5fd8ff;
  --mobile-amber: #f6c75c;
  --mobile-red: #ff6b73;
  --mobile-green: #5ee28d;
  --mobile-radius: 8px;
  font-family: Inter, "Atkinson Hyperlegible", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(62, 163, 255, 0.14), transparent 34%),
    linear-gradient(180deg, #080d16 0%, #03050a 100%);
  color: var(--mobile-text);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  color: inherit;
}

.hidden {
  display: none !important;
}

.mobile-builder-shell {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(14, 24, 41, 0.96), rgba(5, 7, 13, 0.98)),
    var(--mobile-bg);
  box-shadow: 0 0 70px rgba(0, 0, 0, 0.48);
}

.mobile-deck-summary {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--mobile-line);
  background: rgba(6, 10, 18, 0.96);
  backdrop-filter: blur(14px);
}

.mobile-brand-row,
.mobile-filter-meta,
.mobile-sideboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mobile-brand-row img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.mobile-brand-row strong {
  flex: 1;
  font-size: 0.95rem;
  letter-spacing: 0;
}

.mobile-desktop-link,
.mobile-filter-meta button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--mobile-cyan);
  text-decoration: none;
  background: transparent;
}

.mobile-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 96px;
  gap: 8px;
  margin-top: 10px;
}

.mobile-slot-card,
.mobile-count-tile {
  min-width: 0;
  min-height: 58px;
  border: 1px solid var(--mobile-line);
  border-radius: var(--mobile-radius);
  background: rgba(18, 29, 47, 0.84);
}

.mobile-slot-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  text-align: left;
}

.mobile-slot-art {
  display: grid;
  width: 34px;
  height: 44px;
  place-items: center;
  border-radius: 5px;
  background: linear-gradient(150deg, #18253b, #0a101c);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--mobile-cyan);
  font-weight: 800;
}

.mobile-slot-card.is-picking {
  border-color: var(--mobile-amber);
  box-shadow: inset 0 0 0 1px rgba(246, 199, 92, 0.32);
}

.mobile-slot-art-selected {
  overflow: hidden;
  background: #05070d;
}

.mobile-slot-art-selected img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-slot-card span:last-child,
.mobile-count-tile small {
  min-width: 0;
  overflow: hidden;
  font-size: 0.72rem;
  color: var(--mobile-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-count-tile {
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 8px;
  text-align: center;
}

#mobile-total-count {
  color: var(--mobile-amber);
  font-size: 1.15rem;
  font-weight: 800;
}

.mobile-active-aspects {
  display: flex;
  min-height: 30px;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}

.mobile-active-aspects img,
.mobile-aspect-button img {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.mobile-builder-main {
  padding: 12px 10px 86px;
}

.mobile-filter-panel,
.mobile-vault-panel,
.mobile-stats-grid,
.mobile-deck-list {
  display: grid;
  gap: 10px;
}

.mobile-filter-panel,
.mobile-vault-panel {
  padding: 12px;
  border: 1px solid var(--mobile-line);
  border-radius: var(--mobile-radius);
  background: var(--mobile-panel);
}

.mobile-search-field,
.mobile-vault-name,
.mobile-filter-row label {
  display: grid;
  gap: 5px;
}

.mobile-search-field span,
.mobile-vault-name span,
.mobile-filter-row span,
.mobile-stat-card span,
.mobile-focused-count {
  color: var(--mobile-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.mobile-search-field input,
.mobile-vault-name input,
.mobile-filter-row select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--mobile-line);
  border-radius: var(--mobile-radius);
  background: #08111f;
  color: var(--mobile-text);
  padding: 0 12px;
}

.mobile-vault-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mobile-vault-actions button {
  border-radius: var(--mobile-radius);
  background: rgba(95, 216, 255, 0.12);
  border: 1px solid var(--mobile-line);
  color: var(--mobile-cyan);
  font-weight: 800;
}

.mobile-vault-actions button:first-child {
  background: rgba(94, 226, 141, 0.16);
  border-color: rgba(94, 226, 141, 0.48);
  color: #d8ffe4;
}

.mobile-vault-status {
  min-height: 22px;
  color: var(--mobile-muted);
  font-size: 0.78rem;
}

.mobile-vault-list {
  display: grid;
  max-height: 188px;
  gap: 8px;
  overflow-y: auto;
}

.mobile-vault-row {
  display: grid;
  min-height: 54px;
  gap: 3px;
  border: 1px solid var(--mobile-line);
  border-radius: var(--mobile-radius);
  background: #0a1422;
  color: var(--mobile-text);
  padding: 8px 10px;
  text-align: left;
}

.mobile-vault-row.active {
  border-color: var(--mobile-amber);
}

.mobile-vault-row strong,
.mobile-vault-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-vault-row span {
  color: var(--mobile-muted);
  font-size: 0.74rem;
}

.mobile-filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mobile-aspect-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  gap: 6px;
}

.mobile-aspect-button {
  min-width: 44px;
  border: 1px solid var(--mobile-line);
  border-radius: var(--mobile-radius);
  background: #0a1422;
  display: grid;
  place-items: center;
  position: relative;
}

.mobile-aspect-row.is-locked .mobile-aspect-button,
.mobile-aspect-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.mobile-aspect-button::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4a5565;
}

.mobile-aspect-button[data-state="include"] {
  border-color: rgba(94, 226, 141, 0.88);
  box-shadow: inset 0 0 0 1px rgba(94, 226, 141, 0.28);
}

.mobile-aspect-button[data-state="include"]::after {
  background: var(--mobile-green);
}

.mobile-aspect-button[data-state="exclude"] {
  border-color: rgba(255, 107, 115, 0.9);
  opacity: 0.7;
}

.mobile-aspect-button[data-state="exclude"]::after {
  background: var(--mobile-red);
}

.mobile-filter-meta {
  min-height: 44px;
  color: var(--mobile-muted);
  font-size: 0.8rem;
}

.mobile-rolodex-section {
  margin-top: 14px;
  min-height: 338px;
}

.mobile-status {
  min-height: 24px;
  color: var(--mobile-muted);
  font-size: 0.82rem;
  text-align: center;
}

.mobile-rolodex {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 68%);
  align-items: center;
  gap: 10px;
  min-height: 316px;
  overflow-x: auto;
  padding: 12px calc(50% - 115px) 16px;
  scroll-padding-inline: calc(50% - 115px);
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.mobile-rolodex::-webkit-scrollbar {
  display: none;
}

.mobile-card-frame {
  min-height: 296px;
  scroll-snap-align: center;
  border: 1px solid var(--mobile-line);
  border-radius: var(--mobile-radius);
  background: linear-gradient(180deg, #182335, #09111d);
  box-shadow: 0 22px 36px rgba(0, 0, 0, 0.48);
  transform: scale(0.92);
  transition: transform 160ms ease, border-color 160ms ease, opacity 160ms ease;
  opacity: 0.62;
  overflow: hidden;
}

.mobile-card-frame.is-focused {
  border-color: var(--mobile-line-strong);
  opacity: 1;
  transform: scale(1);
}

.mobile-card-art {
  aspect-ratio: 5 / 7;
  display: grid;
  place-items: center;
  background:
    linear-gradient(145deg, rgba(95, 216, 255, 0.22), transparent 48%),
    linear-gradient(180deg, #283852, #0c1626);
}

.mobile-card-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #070b12;
}

.mobile-card-art-fallback {
  width: 72%;
  aspect-ratio: 5 / 7;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: var(--mobile-cyan);
  font-size: 3rem;
  font-weight: 800;
}

.mobile-card-meta {
  color: var(--mobile-muted);
  font-size: 0.75rem;
}

.mobile-card-fallback-title {
  padding: 8px 10px 10px;
  color: var(--mobile-text);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.2;
}

.mobile-focused-controls {
  display: grid;
  gap: 9px;
  margin-top: 4px;
  padding: 0 4px;
}

.mobile-focused-count {
  text-align: center;
}

.mobile-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mobile-remove-button,
.mobile-add-button {
  border-radius: var(--mobile-radius);
  font-weight: 800;
}

.mobile-remove-button {
  background: rgba(255, 107, 115, 0.18);
  border: 1px solid rgba(255, 107, 115, 0.45);
  color: #ffd8dc;
}

.mobile-add-button {
  background: rgba(94, 226, 141, 0.18);
  border: 1px solid rgba(94, 226, 141, 0.5);
  color: #d8ffe4;
}

.mobile-bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 100%;
  max-width: 430px;
  transform: translateX(-50%);
  border-top: 1px solid var(--mobile-line);
  background: rgba(6, 10, 18, 0.96);
  backdrop-filter: blur(14px);
}

.mobile-bottom-nav button,
.mobile-tab-row button {
  background: transparent;
  color: var(--mobile-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.mobile-bottom-nav button.active,
.mobile-tab-row button.active {
  color: var(--mobile-cyan);
  box-shadow: inset 0 -2px 0 var(--mobile-cyan);
}

.mobile-tab-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--mobile-line);
  border-radius: var(--mobile-radius);
  overflow: hidden;
}

.mobile-deck-list {
  margin-top: 12px;
}

.mobile-deck-group {
  display: grid;
  gap: 6px;
}

.mobile-deck-group h3 {
  margin: 12px 0 0;
  color: var(--mobile-cyan);
  font-size: 0.78rem;
}

.mobile-deck-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px 44px;
  align-items: center;
  min-height: 54px;
  gap: 8px;
  border: 1px solid var(--mobile-line);
  border-radius: var(--mobile-radius);
  background: var(--mobile-panel);
  padding: 6px 8px;
  touch-action: pan-y;
}

.mobile-deck-row-cost,
.mobile-deck-row-qty {
  display: grid;
  min-height: 36px;
  place-items: center;
  border-radius: 6px;
  background: #0a1422;
  color: var(--mobile-amber);
  font-weight: 800;
}

.mobile-deck-row-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-sideboard-action {
  min-width: 44px;
  border-radius: 6px;
  background: rgba(95, 216, 255, 0.12);
  color: var(--mobile-cyan);
}

.mobile-stats-grid {
  grid-template-columns: 1fr 1fr;
}

.mobile-stat-card {
  min-height: 110px;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--mobile-line);
  border-radius: var(--mobile-radius);
  background: var(--mobile-panel);
}

.mobile-stat-card:first-child,
.mobile-stat-card:nth-child(2) {
  grid-column: 1 / -1;
}

.mobile-curve-chart {
  display: flex;
  align-items: end;
  gap: 7px;
  min-height: 112px;
}

.mobile-curve-bar {
  flex: 1;
  display: grid;
  align-items: end;
  gap: 4px;
  min-width: 0;
  text-align: center;
  color: var(--mobile-muted);
  font-size: 0.68rem;
}

.mobile-curve-bar span:first-child {
  min-height: 12px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--mobile-cyan), rgba(95, 216, 255, 0.22));
}

.mobile-type-counts {
  display: grid;
  gap: 8px;
}

.mobile-type-counts div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.mobile-empty {
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--mobile-line);
  border-radius: var(--mobile-radius);
  color: var(--mobile-muted);
  text-align: center;
  padding: 16px;
}

@media (min-width: 760px) {
  body {
    padding: 24px 0;
  }

  .mobile-builder-shell {
    min-height: calc(100vh - 48px);
    border: 1px solid var(--mobile-line);
    border-radius: 18px;
    overflow: hidden;
  }

  .mobile-bottom-nav {
    position: sticky;
    transform: none;
    left: auto;
    margin: 0 auto;
  }
}
