/* ── BrickOSINT — Main Stylesheet ─────────────────────────────────────── */

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-sidebar: #141620;
  --bg-hover: #242736;
  --text: #e4e6ed;
  --text-muted: #8b8fa3;
  --accent: #f7d03c;
  --accent-hover: #fde068;
  --green: #34d399;
  --red: #f87171;
  --orange: #fb923c;
  --blue: #60a5fa;
  --border: #2a2d3a;
  --radius: 8px;
  --sidebar-w: 260px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 24px 0 60px; /* bottom padding makes room for sidebar-footer */
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
}
.logo {
  font-size: 1.3rem;
  color: var(--accent);
}
.tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.nav-links {
  list-style: none;
  padding: 12px 0;
}
.nav-links li a {
  display: block;
  padding: 10px 20px;
  color: var(--text-muted);
  font-weight: 500;
  transition: all 0.15s;
}
.nav-links li a:hover,
.nav-links li a.active {
  color: var(--text);
  background: var(--bg-hover);
  border-left: 3px solid var(--accent);
}

.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-sidebar);
}
.sidebar-public-link {
  display: block;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  padding: 7px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-align: center;
  transition:
    color 0.15s,
    border-color 0.15s,
    background 0.15s;
}
.sidebar-public-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-hover);
}

.filter-section {
}
.filter-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.filter-group {
  margin-bottom: 12px;
}
.filter-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
/* Native <select> is kept in the DOM (for form submission) but visually hidden */
.filter-group select,
.cs-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

/* ── Custom searchable select widget ──────────────────────────────────── */

.cs-wrapper {
  position: relative;
}
.cs-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
  gap: 6px;
}
.cs-btn:hover,
.cs-btn:focus {
  border-color: var(--accent);
  outline: none;
}
.cs-btn-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-btn.cs-placeholder .cs-btn-text {
  color: var(--text-muted);
}
.cs-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: transform 0.15s;
  line-height: 1;
}
.cs-btn.cs-open .cs-arrow {
  transform: rotate(180deg);
}
.cs-panel {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.cs-search {
  display: block;
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--text);
  font-size: 0.83rem;
  outline: none;
  box-sizing: border-box;
}
.cs-search::placeholder {
  color: var(--text-muted);
}
.cs-list {
  max-height: 210px;
  overflow-y: auto;
}
.cs-item {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-item:hover {
  background: var(--bg-hover);
}
.cs-item.cs-selected {
  color: var(--accent);
  background: var(--bg-hover);
}
.cs-item.cs-item-placeholder {
  color: var(--text-muted);
  font-style: italic;
}
.cs-no-results {
  padding: 8px 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Content ─────────────────────────────────────────────────────────────── */

.content {
  margin-left: var(--sidebar-w);
  padding: 32px 40px;
  flex: 1;
  max-width: 1400px;
}

.page-header {
  margin-bottom: 28px;
}
.page-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
}

.back-link {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: inline-block;
  margin-bottom: 8px;
}
.back-link:hover {
  color: var(--accent);
}

.set-num-lg {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ── Stats cards ──────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-completed .stat-value {
  color: var(--green);
}
.stat-pending .stat-value {
  color: var(--orange);
}
.stat-failed .stat-value {
  color: var(--red);
}

/* ── Progress bar ─────────────────────────────────────────────────────────── */

.progress-section {
  margin-bottom: 32px;
}
.progress-section h3 {
  font-size: 1rem;
  margin-bottom: 10px;
}
.progress-bar {
  height: 12px;
  background: var(--bg-card);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 6px;
  transition: width 0.5s;
}
.progress-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
  display: inline-block;
}

/* ── Section ──────────────────────────────────────────────────────────────── */

.section {
  margin-bottom: 32px;
}
.section h3 {
  font-size: 1rem;
  margin-bottom: 14px;
}
.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 8px;
}

.badge {
  display: inline-block;
  background: var(--bg-hover);
  color: var(--accent);
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 12px;
  margin-left: 8px;
  font-weight: 500;
}

/* ── Theme grid ───────────────────────────────────────────────────────────── */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.theme-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
}
.theme-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text);
}
.theme-name {
  font-size: 0.85rem;
  color: var(--text);
}
.theme-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ── Year chart ───────────────────────────────────────────────────────────── */

.year-chart-outer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.year-nav-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
  user-select: none;
  padding: 0;
}
.year-nav-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}
.year-nav-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.year-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 360px;
  padding: 36px 4px 0;
  overflow-x: hidden;
  scroll-behavior: smooth;
  flex: 1;
  min-width: 0;
}

.year-bar-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  min-width: 48px;
  height: 100%;
}
.year-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  height: var(--bar-height);
  min-height: 6px;
  transition: opacity 0.15s;
  position: relative;
}
.year-bar:hover {
  opacity: 0.8;
}
.year-bar-count {
  display: block;
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}
.year-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  writing-mode: vertical-rl;
  font-weight: 500;
}

/* ── Set grid (browse page) ───────────────────────────────────────────────── */

.set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.set-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}
.set-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.set-card-img {
  aspect-ratio: 4/3;
  overflow: hidden;
  background: #0c0d12;
  display: flex;
  align-items: center;
  justify-content: center;
}
.set-card-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.no-image {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.set-card-info {
  padding: 12px 14px;
}
.set-num {
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 600;
}
.set-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 2px;
  color: var(--text);
}
.set-meta {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Pagination ───────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 32px;
}
.pagination-inline {
  margin-top: 6px;
  justify-content: flex-start;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  user-select: none;
}
a.page-btn:hover,
button.page-btn:not(.active):not(.disabled):hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}
.page-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 700;
  cursor: default;
}
.page-btn.disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
  border-color: var(--border);
}
.page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 34px;
  font-size: 0.82rem;
  color: var(--text-muted);
  user-select: none;
}
.page-info {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

.btn {
  display: inline-block;
  padding: 8px 18px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}
.btn-secondary {
  font-size: 0.8rem;
  margin-top: 8px;
}

/* ── Detail page ──────────────────────────────────────────────────────────── */

.detail-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

/* Hero + color picker strip side-by-side */
.detail-hero-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.detail-hero-wrap .detail-hero {
  flex: 1 1 auto;
  min-width: 0;
}

/* Color picker strip — two-column swatch grid to the right of the part image */
.color-picker-strip {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 84px;
  flex-shrink: 0;
}
.color-picker-swatches {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 430px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.color-picker-swatches::-webkit-scrollbar {
  width: 4px;
}
.color-picker-swatches::-webkit-scrollbar-track {
  background: transparent;
}
.color-picker-swatches::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
.color-swatch-btn {
  width: 100%;
  height: 30px;
  border-radius: 5px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition:
    border-color 0.12s,
    transform 0.1s;
  padding: 0;
  background-clip: padding-box;
}
.color-swatch-btn:hover {
  border-color: var(--accent);
  transform: scale(1.12);
}
.color-swatch-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.color-swatch-reset {
  background: var(--bg-card) !important;
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-color: var(--border);
  opacity: 1;
}
.color-swatch-reset:hover {
  border-color: var(--red);
  color: var(--red);
}

.hero-img {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
  border-radius: var(--radius);
  background: #0c0d12;
}
.hero-no-image {
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border-radius: var(--radius);
}

.meta-table {
  width: 100%;
  border-collapse: collapse;
}
.meta-table th,
.meta-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.meta-table th {
  color: var(--text-muted);
  font-weight: 500;
  width: 35%;
}

.subsection {
  margin-top: 20px;
}
.subsection h3 {
  font-size: 0.9rem;
  margin-bottom: 8px;
}

/* ── Set appearances dropdown (minifig detail) ───────────────────────────── */

.set-appearances summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  padding: 8px 0;
  list-style: none;
  user-select: none;
}
.set-appearances summary::before {
  content: "▸ ";
  font-size: 0.8rem;
}
.set-appearances[open] summary::before {
  content: "▾ ";
}
.set-appearances-list {
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 6px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.set-appearances-list li {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.set-appearances-list li:last-child {
  border-bottom: none;
}
.set-appearances-list li a {
  font-weight: 600;
  white-space: nowrap;
}
.set-appearances-name {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.set-appearances-year {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* ── Color-grouped appearances (part detail) ─────────────────────────────── */

.part-appearances-colors {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.part-color-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.part-color-group > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-card);
  user-select: none;
}
.part-color-group > summary::before {
  content: "▸";
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.part-color-group[open] > summary::before {
  content: "▾";
}
.part-color-group .set-appearances-list {
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
}
.color-inline-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
  display: inline-block;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 4px;
  font-family: "Courier New", monospace;
}

.status-badge {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-completed {
  background: rgba(52, 211, 153, 0.15);
  color: var(--green);
}
.status-pending {
  background: rgba(251, 146, 60, 0.15);
  color: var(--orange);
}
.status-in_progress {
  background: rgba(96, 165, 250, 0.15);
  color: var(--blue);
}
.status-failed {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
}

/* ── Gallery ──────────────────────────────────────────────────────────────── */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.gallery-item {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  background: #0c0d12;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-item:hover {
  border-color: var(--accent);
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.lightbox.active {
  display: flex;
}
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius);
}

/* ── Parts table ──────────────────────────────────────────────────────────── */

.parts-summary {
  max-height: 400px;
  overflow-y: auto;
}
.parts-table {
  width: 100%;
  border-collapse: collapse;
}
.parts-table thead th {
  background: var(--bg-card);
  position: sticky;
  top: 0;
}
.parts-table th,
.parts-table td {
  padding: 6px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state h2 {
  margin-bottom: 8px;
}
.empty-state p {
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .content {
    margin-left: 0;
    padding: 20px;
  }
  body {
    flex-direction: column;
  }
  .detail-layout {
    grid-template-columns: 1fr;
  }
  .nav-links {
    display: flex;
    padding: 8px 12px;
  }
  .nav-links li a {
    padding: 8px 14px;
  }
  .filter-section {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
  }
  .filter-group {
    margin-bottom: 0;
  }
}

/* ── Job control panel ───────────────────────────────────────────────────── */

.job-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.job-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.job-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-running {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: blink 1.2s ease-in-out infinite;
}
.dot-ok {
  background: var(--green);
}
.dot-error {
  background: var(--red);
}
.dot-warn {
  background: var(--orange);
}
.dot-unknown {
  background: var(--text-muted);
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.job-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-start {
  border-color: var(--green);
  color: var(--green);
}
.btn-start:hover {
  background: rgba(52, 211, 153, 0.1);
}
.btn-stop {
  border-color: var(--red);
  color: var(--red);
}
.btn-stop:hover {
  background: rgba(248, 113, 113, 0.1);
}
.btn-reset {
  border-color: var(--orange);
  color: var(--orange);
}
.btn-reset:hover {
  background: rgba(251, 146, 60, 0.1);
}

/* ── In-progress stat card ───────────────────────────────────────────────── */

.stat-in-progress .stat-value {
  color: var(--blue);
}

/* ── Pulse dot ───────────────────────────────────────────────────────────── */

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.pulse-active {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
  animation: pulse-ring 1.5s ease-out infinite;
}
@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(52, 211, 153, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0);
  }
}

/* ── Live feed ───────────────────────────────────────────────────────────── */

.live-feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 4px;
}

.feed-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.feed-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.feed-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-error {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
}

.feed-list {
  overflow-y: auto;
  max-height: 480px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.feed-empty {
  font-size: 0.82rem;
  padding: 8px 0;
}

.feed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.feed-row:hover {
  border-color: var(--border);
}
.row-ok {
  border-left: 3px solid var(--green);
}
.row-err {
  border-left: 3px solid var(--red);
}
.row-active {
  border-left: 3px solid var(--blue);
}

.feed-badge {
  font-size: 0.8rem;
  font-weight: 700;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}
.row-ok .feed-badge {
  color: var(--green);
}
.row-err .feed-badge {
  color: var(--red);
}
.row-active .feed-badge {
  color: var(--blue);
}

.feed-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.feed-set-num {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
}
.feed-set-name {
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Compact stats strip ─────────────────────────────────────────────────── */

.stats-compact {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  margin-bottom: 20px;
}
.stats-compact .stat-value {
  font-size: 1.5rem;
}

/* ── Catalog grid (parts & minifigs browse pages) ────────────────────────── */

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.catalog-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}
.catalog-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.catalog-card-img {
  aspect-ratio: 1;
  overflow: hidden;
  background: #0c0d12;
  display: flex;
  align-items: center;
  justify-content: center;
}
.catalog-card-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.catalog-card-info {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.catalog-num {
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 600;
}
.catalog-name {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Filter input ────────────────────────────────────────────────────────── */

.filter-input {
  width: 100%;
  padding: 8px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
}
.filter-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Filter checkboxes ───────────────────────────────────────────────────── */

.filter-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
}
.filter-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}
.filter-checkbox span {
  user-select: none;
}

.btn-search {
  width: 100%;
  margin-top: 4px;
  text-align: center;
}

/* ── Color swatch circles (parts browse / detail pages) ──────────────────── */

.color-circle {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  vertical-align: middle;
}

.color-swatches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.color-swatch-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
}
.color-swatch-name {
  color: var(--text);
  font-size: 0.78rem;
}

/* ── Color groups on set detail page ─────────────────────────────────────── */

.color-group {
  margin-bottom: 24px;
}
.color-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.color-group-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.color-group-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

.parts-visual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}
.part-visual-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.part-visual-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.part-visual-img {
  width: 100%;
  aspect-ratio: 1;
  background: #0c0d12;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.part-visual-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.part-visual-info {
  padding: 5px 6px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}
.part-visual-num {
  font-size: 0.65rem;
  color: var(--accent);
  font-family: "Courier New", monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.part-visual-qty {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

/* ── Minifig grid on set detail page ─────────────────────────────────────── */

.minifig-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.minifig-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}
.minifig-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.minifig-card-img {
  aspect-ratio: 3/4;
  background: #0c0d12;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.minifig-card-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.minifig-card-info {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}
.qty-badge {
  position: absolute;
  top: -14px;
  right: 8px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

/* ── Minifig hero image (taller aspect ratio) ────────────────────────────── */

.minifig-hero-img {
  max-height: 400px;
  object-position: center top;
}

/* ── Public landing page ─────────────────────────────────────────────────── */

.public-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 72px 24px 48px;
  text-align: center;
}
.public-title {
  font-size: 3rem;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 12px;
  letter-spacing: -1px;
}
.public-subtitle {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0 0 36px;
  max-width: 460px;
  line-height: 1.6;
}

/* ── Public search box ───────────────────────────────────────────────────── */

/* ── Brick loader (shown while search index primes on first load) ─────────── */

.pub-search-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 760px;
}
.brick-loader {
  background: var(--accent);
  border-radius: 6px;
  padding: 10px 12px 13px;
  box-shadow:
    0 4px 0 #b89300,
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.brick-row {
  display: flex;
  gap: 5px;
}
.brick-stud {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid rgba(0, 0, 0, 0.18);
  box-shadow:
    0 2px 0 #b89300,
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  animation: studPulse 1.6s ease-in-out infinite;
  animation-delay: calc(var(--d, 0) * 0.14s);
}
@keyframes studPulse {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}
.pub-loader-msg {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}
.pub-search-loader.loader-exit {
  animation: loaderFadeOut 0.25s ease forwards;
}
.pub-search-wrap.search-enter {
  animation: searchFadeIn 0.3s ease forwards;
}
@keyframes loaderFadeOut {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}
@keyframes searchFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pub-search-wrap {
  position: relative;
  width: 100%;
  max-width: 760px;
}
.pub-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 13px 18px;
  font-size: 1rem;
  background: var(--bg-card);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.pub-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.pub-search-input::-webkit-search-cancel-button {
  cursor: pointer;
}

/* ── Admin loading overlay (full-page, shown while indexes prime) ─────── */
.admin-loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  transition: opacity 0.25s ease;
}
.admin-loading-overlay.loader-exit {
  opacity: 0;
  pointer-events: none;
}

/* ── Autocomplete dropdown ───────────────────────────────────────────────── */

.pub-search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 200;
  overflow: hidden;
  max-height: 520px;
  overflow-y: auto;
}
.pub-search-dropdown.open {
  display: block;
}
.pub-search-result {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  transition: background 0.1s;
}
.pub-search-result:last-child {
  border-bottom: none;
}
.pub-search-result:hover,
.pub-search-result.focused {
  background: var(--bg-hover);
}
.pub-search-thumb {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
  background: #0c0d12;
}
.pub-search-thumb-placeholder {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  background: #0c0d12;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.pub-search-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.pub-search-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pub-search-setnum {
  font-weight: 700;
  color: var(--text);
  font-size: 0.9rem;
  font-family: monospace;
}
.pub-search-name {
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pub-search-name strong,
.pub-search-setnum strong,
.pub-search-meta strong {
  color: var(--accent);
  font-weight: 700;
}
.pub-search-sep {
  color: var(--border);
  user-select: none;
}
.pub-search-msg {
  padding: 12px 16px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

/* ── Filter loading overlay (shown while page reloads on filter submit) ───── */

.filter-loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.65);
  z-index: 9998;
  align-items: center;
  justify-content: center;
}
.filter-loading-overlay.active {
  display: flex;
}
.filter-spinner {
  width: 46px;
  height: 46px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: filterSpin 0.7s linear infinite;
}
@keyframes filterSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Inline set detail embed ─────────────────────────────────────────────── */

.pub-set-embed {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 60px;
  box-sizing: border-box;
  animation: embedSlideIn 0.2s ease;
}
@keyframes embedSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.pub-embed-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.pub-embed-close {
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  transition:
    color 0.15s,
    border-color 0.15s;
  flex-shrink: 0;
}
.pub-embed-close:hover {
  color: var(--text);
  border-color: var(--muted);
}
.pub-embed-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.pub-embed-setnum {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--muted);
  flex-shrink: 0;
}
.pub-embed-body {
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.pub-embed-top {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 700px) {
  .pub-embed-top {
    grid-template-columns: 1fr;
  }
}
.pub-embed-hero {
  background: #0c0d12;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.pub-embed-hero img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  cursor: zoom-in;
}
.pub-embed-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 14px;
}
.pub-embed-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ── Game System ─────────────────────────────────────────────────────────── */

/* Lobby */
.game-lobby {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.game-lobby-hero {
  text-align: center;
  margin-bottom: 32px;
}
.game-lobby-title {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 8px;
}
.game-lobby-sub {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 500px;
  margin: 0 auto;
}
.game-player-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}
.player-badge {
  font-size: 0.9rem;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.player-badge--user {
  border-color: var(--accent);
  color: var(--accent);
}
.player-badge--guest {
  color: var(--text-muted);
}
.game-link-btn {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  text-decoration: none;
  transition:
    color 0.15s,
    border-color 0.15s;
}
.game-link-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* Mode cards */
.game-mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}
.game-mode-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
}
.game-mode-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}
.game-mode-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 8px;
}
.game-mode-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 16px;
  line-height: 1.5;
}
.game-mode-note {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.game-mode-btn {
  display: inline-block;
  padding: 9px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.game-mode-btn:hover {
  background: var(--accent-hover);
  color: #000;
}
.game-mode-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.game-mode-btn--sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}
.game-mode-btn--secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  margin-left: 8px;
}
.game-mode-btn--secondary:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.game-room-join {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.game-room-input {
  width: 120px;
  text-align: center;
  text-transform: uppercase;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 6px 10px;
  outline: none;
}
.game-room-input:focus {
  border-color: var(--accent);
}
.game-loading {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 20px 0;
}

/* Leaderboard */
.game-leaderboard-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.game-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 16px;
}
.game-lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.game-lb-table th {
  text-align: left;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.game-lb-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

/* Game play page */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}
.game-header-left,
.game-header-right {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.game-header-right {
  text-align: right;
}
.game-header-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.game-header-set {
  font-weight: 600;
  font-size: 0.9rem;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game-header-set--target {
  color: var(--accent);
}
.game-header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.game-timer {
  font-family: monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}
.game-move-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.game-target-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(247, 208, 60, 0.06);
  border-bottom: 1px solid var(--border);
}
.game-target-thumb {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
}
.game-target-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.game-target-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.game-target-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}
.game-target-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Path breadcrumb */
.game-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 10px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  overflow-x: auto;
}
.game-path-step {
  padding: 3px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.78rem;
  white-space: nowrap;
}
.game-path-step--current {
  background: var(--accent);
  color: #000;
  font-weight: 600;
  border-color: var(--accent);
}
.game-path-arrow {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Current set */
.game-current {
  padding: 20px 24px;
}
.game-current-card {
  display: flex;
  gap: 20px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.game-current-img {
  width: 120px;
  height: 100px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
}
.game-current-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.game-current-info h2 {
  font-size: 1.1rem;
  margin: 0 0 4px;
}
.game-current-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 2px;
}

/* Neighbor grid */
.game-neighbors {
  padding: 0 24px 20px;
}
.game-neighbor-section {
  margin-bottom: 24px;
}
.game-neighbor-heading {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.game-neighbor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.game-neighbor-card {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.game-neighbor-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}
.game-neighbor-img {
  width: 56px;
  height: 56px;
  border-radius: 4px;
  object-fit: contain;
  background: var(--bg);
  flex-shrink: 0;
}
.game-neighbor-img--empty {
  border: 1px dashed var(--border);
}
.game-neighbor-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.game-neighbor-name {
  font-size: 0.82rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game-neighbor-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game-neighbor-link {
  font-size: 0.72rem;
  color: var(--blue);
}
.game-no-neighbors {
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
}

/* Game actions */
.game-actions {
  display: flex;
  justify-content: center;
  padding: 16px 24px;
  gap: 12px;
}
.game-btn {
  padding: 8px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.game-btn--danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.3);
}
.game-btn--danger:hover {
  background: rgba(248, 113, 113, 0.25);
}

/* Win modal */
.game-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.game-modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}
.game-modal-title {
  font-size: 1.5rem;
  margin: 0 0 16px;
}
.game-modal-time,
.game-modal-moves {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 4px 0;
}
.game-modal-time strong,
.game-modal-moves strong {
  color: var(--text);
}

/* Result page */
.game-result {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.game-result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.game-result-title {
  font-size: 1.5rem;
  text-align: center;
  margin: 0 0 24px;
}
.game-result-title--win {
  color: var(--green);
}
.game-result-title--loss {
  color: var(--red);
}
.game-result-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 24px;
}
.game-result-stat {
  text-align: center;
}
.game-result-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.game-result-stat-value {
  font-size: 1.3rem;
  font-weight: 700;
}
.game-result-path {
  margin-bottom: 20px;
}
.game-result-path h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.game-result-route {
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.game-result-leaderboard {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.game-result-leaderboard h3 {
  font-size: 0.95rem;
  margin: 0 0 12px;
}
.game-result-cta {
  text-align: center;
  margin-top: 24px;
  padding: 20px;
  background: rgba(247, 208, 60, 0.06);
  border-radius: var(--radius);
}
.game-result-cta p {
  color: var(--text-muted);
  margin: 0 0 12px;
  font-size: 0.9rem;
}
.game-result-actions {
  text-align: center;
  margin-top: 20px;
}

/* Room page */
.game-room {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.game-room-header {
  text-align: center;
  margin-bottom: 32px;
}
.game-room-title {
  font-size: 1.5rem;
  margin: 0 0 12px;
}
.game-room-code-display {
  font-size: 0.95rem;
  color: var(--text-muted);
}
.game-room-code-big {
  font-size: 1.6rem;
  font-family: monospace;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin: 0 8px;
}
.game-room-waiting {
  text-align: center;
  padding: 40px 0;
}
.game-room-waiting-text {
  color: var(--text-muted);
  margin-top: 20px;
  line-height: 1.6;
}
.game-room-battle {
  padding: 20px 0;
}
.game-room-players {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.game-room-player {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 28px;
  text-align: center;
  min-width: 180px;
}
.game-room-player-name {
  font-size: 1rem;
  margin: 0 0 8px;
}
.game-room-player-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.game-room-player-moves {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.game-room-player-status {
  font-size: 0.82rem;
  color: var(--green);
}
.game-room-vs {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-muted);
}
.game-room-completed {
  text-align: center;
  padding: 40px 0;
}
.game-room-play-link {
  text-align: center;
}

/* ── Game Directory (lobby grid) ─────────────────────────────────────────── */

.game-directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 48px;
}

.game-dir-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.game-dir-card:not(.game-dir-card--disabled):hover {
  border-color: var(--accent);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

/* Disabled / coming-soon card */
.game-dir-card--disabled {
  opacity: 0.55;
  filter: grayscale(0.35);
  cursor: default;
}
.game-dir-card--disabled .game-mode-btn {
  pointer-events: none;
}

.game-dir-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.game-dir-icon {
  font-size: 2rem;
  line-height: 1;
}
.game-dir-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.game-dir-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 10px;
}
.game-dir-badge--live {
  background: rgba(52, 211, 153, 0.15);
  color: var(--green);
  border: 1px solid rgba(52, 211, 153, 0.3);
}
.game-dir-badge--soon {
  background: rgba(251, 146, 60, 0.12);
  color: var(--orange);
  border: 1px solid rgba(251, 146, 60, 0.3);
}
.game-dir-badge--players {
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.game-dir-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}
.game-dir-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0;
  flex: 1;
}

.game-dir-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.game-dir-tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
  text-transform: capitalize;
}

.game-dir-footer {
  margin-top: 4px;
}
.game-dir-footer .game-mode-btn {
  width: 100%;
}

/* ── Tic-Tac-Toe Page ────────────────────────────────────────────────────── */

.ttt-page {
  max-width: 520px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.ttt-back {
  margin-bottom: 20px;
}

.ttt-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.ttt-header {
  text-align: center;
}
.ttt-title {
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0 0 6px;
}
.ttt-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

/* Legend + mode toggle row */
.ttt-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 16px;
  flex-wrap: wrap;
}
.ttt-legend {
  display: flex;
  align-items: center;
  gap: 14px;
}
.ttt-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.ttt-brick-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}
.ttt-brick-sm .ttt-brick-svg {
  width: 32px;
  height: 32px;
}
.ttt-vs {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}
.ttt-mode-wrap {
  display: flex;
  align-items: center;
}
.ttt-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  user-select: none;
}
.ttt-toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.ttt-toggle-text {
  font-weight: 600;
}

/* Status banner */
.ttt-status {
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  padding: 8px 20px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  width: 100%;
  box-sizing: border-box;
  transition:
    background 0.2s,
    border-color 0.2s;
}
.ttt-status--win {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.4);
  color: var(--green);
}
.ttt-status--draw {
  background: rgba(251, 146, 60, 0.1);
  border-color: rgba(251, 146, 60, 0.3);
  color: var(--orange);
}

/* Score strip */
.ttt-scores {
  display: flex;
  width: 100%;
  gap: 8px;
}
.ttt-score-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 6px;
  gap: 4px;
}
.ttt-score-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.ttt-score-val {
  font-size: 1.3rem;
  font-weight: 800;
}
.ttt-score-draw .ttt-score-val {
  color: var(--text-muted);
}

/* Board */
.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}
.ttt-cell {
  aspect-ratio: 1;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  transition:
    border-color 0.12s,
    background 0.12s,
    transform 0.1s;
}
.ttt-cell:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--bg-hover);
  transform: scale(1.03);
}
.ttt-cell:disabled {
  cursor: default;
}
.ttt-cell--win {
  border-color: var(--green) !important;
  background: rgba(52, 211, 153, 0.1) !important;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.35);
}

/* Brick SVGs inside cells */
.ttt-brick-svg {
  width: 100%;
  height: 100%;
  max-width: 80px;
  max-height: 80px;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}
.ttt-cell--x .ttt-brick-svg {
  animation: brickPop 0.18s ease-out;
}
.ttt-cell--o .ttt-brick-svg {
  animation: brickPop 0.18s ease-out;
}
@keyframes brickPop {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  70% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Controls row */
.ttt-controls {
  display: flex;
  gap: 10px;
  width: 100%;
}
.ttt-btn {
  flex: 1;
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition:
    background 0.15s,
    border-color 0.15s;
}
.ttt-btn--reset {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.ttt-btn--reset:hover {
  background: var(--accent-hover);
}
.ttt-btn--clear {
  background: var(--bg-card);
  color: var(--text-muted);
}
.ttt-btn--clear:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  color: var(--text);
}

/* ── Daily Challenge banner ───────────────────────────────────────────────── */
.ttt-daily-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.ttt-daily-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fbbf24;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ttt-daily-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Daily leaderboard placeholder ───────────────────────────────────────── */
.ttt-leaderboard-ph {
  width: 100%;
  margin-top: 16px;
  padding: 18px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.ttt-lb-icon {
  font-size: 1.6rem;
  margin-bottom: 6px;
  opacity: 0.5;
}
.ttt-lb-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 0 6px;
}
.ttt-lb-coming {
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.7;
  margin: 0;
  line-height: 1.5;
}

/* ── Game feature pills ───────────────────────────────────────────────────── */
.game-dir-features {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.game-feat {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.game-feat--on {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--green);
}
.game-feat--off {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
  opacity: 0.55;
}

/* ── Lobby action button variants ────────────────────────────────────────── */
.game-mode-btn--daily {
  background: rgba(251, 191, 36, 0.12) !important;
  border-color: rgba(251, 191, 36, 0.4) !important;
  color: #fbbf24 !important;
}
.game-mode-btn--daily:hover {
  background: rgba(251, 191, 36, 0.22) !important;
}
.game-mode-btn--fallback {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}
.game-mode-btn--fallback:hover {
  background: var(--bg-hover) !important;
  color: var(--text) !important;
}

/* ── Tic-Tac-Toe lobby ───────────────────────────────────────────────────── */
.ttt-lobby {
  max-width: 740px;
  margin: 0 auto;
  text-align: center;
}
.ttt-lobby-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 28px;
}
@media (max-width: 600px) {
  .ttt-lobby-options { grid-template-columns: 1fr; }
}
.ttt-lobby-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.ttt-lobby-icon {
  font-size: 2.4rem;
  line-height: 1;
}
.ttt-lobby-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.ttt-lobby-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
  text-align: center;
}
.ttt-btn--primary {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
  width: 100%;
}
.ttt-btn--primary:hover { opacity: .88; }
.ttt-btn--primary:disabled { opacity: .5; cursor: default; }
.ttt-join-row {
  display: flex;
  gap: 8px;
  width: 100%;
}
.ttt-join-input {
  flex: 1;
  background: var(--bg-input, var(--bg));
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 0.88rem;
  color: var(--text);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.ttt-join-input:focus {
  outline: none;
  border-color: var(--accent);
}
.ttt-btn--join {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.ttt-btn--join:hover { background: var(--bg-hover); }
.ttt-join-error {
  font-size: 0.78rem;
  color: var(--red, #e55);
  min-height: 1em;
  margin: 0;
}

/* ── Tic-Tac-Toe room page ───────────────────────────────────────────────── */
.ttt-room-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.ttt-room-code-row strong {
  color: var(--text);
  letter-spacing: .08em;
  font-size: 0.95rem;
}
.ttt-waiting-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 0;
}
.ttt-waiting-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.7;
  margin: 0;
}
.ttt-waiting-text strong { color: var(--text); letter-spacing: .06em; }
.ttt-legend-item--me > span { color: var(--accent); font-weight: 700; }
.ttt-me-badge {
  font-style: normal;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(251,191,36,.15);
  color: #fbbf24;
  border: 1px solid rgba(251,191,36,.3);
  border-radius: 20px;
  padding: 1px 7px;
  vertical-align: middle;
}
.ttt-cell--active {
  cursor: pointer;
}
.ttt-cell--active:hover {
  background: var(--bg-hover);
}
