/* Deck builder — dense “simulator” workspace (inspired by modern web deck builders) */
body.hub-page.deckbuilder-app .hub-main {
  padding-top: 88px;
  max-width: 100%;
}

body.hub-page.deckbuilder-app .hub-container {
  width: min(1600px, 98vw);
}

.deckbuilder-shell {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.deckbuilder-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--hub-border);
  border-radius: 14px;
  background: var(--gradient-card);
}

.deckbuilder-brand {
  flex: 1 1 200px;
  min-width: 0;
}

.deck-name-input {
  width: 100%;
  max-width: 420px;
  margin-top: 0.35rem;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--font-primary, inherit);
  border: 1px solid var(--border-secondary);
  border-radius: 10px;
  background: rgba(10, 6, 18, 0.65);
  color: var(--text-primary);
  padding: 0.45rem 0.65rem;
}

.deckbuilder-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
}

.deck-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border-primary);
  background: rgba(26, 15, 40, 0.85);
  color: var(--text-secondary);
}

.deck-stat-pill strong {
  color: var(--text-accent);
  font-weight: 800;
}

.deckbuilder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.deckbuilder-actions .btn-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}

.deck-smart-wrap {
  align-items: center;
  margin: 0;
  font-size: 0.85rem;
  color: var(--hub-muted);
  user-select: none;
}

.deck-smart-wrap input {
  width: auto;
  margin: 0;
}

.deckbuilder-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 0.85rem;
  align-items: start;
}

@media (max-width: 960px) {
  .deckbuilder-workspace {
    grid-template-columns: 1fr;
  }
}

.deckbuilder-library {
  border: 1px solid var(--hub-border);
  border-radius: 14px;
  background: var(--gradient-card);
  padding: 0.85rem;
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  min-height: 280px;
}

@media (max-width: 960px) {
  .deckbuilder-library {
    position: relative;
    top: auto;
    max-height: none;
  }
}

.library-filters {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
}

.library-results {
  flex: 1;
  overflow-y: auto;
  margin-top: 0.5rem;
  padding-right: 2px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.library-card {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem;
  border-radius: 10px;
  border: 1px solid var(--border-primary);
  background: rgba(12, 8, 22, 0.75);
}

.library-card img {
  width: 52px;
  height: 76px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(124, 58, 237, 0.35);
}

.library-card-meta {
  min-width: 0;
}

.library-card-meta strong {
  display: block;
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.25;
}

.library-card-meta small {
  display: block;
  font-size: 0.72rem;
  color: var(--hub-muted);
  margin-top: 0.15rem;
  line-height: 1.2;
}

.library-card-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.library-card-actions .btn-zone {
  flex: 1;
  min-width: 4.5rem;
  font-size: 0.72rem;
  padding: 0.3rem 0.35rem;
}

.deckbuilder-board {
  border: 1px solid var(--hub-border);
  border-radius: 14px;
  background: linear-gradient(165deg, rgba(18, 10, 32, 0.96) 0%, rgba(8, 6, 16, 0.98) 100%);
  padding: 0.75rem;
}

.deck-zone {
  margin-bottom: 0.85rem;
}

.deck-zone:last-child {
  margin-bottom: 0;
}

.deck-zone > header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
  font-family: var(--font-primary, inherit);
  font-size: 0.95rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(124, 58, 237, 0.25);
  padding-bottom: 0.35rem;
}

.deck-zone > header small {
  font-size: 0.72rem;
  color: var(--hub-muted);
  font-weight: 500;
}

.deck-zone--main .deck-card-grid {
  min-height: 120px;
}

.deck-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 0.4rem;
}

.deck-card-tile {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(34, 211, 238, 0.25);
  background: #0a0612;
  aspect-ratio: 59 / 86;
}

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

.deck-card-tile .deck-card-qty {
  position: absolute;
  right: 2px;
  top: 2px;
  min-width: 1.25rem;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.1rem 0.25rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.82);
  color: #fde047;
  border: 1px solid rgba(251, 191, 36, 0.45);
}

.deck-card-tile .deck-card-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.12s ease;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.92));
  padding: 0.2rem;
}

.deck-card-tile:hover .deck-card-actions,
.deck-card-tile:focus-within .deck-card-actions {
  opacity: 1;
}

.deck-card-tile button {
  flex: 1;
  font-size: 0.75rem;
  font-weight: 700;
  border: none;
  border-radius: 4px;
  padding: 0.2rem 0;
  cursor: pointer;
  background: rgba(124, 58, 237, 0.85);
  color: #fff;
}

.deck-card-tile button:hover {
  background: rgba(168, 85, 247, 0.95);
}

.deck-card-tile button.deck-act-remove {
  flex: 0 0 1.4rem;
  background: rgba(190, 24, 93, 0.9);
}

.deck-zone-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 1.25rem 0.5rem;
  font-size: 0.8rem;
  color: var(--hub-muted);
  border: 1px dashed rgba(124, 58, 237, 0.35);
  border-radius: 10px;
}

#deck-status.deck-status-bar {
  margin-top: 0.45rem;
  display: block;
  min-height: 1.1rem;
}

dialog.deck-dialog {
  border: 1px solid var(--hub-border);
  border-radius: 14px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 0;
  max-width: min(560px, 94vw);
}

dialog.deck-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.deck-dialog-inner {
  padding: 1rem;
}

.deck-dialog-inner h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.deck-dialog-inner textarea {
  width: 100%;
  min-height: 180px;
  margin: 0.5rem 0;
  border-radius: 10px;
  border: 1px solid var(--border-secondary);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 0.5rem;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
}

.deck-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
