@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: hsl(240, 6%, 7%);
  --fg: hsl(40, 10%, 90%);
  --card: hsl(240, 5%, 11%);
  --primary: hsl(36, 90%, 55%);
  --primary-fg: hsl(240, 6%, 7%);
  --secondary: hsl(240, 5%, 15%);
  --muted: hsl(240, 5%, 50%);
  --border: hsl(240, 4%, 18%);
  --card-bg: hsl(240, 5%, 12%);
  --card-hover: hsl(240, 5%, 16%);
  --card-border: hsl(240, 4%, 20%);
  --radius: 0.75rem;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

.font-display { font-family: 'Space Grotesk', system-ui, sans-serif; }

/* ===== LOADING SCREEN ===== */
#loadingScreen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1.5rem;
  transition: opacity 0.6s ease;
}
#loadingScreen.hidden { opacity: 0; pointer-events: none; }
#loadingScreen svg {
  width: 64px; height: 64px; color: var(--primary);
  animation: spin 2s linear infinite;
}
#loadingScreen h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.875rem; font-weight: 700;
  color: var(--primary);
  text-shadow: 0 0 20px hsla(36, 90%, 55%, 0.4);
}
.loading-bar {
  width: 8rem; height: 2px;
  background: hsla(36, 90%, 55%, 0.4);
  border-radius: 9999px; overflow: hidden;
}
.loading-bar-inner {
  height: 100%; width: 0; background: var(--primary);
  animation: loadBar 1.5s ease-in-out forwards;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes loadBar { to { width: 100%; } }

/* ===== ANIMATED BACKGROUND ===== */
#bgCanvas {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
}

/* ===== NAVBAR ===== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: hsla(240, 5%, 11%, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid hsla(240, 4%, 20%, 0.5);
}
.navbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; height: 3.5rem;
}
.navbar-logo {
  display: flex; align-items: center; gap: 0.5rem;
  text-decoration: none; color: var(--fg);
  transition: color 0.2s;
}
.navbar-logo:hover { color: var(--primary); }
.navbar-logo svg { width: 24px; height: 24px; color: var(--primary); }
.navbar-logo span { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.125rem; }
.nav-links { display: flex; gap: 0.25rem; }
.nav-link {
  padding: 0.625rem; border-radius: 0.5rem;
  color: var(--muted); text-decoration: none;
  transition: all 0.2s; display: flex; align-items: center;
}
.nav-link:hover { color: var(--fg); background: var(--secondary); }
.nav-link.active { color: var(--primary); background: hsla(36, 90%, 55%, 0.1); }
.nav-link svg { width: 20px; height: 20px; }

/* ===== MAIN CONTENT ===== */
.content { position: relative; z-index: 1; }

/* ===== HERO ===== */
.hero {
  display: flex; flex-direction: column; align-items: center;
  gap: 2rem; padding: 5rem 1.5rem 2rem;
  animation: fadeUp 0.6s ease;
}
.hero-title {
  display: flex; align-items: center; gap: 0.75rem;
}
.hero-title svg {
  width: 40px; height: 40px; color: var(--primary);
  animation: float 3s ease-in-out infinite;
}
.hero-title h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 2.25rem;
  color: var(--primary);
  text-shadow: 0 0 20px hsla(36, 90%, 55%, 0.4);
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== BOOKMARKS ===== */
.bookmarks { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.bookmarks h3 { font-size: 0.875rem; font-weight: 500; color: var(--muted); letter-spacing: 0.05em; }
.bookmarks-grid { display: flex; gap: 1rem; }
.bookmark {
  display: flex; flex-direction: column; align-items: center; gap: 0.375rem;
  text-decoration: none; color: var(--muted); transition: color 0.2s;
}
.bookmark:hover { color: var(--fg); }
.bookmark-icon {
  width: 3rem; height: 3rem; border-radius: 0.75rem;
  background: var(--secondary); display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.bookmark:hover .bookmark-icon { background: var(--card-hover); transform: scale(1.05); }
.bookmark-icon img { width: 1.5rem; height: 1.5rem; }
.bookmark span { font-size: 0.75rem; }

/* ===== SECTION ===== */
.section {
  max-width: 72rem; margin: 0 auto; padding: 0 1.5rem 3rem;
  animation: fadeUp 0.6s ease 0.3s both;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.section-header h2 { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 1.125rem; }
.section-header a {
  font-size: 0.875rem; color: var(--primary);
  text-decoration: none;
}
.section-header a:hover { text-decoration: underline; }

/* ===== GAME GRID ===== */
.game-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
@media (min-width: 640px) { .game-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 768px) { .game-grid { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1024px) { .game-grid { grid-template-columns: repeat(6, 1fr); } }

/* ===== GAME CARD ===== */
.game-card {
  border-radius: var(--radius); overflow: hidden;
  background: var(--card-bg); border: 1px solid var(--card-border);
  cursor: pointer; transition: all 0.2s; position: relative;
}
.game-card:hover { border-color: hsla(36, 90%, 55%, 0.3); transform: scale(1.05) translateY(-4px); }
.game-card-img {
  aspect-ratio: 1; overflow: hidden; position: relative;
  background: var(--secondary);
}
.game-card-img img {
  width: 100%; height: 100%; object-fit: cover;
  transition: all 0.3s;
}
.game-card:hover .game-card-img img { filter: blur(4px); transform: scale(1.1); }
.game-card-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.3s;
}
.game-card:hover .game-card-overlay { opacity: 1; }
.game-card-overlay span {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 1.5rem; color: var(--fg);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.game-card-fallback {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk', sans-serif; font-size: 1.125rem; color: var(--muted);
}

/* ===== GAME PLAYER ===== */
.game-player {
  position: fixed; inset: 0; z-index: 100;
  background: hsla(240, 6%, 7%, 0.95);
  display: none; flex-direction: column;
  animation: fadeIn 0.2s ease;
}
.game-player.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.player-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem; height: 3rem;
  border-bottom: 1px solid var(--border); background: var(--card);
}
.player-bar span { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 0.875rem; }
.player-controls { display: flex; gap: 0.25rem; }
.player-btn {
  padding: 0.5rem; border-radius: 0.5rem; border: none;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: all 0.2s; display: flex; align-items: center;
}
.player-btn:hover { color: var(--fg); background: var(--secondary); }
.player-btn svg { width: 16px; height: 16px; }
.player-frame { flex: 1; }
.player-frame iframe { width: 100%; height: 100%; border: none; }

/* ===== SEARCH BAR ===== */
.search-wrap { position: relative; width: 100%; max-width: 18rem; }
.search-wrap svg {
  position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted);
}
.search-input {
  width: 100%; height: 2.5rem; padding-left: 2.5rem; padding-right: 1rem;
  border-radius: var(--radius); background: var(--secondary);
  border: 1px solid var(--border); font-size: 0.875rem;
  color: var(--fg); font-family: 'Inter', sans-serif;
  outline: none; transition: all 0.2s;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { box-shadow: 0 0 0 2px hsla(36, 90%, 55%, 0.4); }

/* ===== PAGE HEADER ===== */
.page-header {
  padding-top: 5rem; max-width: 72rem; margin: 0 auto;
  padding-left: 1.5rem; padding-right: 1.5rem;
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 1rem;
  margin-bottom: 1.5rem;
  animation: fadeUp 0.4s ease;
}
.page-header h1 { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.5rem; }

/* ===== SETTINGS ===== */
.settings-wrap {
  padding-top: 5rem; max-width: 40rem; margin: 0 auto;
  padding-left: 1.5rem; padding-right: 1.5rem; padding-bottom: 3rem;
  animation: fadeUp 0.4s ease;
}
.settings-card {
  padding: 1.25rem; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.settings-card h2 { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 1rem; }
.settings-card p { font-size: 0.875rem; color: var(--muted); margin-top: 0.25rem; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
}
.toggle {
  width: 2.75rem; height: 1.5rem; border-radius: 9999px;
  background: var(--secondary); border: none; cursor: pointer;
  position: relative; transition: background 0.2s;
}
.toggle.on { background: var(--primary); }
.toggle-knob {
  position: absolute; top: 2px; left: 2px;
  width: 1.25rem; height: 1.25rem; border-radius: 50%;
  background: var(--fg); transition: transform 0.2s;
}
.toggle.on .toggle-knob { transform: translateX(1.25rem); }
.preset-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;
  margin-top: 0.75rem;
}
.preset-btn {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.625rem; border-radius: 0.5rem;
  background: var(--secondary); border: none; color: var(--fg);
  font-size: 0.875rem; cursor: pointer; transition: background 0.2s;
  font-family: 'Inter', sans-serif; text-align: left;
}
.preset-btn:hover { background: var(--card-hover); }
.preset-btn img { width: 16px; height: 16px; }
.cloak-input {
  width: 100%; height: 2.25rem; padding: 0 0.75rem;
  border-radius: 0.5rem; background: var(--secondary);
  border: 1px solid var(--border); font-size: 0.875rem;
  color: var(--fg); font-family: 'Inter', sans-serif;
  outline: none; margin-top: 0.75rem;
}
.cloak-input:focus { box-shadow: 0 0 0 2px hsla(36, 90%, 55%, 0.4); }
.cloak-options { margin-top: 0.75rem; display: none; }
.cloak-options.show { display: block; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 5rem 0; color: var(--muted);
}
.empty-state p:first-child { font-family: 'Space Grotesk', sans-serif; font-size: 1.125rem; }
.empty-state p:last-child { font-size: 0.875rem; margin-top: 0.25rem; }

/* ===== GAME CARD SHINE ===== */
.game-card::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 40%, hsla(36, 90%, 55%, 0.05) 50%, transparent 60%);
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.game-card:hover::after { opacity: 1; }
