:root {
  --ink: #0f1117;
  --surface: #171a24;
  --surface-raised: #1e2230;
  --line: #2a2f3f;
  --text: #edeef2;
  --text-dim: #9aa0af;
  --gold: #e8b54d;
  --gold-dim: #b8904a;
  --teal: #4fa6a0;
  --danger: #d9685f;

  --font-display: "Fraunces", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* subtle film-grain texture over the ink background */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 40px;
  border-bottom: 1px solid var(--line);
}

.mark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}
.mark-glyph { color: var(--gold); font-size: 1rem; }

.auth-area { display: flex; align-items: center; gap: 14px; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.user-chip img {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line);
}
.user-chip b { color: var(--text); font-weight: 600; }

main { position: relative; z-index: 1; }

/* ---------- Hero / login ---------- */
.hero {
  max-width: 640px;
  margin: 0 auto;
  padding: 18vh 24px 10vh;
  text-align: center;
}
.eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--gold);
  margin-bottom: 18px;
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.1rem, 5vw, 3.2rem);
  line-height: 1.12;
  margin: 0 0 20px;
}
.hero-sub {
  color: var(--text-dim);
  font-size: 1.02rem;
  line-height: 1.6;
  margin: 0 auto 34px;
  max-width: 480px;
}
.hero-note {
  margin-top: 16px;
  color: var(--danger);
  font-size: 0.88rem;
  min-height: 1em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary {
  background: var(--gold);
  color: #1a1300;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(232,181,77,0.25); }
.btn-large { padding: 14px 30px; font-size: 1rem; }

.link-btn {
  background: none;
  border: none;
  color: var(--teal);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font-body);
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Loading ---------- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 22vh 0;
  gap: 16px;
  color: var(--text-dim);
}
.loading-tag {
  color: var(--gold);
  font-size: 1.6rem;
  animation: spin 1.4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Vault / search ---------- */
.vault {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

.vault-toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 720px) {
  .vault-toolbar { grid-template-columns: 1fr; }
}

.search-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
}
.search-glyph { color: var(--text-dim); }
#searchInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
#searchInput::placeholder { color: var(--text-dim); }

.field-select {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 0 14px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  cursor: pointer;
}

.vault-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  margin-bottom: 22px;
  padding: 0 2px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.badge-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
  overflow: hidden;
}
.badge-card:hover {
  border-color: var(--gold-dim);
  transform: translateY(-2px);
}
.badge-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 26px; height: 26px;
  background: var(--gold);
  clip-path: polygon(0 0, 100% 0, 0 100%);
  opacity: 0.9;
}
.badge-icon {
  width: 56px; height: 56px;
  border-radius: 8px;
  background: var(--surface-raised);
  margin-bottom: 12px;
  object-fit: cover;
  border: 1px solid var(--line);
}
.badge-name {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
  margin-bottom: 6px;
}
.badge-game {
  color: var(--teal);
  font-size: 0.82rem;
  margin-bottom: 10px;
}
.badge-ids {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}
.empty-sub { font-size: 0.88rem; margin-top: 6px; }

/* ---------- Detail overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,11,16,0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
}
.detail-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  max-width: 420px;
  width: 100%;
  padding: 30px;
}
.detail-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.detail-close:hover { color: var(--text); }
.detail-body img {
  width: 72px; height: 72px;
  border-radius: 10px;
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.detail-body h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0 0 6px;
}
.detail-game { color: var(--teal); font-size: 0.9rem; margin-bottom: 14px; }
.detail-desc { color: var(--text-dim); font-size: 0.9rem; line-height: 1.5; margin-bottom: 18px; }
.detail-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  display: grid;
  gap: 6px;
  border-top: 1px dashed var(--line);
  padding-top: 14px;
}
.detail-meta b { color: var(--text); }
