:root {
  --bg: #1b1240;
  --bg-2: #24185a;
  --card: #2f2275;
  --card-hover: #3a2b8f;
  --text: #ffffff;
  --muted: #c7bff5;
  --pink: #ff4fa3;
  --yellow: #ffd23f;
  --cyan: #3fe0ff;
  --green: #4dff9a;
  --radius: 18px;
}

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

html, body {
  background: radial-gradient(circle at 20% 0%, #3a1f8a 0%, var(--bg) 55%) fixed;
  background-color: var(--bg);
  color: var(--text);
  font-family: "Fredoka", system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: rgba(27, 18, 64, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid rgba(255, 255, 255, 0.06);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.logo-mark { width: 38px; height: 38px; }
.logo span:nth-child(2) { color: var(--yellow); }
.logo .l1 { color: var(--pink); }
.logo .l2 { color: var(--cyan); }
.logo .l3 { color: var(--yellow); }

.search {
  flex: 1;
  max-width: 460px;
  margin-left: auto;
}
.search input {
  width: 100%;
  padding: 11px 18px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--cyan); }

/* ---------- Layout ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 16px; }

.chips {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0 14px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 9px 18px;
  border-radius: 999px;
  border: none;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.chip:hover { transform: translateY(-2px); background: var(--card-hover); }
.chip.active { background: var(--yellow); color: #2a1a00; }

.section-title {
  font-size: 22px;
  font-weight: 700;
  margin: 18px 0 12px;
}

/* ---------- Game grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  aspect-ratio: 1 / 1;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.18s, box-shadow 0.18s;
}
.card:hover {
  transform: translateY(-5px) scale(1.03);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}
.card img { width: 100%; height: 100%; object-fit: cover; }
.card .name {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 26px 10px 9px;
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  opacity: 0;
  transition: opacity 0.18s;
}
.card:hover .name, .card:focus .name { opacity: 1; }
.card.big { grid-column: span 2; grid-row: span 2; }

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
  font-size: 18px;
}

/* ---------- Game page ---------- */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 18px;
}
.player {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 10;
  position: relative;
}
.player iframe { width: 100%; height: 100%; border: 0; display: block; }

.about-game {
  margin-top: 14px;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
  line-height: 1.6;
  color: var(--muted);
}
.about-game h2 { color: var(--text); font-size: 18px; margin: 6px 0; }

.side .grid { grid-template-columns: repeat(2, 1fr); }

/* ---------- Text pages ---------- */
.page {
  max-width: 760px;
  margin: 0 auto;
  line-height: 1.7;
  color: var(--muted);
}
.page h1 { color: var(--text); margin-bottom: 14px; }
.page h2 { color: var(--text); margin: 22px 0 8px; font-size: 20px; }
.page p, .page li { margin-bottom: 10px; }
.page ul { padding-left: 22px; }

/* ---------- Footer ---------- */
.footer {
  margin-top: 40px;
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border-top: 2px solid rgba(255, 255, 255, 0.06);
}
.footer nav { display: flex; justify-content: center; gap: 18px; margin-bottom: 8px; flex-wrap: wrap; }
.footer a:hover { color: var(--yellow); }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .game-layout { grid-template-columns: 1fr; }
  .side .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
@media (max-width: 600px) {
  .header { flex-wrap: wrap; }
  .search { max-width: none; flex-basis: 100%; }
  .logo { font-size: 24px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 10px; }
  .card .name { display: none; }
  .player { aspect-ratio: 3 / 4; }
  .game-bar h1 { font-size: 18px; }
}

/* ---------- Poki-style game bar ---------- */
.game-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--card);
  border-radius: var(--radius);
}
.bar-thumb { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.bar-title { flex: 1; min-width: 0; }
.bar-title h1 { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-tags { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.tag { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--bg-2); color: var(--muted); }
.tag:hover { color: var(--yellow); }
.bar-actions { display: flex; align-items: center; gap: 8px; }
.bar-sep { width: 2px; height: 30px; background: rgba(255,255,255,0.12); margin: 0 2px; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 14px; border: none;
  background: var(--bg-2); color: #fff; font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, background 0.15s;
}
.icon-btn:hover { transform: translateY(-2px); background: var(--card-hover); }
.icon-btn.on { background: var(--yellow); }
#dislike.on { background: var(--pink); }
#bigger.on { background: var(--cyan); }
.icon-btn.pop { animation: pop 0.4s; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.35) rotate(-10deg); } 100% { transform: scale(1); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px);
  background: #fff; color: #1b1240; font-weight: 700; padding: 12px 20px; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35); opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 100;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Bigger (theater) mode: the game takes the full width */
.game-layout.theater { grid-template-columns: 1fr; }
.game-layout.theater .player { aspect-ratio: auto; height: calc(100vh - 180px); min-height: 420px; }
.game-layout.theater .side .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.card .liked-badge {
  position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,0.9);
  border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; font-size: 15px;
}

/* ---------- Category tiles ---------- */
.cat-section { margin-top: 30px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.cat-tile {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end;
  height: 110px; padding: 14px 16px; border-radius: var(--radius); overflow: hidden;
  background: var(--c); box-shadow: 0 6px 0 rgba(0,0,0,0.25);
  transition: transform 0.18s;
}
.cat-tile:hover { transform: translateY(-5px) scale(1.03); }
.cat-icon { position: absolute; right: 10px; top: 6px; font-size: 52px; transform: rotate(12deg); filter: drop-shadow(0 4px 0 rgba(0,0,0,0.2)); }
.cat-name { font-size: 22px; font-weight: 700; text-shadow: 0 2px 0 rgba(0,0,0,0.25); }
.cat-count { font-size: 14px; opacity: 0.9; }

@media (max-width: 600px) {
  .bar-thumb { display: none; }
  .game-bar { flex-wrap: wrap; }
  .bar-actions { width: 100%; justify-content: space-between; }
  .icon-btn { width: 42px; height: 42px; font-size: 20px; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .cat-tile { height: 90px; }
  .cat-icon { font-size: 40px; }
  .game-layout.theater .player { height: calc(100vh - 220px); }
}

.btn {
  display: inline-block; padding: 10px 18px; border: none; border-radius: 999px;
  background: var(--pink); color: #fff; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
}
