*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface2: #23232f;
  --border: #2e2e3e;
  --accent: #7c5cfc;
  --accent-hover: #9b82ff;
  --text: #e4e4f0;
  --muted: #8888aa;
  --danger: #e05555;
  --radius: 10px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent-hover);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-chip {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Main content ── */
.main { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ── Game grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}
.card-thumb-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.card-body { padding: 0.875rem 1rem; }
.card-title { font-weight: 600; font-size: 1rem; margin-bottom: 0.25rem; }
.card-desc {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
}
.play-count { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 5rem 1rem;
  color: var(--muted);
}
.empty h2 { font-size: 1.25rem; margin-bottom: 0.5rem; color: var(--text); }

/* ── Auth modal ── */
.auth-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.auth-overlay.hidden { display: none; }

.auth-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}
.auth-modal h2 { font-size: 1.25rem; margin-bottom: 1.25rem; text-align: center; }

.auth-tabs { display: flex; gap: 0; margin-bottom: 1.25rem; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.auth-tab {
  flex: 1; padding: 0.5rem; font-size: 0.875rem; background: transparent;
  border: none; color: var(--muted); cursor: pointer; transition: background 0.15s;
}
.auth-tab.active { background: var(--accent); color: #fff; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
.form-group input {
  width: 100%; padding: 0.6rem 0.75rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 0.875rem;
}
.form-group input:focus { outline: none; border-color: var(--accent); }

.auth-error { font-size: 0.8rem; color: var(--danger); margin-bottom: 0.75rem; min-height: 1rem; }

/* ── Publish form ── */
.publish-wrap { max-width: 640px; margin: 0 auto; padding: 2rem 1.5rem; }
.publish-wrap h2 { font-size: 1.5rem; margin-bottom: 1.5rem; }

.field { margin-bottom: 1.25rem; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem; }
.field input, .field textarea {
  width: 100%; padding: 0.65rem 0.85rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 0.9rem; font-family: inherit;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 80px; }
.field-hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.3rem; }
.slug-preview { font-size: 0.78rem; color: var(--accent); margin-top: 0.3rem; font-family: monospace; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 0.9rem;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(124, 92, 252, 0.06);
}
.drop-zone.has-file { border-color: #4caf7d; color: #4caf7d; }
.drop-zone input[type=file] { display: none; }

.form-error { color: var(--danger); font-size: 0.85rem; margin-bottom: 1rem; min-height: 1.2rem; }
.form-success { color: #4caf7d; font-size: 0.85rem; margin-bottom: 1rem; }
