: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;
}

* {
  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;
}

/* 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);
}

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

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

.filter-clear {
  display: flex;
  align-items: center;
  padding-right: 1rem;
  border-right: 1px solid var(--border);
}

.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;
}

/* Card Grid */
.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;
}

.impl-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  flex-shrink: 0;
}

.filter-btn .impl-dot {
  width: 14px;
  height: 14px;
  margin: 0;
}

.card-cost {
  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;
  color: var(--accent);
}

.card-meta {
  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);
  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-aspect {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.badge-strength {
  background: #3a1a1a;
  border: 1px solid #6b3030;
  color: #ff8888;
  font-weight: 700;
}

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

/* Domain colors */
.domain-Лес .badge-domain,
.badge-domain[data-domain="Лес"] {
  background: var(--forest);
}
.domain-Искры .badge-domain,
.badge-domain[data-domain="Искры"] {
  background: var(--sparks);
}
.domain-Ледник .badge-domain,
.badge-domain[data-domain="Ледник"] {
  background: var(--glacier);
  color: #000;
}
.domain-Вулкан .badge-domain,
.badge-domain[data-domain="Вулкан"] {
  background: var(--volcano);
}
.domain-Океан .badge-domain,
.badge-domain[data-domain="Океан"] {
  background: var(--ocean);
}
.domain-Ветер .badge-domain,
.badge-domain[data-domain="Ветер"] {
  background: var(--wind);
  color: #000;
}
.domain-Пустошь .badge-domain,
.badge-domain[data-domain="Пустошь"] {
  background: var(--wasteland);
}
.domain-Звёзды .badge-domain,
.badge-domain[data-domain="Звёзды"] {
  background: var(--stars);
  color: #000;
}

/* Domain left border accent */
.domain-Лес {
  border-left: 3px solid var(--forest);
}
.domain-Искры {
  border-left: 3px solid var(--sparks);
}
.domain-Ледник {
  border-left: 3px solid var(--glacier);
}
.domain-Вулкан {
  border-left: 3px solid var(--volcano);
}
.domain-Океан {
  border-left: 3px solid var(--ocean);
}
.domain-Ветер {
  border-left: 3px solid var(--wind);
}
.domain-Пустошь {
  border-left: 3px solid var(--wasteland);
}
.domain-Звёзды {
  border-left: 3px solid var(--stars);
}

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

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hidden {
  display: none;
}
.modal.hidden {
  display: none;
}

.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-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  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 {
  position: absolute;
  top: 0.75rem;
  right: 2.5rem;
  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);
  z-index: 1;
}
.btn-minimize-modal:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

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

.modal-card-meta {
  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;
  white-space: pre-line;
  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: auto;
  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%;
  height: auto;
  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;
  gap: 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;
}

@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;
}

/* ---- 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 {
  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-domain[data-domain="Лес"] {
  border-color: var(--forest);
  background: rgba(45, 138, 78, 0.15);
}
.diagram-domain[data-domain="Ледник"] {
  border-color: var(--glacier);
  background: rgba(96, 181, 232, 0.15);
}

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

.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;
  width: 100%;
}

.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);
}

.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 {
  font-size: 1.4rem;
  flex-shrink: 0;
  width: 2rem;
  text-align: center;
  line-height: 1.4;
}
.rules-stat-card.stat-integrity .rules-stat-icon {
  color: #ff6b6b;
}
.rules-stat-card.stat-power .rules-stat-icon {
  color: #ffd93d;
}
.rules-stat-card.stat-energy .rules-stat-icon {
  color: #6bcb77;
}
.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: #e8553a;
  border-color: #e8553a;
  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-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;
}
.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: 5rem;
}
.game-win .game-result {
  color: #4caf50;
}
.game-loss .game-result {
  color: #f44336;
}
.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="Лес"] {
  background: var(--forest);
}
.game-domain-dot[data-domain="Искры"] {
  background: var(--sparks);
}
.game-domain-dot[data-domain="Ледник"] {
  background: var(--glacier);
  color: #000;
}
.game-domain-dot[data-domain="Вулкан"] {
  background: var(--volcano);
}
.game-domain-dot[data-domain="Океан"] {
  background: var(--ocean);
}
.game-domain-dot[data-domain="Ветер"] {
  background: var(--wind);
  color: #000;
}
.game-domain-dot[data-domain="Пустошь"] {
  background: var(--wasteland);
}
.game-domain-dot[data-domain="Звёзды"] {
  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;
}
.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;
}

/* 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;
  image-rendering: pixelated;
}
.link-url {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  word-break: break-all;
}

/* ---- 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-clear {
    display: none;
  }
  .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-cost {
    width: 1.8rem;
    height: 1.8rem;
    font-size: 0.8rem;
  }
  .card-meta {
    font-size: 0.68rem;
  }
  .card-text {
    font-size: 0.75rem;
    max-height: 4rem;
  }

  /* Rules page — mobile */
  .rules-page {
    padding: 1rem;
  }
  .rules-hero h2 {
    font-size: 1.5rem;
  }
  /* Modal — near full screen */
  .modal-content {
    width: 95%;
    max-width: none;
    max-height: 90vh;
    padding: 1.25rem;
  }
  .modal-card-name {
    font-size: 1.15rem;
  }
}
