@font-face {
  font-family: 'Inter';
  src: url('/fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: 'Orbitron';
  src: url('/fonts/Orbitron-Bold.ttf') format('truetype');
  font-weight: 600 700;
  font-display: swap;
}

@font-face {
  font-family: 'Orbitron';
  src: url('/fonts/Orbitron-Black.ttf') format('truetype');
  font-weight: 800 900;
  font-display: swap;
}

:root {
  --bg: #0b0d11;
  --surface: #14181f;
  --surface-2: #1b2029;
  --border: #262d3a;
  --text: #d4d8e0;
  --text-dim: #7b8494;
  --accent: #38bdf8;
  --font: 'Orbitron', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(56, 189, 248, 0.07), transparent 60%),
    radial-gradient(900px 420px at 10% -10%, rgba(168, 85, 247, 0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
}

/* ============ display font ============ */

.brand,
.page-title,
.section-title,
.modal-title,
.franchise-title,
.pack-reveal-title,
.pack-progress-title,
.trade-side-name,
.pack-card-name {
  font-family: var(--font);
}

/* ============ top bar ============ */

#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.2rem;
  background: rgba(11, 13, 17, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.35);
}

#nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-right: auto;
  margin-left: 1rem;
}

#nav a {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
}

#nav a:hover,
#nav a.active {
  color: var(--accent);
  border-color: var(--border);
}

.nav-badge {
  display: inline-block;
  min-width: 1.1rem;
  margin-left: 0.45rem;
  padding: 1px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.58rem;
  text-align: center;
}

.nav-badge.action {
  background: #b45309;
  border-color: #f59e0b;
  color: #fff;
}

.user {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.user img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
}

.user-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

#user-name {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  text-decoration: none;
  max-width: 100%;
}

#user-name:hover,
#user-name:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  outline: none;
}

#user-progress {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  white-space: nowrap;
}

#user-credits {
  font-family: inherit;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
  white-space: nowrap;
}

button#user-credits {
  padding: 0;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
}

button#user-credits:hover,
button#user-credits:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

#logout {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
}

#logout:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ============ franchises ============ */

.gallery {
  max-width: none;
  margin: 0 auto;
  padding: 1.5rem 1.2rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2.2rem;
}

.status {
  text-align: center;
  color: var(--text-dim);
  padding: 4rem 1rem;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.status.error {
  color: #f87171;
}

/* ============ filter ============ */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.filter-bar .search-input {
  flex: 1;
  min-width: 0;
  max-width: 9cm;
  margin-bottom: 0;
}

.filter-bar .search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.filter-bar .filter-progress {
  flex-shrink: 0;
  margin-left: auto;
}

.filter-bar .progress-bar {
  width: 200px;
}

.filter-clear {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-dim);
  font: inherit;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.filter-clear:hover {
  color: #f87171;
  border-color: #f87171;
}

/* ============ franchise filter ============ */

.franchise-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.franchise-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.franchise-chip:hover,
.franchise-chip:focus-visible {
  color: var(--text);
  border-color: var(--accent);
}

.franchise-chip.active {
  color: var(--text);
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.12);
}

.franchise-chip .progress {
  gap: 0.45rem;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
}

.franchise-chip .progress-bar {
  width: 44px;
}

.franchise-section {
  min-width: 0;
}

.franchise-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
}

.franchise-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  white-space: nowrap;
}

.progress-bar {
  width: 130px;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  transition: width 0.4s ease;
}

/* ============ tiles ============ */

.grid {
  display: grid;
  /* Keep an odd number of columns so every centred row shares the same tracks
     across the page. Cards target 275-300px, so only advance to the next odd
     count once it fits. */
  grid-template-columns: minmax(0, 300px);
  justify-content: center;
  gap: 0.8rem;
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 300px));
  }
}

@media (min-width: 1500px) {
  .grid {
    grid-template-columns: repeat(5, minmax(0, 300px));
  }
}

@media (min-width: 2100px) {
  .grid {
    grid-template-columns: repeat(7, minmax(0, 300px));
  }
}

@media (min-width: 2700px) {
  .grid {
    grid-template-columns: repeat(9, minmax(0, 300px));
  }
}

.tile {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 12px; /* rounded keyboard outline; the card image supplies the visual shape */
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
}

.tile:hover {
  transform: translateY(-2px);
}

.tile:focus-visible {
  outline: 2px solid var(--tile-accent, var(--accent));
  outline-offset: 4px;
}

.tile-art {
  display: block;
  width: 100%;
  aspect-ratio: 528 / 700; /* renderer canvas: 432x604 template + 48 margin a side */
  object-fit: cover;
  background: transparent;
}

.tile.unowned .tile-art {
  filter: grayscale(1) brightness(0.38);
}

/* Shown when the card image fails even after the retry: the tile must still say
   which character it belongs to. */
.tile-fallback {
  display: none;
  position: absolute;
  inset: 6.86% 9.09%; /* align with the rendered card inside the output margin */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.8rem;
  border-radius: 8px;
  text-align: center;
  background: var(--surface-2);
}

.tile.image-error .tile-fallback {
  display: flex;
}

.tile-fallback-name {
  max-width: 100%;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.tile-fallback-rarity {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tile-accent, var(--text-dim));
}

/* Every card badge (duplicate count and "for sale") shares the bottom-right
   corner of the rendered card, inside its output margin. */
.tile-badge {
  position: absolute;
  bottom: calc(6.86% + 4px);
  right: calc(9.09% + 4px);
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 900;
  color: #0b0d11;
  background: var(--tile-accent, var(--accent));
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
}

/* "For sale" $ badge on uncollected tiles: grey, like the pack duplicate tag,
   overriding the rarity accent the duplicate pill uses. */
.tile-badge.listed {
  background: #9ca3af;
}

/* ============ overlays ============ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.overlay.hidden,
.hidden {
  display: none !important;
}

/* Available to assistive technology without taking up visual space. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 9, 0.82);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: min(860px, 96vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 1.4rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-card.modal-wide {
  width: min(1180px, 96vw);
}

.modal-close {
  position: sticky;
  top: 0;
  z-index: 2;
  display: block;
  width: fit-content;
  margin: -0.6rem -0.4rem -1.5rem auto;
  padding: 0.1rem 0.35rem;
  border: none;
  border-radius: 8px;
  /* Opaque surface masks the content scrolling underneath the sticky button. */
  background: var(--surface);
  box-shadow: 0 0 0 0.25rem var(--surface);
  color: var(--text-dim);
  font-size: 1.3rem;
  font-weight: 900;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--accent);
}

/* Two-column card detail: the full rendered card (plus report control) on the left
   and the owner list on the right. */
.modal-layout {
  display: grid;
  grid-template-columns: minmax(0, 528px) minmax(0, 1fr);
  gap: 1.4rem;
  align-items: start;
}

.modal-card-column {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-width: 0;
}

/* The renderer's 1x canvas: 432x604 template + 48px margin a side. */
.modal-card-art {
  position: relative;
  width: 100%;
  max-width: 528px;
  aspect-ratio: 528 / 700;
}

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

/* Shown when the full card render keeps failing: the image is hidden and this
   fallback takes its place. */
.modal-card-fallback {
  display: none;
  position: absolute;
  inset: 6.86% 9.09%; /* align with the rendered card inside the output margin */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.8rem;
  border-radius: 8px;
  text-align: center;
  background: var(--surface-2);
}

.modal-card-art.image-error .modal-card-fallback {
  display: flex;
}

.modal-card-fallback-name {
  max-width: 100%;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.modal-card-fallback-rarity {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tile-accent, var(--text-dim));
}

.modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

/* ============ credit history ============ */

.history-status,
.history-empty {
  margin: 1.4rem 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}

.history-more {
  margin: 0.9rem 0 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 1rem;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.history-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.history-reason {
  font-size: 0.82rem;
}

.history-date {
  font-size: 0.66rem;
  color: var(--text-dim);
}

.history-amount {
  font-weight: 800;
  white-space: nowrap;
}

.history-amount.positive {
  color: #4ade80;
}

.history-amount.negative {
  color: #f87171;
}

/* ============ modal report form ============ */

.modal-report {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
}

.report-toggle {
  font-size: 0.62rem;
}

.report-form {
  display: flex;
  flex-direction: column;
  /* The report section centers its toggle; the expanded form stays column-wide. */
  align-self: stretch;
  gap: 0.6rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.report-prompt {
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.report-hint {
  margin: -0.35rem 0 0;
  color: var(--text-dim);
  font-size: 0.68rem;
  line-height: 1.4;
}

.report-textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  line-height: 1.5;
}

.report-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.report-status {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.7rem;
  line-height: 1.4;
}

.report-status.error {
  color: #f87171;
}

/* ============ modal owners ============ */

/* The owner column sits beside the card, so its heading needs top space to clear the
   sticky close button above it. */
.modal-owners {
  min-width: 0;
  padding-top: 2.2rem;
}

.modal-section-title {
  margin: 0 0 0.8rem;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.owner-heroes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.8rem;
}

/* Portrait hero card: the avatar is the picture, name and copy counts sit below */
.owner-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  text-align: center;
}

.owner-hero.you {
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.15);
}

.owner-hero-avatar {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.owner-hero-name {
  max-width: 100%;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.owner-hero-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.6rem;
  font-size: 0.6rem;
}

.owner-count {
  color: var(--text-dim);
  white-space: nowrap;
}

.owner-count strong {
  color: var(--text);
  font-size: 0.68rem;
}

.owner-count.holo,
.owner-count.holo strong {
  color: #e9d5ff;
}

.owner-you {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: #0b0d11;
  font-size: 0.52rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.owner-status {
  grid-column: 1 / -1;
  margin: 0.2rem 0;
  color: var(--text-dim);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.owner-status-error {
  color: #f87171;
}

/* ============ pages / trades ============ */

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.2rem 4rem;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}

.page-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.page-back {
  color: var(--text-dim);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
}

.page-back:hover {
  color: var(--accent);
}

.page-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-title {
  margin: 1.4rem 0 0.7rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn.primary {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.5);
  color: var(--accent);
}

.btn.danger {
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.4);
  color: #f87171;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.avatar-sm {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

/* ---------- trade list ---------- */

.trade-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.trade-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.trade-row:hover {
  border-color: var(--accent);
}

.trade-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}

.trade-partner {
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trade-sub {
  font-size: 0.64rem;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.trade-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  text-align: right;
}

.trade-chip {
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.trade-chip.action {
  color: #fbbf24;
  border-color: #b45309;
  background: rgba(180, 83, 9, 0.15);
}

.trade-chip.ready {
  color: #4ade80;
  border-color: #166534;
  background: rgba(22, 101, 52, 0.2);
}

.trade-timer {
  font-size: 0.6rem;
  color: var(--text-dim);
}

/* ---------- new trade ---------- */

.search-input {
  width: 100%;
  max-width: 420px;
  margin-bottom: 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

/* ---------- trade detail ---------- */

.trade-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.trade-bar-status {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.trade-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.trade-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.trade-side {
  min-height: 180px;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.trade-side-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.trade-side-name {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.trade-side-count {
  font-size: 0.62rem;
  color: var(--text-dim);
}

.trade-empty {
  padding: 1.2rem 0.2rem;
  color: var(--text-dim);
  font-size: 0.72rem;
}



/* ============ lightbox ============ */

#lightbox img {
  position: relative;
  max-width: min(92vmin, 620px);
  max-height: 92vh;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.7));
}

/* ============ toast ============ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  z-index: 30;
  padding: 0.6rem 1rem;
  border: 1px solid #7f1d1d;
  border-radius: 10px;
  background: #2a1215;
  color: #fca5a5;
  font-size: 0.75rem;
}

.toast.ok {
  border-color: #166534;
  background: #0f2417;
  color: #86efac;
}

/* ============ small screens ============ */

/* Stack the card above the owners on narrow screens. The card column keeps top space
   so it starts below the sticky close button. */
@media (max-width: 900px) {
  .modal-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .modal-card-column {
    width: 100%;
    max-width: 528px;
    margin: 0 auto;
    padding-top: 2rem;
  }

  .modal-owners {
    padding-top: 0;
  }
}

@media (max-width: 700px) {
  .trade-cols {
    grid-template-columns: 1fr;
  }

  .trade-meta {
    align-items: flex-start;
    text-align: left;
  }

  .trade-row,
  .player-row {
    flex-wrap: wrap;
  }
}

@media (max-width: 620px) {
  .grid {
    gap: 0.6rem;
  }
}

@media (max-width: 560px) {
  #topbar {
    flex-wrap: wrap;
    justify-content: center;
  }

  #nav {
    margin: 0;
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .filter-bar .progress-bar {
    width: 80px;
  }
}

/* ============ packs ============ */

.page-sub {
  margin: -0.6rem 0 1rem;
  color: var(--text-dim);
  font-size: 0.74rem;
  line-height: 1.5;
}

.pack-progress {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}

.pack-progress-item {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.pack-progress-item .progress {
  width: 100%;
}

.pack-progress-item .progress-bar {
  flex: 1 1 auto;
  width: auto;
}

.pack-progress-title {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.pack-progress-note {
  color: var(--text-dim);
  font-size: 0.68rem;
  line-height: 1.4;
}

.pack-progress-note.ready {
  color: #fbbf24;
  font-weight: 700;
}

.pack-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.pack-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.pack-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 74px;
  flex-shrink: 0;
  border: 1px solid var(--pack-accent, #38bdf8);
  border-radius: 8px;
  background: linear-gradient(160deg, var(--pack-accent, #38bdf8), #0b1220 88%);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.pack-visual-mark {
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.88);
  color: #0b1220;
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.pack-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
}

.pack-source {
  font-size: 0.8rem;
  font-weight: 800;
}

.pack-date {
  color: var(--text-dim);
  font-size: 0.68rem;
}

/* During a reveal the packs page becomes just the cards: no page heading and a
   wider canvas so the cards can grow with the window. The top bar stays put. */
.page.pack-reveal-mode {
  display: flex;
  flex-direction: column;
  max-width: 1600px;
  /* Fill the viewport below the sticky top bar so the reveal can center vertically.
     packs.js keeps the measured top-bar height in this custom property. */
  min-height: calc(100vh - var(--pack-topbar-height, 4rem));
  min-height: calc(100dvh - var(--pack-topbar-height, 4rem));
  padding-bottom: 1.5rem;
}

.pack-reveal-mode .page-head {
  display: none;
}

.pack-reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
}

.pack-reveal-mode .packs-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.pack-reveal-mode .pack-reveal {
  flex: 1;
  justify-content: center;
}

.pack-reveal-grid {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(0.6rem, 1.4vw, 1.25rem);
  width: 100%;
  /* packs.js replaces this with the measured card width so the whole pack stays on
     one row and every card is the same size. */
  --pack-card-width: 190px;
}

.pack-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  flex: 0 1 var(--pack-card-width);
  max-width: 380px;
  min-width: 0;
}

.pack-flip {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 7;
  perspective: 900px;
}

.pack-card-back,
.pack-card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--card-accent, #38bdf8);
  border-radius: 12px;
  backface-visibility: hidden;
  transition: transform 0.6s ease;
}

.pack-card-back {
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0 8px, transparent 8px 16px),
    linear-gradient(160deg, var(--card-accent, #38bdf8), #0b1220 90%);
  transform: rotateY(0deg);
}

.pack-card-back-mark {
  font-size: 2rem;
  font-weight: 800;
  color: var(--card-accent, #38bdf8);
  text-shadow: 0 0 16px rgba(0, 0, 0, 0.5);
}

.pack-card-face {
  overflow: hidden;
  background: #0b1220;
  transform: rotateY(180deg);
}

.pack-card.revealed .pack-card-back {
  transform: rotateY(180deg);
}

.pack-card.revealed .pack-card-face {
  transform: rotateY(360deg);
}

.pack-card.holo .pack-card-face {
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.35);
}

.pack-card-art {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}

.pack-card-name {
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.pack-card-meta {
  color: var(--text-dim);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* First-copy / duplicate pill above the card box, centered by the card's flex column. */
.pack-card-tag {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0b0d11;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
}

.pack-card-tag.new {
  background: #38bdf8;
}

.pack-card-tag.dupe {
  background: #9ca3af;
}

/* The name, rarity and tag stay hidden while the card is face-down. visibility (not
   display) keeps their space reserved so the grid does not jump on reveal, and the
   delayed fade lands as the 0.6s flip finishes (packs.js FLIP_MS). */
.pack-card-name,
.pack-card-meta,
.pack-card-tag {
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.25s ease 0.35s;
}

.pack-card.revealed .pack-card-name,
.pack-card.revealed .pack-card-meta,
.pack-card.revealed .pack-card-tag {
  visibility: visible;
  opacity: 1;
}

/* The sell/list controls and Back button are present but invisible (and not
   focusable) until every card has landed; visibility keeps their space reserved so
   the grid does not jump when they fade in. */
.pack-card-actions,
.pack-reveal-done {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.pack-reveal.is-ready .pack-card-actions,
.pack-reveal.is-ready .pack-reveal-done {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.pack-card-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  width: 100%;
  max-width: 260px;
  margin-top: 0.3rem;
}

.pack-card-price-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.pack-card-price-row .price-input {
  width: 100%;
  min-width: 0;
  padding: 0.35rem 0.4rem;
}

/* On narrow cards stack the price form and actions instead of crushing them into
   one line. packs.js toggles this when the shared card width drops below 180px. */
.pack-reveal-grid.pack-reveal-compact .pack-card-price-row {
  flex-direction: column;
  align-items: stretch;
}

/* Also keep the labels inside the shrunken card. Long names break, while the
   First/Duplicate pill truncates rather than spilling over neighbouring cards. */
.pack-reveal-grid.pack-reveal-compact .pack-card-name {
  max-width: 100%;
  font-size: 0.62rem;
  overflow-wrap: anywhere;
}

.pack-reveal-grid.pack-reveal-compact .pack-card-meta {
  max-width: 100%;
  font-size: 0.5rem;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

.pack-reveal-grid.pack-reveal-compact .pack-card-tag {
  max-width: 100%;
  padding: 2px 4px;
  font-size: 0.5rem;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pack-card-actions .btn {
  padding: 0.35rem 0.55rem;
  font-size: 0.6rem;
}

.pack-card-actions > .btn {
  justify-content: center;
}

.pack-card-action-note {
  color: var(--text-dim);
  font-size: 0.64rem;
  font-weight: 700;
  text-align: center;
}

.pack-reveal-done {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* A sold copy stays on the reveal for context, but is visibly spent. */
.pack-card.sold .pack-flip {
  opacity: 0.55;
  filter: grayscale(0.35);
}

@media (max-width: 700px) {
  .pack-progress {
    grid-template-columns: 1fr;
  }

  .pack-row {
    flex-wrap: wrap;
  }

  .pack-reveal-grid {
    gap: 0.6rem;
  }
}

/* ============ pack shop ============ */

.pack-shop {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 0.9rem;
  margin-bottom: 1.2rem;
}

.pack-shop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.pack-shop-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pack-shop-balance {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.pack-shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.7rem;
}

.shop-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-top: 3px solid var(--pack-accent, var(--border));
  border-radius: 10px;
  background: var(--surface-2);
}

.shop-card-name {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.shop-card-size {
  color: var(--text-dim);
  font-size: 0.66rem;
  line-height: 1.35;
}

/* ============ pack history ============ */

.pack-history {
  margin-top: 1.6rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}

.pack-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.pack-history-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pack-history-scope {
  display: flex;
  gap: 0.35rem;
}

.pack-history-tab {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  font: inherit;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.pack-history-tab:hover,
.pack-history-tab:focus-visible {
  color: var(--text);
  border-color: var(--accent);
}

.pack-history-tab.active {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
}

.pack-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.pack-history-row {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--pack-accent, var(--border));
  border-radius: 12px;
  background: var(--surface-2);
}

.pack-history-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.pack-history-pack {
  font-size: 0.8rem;
  font-weight: 800;
}

.pack-history-meta {
  color: var(--text-dim);
  font-size: 0.68rem;
}

.pack-history-opener {
  font-weight: 800;
}

/* Cards share the full row width equally: every pack row is the same width, so the
   five thumbnails at pack size 5 land around 214px each at the 1200px page width.
   min-width: 0 lets them shrink on narrow screens instead of overflowing. */
.pack-history-cards {
  display: flex;
  gap: 1rem;
}

.pack-history-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 0;
  min-width: 0;
}

.pack-history-art {
  width: 100%;
  height: auto;
  aspect-ratio: 528 / 700; /* renderer canvas: 432x604 template + 48 margin a side */
  object-fit: cover;
  border: 1px solid var(--card-accent, var(--border));
  border-radius: 8px;
  background: var(--surface);
  cursor: zoom-in;
}

.pack-history-card-name {
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.25;
}

.pack-history-card-meta {
  color: var(--text-dim);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pack-history-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.pack-history-tag {
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pack-history-tag.new {
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
}

.pack-history-tag.dupe {
  background: rgba(156, 163, 175, 0.16);
  color: #9ca3af;
}

.pack-history-tag.holo {
  background: rgba(251, 191, 36, 0.16);
  color: #fbbf24;
}

.pack-history-more {
  align-self: center;
}

/* On phones a full five-across row would shrink the thumbnails below the old 74px
   size, so wrap into three equal columns instead. */
@media (max-width: 700px) {
  .pack-history-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
  }
}

/* ============ market rows ============ */

.market-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.market-row:last-child {
  border-bottom: none;
}

.market-thumb {
  width: 56px;
  height: 78px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  cursor: zoom-in;
}

.market-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}

.market-title {
  font-size: 0.76rem;
  font-weight: 700;
}

.market-sub {
  color: var(--text-dim);
  font-size: 0.66rem;
}

.price-input {
  width: 92px;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.72rem;
}

.price-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Sell/buy controls of one market row */
.market-copy-actions,
.market-offer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.market-copy-row {
  flex-wrap: wrap;
}

/* Keep the listing form on the right of the copy row: price + List on the first
   line, then Sell beneath it. */
.market-copy-actions {
  flex-direction: column;
  align-items: flex-end;
  margin-left: auto;
}

.market-price-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.market-price-row .price-input {
  width: 78px;
  padding: 0.35rem 0.4rem;
}

.market-copy-actions .btn,
.market-offer-actions .btn {
  padding: 0.35rem 0.55rem;
  font-size: 0.6rem;
}

/* Heading above the player listings in a market card's buy column */
.market-subhead {
  display: block;
  padding: 0.55rem 0.4rem 0.15rem;
  color: var(--text-dim);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.market-system-row {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

@media (max-width: 700px) {
  .market-row {
    flex-wrap: wrap;
  }

  .market-offer-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ============ cards view switch ============ */

.view-switch {
  display: inline-flex;
  flex-shrink: 0;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.view-switch-btn {
  padding: 0.4rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.view-switch-btn:hover,
.view-switch-btn:focus-visible {
  color: var(--text);
}

.view-switch-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

/* Let the filter bar wrap the progress (and, on very narrow screens, the view
   switch) to a second line instead of squeezing the search input to nothing. */
@media (max-width: 900px) {
  .filter-bar {
    flex-wrap: wrap;
  }
}

/* ============ market view ============ */

/* Every Market card has three internal columns, so two cards per row is the
   widest comfortable arrangement. It still uses the wider container on large
   screens instead of the Gallery's 1200px cap. */
.gallery.market {
  max-width: 1800px;
}

.market-franchise {
  min-width: 0;
}

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

/* One card per row once two three-column cards would squeeze the sell/buy
   columns past the 56×78 thumbnails and leave too little room for seller
   names beside the Buy buttons. */
@media (max-width: 1500px) {
  .market-grid {
    grid-template-columns: 1fr;
  }
}

.market-card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: 0.9rem;
  min-width: 0;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

/* Sell and buy columns share a divider; the left head stays borderless. */
.market-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.market-sell,
.market-buy {
  padding-left: 0.9rem;
  border-left: 1px solid var(--border);
}

.market-column-head {
  display: block;
  margin-bottom: 0.45rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.market-card-head {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 0.4rem;
  width: 104px;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.market-card-head:focus-visible {
  outline: none;
}

.market-card-art-wrap {
  position: relative;
  display: block;
}

.market-card-art {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.market-card-head:hover .market-card-art,
.market-card-head:focus-visible .market-card-art {
  border-color: var(--tile-accent, var(--accent));
}

.market-card.unowned .market-card-art {
  filter: grayscale(1) brightness(0.38);
}

.market-card-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.market-card-name {
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.market-card-rarity {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tile-accent, var(--text-dim));
}

.market-card.unowned .market-card-name,
.market-card.unowned .market-card-rarity {
  color: var(--text-dim);
}

/* Below this width the identity folds into a compact horizontal header above
   the sell and buy columns instead of taking a third of the card width. */
@media (max-width: 820px) {
  .market-card {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .market-card-head {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    width: auto;
  }

  .market-card-art-wrap {
    flex: 0 0 auto;
    width: 84px;
  }

  .market-card-meta {
    flex: 1 1 auto;
  }

  .market-sell {
    padding-left: 0;
    border-left: none;
  }
}

@media (max-width: 700px) {
  .market-card {
    grid-template-columns: 1fr;
  }

  .market-buy {
    padding-left: 0;
    border-left: none;
  }
}

/* Rows inside one of a card's two action columns */
.market-list {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.market-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  min-width: 0;
}

.market-row-head .market-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-price {
  flex-shrink: 0;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
}

.market-status {
  color: var(--text-dim);
  font-size: 0.66rem;
}

.market-status.listed {
  color: var(--accent);
}

.market-status.locked {
  color: #f59e0b;
}

.market-note-row {
  display: block;
  flex: 1;
  align-self: center;
  padding: 0.6rem 0.4rem;
  color: var(--text-dim);
  font-size: 0.68rem;
}

/* "+N more offers": expands the full list inline */
.market-note-link {
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.68rem;
  text-align: left;
  cursor: pointer;
}

.market-note-link:hover,
.market-note-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

/* ============ users ranking ============ */

.users-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.user-row {
  display: grid;
  grid-template-columns: 3rem 44px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.user-row:hover,
.user-row:focus-visible {
  border-color: var(--accent);
  background: var(--surface-2);
  outline: none;
}

.user-row.self {
  border-color: rgba(56, 189, 248, 0.45);
}

.user-rank {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  text-align: center;
}

.user-row.podium-1 .user-rank {
  color: #fbbf24;
}

.user-row.podium-2 .user-rank {
  color: #cbd5e1;
}

.user-row.podium-3 .user-rank {
  color: #d97706;
}

.user-row-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
}

.user-row-main {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 0;
}

.user-row-name-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.user-row-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-row-you {
  flex-shrink: 0;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: #0b0d11;
  font-size: 0.5rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.user-row-sub {
  color: var(--text-dim);
  font-size: 0.68rem;
}

.user-tier {
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.user-tier.tier-s {
  border-color: #fbbf24;
  color: #fbbf24;
}

.user-tier.tier-a {
  border-color: #a855f7;
  color: #c084fc;
}

.user-tier.tier-b {
  border-color: #38bdf8;
  color: #7dd3fc;
}

.user-row-points {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  white-space: nowrap;
}

.user-row-points-value {
  font-family: var(--font);
  font-size: 0.9rem;
}

.user-row-points-label {
  color: var(--text-dim);
  font-size: 0.56rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 620px) {
  .user-row {
    grid-template-columns: 2.4rem 38px minmax(0, 1fr) auto;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
  }

  .user-row-avatar {
    width: 38px;
    height: 38px;
  }

  .user-tier {
    display: none;
  }
}

/* ============ profiles ============ */

.profile-link {
  color: var(--accent);
  text-decoration: none;
}

.profile-link:hover,
.profile-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 2px;
}

a.owner-hero {
  color: inherit;
  text-decoration: none;
}

a.owner-hero:hover,
a.owner-hero:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.profile-body {
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(56, 189, 248, 0.08), transparent 55%),
    var(--surface);
}

.profile-avatar {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-radius: 50%;
}

.profile-identity {
  flex: 1;
  min-width: 0;
}

.profile-name-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.profile-name {
  margin: 0;
  font-family: var(--font);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.profile-you {
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--accent);
  color: #0b0d11;
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.profile-hero-tier {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: center;
  gap: 0.05rem;
  min-width: 3.2rem;
  margin-right: 0.75rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.profile-hero-tier-label {
  color: var(--text-dim);
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.profile-hero-tier-value {
  font-family: var(--font);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
}

.profile-hero-tier.tier-s .profile-hero-tier-value {
  color: #fbbf24;
}

.profile-hero-tier.tier-a .profile-hero-tier-value {
  color: #c084fc;
}

.profile-hero-tier.tier-b .profile-hero-tier-value {
  color: #7dd3fc;
}

.profile-hero-tier.tier-c .profile-hero-tier-value {
  color: #4ade80;
}

.profile-username,
.profile-user-id {
  margin: 0.2rem 0 0;
  color: var(--text-dim);
  font-size: 0.72rem;
}

.profile-user-id {
  font-size: 0.64rem;
  letter-spacing: 0.04em;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: 0.7rem;
}

.profile-stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.profile-stat-label {
  color: var(--text-dim);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.profile-stat-value {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 800;
}

.profile-stat-note {
  color: var(--text-dim);
  font-size: 0.64rem;
}

.profile-section {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.profile-section-head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.profile-section-head > .section-title {
  margin: 0;
}

.profile-section-sub {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.68rem;
}

.profile-collection-summary {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.profile-collection-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
}

.profile-collection-summary .progress,
.profile-progress-row .progress {
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1fr);
  gap: 0.55rem;
  width: 100%;
}

.profile-collection-summary .progress-text,
.profile-progress-row .progress-text {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.profile-collection-summary .progress-bar,
.profile-progress-row .progress-bar {
  width: 100%;
}

.profile-progress-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.profile-progress-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.profile-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.profile-progress-name {
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-progress-percent {
  color: var(--text-dim);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.profile-empty {
  margin: 0;
  padding: 1.2rem 0.4rem;
  color: var(--text-dim);
  font-size: 0.78rem;
}

/* ============ profile activity heatmap ============ */

.profile-heatmap-scroll {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.profile-heatmap {
  display: grid;
  width: 100%;
  min-width: 720px;
  gap: 2px;
}

.profile-heatmap-month {
  color: var(--text-dim);
  font-size: 0.5rem;
  line-height: 1.2;
  white-space: nowrap;
}

.profile-heatmap-weekday {
  align-self: center;
  color: var(--text-dim);
  font-size: 0.48rem;
  line-height: 1;
  padding-right: 0.15rem;
  text-align: right;
  white-space: nowrap;
}

.profile-heatmap-cell {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 2px;
}

.profile-heatmap-cell.level-0 {
  background: var(--surface-2);
}

.profile-heatmap-cell.level-1 {
  background: rgba(56, 189, 248, 0.18);
}

.profile-heatmap-cell.level-2 {
  background: rgba(56, 189, 248, 0.36);
}

.profile-heatmap-cell.level-3 {
  background: rgba(56, 189, 248, 0.58);
}

.profile-heatmap-cell.level-4 {
  background: var(--accent);
}

.profile-heatmap-legend {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-dim);
  font-size: 0.58rem;
}

.profile-heatmap-legend .profile-heatmap-cell {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  aspect-ratio: auto;
}

.profile-heatmap-legend-label {
  margin: 0 0.15rem;
}

/* ============ profile channel leaders ============ */

.profile-channel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.profile-channel-card {
  min-width: 0;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.profile-channel-title {
  margin: 0 0 0.55rem;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-channel-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.profile-channel-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.profile-channel-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.72rem;
}

.profile-channel-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-channel-points {
  flex: 0 0 auto;
  color: var(--text-dim);
  font-size: 0.64rem;
  font-variant-numeric: tabular-nums;
}

.profile-channel-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.profile-channel-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), #a855f7);
}

/* ============ profile ranking ============ */

.profile-rank-grid {
  display: grid;
  grid-template-columns: minmax(190px, 0.75fr) minmax(0, 1.7fr);
  gap: 0.8rem;
}

.profile-rank-card {
  min-width: 0;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.profile-rank-nearby-card {
  display: flex;
  flex-direction: column;
}

.profile-rank-nearby-card .profile-rank-nearby {
  flex: 1;
  justify-content: center;
}

.profile-rank-title {
  margin: 0;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-rank-headline {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  margin: 0.4rem 0 0.7rem;
}

.profile-rank-tier-now {
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 800;
}

.profile-rank-points,
.profile-rank-nearby-total {
  color: var(--text-dim);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.profile-rank-ladder {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  min-height: 230px;
}

.profile-rank-track {
  position: relative;
  flex: 0 0 12px;
  width: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.profile-rank-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(0deg, #38bdf8, #a855f7 65%, #fbbf24);
  transition: height 0.4s ease;
}

.profile-rank-tick {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1px;
  background: rgba(212, 216, 224, 0.32);
}

.profile-rank-tiers {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.profile-rank-tier {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.15rem 0.35rem;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-dim);
}

.profile-rank-tier.reached {
  color: var(--text);
}

.profile-rank-tier.current {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.08);
  color: var(--text);
}

.profile-rank-letter {
  width: 1.1rem;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.profile-rank-tier.tier-s .profile-rank-letter {
  color: #fbbf24;
}

.profile-rank-tier.tier-a .profile-rank-letter {
  color: #c084fc;
}

.profile-rank-tier.tier-b .profile-rank-letter {
  color: #7dd3fc;
}

.profile-rank-tier.tier-c .profile-rank-letter {
  color: #4ade80;
}

.profile-rank-threshold {
  font-size: 0.62rem;
}

.profile-rank-next {
  margin: 0.65rem 0 0;
  color: var(--text-dim);
  font-size: 0.66rem;
  line-height: 1.4;
}

.profile-rank-nearby-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.profile-rank-nearby {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.profile-rank-row {
  display: grid;
  grid-template-columns: 2.6rem 30px minmax(0, 1fr) 4.7rem 5rem;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 9px;
  color: inherit;
  text-decoration: none;
}

.profile-rank-row:hover,
.profile-rank-row:focus-visible {
  border-color: var(--accent);
  background: var(--surface-2);
  outline: none;
}

.profile-rank-row.self {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.06);
}

.profile-rank-row-position {
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: center;
}

.profile-rank-row-avatar {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.profile-rank-row-name-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.profile-rank-row-name {
  overflow: hidden;
  font-size: 0.76rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-rank-row-you {
  flex: 0 0 auto;
  padding: 0.08rem 0.35rem;
  border-radius: 999px;
  background: var(--accent);
  color: #0b0d11;
  font-size: 0.46rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.profile-rank-row-tier {
  justify-self: center;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.profile-rank-row-tier.tier-s {
  border-color: #fbbf24;
  color: #fbbf24;
}

.profile-rank-row-tier.tier-a {
  border-color: #a855f7;
  color: #c084fc;
}

.profile-rank-row-tier.tier-b {
  border-color: #38bdf8;
  color: #7dd3fc;
}

.profile-rank-row-points {
  justify-self: end;
  font-family: var(--font);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .profile-progress-list,
  .profile-channel-grid,
  .profile-rank-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .profile-hero {
    flex-direction: column;
    text-align: center;
  }

  .profile-name-row {
    justify-content: center;
  }

  .profile-hero-tier {
    order: -1;
    align-self: flex-end;
  }

  .profile-rank-row {
    grid-template-columns: 2.4rem 28px minmax(0, 1fr) 5rem;
  }

  .profile-rank-row-tier {
    display: none;
  }
}
