:root {
  --bg: #0a0a0f;
  --surface: #14141f;
  --surface-hover: #1e1e2e;
  --border: #2a2a3a;
  --text: #e0e0e8;
  --text-dim: #8888a0;
  --accent: #6c8cff;
  --accent-glow: rgba(108, 140, 255, 0.15);

  --forest: #2d8a4e;
  --sparks: #a855f7;
  --glacier: #60b5e8;
  --volcano: #e8553a;
  --ocean: #2563eb;
  --wind: #94a3b8;
  --wasteland: #6b5b4f;
  --stars: #f0c040;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --transition: 0.18s ease;

  --stat-energy: #60a0ff;
  --stat-integrity: #e05050;
  --stat-power: #f0c040;
  --stat-strength: #ff8844;
  --stat-options: #b090d0;
  --stat-target: #b090d0;
  --stat-self: #aaa;
  --stat-reveal: #70c0b0;
  --stat-card-type: #c0a070;
  --stat-trigger: #d0b060;
  --stat-ability: #80b0d0;
  --stat-damage: #d05050;
  --stat-tap: #aaa;
  --stat-untap: #aaa;

  --success: #6bcb77;
  --success-hover: #5ab868;
  --danger: #ff4444;
  --danger-soft: #ff6b6b;
  --danger-bg: rgba(255, 68, 68, 0.2);
  --danger-glow: rgba(255, 68, 68, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

header {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.75rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1.3rem;
  letter-spacing: 0.05em;
  font-weight: 700;
}

nav {
  display: flex;
  gap: 0.5rem;
}

.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  font-size: 0.9rem;
  font-weight: 500;
}
.nav-link:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.nav-link.active {
  color: var(--text);
  background: var(--accent-glow);
  border: 1px solid rgba(108, 140, 255, 0.25);
}
.nav-link-play {
  color: var(--accent);
  border: 1px solid rgba(108, 140, 255, 0.3);
  font-weight: 600;
}
.nav-link-play:hover {
  background: var(--accent);
  color: #fff;
}
.nav-link-play.has-active-game {
  position: relative;
}
.nav-link-play.has-active-game::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-active-game 2s ease-in-out infinite;
}
@keyframes pulse-active-game {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 4px var(--success);
  }
  50% {
    opacity: 0.5;
    box-shadow: 0 0 8px var(--success);
  }
}

/* Profile avatar in header */
.profile-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  margin-left: auto;
  flex-shrink: 0;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-dim);
}
.profile-avatar-circle {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  opacity: 1;
  transition: all var(--transition);
}
.profile-avatar-wrap.authenticated .profile-avatar-circle {
  border-color: var(--text);
  opacity: 1;
}
.profile-avatar-name {
  font-size: 0.65rem;
  line-height: 1;
  max-width: 5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--transition);
}
.profile-avatar-wrap:hover .profile-avatar-circle {
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.profile-avatar-wrap:hover .profile-avatar-name {
  color: var(--text);
}
.profile-avatar-wrap.active .profile-avatar-circle {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.profile-avatar-wrap.active .profile-avatar-name {
  color: var(--text);
}

main {
  padding: 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
}

.filter-section {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 0.6rem;
}

#type-filter-grid {
  grid-template-columns: repeat(2, auto);
}

#count-filter-grid {
  grid-template-columns: repeat(1, auto);
}

.filter-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-group + .filter-group {
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.filter-btn {
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  padding: 0;
}

.filter-btn svg {
  width: 1.4rem;
  height: 1.4rem;
}

.filter-btn:hover {
  border-color: var(--text-dim);
  background: var(--surface-hover);
}

.filter-btn.active {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text);
  box-shadow: 0 0 8px var(--accent-glow);
}

.card-count {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  min-height: 1.3em;
}

/* Card Grid Spinner — absolutely positioned to avoid layout shift */
.card-grid-spinner {
  display: flex;
  justify-content: center;
  padding: 3rem 0;
  position: absolute;
  left: 0;
  right: 0;
}
.card-grid-spinner::after {
  content: "";
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Card Grid */
.card-grid-wrap {
  position: relative;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1rem 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(108, 140, 255, 0.12);
}
.card:active {
  transform: translateY(-1px);
  box-shadow: 0 2px 12px rgba(108, 140, 255, 0.1);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.card-name {
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
}

.card-stats {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.card-badge {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 2.1rem;
  height: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}
.card-strength {
  color: var(--stat-strength);
}
.card-cost {
  color: var(--accent);
}

.card-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
}

.card-aspects {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
}

.badge {
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-weight: 500;
  line-height: 1.4;
}

.badge-type {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--stat-card-type);
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
}

.badge-type svg {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
}

.badge-domain {
  color: #fff;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
}

.badge-domain svg {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
}

.badge-count {
  background: transparent;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text);
}

.badge-aspect {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.badge-id {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: monospace;
  font-size: 0.75rem;
}

/* Domain colors */
.domain-forest .badge-domain,
.badge-domain[data-domain="forest"] {
  background: var(--forest);
}
.domain-sparks .badge-domain,
.badge-domain[data-domain="sparks"] {
  background: var(--sparks);
}
.domain-glacier .badge-domain,
.badge-domain[data-domain="glacier"] {
  background: var(--glacier);
  color: #000;
}
.domain-volcano .badge-domain,
.badge-domain[data-domain="volcano"] {
  background: var(--volcano);
}
.domain-ocean .badge-domain,
.badge-domain[data-domain="ocean"] {
  background: var(--ocean);
}
.domain-wind .badge-domain,
.badge-domain[data-domain="wind"] {
  background: var(--wind);
  color: #000;
}
.domain-wasteland .badge-domain,
.badge-domain[data-domain="wasteland"] {
  background: var(--wasteland);
}
.domain-stars .badge-domain,
.badge-domain[data-domain="stars"] {
  background: var(--stars);
  color: #000;
}

/* Domain left border accent */
.domain-forest {
  border-left: 3px solid var(--forest);
}
.domain-sparks {
  border-left: 3px solid var(--sparks);
}
.domain-glacier {
  border-left: 3px solid var(--glacier);
}
.domain-volcano {
  border-left: 3px solid var(--volcano);
}
.domain-ocean {
  border-left: 3px solid var(--ocean);
}
.domain-wind {
  border-left: 3px solid var(--wind);
}
.domain-wasteland {
  border-left: 3px solid var(--wasteland);
}
.domain-stars {
  border-left: 3px solid var(--stars);
}

.card-text {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
  height: 6rem;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, #000 60%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent);
}

/* Modal — scroll lock */
html.modal-open,
body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hidden {
  display: none !important;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  animation: modal-enter 0.2s ease-out;
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-buttons {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  z-index: 1;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition);
}
.modal-close:hover {
  color: var(--text);
  background: var(--surface-hover);
}

/* Minimized modal */
.modal.minimized .modal-backdrop {
  display: none;
}
.modal.minimized {
  pointer-events: none;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 80px;
}
.modal.minimized .modal-content {
  pointer-events: auto;
  max-width: none;
  width: auto;
  padding: 0.45rem 1rem;
  cursor: pointer;
  animation: none;
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(108, 140, 255, 0.25);
  max-height: none;
  overflow: hidden;
}
.modal.minimized .modal-content > *:not(.modal-minimized-label) {
  display: none;
}
.modal-minimized-label {
  display: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.modal.minimized .modal-minimized-label {
  display: block;
}
.btn-minimize-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.btn-minimize-modal:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.modal-card-stats {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.3rem;
}

.modal-card-name {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  padding-right: 5rem;
}

.modal-card-meta {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
}

.modal-card-aspects {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.82rem;
}

.modal-card-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
}

.modal-card-count {
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* ---- Header title link ---- */
.header-title {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header-logo {
  height: 1.8rem;
  width: 1.8rem;
  filter: invert(1);
}
.header-title:hover h1 {
  color: var(--accent);
}

/* ---- Landing Page ---- */
.landing-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 52px);
  padding: 2rem;
  text-align: center;
}

.landing-hero {
  margin-bottom: 3rem;
}

.landing-logo {
  max-width: 420px;
  width: 100%;
  aspect-ratio: 1260 / 486;
  margin-bottom: 1rem;
  filter: invert(1);
}

.landing-title {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.landing-tagline {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

.landing-quote {
  color: var(--text-dim);
  font-size: 0.9rem;
  font-style: italic;
  line-height: 1.7;
}

.landing-actions {
  display: flex;
  gap: 1.25rem;
  max-width: 700px;
  width: 100%;
  margin-bottom: 1rem;
}

.landing-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.75rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  cursor: pointer;
}
.landing-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(108, 140, 255, 0.12);
}

.landing-card-icon {
  font-size: 2rem;
  margin-bottom: 0.3rem;
}

.landing-card strong {
  font-size: 1.1rem;
}

.landing-card p {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0;
}

.landing-card-primary {
  border-color: rgba(108, 140, 255, 0.3);
  background: rgba(108, 140, 255, 0.06);
}
.landing-card-primary:hover {
  background: rgba(108, 140, 255, 0.12);
}

.landing-footer {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: center;
}
.landing-footer a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.8rem;
}
.landing-footer a:hover {
  color: var(--text);
  text-decoration: underline;
}
.landing-copyright {
  width: 100%;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-dim);
  opacity: 0.6;
  margin: 0.5rem 0 0;
}

.landing-version {
  width: 100%;
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-dim);
  opacity: 0.4;
  margin: 0.25rem 0 0;
  font-family: monospace;
}

/* ---- Card text paragraph icons ---- */
.card-para {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.card-para + .card-para {
  margin-top: 0.4rem;
}
.card-para-bracket {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  flex-shrink: 0;
  padding-left: 0.5em;
  gap: 0.15em;
  opacity: 0.4;
}
/* Bracket line alongside icon */
.card-para-bracket::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0.45em;
  border-left: 1px solid currentColor;
  border-top: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  border-radius: 3px 0 0 3px;
}

.card-para-text {
  white-space: pre-line;
  flex: 1;
  min-width: 0;
}
.ability-icon {
  display: block;
  flex-shrink: 0;
  width: 1.4em;
  height: 1.4em;
}

/* ---- Inline stat icons ---- */
.stat-icon-group {
  white-space: nowrap;
}
.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
  margin: 0 0.05em;
  opacity: 0.7;
}
.stat-icon svg {
  width: 100%;
  height: 100%;
}
.stat-icon-energy {
  color: var(--stat-energy);
}
.stat-icon-integrity {
  color: var(--stat-integrity);
}
.stat-icon-power {
  color: var(--stat-power);
}
.stat-icon-strength {
  color: var(--stat-strength);
}
.stat-icon-options {
  color: var(--stat-options);
}
.stat-icon-target {
  color: var(--stat-target);
}
.stat-icon-self {
  color: var(--stat-self);
}
.stat-icon-reveal {
  color: var(--stat-reveal);
}
.stat-icon-creature {
  color: var(--stat-card-type);
}
.stat-icon-structure {
  color: var(--stat-card-type);
}
.stat-icon-impact {
  color: var(--stat-card-type);
}
.stat-icon-reaction {
  color: var(--stat-card-type);
}
.stat-icon-trigger {
  color: var(--stat-trigger);
}
.stat-icon-ability {
  color: var(--stat-ability);
}
.stat-icon-damage {
  color: var(--stat-damage);
}
.stat-icon-tap {
  color: var(--stat-tap);
}
.stat-icon-untap {
  color: var(--stat-untap);
}

@media (max-width: 768px) {
  .landing-logo {
    max-width: 280px;
  }
  .landing-title {
    font-size: 2rem;
  }
  .landing-actions {
    flex-direction: column;
  }
  .landing-card {
    padding: 1.25rem 1rem;
  }
}

/* ---- Resources Page ---- */
.resources-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem;
}
.resources-page h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}
.resources-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.resource-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
}
.resource-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(108, 140, 255, 0.1);
}
.resource-icon {
  font-size: 2rem;
  flex-shrink: 0;
  width: 2.5rem;
  text-align: center;
}
.resource-card strong {
  display: block;
  font-size: 1.05rem;
  margin-bottom: 0.15rem;
}
.resource-card p {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 0;
}

/* ---- Icons Reference ---- */
.icons-ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem;
}
.icons-ref-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface, #252540);
  border: 1px solid var(--border, #333);
  border-radius: 8px;
}
.icons-ref-item svg {
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
}
.icons-ref-item strong {
  display: block;
  font-size: 0.9rem;
}
.icons-ref-item div span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim, #888);
}
.icons-ref-item [data-icon] {
  display: inline-flex;
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
}
.icons-ref-item [data-icon] svg {
  width: 100%;
  height: 100%;
}

/* ---- Rules Page ---- */
.rules-page {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem;
}

.rules-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.rules-tab {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition:
    color 0.15s,
    border-color 0.15s;
}

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

.rules-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.rules-content {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.rules-hero {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.rules-hero h2 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}
.rules-subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
}
.rules-version {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-top: 0.2rem;
}

/* Table of contents */
.rules-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  align-items: baseline;
}
.rules-toc-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  width: 100%;
  margin-bottom: 0.2rem;
}
.rules-toc a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 0.15rem 0;
  transition: color var(--transition);
}
.rules-toc a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* Section headings */
.rules-content section,
.rules-content h3[id],
.rules-content h4[id] {
  scroll-margin-top: 60px;
}
.rules-content h3,
.rules-content h4 {
  position: relative;
}

.rules-content h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.02em;
}

.rules-content h4 {
  font-size: 1.02rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.rules-content :is(h3, h4) .heading-anchor {
  color: var(--text-dim);
  text-decoration: none;
  margin-left: 0.4em;
  font-size: 0.9em;
  opacity: 0;
  transition: opacity 0.15s;
}

.rules-content :is(h3, h4):hover .heading-anchor {
  opacity: 0.6;
}

.rules-content :is(h3, h4) .heading-anchor:hover {
  opacity: 1;
  color: var(--accent);
}

.rules-content p {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 0.6rem;
}

.rules-content ol,
.rules-content ul {
  padding-left: 1.5rem;
  font-size: 0.92rem;
  line-height: 1.7;
  margin-bottom: 0.6rem;
}
.rules-content ol ol,
.rules-content ol ul,
.rules-content ul ul {
  margin-top: 0.3rem;
  margin-bottom: 0.3rem;
}
.rules-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(108, 140, 255, 0.4);
  text-underline-offset: 2px;
}

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

.rules-content u {
  text-decoration-color: var(--accent);
  text-underline-offset: 2px;
}
.rules-content li {
  margin-bottom: 0.3rem;
}

.rules-card-link {
  cursor: pointer;
  border-bottom: 1px dashed var(--text-dim);
  transition:
    color 0.15s,
    border-color 0.15s;
}

.rules-card-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.rules-added {
  background: rgba(34, 197, 94, 0.15);
  border-bottom: 1.5px solid rgba(34, 197, 94, 0.5);
}

.rules-removed {
  background: rgba(239, 68, 68, 0.12);
  text-decoration: line-through;
  text-decoration-color: rgba(239, 68, 68, 0.6);
  color: var(--text-dim);
}

/* Domain-aspect diagrams */
.rules-diagram {
  margin: 1.2rem 0;
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.2rem;
}

.diagram-tree {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.diagram-domain {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  text-align: center;
  line-height: 1.3;
  white-space: nowrap;
}

.diagram-aspects {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

.diagram-tree .diagram-aspects,
.diagram-deck-group .diagram-aspects {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-items: center;
}

.diagram-tree .diagram-connectors,
.diagram-tree .diagram-aspects {
  width: 100%;
  max-width: 22rem;
}

.diagram-deck-group .diagram-connectors,
.diagram-deck-group .diagram-aspects {
  width: 100%;
  max-width: 18rem;
}

.diagram-deck-group .diagram-aspect {
  min-width: 0;
  max-width: 100%;
  padding: 0.3rem 0.4rem;
  font-size: 0.75rem;
}

.diagram-aspect {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.3;
  min-width: 5rem;
}

.diagram-label-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.diagram-aspect.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.diagram-aspect .diagram-check {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: #22c55e;
  color: #000;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.diagram-connectors {
  display: flex;
  justify-content: center;
  height: 1.8rem;
  position: relative;
}

.diagram-connectors svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.diagram-connectors svg line {
  stroke: var(--border);
  stroke-width: 1.5;
}

.diagram-deck-example {
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
}

.diagram-deck-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.diagram-caption {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
  max-width: 14rem;
  padding: 0.3rem 0.6rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* Draft pick diagram */
.diagram-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  margin: 0 0 1rem;
}

.draft-diagram {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.draft-diagram-timeline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.draft-diagram-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  min-width: 3.2rem;
  position: relative;
}

.draft-diagram-step.ban {
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.06);
}

.draft-diagram-step.pick {
  border-color: rgba(108, 140, 255, 0.4);
  background: rgba(108, 140, 255, 0.06);
}

.draft-diagram-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-dim);
}

.draft-diagram-step.ban .draft-diagram-label {
  color: var(--danger-soft);
}

.draft-diagram-step.pick .draft-diagram-label {
  color: var(--accent);
}

.draft-diagram-player {
  font-size: 0.72rem;
  font-weight: 700;
}

.draft-diagram-player.player-a {
  color: var(--accent);
}

.draft-diagram-player.player-b {
  color: #f0c040;
}

.draft-diagram-domain {
  display: flex;
  align-items: center;
  justify-content: center;
}

.draft-diagram-domain svg {
  width: 1.15rem;
  height: 1.15rem;
}

.draft-diagram-cross {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: var(--danger-soft);
  color: #000;
  font-size: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.draft-diagram-arrow {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 0 0.1rem;
}

.draft-diagram-result {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.draft-diagram-result-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

.draft-diagram-result-domains {
  display: flex;
  gap: 0.3rem;
}

.draft-diagram-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border: 1.5px solid;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

.draft-diagram-badge svg {
  width: 0.9rem;
  height: 0.9rem;
}

.draft-diagram-note {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-style: italic;
}

/* ---- Domains & Aspects Explorer ---- */
.domains-explorer {
  padding: 1rem 0;
}

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

.domain-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.2rem 1.4rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s,
    transform 0.15s;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
}

.domain-btn svg {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
}

.domain-btn:hover {
  border-color: var(--btn-color, var(--accent));
  background: var(--surface-hover);
  transform: translateY(-2px);
}

/* Expanded domain detail */
.domain-detail {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.domain-back-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.88rem;
  padding: 0.4rem 0;
  margin-bottom: 1rem;
  transition: color 0.15s;
}

.domain-back-btn:hover {
  color: var(--text);
}

.domain-detail-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

.domain-detail-header svg {
  width: 2.5rem;
  height: 2.5rem;
}

.domain-detail-header .domain-detail-name {
  font-size: 1.5rem;
  font-weight: 700;
}

.aspect-buttons {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.aspect-btn {
  padding: 0.6rem 1.2rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s,
    color 0.2s;
}

.aspect-btn:hover {
  border-color: var(--btn-color, var(--accent));
  background: var(--surface-hover);
}

.aspect-btn.active {
  border-color: var(--btn-color, var(--accent));
  background: var(--surface-hover);
  color: var(--btn-color, var(--accent));
}

.aspect-description {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text);
  animation: fadeIn 0.2s ease;
}

.aspect-description h4 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.aspect-description p {
  margin-bottom: 0.6rem;
}

.aspect-key-cards {
  margin-top: 1.5rem;
}

.aspect-key-cards-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.aspect-key-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

@media (max-width: 600px) {
  .draft-diagram-timeline {
    gap: 0.2rem;
  }
  .draft-diagram-step {
    min-width: 2.5rem;
    padding: 0.3rem 0.35rem;
  }
  .draft-diagram-arrow {
    font-size: 0.7rem;
  }
  .draft-diagram-result {
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
  }
}

.rules-note {
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 0.6rem 0.9rem;
  background: rgba(108, 140, 255, 0.04);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-top: 0.75rem;
}

.rules-beginner {
  padding: 0.6rem 0.9rem;
  background: rgba(255, 210, 50, 0.08);
  border-left: 4px solid #e6b800;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0.75rem 0;
}

/* Player stats cards */
.rules-stats-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.rules-stat-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.rules-stat-icon {
  flex-shrink: 0;
  width: 2rem;
  text-align: center;
}
.rules-stat-icon svg {
  width: 1.4rem;
  height: 1.4rem;
  vertical-align: middle;
}
.rules-stat-card.stat-integrity .rules-stat-icon {
  color: var(--stat-integrity);
}
.rules-stat-card.stat-power .rules-stat-icon {
  color: var(--stat-power);
}
.rules-stat-card.stat-energy .rules-stat-icon {
  color: var(--stat-energy);
}
.rules-stat-card strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 0.1rem;
}
.rules-stat-card p {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.5;
}

/* Actions list */
.rules-actions-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.rules-action {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.rules-action-num {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-glow);
  border: 1px solid rgba(108, 140, 255, 0.25);
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
}
.rules-action div {
  font-size: 0.88rem;
  line-height: 1.6;
}

/* Glossary */
.rules-glossary dl {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.rules-glossary dt {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  padding: 0.65rem 0 0.2rem;
  border-top: 1px solid var(--border);
}
.rules-glossary dt:first-child {
  border-top: none;
  padding-top: 0;
}
.rules-glossary dd {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-left: 0;
  padding-bottom: 0.5rem;
}

/* ---- Cookie Banner ---- */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  z-index: 1000;
}
.cookie-banner.hidden {
  display: none;
}
.cookie-banner p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.cookie-banner p a {
  color: var(--accent);
  text-decoration: underline;
}
.cookie-banner-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn:hover {
  border-color: var(--text-dim);
  background: var(--surface-hover);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover {
  background: #5a7ae6;
  border-color: #5a7ae6;
}
.btn-secondary {
  background: transparent;
  color: var(--text-dim);
}
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #d04030;
}
.btn-sm {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
}

/* ---- Profile Page ---- */
.profile-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 1rem;
}
.profile-page h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}
.profile-section {
  margin-bottom: 2rem;
}
.profile-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.profile-name-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.profile-name-row input {
  flex: 1;
  padding: 0.45rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
}
.profile-name-row input:focus {
  outline: none;
  border-color: var(--accent);
}
#profile-monitoring-link {
  margin-top: 0.75rem;
}
.profile-role-badge {
  font-size: 1.3em;
  color: gold;
}
.profile-name-saved {
  font-size: 0.85rem;
  color: #4caf50;
  opacity: 0;
  transition: opacity 0.3s;
}
.profile-name-saved.show {
  opacity: 1;
}
.profile-hint {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 0.5rem 0;
}
.settings-row label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  color: var(--text-dim);
}
.settings-key-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.settings-key-row input {
  flex: 1;
  padding: 0.45rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
}
.settings-key-row input:focus {
  outline: none;
  border-color: var(--accent);
}
.profile-filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.btn-filter {
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-filter:hover {
  color: var(--text);
  border-color: var(--text-dim);
}
.btn-filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Game history */
.games-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.game-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}
.game-result {
  font-weight: 600;
  min-width: 2.5rem;
}
.game-win .game-result {
  color: #4caf50;
}
.game-loss .game-result {
  color: #f44336;
}
.game-local .game-result {
  color: var(--text-dim);
}
.game-opponent {
  font-weight: 500;
}
.game-domains {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}
.game-domain-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  color: #fff;
}
.game-domain-dot svg {
  width: 0.85rem;
  height: 0.85rem;
}
.game-domain-dot[data-domain="forest"] {
  background: var(--forest);
}
.game-domain-dot[data-domain="sparks"] {
  background: var(--sparks);
}
.game-domain-dot[data-domain="glacier"] {
  background: var(--glacier);
  color: #000;
}
.game-domain-dot[data-domain="volcano"] {
  background: var(--volcano);
}
.game-domain-dot[data-domain="ocean"] {
  background: var(--ocean);
}
.game-domain-dot[data-domain="wind"] {
  background: var(--wind);
  color: #000;
}
.game-domain-dot[data-domain="wasteland"] {
  background: var(--wasteland);
}
.game-domain-dot[data-domain="stars"] {
  background: var(--stars);
  color: #000;
}
.game-vs {
  color: var(--text-dim);
  font-size: 0.8rem;
}
.game-rounds {
  color: var(--text-dim);
  font-size: 0.85rem;
}
.game-mmr {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 500;
}
.game-mmr.mmr-positive {
  color: #4caf50;
}
.game-mmr.mmr-negative {
  color: #f44336;
}
.replay-buttons {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}
.replay-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1;
  transition: opacity 0.15s;
  opacity: 0.7;
}
.replay-btn:hover {
  opacity: 1;
}
.replay-btn-play {
  border: 1.5px solid #4caf50;
  color: #4caf50;
}
.replay-btn-download {
  border: 1.5px solid var(--text-dim);
  color: var(--text-dim);
  font-size: 1rem;
}
.game-date {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 0.8rem;
}
.empty-hint {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 1rem 0;
}
.games-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.pagination-info {
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Device list */
.devices-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.device-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.device-current {
  border-color: var(--accent);
}
.device-name {
  font-weight: 500;
}
.device-seen {
  color: var(--text-dim);
  font-size: 0.85rem;
  flex: 1;
}

/* Link code display */
.link-code {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-align: center;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 1rem 0;
  font-family: monospace;
  color: var(--accent);
}
.link-qr {
  display: block;
  margin: 0.5rem auto;
  max-width: 200px;
  aspect-ratio: 1;
  image-rendering: pixelated;
}
.link-url {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  word-break: break-all;
}

/* Not-logged-in profile state */
.noauth-hero {
  text-align: center;
  padding: 2rem 1rem 2.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.noauth-hero-icon {
  font-size: 3rem;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 24px var(--accent-glow);
  margin-bottom: 0.75rem;
}
.noauth-hero h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  border: none;
  padding: 0;
}
.noauth-hero-sub {
  color: var(--text-dim);
  font-size: 0.95rem;
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.5;
}

.noauth-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.noauth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}
.noauth-card:hover,
.noauth-card:focus-within {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px var(--accent-glow),
    0 8px 24px -12px var(--accent-glow);
}

.noauth-card-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.noauth-card-head h4 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}
.noauth-card-badge {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--accent-glow);
  color: var(--accent);
}
.noauth-card-badge-alt {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.noauth-card-desc {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 1rem;
  flex: 1;
}
.noauth-card-btn {
  width: 100%;
}
.noauth-card-hint {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
}

.noauth-divider {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding: 0.25rem 0;
}
.noauth-divider::before,
.noauth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.noauth-divider span {
  padding: 0 0.75rem;
}

.noauth-code-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.noauth-code-input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: monospace;
  font-size: 1.15rem;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
}
.noauth-code-input::placeholder {
  letter-spacing: 0.2em;
  color: var(--text-dim);
  text-transform: none;
}
.noauth-code-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.noauth-code-error {
  color: #e05050;
}

@media (max-width: 640px) {
  .noauth-hero {
    padding: 1.5rem 0.5rem 2rem;
  }
  .noauth-hero-icon {
    font-size: 2.5rem;
  }
  .noauth-hero h3 {
    font-size: 1.25rem;
  }
}

/* ---- Mobile (<768px) ---- */
@media (max-width: 768px) {
  header {
    padding: 0.5rem 1rem;
    gap: 0.5rem 1rem;
    flex-wrap: wrap;
  }
  header h1 {
    font-size: 1.1rem;
  }
  nav {
    flex-wrap: wrap;
  }
  .nav-link {
    padding: 0.35rem 0.7rem;
    font-size: 0.82rem;
  }

  main {
    padding: 1rem;
  }

  .filter-bar {
    gap: 0.5rem;
  }
  .filter-group + .filter-group {
    padding-left: 0.5rem;
  }
  .filter-section {
    gap: 0.3rem;
  }
  .filter-btn {
    width: 2rem;
    height: 2rem;
  }
  .filter-btn svg {
    width: 0.9rem;
    height: 0.9rem;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
  }

  .card {
    padding: 0.75rem 0.75rem 0.6rem;
    gap: 0.35rem;
  }
  .card-name {
    font-size: 0.9rem;
  }
  .card-strength {
    width: 1.8rem;
    height: 1.8rem;
    font-size: 0.8rem;
  }
  .card-cost {
    width: 1.8rem;
    height: 1.8rem;
    font-size: 0.8rem;
  }
  .card-meta {
    font-size: 0.68rem;
  }
  .card-aspects {
    font-size: 0.68rem;
  }
  .card-text {
    font-size: 0.75rem;
    height: 4rem;
  }

  /* Rules page — mobile */
  .rules-page {
    padding: 1rem;
  }
  .rules-hero h2 {
    font-size: 1.5rem;
  }
  /* Domains explorer — mobile */
  .domains-grid {
    grid-template-columns: 1fr;
  }
  .domain-btn {
    padding: 1rem 1.1rem;
  }
  .aspect-buttons {
    flex-direction: column;
  }
  .rules-tabs {
    flex-wrap: wrap;
  }
  .aspect-key-cards-grid {
    grid-template-columns: 1fr;
  }
  /* Modal — near full screen */
  .modal-content {
    width: 95%;
    max-width: none;
    max-height: 90vh;
    padding: 1.25rem;
  }
  .modal-card-name {
    font-size: 1.15rem;
  }
}
