:root {
  --bg: #0c0e12;
  --bg-elev: #141821;
  --text: #e8eaef;
  --muted: #8b93a7;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.15);
  --border: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  position: relative;
  overflow-x: clip;
}

img,
video,
svg {
  max-width: 100%;
  height: auto;
}

.bg-grid {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% -20%, black 40%, transparent 70%);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  color: #8cb0ff;
}

.site-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

.site-header-home {
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
  padding-bottom: 1rem;
}

.site-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-header-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-small {
  padding: 0.4rem 0.85rem;
  font-size: 0.88rem;
}

.home-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.55);
}

.home-nav-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  min-width: 0;
}

.home-nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 0 0 auto;
}

.home-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
}

.home-nav-links a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
}

.home-nav-links a:hover {
  color: var(--accent);
  background: rgba(91, 140, 255, 0.1);
}

.home-nav-more {
  margin-left: auto;
  position: relative;
}

.home-nav-more summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.home-nav-more summary::-webkit-details-marker {
  display: none;
}

.home-nav-more[open] summary {
  color: var(--text);
}

.home-nav-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 11rem;
  padding: 0.35rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.home-nav-more-menu a {
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.home-nav-more-menu a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.referral-promo {
  margin: 0 0 1.35rem;
  padding: 1.1rem 1.2rem;
  border-radius: calc(var(--radius) + 2px);
  border: 1px solid rgba(192, 132, 252, 0.4);
  background: linear-gradient(
    135deg,
    rgba(192, 132, 252, 0.14) 0%,
    rgba(91, 140, 255, 0.08) 55%,
    var(--bg-elev) 100%
  );
  box-shadow: 0 12px 40px rgba(192, 132, 252, 0.12);
}

.referral-promo-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #e9d5ff;
}

.referral-promo-title {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.25;
}

.referral-promo-text {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.5;
  max-width: 42rem;
}

.referral-promo-text strong {
  color: var(--text);
}

.home-features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 0 0 2.5rem;
}

.home-feature-card {
  display: block;
  padding: 1rem 1rem 0.95rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.home-feature-card:hover {
  transform: translateY(-2px);
  border-color: rgba(129, 140, 248, 0.45);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.2);
}

.home-feature-card-shop {
  border-color: rgba(251, 191, 36, 0.35);
  background: linear-gradient(165deg, rgba(251, 191, 36, 0.08), var(--bg-elev));
}

.home-feature-icon {
  display: block;
  font-size: 1.25rem;
  margin-bottom: 0.45rem;
  color: var(--accent);
}

.home-feature-card h3 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
}

.home-feature-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.logo {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

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

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  font-size: 0.95rem;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
}

.nav a:hover {
  color: var(--text);
}

.nav-cta {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  color: var(--accent) !important;
}

.nav-cta:hover {
  background: rgba(91, 140, 255, 0.28);
  color: #b6ceff !important;
}

main {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.hero {
  padding: 2.5rem 0 3rem;
}

.hero-kicker {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  max-width: 18ch;
}

.hero-lead {
  margin: 0 0 1.75rem;
  max-width: 52ch;
  color: var(--muted);
  font-size: 1.1rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn-primary {
  background: var(--accent);
  color: #0a0c10 !important;
  border-color: transparent;
}

.btn-primary:hover {
  background: #7a9fff;
  transform: translateY(-1px);
}

.btn-ghost {
  background: var(--bg-elev);
  border-color: var(--border);
  color: var(--text) !important;
}

.btn-ghost:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: #1a2030;
}

.hero-note {
  margin: 0;
  max-width: 52ch;
  font-size: 0.85rem;
  color: var(--muted);
}

.hero-note code {
  font-family: var(--mono);
  font-size: 0.82em;
  padding: 0.12rem 0.35rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
}

.legal-strip {
  margin-top: 2rem;
  padding: 1.75rem 1.5rem;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--border);
}

.legal-strip h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.legal-strip p {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.legal-links {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}

.legal-links a {
  font-weight: 600;
}

.prose {
  padding-top: 0.5rem;
  padding-bottom: 3rem;
}

.prose h1 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.prose .meta {
  margin: 0 0 2rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.prose h2 {
  margin: 2rem 0 0.65rem;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.prose h3 {
  margin: 1.35rem 0 0.5rem;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
}

#player-guide {
  scroll-margin-top: 5rem;
}

.player-guide-on-home {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  padding-bottom: 1rem;
}

.player-guide-on-home > .guide-kicker {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.player-guide-on-home > h2 {
  margin-top: 0;
}

.player-guide-on-home .back-to-top {
  margin-top: 2rem;
  font-size: 0.95rem;
}

.player-guide-on-home .back-to-top a {
  color: var(--muted);
}

.player-guide-on-home .back-to-top a:hover {
  color: var(--accent);
}

.redirect-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.redirect-main {
  position: relative;
  z-index: 1;
  padding: 2rem;
  max-width: 28rem;
  text-align: center;
  color: var(--muted);
}

.redirect-main a {
  font-weight: 600;
}

.redirect-main p {
  margin: 0 0 1rem;
}

.prose p,
.prose li {
  color: #c2c8d6;
}

.prose ul {
  padding-left: 1.25rem;
}

.prose ol {
  padding-left: 1.25rem;
  color: #c2c8d6;
}

.prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 0.12rem 0.35rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
}

.site-footer {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.footer-links {
  display: flex;
  gap: 1.25rem;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text);
}

/* =========================================================================
   App / dashboard surface (collection.html)
   ========================================================================= */

.app-body {
  min-height: 100vh;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  min-height: 100vh;
  max-width: 1320px;
  margin: 0 auto;
  gap: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 1.25rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: linear-gradient(180deg, rgba(20, 24, 33, 0.95), rgba(12, 14, 18, 0.95));
  border-right: 1px solid var(--border);
  backdrop-filter: blur(6px);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-logo {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-direction: column;
  padding: 8px;
}

.sidebar-toggle-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 auto;
  overflow-y: auto;
}

.sidebar-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-section {
  margin: 1.5rem 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 0.6rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  cursor: pointer;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.sidebar-link.is-active {
  background: var(--accent-soft);
  border-color: rgba(91, 140, 255, 0.35);
  color: var(--text);
}

.sidebar-link.is-soon {
  pointer-events: none;
  opacity: 0.55;
}

.sidebar-link-icon {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
  color: var(--accent);
}

.sidebar-link-text {
  flex: 1 1 auto;
}

.sidebar-link-external .sidebar-link-text::after {
  content: "↗";
  margin-left: 0.35rem;
  font-size: 0.75em;
  opacity: 0.55;
}

.sidebar-pill {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.sidebar-user {
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
  font-size: 0.9rem;
}

.sidebar-user-loading {
  color: var(--muted);
  padding: 0.3rem 0;
}

.sidebar-user-signedout p {
  margin: 0 0 0.65rem;
  color: var(--muted);
}

.btn-block {
  width: 100%;
}

.sidebar-user-signedin {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  object-fit: cover;
  flex: 0 0 auto;
}

/* Discord user row (auctions seller, trades partner, bid list, etc.) */
.pokepon-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.pokepon-user-chip-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elev);
}

.pokepon-user-chip-avatar--ph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
}

.pokepon-user-chip-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.pokepon-user-chip-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pokepon-user-chip-handle {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pokepon-user-chip--sm .pokepon-user-chip-avatar,
.pokepon-user-chip--sm .pokepon-user-chip-avatar--ph {
  width: 26px;
  height: 26px;
  font-size: 0.72rem;
}

.auction-tile-seller {
  margin-top: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
}

.auction-detail-seller {
  margin: 0.65rem 0 0.35rem;
}

.auction-bid-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.auction-bid-row + .auction-bid-row {
  margin-top: 0.45rem;
}

.trade-list-user {
  margin-bottom: 0.35rem;
}

.trade-room-partner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.35rem;
}

.trade-room-header h2 {
  margin: 0;
}

.sidebar-user-text {
  flex: 1 1 auto;
  min-width: 0;
}

.sidebar-user-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-hint {
  color: var(--muted);
  font-size: 0.78rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
}

.btn-link:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
}

/* ----- Main panel ------------------------------------------------------- */

.app-main {
  padding: 2rem 2rem 4rem;
  min-width: 0;
}

.page-head {
  margin-bottom: 1.5rem;
}

.page-head h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  letter-spacing: -0.02em;
}

.page-lead {
  margin: 0;
  color: var(--muted);
  max-width: 56ch;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.toolbar-search {
  position: relative;
  flex: 1 1 320px;
  display: flex;
  align-items: center;
}

.toolbar-search .search-icon {
  position: absolute;
  left: 14px;
  color: var(--muted);
  font-size: 1.05rem;
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 0.7rem 2.4rem 0.7rem 2.4rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.12s ease, background 0.12s ease;
}

#search-input::placeholder {
  color: var(--muted);
}

#search-input:focus {
  border-color: rgba(91, 140, 255, 0.6);
  background: #1a2030;
}

.search-clear {
  position: absolute;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}

.search-clear:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
}

.toolbar-sort {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--muted);
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.chip:hover {
  color: var(--text);
}

.chip.is-active {
  background: var(--accent-soft);
  color: #d3deff;
  border-color: rgba(91, 140, 255, 0.5);
}

.collection-status {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 1rem;
}

.collection-status.state-error {
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
  color: #ffd0d0;
}

.collection-status.state-empty {
  background: rgba(91, 140, 255, 0.06);
  border-color: rgba(91, 140, 255, 0.25);
  color: #cfdcff;
}

.collection-status.state-auth {
  background: rgba(91, 140, 255, 0.06);
  border-color: rgba(91, 140, 255, 0.25);
  color: #cfdcff;
}

.collection-status code {
  font-family: var(--mono);
  font-size: 0.85em;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
}

.collection-status .muted {
  color: var(--muted);
  font-size: 0.85em;
}

/* ----- Card grid -------------------------------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr));
  gap: 1rem;
}

.collection-evo-sections {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  margin-top: 1.75rem;
}

.collection-evo-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.collection-evo-heading {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.collection-evo-grid {
  margin-top: 0;
}

.card-tile-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  position: relative;
}

.card-tile-fav {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  z-index: 2;
  font-size: 1rem;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.85));
}

.modal-image {
  position: relative;
}

.modal-favorite-btn {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 2;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.55);
  color: #fde68a;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.modal-favorite-btn:hover:not(:disabled) {
  transform: scale(1.06);
  background: rgba(0, 0, 0, 0.75);
  border-color: #fde68a;
}

.modal-favorite-btn.is-favorite {
  background: rgba(120, 53, 15, 0.75);
  border-color: #fbbf24;
}

.modal-favorite-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.picker-card.is-favorite {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.picker-fav {
  margin-left: 0.25rem;
}

.card-tile-copy {
  appearance: none;
  width: 100%;
  margin: 0;
  padding: 0.35rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.card-tile-copy:hover {
  background: rgba(91, 140, 255, 0.12);
  border-color: rgba(91, 140, 255, 0.45);
  color: var(--text);
}

.card-tile {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 14px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease,
    background 0.12s ease;
  position: relative;
  overflow: hidden;
}

.card-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% -20%, rgba(91, 140, 255, 0.18), transparent 70%);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.card-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(91, 140, 255, 0.45);
  box-shadow: 0 12px 30px -16px rgba(91, 140, 255, 0.45);
}

.card-tile:hover::before {
  opacity: 1;
}

.card-tile-img {
  display: block;
  width: 100%;
  aspect-ratio: 245 / 342;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
}

.card-tile-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.card-tile-name {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-tile-sub {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-tile-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.card-tile-rarity {
  margin-left: auto;
  padding: 0.05rem 0.45rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.72rem;
}

.card-tile.rarity-common .card-tile-rarity { color: #cbd5e1; }
.card-tile.rarity-uncommon .card-tile-rarity { color: #86efac; }
.card-tile.rarity-rare .card-tile-rarity { color: #93c5fd; }
.card-tile.rarity-ultra .card-tile-rarity { color: #c4b5fd; }
.card-tile.rarity-hyper .card-tile-rarity { color: #fda4af; }
.card-tile.rarity-secret .card-tile-rarity { color: #fde68a; }
.card-tile.rarity-special .card-tile-rarity { color: #f0abfc; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.pager-info {
  color: var(--muted);
  font-size: 0.9rem;
}

.pager .btn-ghost[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ----- Modal ------------------------------------------------------------ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  z-index: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  max-width: 880px;
  width: 100%;
  max-height: calc(100vh - 3rem);
  overflow: auto;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
}

#card-modal .modal-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#card-modal .modal-grid {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  align-items: stretch;
}

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

#card-modal .modal-aside .modal-image img {
  max-height: min(48vh, 400px);
  width: auto;
  max-width: 100%;
  margin-inline: auto;
  display: block;
}

#card-modal .modal-aside .modal-footer {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  box-shadow: none;
  gap: 0.75rem;
}

#card-modal .modal-aside .modal-footer-sell-main,
#card-modal .modal-aside .modal-footer-evo {
  flex-direction: column;
  align-items: stretch;
}

#card-modal .modal-aside .modal-footer-evo {
  border-top: 1px solid var(--border);
  border-left: none;
  padding-top: 0.75rem;
  padding-left: 0;
}

#card-modal .modal-aside .modal-sell-actions,
#card-modal .modal-aside .modal-footer-evo .btn {
  width: 100%;
}

@media (min-width: 720px) {
  #card-modal .modal-aside {
    position: sticky;
    top: 1.25rem;
    align-self: start;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    padding-right: 0.15rem;
  }
}

.modal-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.5);
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.modal-close:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.8);
}

.modal-grid {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
}

.modal-image img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

#card-modal .modal-body {
  flex: 1;
  min-height: 0;
  gap: 0;
}

.modal-body-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-right: 0.15rem;
}

.modal-footer {
  flex-shrink: 0;
  margin-top: 0.65rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: 0 -12px 24px rgba(0, 0, 0, 0.22);
}

/* Enforce sell → evolve → grade even if an old cached collection.html has different DOM order */
.modal-footer > .modal-sell {
  order: 1;
}

.modal-footer > .modal-footer-evo {
  order: 2;
}

.modal-footer > .modal-grade {
  order: 3;
}

.modal-footer-sell-main,
.modal-footer-evo {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.modal-footer-sell-copy {
  flex: 1;
  min-width: 0;
}

.modal-footer-evo {
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border);
}

.modal-footer-evo-main {
  flex: 1;
  min-width: 0;
}

.modal-footer-evo-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.modal-footer .modal-sell {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.modal-footer .modal-sell-desc {
  margin: 0;
  font-size: 0.78rem;
}

.modal-footer .modal-sell-heading {
  margin-bottom: 0.2rem;
}

.modal-footer .modal-sell-quote {
  margin-bottom: 0.35rem;
}

.modal-footer .modal-sell-actions {
  flex-shrink: 0;
}

/* Collection card modal: sell + evolve stack under the image (not side-by-side). */
@media (min-width: 640px) {
  #card-modal .modal-aside .modal-footer {
    display: flex;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .modal-footer-sell-main,
  .modal-footer-evo {
    flex-direction: column;
  }

  .modal-footer .modal-sell-actions,
  .modal-footer-evo .btn {
    width: 100%;
  }
}

.modal-set {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.modal-title {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.modal-rarity {
  margin: 0;
  font-weight: 600;
  font-size: 0.9rem;
}

.modal-rarity.rarity-common { color: #cbd5e1; }
.modal-rarity.rarity-uncommon { color: #86efac; }
.modal-rarity.rarity-rare { color: #93c5fd; }
.modal-rarity.rarity-ultra { color: #c4b5fd; }
.modal-rarity.rarity-hyper { color: #fda4af; }
.modal-rarity.rarity-secret { color: #fde68a; }
.modal-rarity.rarity-special { color: #f0abfc; }

.modal-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem 1rem;
  margin: 0;
}

.modal-stats > div {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
}

.modal-stats dt {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.modal-stats dd {
  margin: 0.2rem 0 0;
  font-weight: 600;
}

.modal-stats code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
}

.modal-stats .modal-id-row {
  grid-column: 1 / -1;
}

.modal-id-dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  word-break: break-all;
}

.btn-copy-inline {
  flex-shrink: 0;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
}

.modal-attacks {
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}

.modal-attacks h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.modal-attacks ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.modal-attacks li {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}

.atk-row {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.atk-name {
  font-weight: 600;
}

.atk-cost {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.atk-dmg {
  margin-left: auto;
  font-family: var(--mono);
  color: #fda4af;
}

.atk-text {
  margin: 0.3rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.modal-obtained {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.modal-sell {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.modal-sell-heading {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.modal-sell-desc {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.modal-sell-quote {
  margin: 0 0 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
}

.modal-sell-block {
  margin: 0 0 0.5rem;
  font-size: 0.86rem;
  line-height: 1.45;
  color: #fda4af;
}

.modal-sell-warn {
  margin: 0 0 0.65rem;
  font-size: 0.84rem;
  line-height: 1.45;
}

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

#modal-sell-btn.btn-primary {
  background: #dc2626;
  color: #fff !important;
}

#modal-sell-btn.btn-primary:hover:not(:disabled) {
  background: #ef4444;
  transform: translateY(-1px);
}

#modal-sell-btn.btn-primary:disabled {
  background: #7f1d1d;
  color: rgba(255, 255, 255, 0.55) !important;
  cursor: not-allowed;
  transform: none;
}

.modal-sell-msg {
  margin: 0.55rem 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

.modal-sell-msg.is-error {
  color: #fda4af;
}

.modal-sell-msg.is-ok {
  color: #86efac;
}

.modal-footer .modal-sell:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.modal-footer .modal-grade {
  margin-top: 0;
  padding-top: 0.85rem;
  padding-bottom: 0;
  border-top: 1px solid var(--border);
  border-bottom: none;
}

.modal-grade-heading {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.modal-grade-desc {
  margin: 0.65rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.modal-grade-summary {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.modal-footer-grade-main {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
}

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

.modal-grade-msg {
  margin: 0.35rem 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

.modal-grade-msg.is-error {
  color: #fda4af;
}

.modal-grade-msg.is-ok {
  color: #86efac;
}

.card-tile-img--slab,
.modal-img--slab {
  object-fit: contain;
  background: rgba(0, 0, 0, 0.2);
}

.card-tile-grade {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  z-index: 2;
  min-width: 1.6rem;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  background: rgba(196, 30, 58, 0.92);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.modal-evolve {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.modal-evolve-heading {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.modal-evolve-desc {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.modal-evolve-stages {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.modal-evolve-block {
  margin: 0 0 0.5rem;
  font-size: 0.86rem;
  line-height: 1.45;
  color: #fda4af;
}

.modal-evolve-targets {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.2rem;
  scroll-snap-type: x proximity;
}

.modal-evo-target {
  display: flex;
  align-items: stretch;
  gap: 0.45rem;
  flex: 0 0 min(240px, 82vw);
  scroll-snap-align: start;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  overflow: hidden;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.modal-evo-target.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.modal-evo-target-hit {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

.modal-evo-target-hit:hover,
.modal-evo-target-hit:focus-visible {
  background: rgba(255, 255, 255, 0.04);
  outline: none;
}

.modal-evo-target-pick {
  flex-shrink: 0;
  align-self: center;
  margin-right: 0.45rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.78rem;
  cursor: pointer;
}

.modal-evo-target-pick:hover,
.modal-evo-target-pick:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.modal-evo-target-hit img {
  width: 44px;
  height: 62px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.modal-evo-target-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.modal-evo-target-name {
  font-weight: 600;
}

.modal-evo-target-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.modal-evo-target-hint {
  font-size: 0.72rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.evo-focus-modal {
  z-index: 25;
}

.evo-focus-card .modal-evo-back {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  z-index: 3;
}

.evo-focus-card {
  max-width: 820px;
}

.evo-focus-cost {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: #fde68a;
}

.evo-focus-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

body.evo-focus-open #card-modal .modal-card {
  filter: brightness(0.55);
}

/* Keep sell / back actions clickable above the evolution preview overlay */
body.evo-focus-open #card-modal .modal-aside .modal-footer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  width: min(280px, calc(100vw - 3rem));
  z-index: 30;
  margin: 0;
  filter: none;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.55);
}

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

.modal-evolve-msg {
  margin: 0.55rem 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

.modal-evolve-msg.is-error {
  color: #fda4af;
}

.modal-evolve-msg.is-ok {
  color: #86efac;
}

body.modal-open {
  overflow: hidden;
}

/* ----- Deck editor ------------------------------------------------------ */

body.deck-editor-active .page-head {
  display: none;
}

body.deck-editor-active .app-main {
  padding-top: 0.25rem;
}

.deck-workspace {
  position: sticky;
  top: 0;
  z-index: 12;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem 1rem;
  background: var(--bg-elev);
  border: 1px solid rgba(91, 140, 255, 0.28);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.deck-workspace-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.85rem;
}

.deck-workspace-title {
  margin: 0;
  font-size: 1.05rem;
}

.deck-workspace-meta {
  margin: 0.25rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.deck-fill-count {
  font-weight: 600;
  color: var(--text);
}

.deck-selected-hint strong {
  color: var(--accent);
}

.deck-workspace-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
}

.deck-picker-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.deck-picker-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
  border-bottom: 1px solid transparent;
}

.deck-picker-panel[open] .deck-picker-summary {
  border-bottom-color: var(--border);
}

.deck-picker-summary::-webkit-details-marker {
  display: none;
}

.deck-picker-summary::before {
  content: "▸";
  color: var(--accent);
  transition: transform 0.15s ease;
}

.deck-picker-panel[open] .deck-picker-summary::before {
  transform: rotate(90deg);
}

.deck-picker-inner {
  padding: 0.85rem 1rem 1rem;
}

.deck-picker-lead {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
}

.deck-picker-toolbar {
  margin-bottom: 0.75rem;
}

@keyframes deck-slot-pop {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(134, 239, 172, 0.5);
  }
  35% {
    transform: scale(1.03);
    box-shadow: 0 0 0 4px rgba(134, 239, 172, 0.35);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(134, 239, 172, 0);
  }
}

.deck-slot.is-just-added {
  animation: deck-slot-pop 0.85s ease;
  border-color: rgba(134, 239, 172, 0.65);
}

.deck-status,
.deck-picker-status {
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
}
.deck-status.state-auth,
.deck-picker-status.state-auth {
  background: rgba(91, 140, 255, 0.08);
  border: 1px solid rgba(91, 140, 255, 0.25);
}
.deck-status.state-error,
.deck-picker-status.state-error {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
}
.deck-status.state-info,
.deck-picker-status.state-info {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
}
.deck-status.state-empty,
.deck-picker-status.state-empty {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
}

.deck-bench {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 0;
}

.deck-slot {
  position: relative;
  background: var(--bg-elev);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 0.65rem 0.65rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  min-height: 180px;
  text-align: center;
}

@media (min-width: 900px) {
  .deck-bench {
    grid-template-columns: repeat(6, 1fr);
    gap: 0.55rem;
  }

  .deck-slot {
    min-height: 150px;
    padding: 0.55rem 0.45rem 0.45rem;
  }

  .deck-slot-img {
    width: 72px;
  }

  .deck-slot-name {
    font-size: 0.78rem;
  }

  .deck-slot-label {
    font-size: 0.72rem;
  }
}

.deck-slot:hover {
  border-color: rgba(91, 140, 255, 0.35);
}

.deck-slot.is-selected {
  border-color: rgba(91, 140, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(91, 140, 255, 0.18);
  background: rgba(91, 140, 255, 0.04);
}

.deck-slot.is-filled {
  border-color: rgba(134, 239, 172, 0.35);
}

.deck-slot.is-filled.is-selected {
  border-color: rgba(91, 140, 255, 0.7);
}

.deck-slot-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.deck-slot-lead {
  color: #fde68a;
}

.deck-slot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  flex: 1;
  justify-content: center;
  min-width: 0;
  width: 100%;
}

.deck-slot-img {
  width: 110px;
  height: auto;
  border-radius: 8px;
  pointer-events: none;
}

.deck-slot-name {
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.deck-slot-hp {
  font-size: 0.78rem;
  color: var(--muted);
}

.deck-slot-empty {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
}

.deck-slot-clear {
  appearance: none;
  width: 100%;
  margin: auto 0 0;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(248, 113, 113, 0.25);
  background: rgba(248, 113, 113, 0.1);
  color: #fda4af;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.deck-slot-clear:hover {
  background: rgba(248, 113, 113, 0.25);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}

.deck-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.25rem 0 0.5rem;
}

.deck-save-hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.deck-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.deck-picker-head {
  margin-bottom: 0.75rem;
}

.deck-picker-head h2 {
  font-size: 1.15rem;
  margin: 0 0 0.2rem;
}

.deck-picker-head .page-lead {
  margin: 0;
}

/* Picker tile overrides */
.picker-tile {
  position: relative;
}

.picker-tile.is-in-deck {
  opacity: 0.55;
  pointer-events: none;
}

.picker-tile.is-ineligible {
  opacity: 0.35;
  pointer-events: none;
}

.picker-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  color: var(--muted);
}

/* ----- Responsive ------------------------------------------------------- */

/* Tablet / narrow desktop — keep sidebar, give main column room to shrink */
@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: minmax(188px, 220px) minmax(0, 1fr);
  }

  .app-main {
    padding: 1.5rem 1.25rem 3rem;
  }

  .toolbar-search {
    flex: 1 1 100%;
  }
}

/* Phone / small tablet — slide-out nav, single column layouts */
@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    height: auto;
    max-height: none;
    padding: 0.75rem 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
    transition: box-shadow 0.22s ease;
  }

  .sidebar.is-open {
    position: fixed;
    top: 0;
    left: 0;
    width: min(288px, 92vw);
    height: 100dvh;
    max-height: 100dvh;
    padding: 1rem 1rem 1.25rem;
    border-bottom: none;
    border-right: 1px solid var(--border);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.45);
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar-nav,
  .sidebar-user {
    display: none;
  }

  .sidebar.is-open .sidebar-nav,
  .sidebar.is-open .sidebar-user {
    display: flex;
  }

  .sidebar.is-open .sidebar-nav {
    flex-direction: column;
    padding-top: 0.5rem;
  }

  .app-shell::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(6, 8, 12, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .app-shell:has(.sidebar.is-open)::after {
    opacity: 1;
    pointer-events: auto;
  }

  .app-main {
    padding: 1rem 0.85rem 2.75rem;
    min-height: 100vh;
  }

  .toolbar {
    gap: 0.65rem;
  }

  .toolbar-sort {
    width: 100%;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
    gap: 0.65rem;
  }

  .modal {
    padding: 0;
    align-items: stretch;
  }

  .modal-card {
    max-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .modal-grid,
  #card-modal .modal-grid {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  #card-modal .modal-card {
    max-height: 100dvh;
  }

  #card-modal .modal-aside {
    position: static;
    max-height: none;
    overflow: visible;
  }

  #card-modal .modal-body {
    overflow: visible;
  }

  .deck-bench {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 128px), 1fr));
  }

  .deck-workspace {
    position: static;
  }

  .deck-workspace-actions {
    width: 100%;
  }

  .deck-workspace-actions .btn {
    flex: 1 1 auto;
  }

  .pager {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1.15rem;
  }

  .nav {
    width: 100%;
    gap: 0.4rem 0.85rem;
    font-size: 0.9rem;
  }

  .home-features {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-nav-more {
    margin-left: 0;
    width: 100%;
  }

  .home-nav-more-menu {
    position: static;
    margin-top: 0.35rem;
    box-shadow: none;
  }
}

@media (max-width: 600px) {
  .home-features {
    grid-template-columns: 1fr;
  }

  body {
    font-size: 1rem;
  }

  .app-main {
    padding: 0.85rem 0.75rem 2.5rem;
  }

  .page-head h1 {
    font-size: clamp(1.35rem, 6vw, 1.75rem);
  }

  .toolbar-search {
    flex: 1 1 100%;
  }

  .chip {
    padding: 0.45rem 0.7rem;
    font-size: 0.8rem;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 118px), 1fr));
    gap: 0.5rem;
  }

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

  .modal-title {
    font-size: 1.35rem;
    padding-right: 2.25rem;
  }

  .deck-slot {
    min-height: 150px;
  }
}

@media (max-width: 400px) {
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Short viewports (phone landscape, small windows) — stack panels, limit scroll regions */
@media (max-height: 520px) and (orientation: landscape) {
  .app-main {
    padding-top: 0.65rem;
    padding-bottom: 1.5rem;
  }

  .page-head {
    margin-bottom: 0.85rem;
  }

  .page-head h1 {
    font-size: 1.35rem;
  }

  .modal {
    padding: 0.35rem;
    align-items: center;
  }

  .modal-card {
    max-height: calc(100dvh - 0.75rem);
    border-radius: 12px;
  }

  #card-modal .modal-grid {
    grid-template-columns: minmax(140px, 34%) minmax(0, 1fr);
    overflow: hidden;
  }

  #card-modal .modal-aside .modal-image img {
    max-height: min(36vh, 220px);
  }

  .deck-bench {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .deck-slot {
    min-height: 0;
    padding: 0.35rem 0.3rem;
  }

  .deck-slot-img {
    width: 52px;
  }
}
