:root {
  --bg0: #050b12;
  --bg1: #0a1520;
  --bg2: #102033;
  --panel: rgba(12, 24, 38, 0.88);
  --line: rgba(212, 175, 105, 0.18);
  --gold: #d4af69;
  --gold-2: #f0d49a;
  --text: #eef3f8;
  --muted: #8fa0b3;
  --danger: #ff6b6b;
  --ok: #3dd68c;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --font: "Outfit", system-ui, sans-serif;
  --display: "Syne", "Outfit", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(212, 175, 105, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(42, 110, 168, 0.18), transparent 50%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 40%, #03070c);
  color: var(--text);
  font-family: var(--font);
}

body {
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

/* ---- Auth ---- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fadeIn 0.45s ease;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  padding: 36px 28px 28px;
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.brand {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: clamp(1.8rem, 5vw, 2.3rem);
  margin: 0 0 6px;
  background: linear-gradient(120deg, var(--gold-2), var(--gold) 45%, #fff6df);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-sub {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field label {
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.field input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
  border-color: rgba(212, 175, 105, 0.55);
  box-shadow: 0 0 0 3px rgba(212, 175, 105, 0.12);
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #e2c07a, #b8893d);
  color: #1a1205;
  margin-top: 8px;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.error-box {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.28);
  color: #ffb4b4;
  font-size: 0.9rem;
}

/* ---- Lobby ---- */
.lobby {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: rgba(5, 11, 18, 0.86);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
}

.topbar .brand {
  font-size: 1.25rem;
  margin: 0;
  flex: 0 0 auto;
}

.search-wrap {
  flex: 1;
  min-width: 0;
}

.search-wrap input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 11px 16px;
  outline: none;
}

.search-wrap input:focus {
  border-color: rgba(212, 175, 105, 0.45);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 18px 6px;
  scrollbar-width: none;
}

.cats::-webkit-scrollbar {
  display: none;
}

.cat {
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  padding: 8px 14px;
  font-size: 0.86rem;
  font-weight: 500;
}

.cat.active {
  color: #1a1205;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  border-color: transparent;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 4px 18px 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.mirror-status {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.mirror-status.ok {
  color: var(--ok);
}

.mirror-status.bad {
  color: var(--danger);
}

.auth-card .mirror-status {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 8px 14px 100px;
}

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    padding-inline: 18px;
  }
}

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

@media (min-width: 1280px) {
  .grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.card {
  position: relative;
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
  color: inherit;
  border-radius: 16px;
  overflow: hidden;
  isolation: isolate;
  transform: translateZ(0);
  transition: transform 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
}

.card-media {
  aspect-ratio: 3 / 4;
  background:
    linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.75)),
    var(--bg2);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.card:hover .card-play,
.card:focus-visible .card-play {
  opacity: 1;
}

.play-orb {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  color: #1a1205;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.card-body {
  padding: 10px 4px 0;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.loader,
.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 16px 20px;
}

.more-wrap {
  display: flex;
  justify-content: center;
  padding: 4px 16px 24px;
}

#load-more {
  min-width: 200px;
}

#scroll-sentinel {
  height: 8px;
  margin-bottom: 60px;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--gold);
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

.launch-toast {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(3, 7, 12, 0.72);
  backdrop-filter: blur(6px);
}

.launch-toast-card {
  width: min(320px, calc(100% - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: var(--shadow);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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