:root {
  --bg: #07070c;
  --panel: rgba(8, 8, 14, 0.58);       /* dark frosted glass — readable over bright trailers */
  --panel-solid: #14141f;              /* modals stay solid for form legibility */
  --border: rgba(255, 255, 255, 0.14);
  --text: #f3f3fb;
  --muted: #9a9ab0;
  --accent: #7c5cff;
  --accent-2: #00d4ff;
  --danger: #ff5470;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.hidden { display: none !important; }

input, textarea, select {
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  outline: none;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.2);
}

/* ---------------- Background trailers ---------------- */
.bg-trailers {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #04040a;
}
.bg-trailers iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100vw;
  height: 56.25vw;
  min-height: 100vh;
  min-width: 177.78vh;
  transform: translate(-50%, -50%) scale(1.12);
  filter: blur(22px) brightness(0.85) saturate(1.15);
  pointer-events: none;
  border: 0;
  transition: opacity 1.2s ease;
}
/* Hidden background-music player — rendered (so it actually plays) but
   invisible and non-interactive. No controls; volume follows the trailers. */
.bg-audio {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 160px;
  height: 90px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.bg-trailers::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% 0%, transparent 45%, rgba(4, 4, 10, 0.32) 100%),
    linear-gradient(180deg, rgba(4, 4, 10, 0.12), rgba(4, 4, 10, 0.42));
}

/* ---------------- Landing layout ---------------- */
.landing {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 6vh 2rem 6rem;
}
.brand {
  text-align: center;
  font-size: clamp(2.6rem, 7vw, 5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 0 0 1.6rem;
  background: linear-gradient(120deg, #fff 20%, var(--accent) 60%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 8px 40px rgba(124, 92, 255, 0.25);
}
.search { max-width: 620px; margin: 0 auto 1.1rem; }
.search input {
  font-size: 1.1rem;
  padding: 0.95rem 1.2rem;
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(12px);
}

/* Shrink-to-content block, centered as a unit under the search bar. The two
   groups share an aligned label column so genres and tags line up. */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: fit-content;
  max-width: 100%;
  margin: 1.2rem auto 0.5rem;
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.filter-group-label {
  flex: none;
  width: 60px;
  text-align: right;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.chip {
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
  transition: all 0.15s ease;
}
.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------------- List + legend ---------------- */
.list-wrap {
  margin-top: 1.8rem;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.legend, .game-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1.4fr 1.5fr 1.1fr 40px;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.2rem;
}
.legend {
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}
.legend button {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  text-transform: inherit;
  letter-spacing: inherit;
  font-size: inherit;
}
.legend button:hover { color: var(--text); }
.legend button.sorted { color: var(--accent-2); }
.sort-caret { font-size: 0.6rem; opacity: 0.8; }

.game-row {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease;
  cursor: pointer;
  padding-top: 1.15rem;
  padding-bottom: 1.15rem;
}
.game-row:hover { background: rgba(124, 92, 255, 0.08); }
.game-title { font-weight: 650; display: flex; align-items: center; gap: 0.8rem; }
.game-title img {
  width: 72px; height: 41px; object-fit: cover; border-radius: 6px;
  background: #222; flex: none;
}
.game-genre { color: var(--muted); font-size: 0.9rem; }
.tag-list { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tag {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 0.12rem 0.45rem;
  color: var(--muted);
}
.game-date { font-size: 0.9rem; color: var(--muted); white-space: nowrap; }

/* Platform badges get a faint accent tint to set them apart from tags. */
.tag-platform {
  background: rgba(124, 92, 255, 0.18);
  color: #cfc4ff;
}
.pill-platform {
  border-color: rgba(124, 92, 255, 0.5);
  background: rgba(124, 92, 255, 0.18);
}

/* Toggle-chip group used in the add/edit form (e.g. Platforms). */
.chip-select {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.row-edit { color: var(--muted); opacity: 0; transition: opacity 0.15s; }
.game-row:hover .row-edit { opacity: 1; }
.row-edit:hover { color: var(--accent-2); }
.empty { padding: 3rem 1rem; text-align: center; color: var(--muted); }

/* ---------------- Top-right controls ---------------- */
.top-controls {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 3;
  display: flex;
  gap: 0.5rem;
}
.btn {
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(8px);
  transition: all 0.15s ease;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.25); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #6a4bff; }
.btn-danger { color: var(--danger); }
.btn-ghost { background: transparent; }

/* ---------------- Modal ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(2, 2, 6, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 1rem;
  overflow-y: auto;
}
.modal {
  width: 100%;
  max-width: 560px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem;
}
.modal h2 { margin: 0 0 1.2rem; font-size: 1.3rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
.field-row { display: flex; gap: 0.7rem; }
.field-row > * { flex: 1; }
.modal-actions { display: flex; justify-content: space-between; gap: 0.7rem; margin-top: 1.4rem; }
.modal-actions .right { display: flex; gap: 0.6rem; }
.error-text { color: var(--danger); font-size: 0.85rem; margin-top: 0.4rem; }
.hint { color: var(--muted); font-size: 0.78rem; margin-top: 0.3rem; }
.thumb-strip { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.thumb-strip .thumb { position: relative; }
.thumb-strip img { width: 70px; height: 46px; object-fit: cover; border-radius: 8px; }
.thumb-strip .remove {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--danger); color: #fff; font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center;
}

/* ---------------- Fullscreen game view ---------------- */
.detail {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #000;
  overflow: hidden;
  cursor: default;
}
.detail.hide-cursor { cursor: none; }

/* Fit the player like fullscreen YouTube: largest 16:9 box that fits the
   viewport (letterboxed if the screen isn't 16:9), so the control bar stays
   on-screen. Interactive, so you can scrub / pause / change volume. */
.detail-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-video {
  aspect-ratio: 16 / 9;
  width: min(100vw, 177.78vh);
  height: auto;
  max-height: 100vh;
  border: 0;
}
/* Image fallback (no trailer) still covers the screen. */
.detail-image {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.detail-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  /* extra bottom padding keeps the text clear of the player's control bar */
  padding: 3rem 3rem 5.5rem;
  background: linear-gradient(0deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 45%, transparent 72%);
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.detail-overlay.faded { opacity: 0; }
.detail-overlay h1 {
  font-size: clamp(2rem, 6vw, 4.5rem);
  margin: 0 0 0.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.detail-meta { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 1rem; color: var(--muted); }
.detail-meta .pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.3);
}
.detail-desc { max-width: 680px; line-height: 1.6; color: #d8d8e6; font-size: 1.05rem; }
.detail-hint {
  position: absolute;
  top: 1.4rem; left: 1.6rem;
  z-index: 3;
  transition: opacity 0.6s ease;
  pointer-events: auto;
}
.detail-hint.faded { opacity: 0; }

