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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
  background: #08080f;
  background-image:
    radial-gradient(ellipse 80% 55% at 12% 12%, rgba(233,69,96,0.22) 0%, transparent 58%),
    radial-gradient(ellipse 65% 50% at 88% 85%, rgba(94,114,235,0.20) 0%, transparent 55%),
    radial-gradient(ellipse 55% 45% at 72% 18%, rgba(126,200,80,0.10) 0%, transparent 50%),
    radial-gradient(ellipse 40% 35% at 30% 75%, rgba(80,180,220,0.10) 0%, transparent 45%);
  background-attachment: fixed;
  color: #f0f0f5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Header ────────────────────────────────── */
header {
  background: rgba(8,8,18,0.55);
  backdrop-filter: blur(40px) saturate(200%);
  -webkit-backdrop-filter: blur(40px) saturate(200%);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.6px;
}

header h1 span {
  background: linear-gradient(135deg, #e94560 0%, #ff8fa3 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Search ────────────────────────────────── */
#search-bar {
  padding: 9px 18px;
  border-radius: 50px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #fff;
  font-family: inherit;
  font-size: .92rem;
  width: 220px;
  outline: none;
  transition: all .2s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
#search-bar::placeholder { color: rgba(255,255,255,0.35); }
#search-bar:focus {
  border-color: rgba(233,69,96,0.55);
  background: rgba(255,255,255,0.11);
  box-shadow: 0 0 0 3px rgba(233,69,96,0.15), inset 0 1px 0 rgba(255,255,255,0.1);
}

/* ── Category pills ────────────────────────── */
.categories {
  display: flex;
  gap: 8px;
  padding: 20px 28px 8px;
  flex-wrap: wrap;
}

.cat-btn {
  padding: 7px 18px;
  border-radius: 50px;
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: rgba(255,255,255,0.65);
  transition: all .18s ease;
  letter-spacing: 0.1px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07);
}
.cat-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.18);
}
.cat-btn.active {
  background: rgba(233,69,96,0.22);
  border-color: rgba(233,69,96,0.45);
  color: #fff;
  box-shadow: 0 0 18px rgba(233,69,96,0.18), inset 0 1px 0 rgba(255,255,255,0.1);
}

/* ── Section label ─────────────────────────── */
.section-title {
  font-size: .72rem;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  padding: 18px 28px 8px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

/* ── Game grid ─────────────────────────────── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 16px;
  padding: 6px 28px 32px;
}

.game-card {
  background: rgba(255,255,255,0.055);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .22s ease, border-color .22s, background .22s;
  text-decoration: none;
  color: inherit;
  display: block;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.09);
}
.game-card:hover {
  transform: translateY(-8px) scale(1.025);
  box-shadow: 0 22px 50px rgba(0,0,0,0.45), 0 0 0 1px rgba(233,69,96,0.28), inset 0 1px 0 rgba(255,255,255,0.14);
  border-color: rgba(233,69,96,0.38);
  background: rgba(255,255,255,0.09);
}

.game-card .thumb {
  width: 100%;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  background: linear-gradient(135deg, var(--c1, #0f3460), var(--c2, #e94560));
  position: relative;
  user-select: none;
}
.game-card .thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 55%);
  pointer-events: none;
}

.game-card .info {
  padding: 10px 14px 13px;
}

.game-card .name {
  font-weight: 700;
  font-size: .94rem;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255,255,255,0.92);
  letter-spacing: -0.1px;
}

.game-card .tag {
  font-size: .7rem;
  color: rgba(233,69,96,0.85);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .9px;
}

/* ── Game page ─────────────────────────────── */
.game-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  min-height: 100vh;
}

.back-btn {
  align-self: flex-start;
  margin-bottom: 16px;
  padding: 8px 20px;
  background: rgba(255,255,255,0.09);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50px;
  cursor: pointer;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: all .18s ease;
  box-shadow: 0 2px 14px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.12);
  letter-spacing: 0.1px;
}
.back-btn:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.25);
  color: #fff;
}

.game-frame {
  width: 100%;
  max-width: 900px;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.09);
}

.game-frame canvas, .game-frame #game-container {
  display: block;
  margin: 0 auto;
}

.game-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 14px;
  text-align: center;
  letter-spacing: -0.5px;
}

.game-instructions {
  max-width: 900px;
  width: 100%;
  background: rgba(255,255,255,0.055);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 16px;
  padding: 14px 20px;
  margin-top: 14px;
  font-size: .88rem;
  color: rgba(255,255,255,0.55);
  line-height: 1.65;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
  letter-spacing: 0.1px;
}

/* ── Footer ────────────────────────────────── */
footer {
  text-align: center;
  padding: 28px;
  color: rgba(255,255,255,0.2);
  font-size: .8rem;
  letter-spacing: 0.3px;
}

/* ── Mobile ────────────────────────────────── */
@media (max-width: 600px) {
  header { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  header h1 { font-size: 1.45rem; }
  #search-bar { width: 100%; }
  .categories { padding: 14px 16px 6px; gap: 7px; }
  .section-title { padding: 14px 16px 6px; }
  .games-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding: 6px 16px 24px; }
  .game-page { padding: 14px; }
}
