:root {
  --bg: #1e1f22;
  --surface: #2b2d31;
  --border: #3f4147;
  --text: #f2f3f5;
  --muted: #b5bac1;
  --accent: #00ad9f;
  --fire: #e85d04;
  --shit: #5c636a;
  --media-bg: #121316;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.35;
}

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
}

.header-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.header h1 {
  margin: 0;
  font-size: 1.35rem;
}

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

.error {
  color: #ff6b6b;
}

.type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.type-tab {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

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

.type-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0d1f1e;
  font-weight: 600;
}

.controls {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}

.control-row label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.control-row input,
.control-row select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  min-width: 8rem;
  font-size: 0.9rem;
}

#search {
  min-width: 14rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  max-width: 100%;
  margin: 0 auto;
}

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

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

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

.loading,
.grid-sentinel {
  grid-column: 1 / -1;
  padding: 1.5rem;
  text-align: center;
}

.grid-sentinel {
  color: var(--muted);
  font-size: 0.85rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card-link {
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card-media {
  position: relative;
  width: 100%;
  background: var(--media-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
}

.card-rank {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  min-width: 1.6rem;
  padding: 0.2rem 0.45rem;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  color: #0d1f1e;
  background: var(--accent);
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.card-img {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
}

.card-img[data-src]:not(.img-loaded) {
  width: 100%;
  min-height: 120px;
  background: var(--media-bg);
  opacity: 0.15;
}

.card-img.img-loaded {
  opacity: 1;
  transition: opacity 0.15s ease-out;
}

.card-img.img-missing {
  min-height: 120px;
  opacity: 0.35;
}

.card-body {
  padding: 0.5rem 0.45rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.card-name {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;
}

.vote-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.25rem;
}

.vote-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.25rem 0.1rem;
  background: var(--bg);
  border-radius: 6px;
  min-width: 0;
}

.vote-emoji {
  font-size: 0.75rem;
  line-height: 1;
}

.vote-num {
  font-size: 0.58rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.25rem;
  font-size: 0.65rem;
  text-align: center;
  margin-top: auto;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.pop-score {
  color: var(--accent);
  font-weight: 700;
  cursor: help;
}

.wishlist,
.locker {
  color: var(--muted);
}
