/* RetroMedia — dark arcade-cabinet theme with a phosphor-green accent. */

:root {
  --bg: #0b0d12;
  --bg-2: #12151d;
  --panel: #171b25;
  --panel-2: #1d2230;
  --border: #2a3142;
  --text: #e8ecf4;
  --muted: #8b93a7;
  --accent: #34d399;
  --accent-dim: #1f9d6e;
  --accent-glow: rgba(52, 211, 153, 0.35);
  --amber: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(52, 211, 153, 0.07), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(251, 191, 36, 0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--mono);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 3px,
    rgba(0, 0, 0, 0.08) 3px 4px
  );
  opacity: 0.5;
}

/* ---- hero / header ---- */

.hero {
  padding: 48px 24px 28px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.logo {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 4rem);
  letter-spacing: 0.12em;
  font-weight: 800;
  text-shadow: 0 0 24px var(--accent-glow);
}

.logo .accent { color: var(--accent); }

.tagline {
  color: var(--muted);
  max-width: 640px;
  margin: 12px auto 28px;
  line-height: 1.6;
}

.searchbar {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  position: relative;
}

.searchbar input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 14px 42px 14px 16px;
  font-family: var(--mono);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.searchbar input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.searchbar .icon-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
}

/* ---- system bar ---- */

.system-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 8px 24px 16px;
  position: relative;
  z-index: 1;
}

.system-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 14px 9px 18px;
  font-family: var(--mono);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

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

.system-chip.active {
  background: linear-gradient(135deg, var(--accent-dim), #12855e);
  border-color: transparent;
  box-shadow: 0 4px 18px var(--accent-glow);
}

.chip-count {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.75rem;
  color: var(--accent);
}

.system-chip.active .chip-count { color: #fff; }

/* ---- content ---- */

.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 24px 60px;
  position: relative;
  z-index: 1;
}

.toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.toolbar h2 {
  margin: 0;
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.filters { display: flex; align-items: center; gap: 12px; }

.filters select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--mono);
  cursor: pointer;
}

.count-label { color: var(--muted); font-size: 0.8rem; }

/* ---- letter filter bar (0-9, A-Z) ---- */

.letter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 20px;
}

.letter-btn {
  min-width: 34px;
  padding: 6px 9px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.letter-btn:hover { color: var(--text); border-color: var(--accent-dim); }

.letter-btn.active {
  background: linear-gradient(135deg, var(--accent-dim), #12855e);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px var(--accent-glow);
}

/* ---- grid / cards ---- */

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

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-dim);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.card-art {
  aspect-ratio: 4 / 3;
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fallback {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--accent-dim);
  text-shadow: 0 0 18px var(--accent-glow);
}

/* category badges on cards: video/audio/doc presence at a glance, never
   any autoplaying media in the grid */
.card-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 4px;
  z-index: 2;
}

.card-art { position: relative; }

.badge {
  background: rgba(10, 13, 20, 0.82);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.8rem;
  line-height: 1.2;
}

.badge-video { border-color: var(--amber); }

/* video in the detail gallery: poster + controls, nothing streams until play */
.video-stage {
  width: 100%;
  display: flex;
  justify-content: center;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

.video-stage video {
  max-width: 100%;
  max-height: 46vh;
  aspect-ratio: 16 / 9;
}

.thumb { position: relative; }

.thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.thumb-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  background: rgba(0, 0, 0, 0.25);
}

.card-info { padding: 12px 14px 4px; flex: 1; }

.card-name {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
  line-height: 1.3;
}

.card-meta { color: var(--muted); font-size: 0.72rem; line-height: 1.5; }

/* tick boxes for media present under each game */
.card-ticks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 4px 14px 2px;
  font-size: 0.7rem;
  color: var(--muted);
}

.card-ticks .tick {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  color: var(--text);
}

.card-ticks .tick input {
  accent-color: var(--accent-dim);
  cursor: pointer;
  width: 13px;
  height: 13px;
  margin: 0;
}

.card-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px 14px;
}

/* ---- buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-dim), #12855e);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

.btn-primary:hover {
  filter: brightness(1.12);
  color: #fff;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-small { padding: 7px 12px; font-size: 0.78rem; flex: 1; }
.btn-ghost { background: transparent; }

.btn-block { width: 100%; margin-bottom: 14px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.icon-btn:hover { color: var(--text); }

/* ---- pager / empty ---- */

.pager { text-align: center; margin-top: 28px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* ---- detail dialog ---- */

.detail {
  width: min(940px, 94vw);
  max-height: 88vh;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
}

.detail::backdrop {
  background: rgba(5, 7, 11, 0.78);
  backdrop-filter: blur(4px);
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.detail-head h2 { margin: 0; font-size: 1.25rem; }

.detail-body {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
  gap: 0;
  overflow: auto;
  max-height: calc(88vh - 62px);
}

/* gallery */

.gallery {
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-right: 1px solid var(--border);
  position: relative;
}

.gallery-stage {
  flex: 1;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #05070b;
  border-radius: 10px;
  padding: 14px;
  border: 1px solid var(--border);
}

.gallery-stage img {
  max-width: 100%;
  max-height: 46vh;
  object-fit: contain;
}

.gallery-stage figcaption {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 10px;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(10, 13, 20, 0.8);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.3rem;
  cursor: pointer;
  z-index: 2;
  transition: all 0.15s ease;
}

.gallery-nav:hover { border-color: var(--accent); color: var(--accent); }
#gallery-prev { left: 8px; }
#gallery-next { right: 8px; }

.gallery-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  padding: 4px 2px;
}

.thumb {
  flex: 0 0 auto;
  width: 64px;
  height: 48px;
  padding: 0;
  background: var(--panel);
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.thumb.active { border-color: var(--accent); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.no-images { color: var(--muted); text-align: center; padding: 30px; }

/* side panel */

.detail-side { padding: 20px; min-width: 0; }

.meta p { margin: 0 0 8px; font-size: 0.82rem; color: var(--text); }
.meta strong { color: var(--accent); font-weight: 600; }

.type-links { margin: 12px 0 18px; }
.type-links summary { cursor: pointer; color: var(--muted); font-size: 0.8rem; margin-bottom: 8px; }
.type-links summary:hover { color: var(--accent); }
.type-links div { display: flex; flex-wrap: wrap; gap: 8px; }

.filelist { margin-top: 6px; }

.file-group {
  margin: 14px 0 6px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--amber);
}

.file-ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.file-ul li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 2px;
  border-bottom: 1px dashed var(--border);
  font-size: 0.78rem;
}

.file-ul a { color: var(--text); text-decoration: none; word-break: break-all; }
.file-ul a:hover { color: var(--accent); }
.file-size { color: var(--muted); font-size: 0.7rem; margin-left: 10px; white-space: nowrap; }

/* ---- upload dialog ---- */

.upload-dialog {
  width: min(560px, 94vw);
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
}

.upload-dialog::backdrop {
  background: rgba(5, 7, 11, 0.78);
  backdrop-filter: blur(4px);
}

.upload-body { padding: 20px 22px; }

.upload-hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
  margin: 0 0 16px;
}

.upload-field { margin-bottom: 14px; }

.upload-field label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.upload-field label .muted { text-transform: none; letter-spacing: 0; color: var(--muted); opacity: 0.8; }

.upload-field input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.upload-field input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  margin-bottom: 14px;
}

.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent-dim); }

.dropzone.drag {
  border-color: var(--accent);
  background: rgba(52, 211, 153, 0.06);
  box-shadow: inset 0 0 40px var(--accent-glow);
}

.dz-icon { font-size: 2rem; display: block; margin-bottom: 6px; }

.dz-title { margin: 0; color: var(--muted); font-size: 0.85rem; }

.dz-name {
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 0.8rem;
  word-break: break-all;
}

.upload-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.upload-progress .bar {
  flex: 1;
  height: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 999px;
  transition: width 0.15s ease;
  box-shadow: 0 0 12px var(--accent-glow);
}

.bar-pct { color: var(--muted); font-size: 0.78rem; min-width: 42px; text-align: right; }

.upload-status {
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--accent);
  margin: 0 0 14px;
}

.upload-status.error { color: var(--danger); }

.upload-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---- footer ---- */

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 30px 20px 40px;
  position: relative;
  z-index: 1;
}

.footer a { color: var(--accent); text-decoration: none; }

/* ---- responsive ---- */

@media (max-width: 760px) {
  .detail-body { grid-template-columns: 1fr; }
  .gallery { border-right: none; border-bottom: 1px solid var(--border); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* ---- account bar / credits ---- */

.account-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px 0;
}

.account-info {
  color: var(--muted);
  font-size: 0.75rem;
}

.account-info.flash {
  color: var(--accent);
  text-shadow: 0 0 16px var(--accent-glow);
}

.buy-packs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.pack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  cursor: pointer;
  text-align: left;
}

.pack:hover { border-color: var(--accent-dim); transform: translateY(-2px); }
.pack strong { font-size: 1.05rem; color: var(--accent); }
.pack span { font-size: 0.85rem; }
.pack em { font-size: 0.7rem; color: var(--muted); font-style: normal; }

.buy-total {
  color: var(--amber);
  font-size: 0.8rem;
  margin: 8px 0 4px;
}

.apikey-out {
  margin-top: 10px;
  padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 0.75rem;
  word-break: break-all;
}

/* ---- Supabase sign-in extras ---- */

.account-or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.account-or::before,
.account-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #fff;
  color: #1f2430;
  border: 1px solid var(--border);
}

.btn-google:hover { background: #eef1f6; }
.btn-google svg { flex: 0 0 auto; }
