/* ===== CSS Variables ===== */
:root {
  --primary: #5e17eb;
  --primary-dark: #4a12c0;
  --primary-light: #7c3aed;
  --accent: #ff5a5f;
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface2: #f8f9fb;
  --text: #1a1a2e;
  --text-sec: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 2px 12px rgba(94,23,235,0.1);
  --shadow-lg: 0 8px 32px rgba(94,23,235,0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --nav-height: 64px;
  --header-height: 56px;
  --transition: 0.2s ease;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: var(--nav-height);
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
img { max-width: 100%; }
input { font-family: inherit; }

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(94,23,235,0.3);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--header-height);
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.logo-icon { font-size: 26px; line-height: 1; }
.logo-text {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.15);
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { background: rgba(255,255,255,0.3); }

/* Sub-header (category/game pages) */
.sub-header .header-inner { gap: 12px; }
.back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.back-btn:active { background: rgba(255,255,255,0.3); }
.page-title {
  flex: 1;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

/* ===== Search ===== */
.search-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200;
  background: rgba(10,0,40,0.65);
  backdrop-filter: blur(4px);
  padding: 16px;
  flex-direction: column;
  gap: 12px;
}
.search-overlay.active { display: flex; }
.search-box {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: var(--radius);
  padding: 10px 14px;
  gap: 10px;
}
.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  color: var(--text);
  background: transparent;
}
.search-close-btn {
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px 8px;
}
.search-results {
  overflow-y: auto;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: transform var(--transition);
}
.search-result-item:active { transform: scale(0.98); }
.search-result-icon { font-size: 28px; }
.search-result-info { flex: 1; }
.search-result-name { font-weight: 600; font-size: 15px; color: var(--text); }
.search-result-cat { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== Hero ===== */
.hero {
  position: relative;
  background: linear-gradient(135deg, var(--primary) 0%, #9333ea 50%, #7c3aed 100%);
  overflow: hidden;
  padding: 36px 20px 40px;
  text-align: center;
}
.hero-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 70% 30%, rgba(255,255,255,0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(255,90,95,0.2) 0%, transparent 50%);
  pointer-events: none;
}
.hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -40px;
  width: 220px; height: 220px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -80px; left: -60px;
  width: 280px; height: 280px;
  background: rgba(255,90,95,0.1);
  border-radius: 50%;
}
.hero-content { position: relative; z-index: 1; }
.hero-emoji { font-size: 52px; margin-bottom: 8px; display: block; }
.hero h1 {
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.hero p {
  font-size: 15px;
  color: rgba(255,255,255,0.85);
  margin-bottom: 24px;
}
.hero-stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 14px 24px;
  display: inline-flex;
}
.stat { text-align: center; }
.stat-num { display: block; font-size: 20px; font-weight: 900; color: #fff; }
.stat-label { display: block; font-size: 11px; color: rgba(255,255,255,0.75); margin-top: 2px; }
.stat-divider { width: 1px; height: 36px; background: rgba(255,255,255,0.25); }

/* ===== Main ===== */
.main { padding: 0 0 24px; }

/* ===== Section ===== */
.section { padding: 20px 16px 0; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}
.section-count {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--border);
  padding: 3px 10px;
  border-radius: 20px;
}

/* ===== Hot Grid (horizontal scroll) ===== */
.hot-grid {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.hot-grid::-webkit-scrollbar { display: none; }
.hot-card {
  flex-shrink: 0;
  width: 140px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.hot-card:active { transform: scale(0.96); box-shadow: none; }
.hot-card-thumb {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}
.hot-card-info { padding: 8px 10px 10px; }
.hot-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.hot-card-cat {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Hot Games Grid ===== */
.hot-games-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.hot-game-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  animation: fadeUp 0.3s ease backwards;
}
.hot-game-card:active { transform: scale(0.96); box-shadow: none; }
.hot-game-thumb {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  position: relative;
}
.hot-game-rank {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hot-game-rank.top3 {
  background: linear-gradient(135deg, #ff5a5f, #e0414e);
}
.hot-game-info { padding: 8px 8px 10px; }
.hot-game-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.hot-game-cat {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ===== Categories Grid ===== */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.cat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}
.cat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--cat-color, var(--primary));
}
.cat-card:active { transform: scale(0.96); box-shadow: none; }
.cat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: var(--cat-bg, #f0ebff);
  flex-shrink: 0;
}
.cat-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
}
.cat-count {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== Expand Button ===== */
.expand-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  margin-top: 12px;
  padding: 10px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-sec);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.expand-btn:active { background: var(--surface2); }
.expand-btn.expanded svg { transform: rotate(180deg); }
.expand-btn svg { transition: transform 0.25s ease; }

/* ===== Category Page ===== */
.cat-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  padding: 20px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.cat-banner-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  flex-shrink: 0;
}
.cat-banner-info h2 {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
}
.cat-banner-info p {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  margin-top: 4px;
}

/* ===== Games Grid ===== */
.games-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.game-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.game-card:active { transform: scale(0.97); box-shadow: none; }
.game-card-thumb {
  aspect-ratio: 16/10;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  background: var(--cat-bg, linear-gradient(135deg, #f0ebff 0%, #e8d5ff 100%));
}
.game-card-body { padding: 10px 12px 12px; }
.game-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.game-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}
.game-play-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

/* ===== Play Page (play.html) — fullscreen ===== */
body.play-page {
  padding-bottom: 0;
  overflow: hidden;
  background: #000;
  height: 100vh;
  height: 100dvh;
}

.play-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  height: 50px;
  background: rgba(10, 3, 24, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.09);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
}

.play-back-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.13);
  color: rgba(255,255,255,0.92);
  border: none;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}
.play-back-btn:active { background: rgba(255,255,255,0.28); }

.play-title {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: center;
}

.play-fs-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.13);
  color: rgba(255,255,255,0.92);
  border: none;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}
.play-fs-btn:active { background: rgba(255,255,255,0.28); }

.play-frame-wrap {
  position: fixed;
  top: 50px;
  left: 0; right: 0; bottom: 0;
  background: #000;
  overflow: hidden;
}

.play-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.game-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #0a0015;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  z-index: 5;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(94,23,235,0.3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Safe-area support for play page on notch phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body.play-page { padding-bottom: 0 !important; }
  .play-frame-wrap { bottom: env(safe-area-inset-bottom); }
}

.game-info-section { padding: 16px; }
.game-info-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.game-info-header {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}
.game-thumb-large {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  background: var(--cat-bg, #f0ebff);
  flex-shrink: 0;
}
.game-meta { flex: 1; }
.game-meta h2 { font-size: 17px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.game-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.game-tag {
  background: #f0ebff;
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}
.game-rating { display: flex; align-items: center; gap: 6px; }
.stars { color: #fbbf24; font-size: 14px; letter-spacing: 1px; }
.rating-num { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.game-desc {
  font-size: 14px;
  color: var(--text-sec);
  line-height: 1.6;
  margin-bottom: 16px;
}

.controls-guide {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.controls-guide h3 { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.controls-list { display: flex; flex-direction: column; gap: 6px; }
.control-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-sec); }
.control-key {
  background: var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  min-width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.related-section { margin-top: 20px; }
.related-section .section-title { font-size: 16px; margin-bottom: 12px; }
.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.related-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: var(--shadow);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--transition);
}
.related-card:active { transform: scale(0.96); }
.related-icon { font-size: 28px; }
.related-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
}

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.nav-item.active { color: var(--primary); }
.nav-item:active { opacity: 0.7; }
.nav-item svg { flex-shrink: 0; }

/* ===== Category Colors ===== */
.cat-action    { --cat-color: #ef4444; --cat-bg: #fef2f2; }
.cat-adventure { --cat-color: #f97316; --cat-bg: #fff7ed; }
.cat-airplane  { --cat-color: #3b82f6; --cat-bg: #eff6ff; }
.cat-animal    { --cat-color: #22c55e; --cat-bg: #f0fdf4; }
.cat-arcade    { --cat-color: #a855f7; --cat-bg: #faf5ff; }
.cat-ball      { --cat-color: #ec4899; --cat-bg: #fdf2f8; }
.cat-battle    { --cat-color: #dc2626; --cat-bg: #fef2f2; }
.cat-board     { --cat-color: #92400e; --cat-bg: #fffbeb; }
.cat-boat      { --cat-color: #0ea5e9; --cat-bg: #f0f9ff; }
.cat-brain     { --cat-color: #8b5cf6; --cat-bg: #f5f3ff; }
.cat-bubble    { --cat-color: #06b6d4; --cat-bg: #ecfeff; }
.cat-bus       { --cat-color: #f59e0b; --cat-bg: #fffbeb; }
.cat-car       { --cat-color: #ef4444; --cat-bg: #fef2f2; }
.cat-cards     { --cat-color: #10b981; --cat-bg: #ecfdf5; }
.cat-christmas { --cat-color: #16a34a; --cat-bg: #f0fdf4; }
.cat-classic   { --cat-color: #6366f1; --cat-bg: #eef2ff; }
.cat-clicker   { --cat-color: #f97316; --cat-bg: #fff7ed; }
.cat-cooking   { --cat-color: #f43f5e; --cat-bg: #fff1f2; }
.cat-cool      { --cat-color: #6d28d9; --cat-bg: #f5f3ff; }
.cat-cozy      { --cat-color: #84cc16; --cat-bg: #f7fee7; }
.cat-craft     { --cat-color: #f59e0b; --cat-bg: #fffbeb; }
.cat-dino      { --cat-color: #65a30d; --cat-bg: #f7fee7; }
.cat-motocross { --cat-color: #dc2626; --cat-bg: #fef2f2; }
.cat-drawing   { --cat-color: #d946ef; --cat-bg: #fdf4ff; }
.cat-drift     { --cat-color: #f97316; --cat-bg: #fff7ed; }
.cat-driving   { --cat-color: #3b82f6; --cat-bg: #eff6ff; }
.cat-easter    { --cat-color: #a855f7; --cat-bg: #faf5ff; }
.cat-escape    { --cat-color: #4b5563; --cat-bg: #f9fafb; }
.cat-fighting  { --cat-color: #ef4444; --cat-bg: #fef2f2; }
.cat-fish      { --cat-color: #0ea5e9; --cat-bg: #f0f9ff; }
.cat-flappy    { --cat-color: #eab308; --cat-bg: #fefce8; }
.cat-football  { --cat-color: #16a34a; --cat-bg: #f0fdf4; }
.cat-funny     { --cat-color: #f59e0b; --cat-bg: #fffbeb; }
.cat-gta       { --cat-color: #1e293b; --cat-bg: #f8fafc; }
.cat-girls     { --cat-color: #ec4899; --cat-bg: #fdf2f8; }
.cat-geography { --cat-color: #0ea5e9; --cat-bg: #f0f9ff; }
.cat-halloween { --cat-color: #f97316; --cat-bg: #fff7ed; }
.cat-hidden    { --cat-color: #6366f1; --cat-bg: #eef2ff; }
.cat-hockey    { --cat-color: #3b82f6; --cat-bg: #eff6ff; }
.cat-casual    { --cat-color: #22c55e; --cat-bg: #f0fdf4; }
.cat-logic     { --cat-color: #8b5cf6; --cat-bg: #f5f3ff; }
.cat-mahjong   { --cat-color: #dc2626; --cat-bg: #fef2f2; }
.cat-makeup    { --cat-color: #f472b6; --cat-bg: #fdf2f8; }
.cat-management{ --cat-color: #16a34a; --cat-bg: #f0fdf4; }
.cat-match3    { --cat-color: #a855f7; --cat-bg: #faf5ff; }
.cat-llk       { --cat-color: #06b6d4; --cat-bg: #ecfeff; }
.cat-merge     { --cat-color: #f59e0b; --cat-bg: #fffbeb; }
.cat-minecraft { --cat-color: #65a30d; --cat-bg: #f7fee7; }
.cat-minigolf  { --cat-color: #22c55e; --cat-bg: #f0fdf4; }
.cat-mobile    { --cat-color: #6366f1; --cat-bg: #eef2ff; }
.cat-monster   { --cat-color: #7c3aed; --cat-bg: #f5f3ff; }
.cat-monstertr { --cat-color: #dc2626; --cat-bg: #fef2f2; }
.cat-ninja     { --cat-color: #1e293b; --cat-bg: #f8fafc; }
.cat-numbers   { --cat-color: #f59e0b; --cat-bg: #fffbeb; }
.cat-olympic   { --cat-color: #0ea5e9; --cat-bg: #f0f9ff; }
.cat-parking   { --cat-color: #64748b; --cat-bg: #f8fafc; }
.cat-physics   { --cat-color: #3b82f6; --cat-bg: #eff6ff; }
.cat-princess  { --cat-color: #ec4899; --cat-bg: #fdf2f8; }
.cat-puzzle    { --cat-color: #6366f1; --cat-bg: #eef2ff; }
.cat-quiz      { --cat-color: #10b981; --cat-bg: #ecfdf5; }
.cat-racing    { --cat-color: #ef4444; --cat-bg: #fef2f2; }
.cat-running   { --cat-color: #f97316; --cat-bg: #fff7ed; }
.cat-shooting  { --cat-color: #64748b; --cat-bg: #f8fafc; }
.cat-simulation{ --cat-color: #0ea5e9; --cat-bg: #f0f9ff; }
.cat-skateboard{ --cat-color: #f97316; --cat-bg: #fff7ed; }
.cat-skill     { --cat-color: #a855f7; --cat-bg: #faf5ff; }
.cat-slime     { --cat-color: #22c55e; --cat-bg: #f0fdf4; }
.cat-sniper    { --cat-color: #1e293b; --cat-bg: #f8fafc; }
.cat-soccer    { --cat-color: #16a34a; --cat-bg: #f0fdf4; }
.cat-sports    { --cat-color: #3b82f6; --cat-bg: #eff6ff; }
.cat-stickman  { --cat-color: #64748b; --cat-bg: #f8fafc; }
.cat-strategy  { --cat-color: #7c3aed; --cat-bg: #f5f3ff; }
.cat-sudoku    { --cat-color: #6366f1; --cat-bg: #eef2ff; }
.cat-survival  { --cat-color: #65a30d; --cat-bg: #f7fee7; }
.cat-tank      { --cat-color: #4b5563; --cat-bg: #f9fafb; }
.cat-tennis    { --cat-color: #22c55e; --cat-bg: #f0fdf4; }
.cat-towerdef  { --cat-color: #7c3aed; --cat-bg: #f5f3ff; }
.cat-train     { --cat-color: #dc2626; --cat-bg: #fef2f2; }
.cat-truck     { --cat-color: #f97316; --cat-bg: #fff7ed; }
.cat-tycoon    { --cat-color: #f59e0b; --cat-bg: #fffbeb; }
.cat-typing    { --cat-color: #6366f1; --cat-bg: #eef2ff; }
.cat-war       { --cat-color: #dc2626; --cat-bg: #fef2f2; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,20,60,0.9);
  color: #fff;
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Responsive ===== */
@media (min-width: 480px) {
  .categories-grid { grid-template-columns: repeat(4, 1fr); }
  .hot-games-grid { grid-template-columns: repeat(4, 1fr); }
  .games-grid { grid-template-columns: repeat(3, 1fr); }
  .related-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 768px) {
  .hero h1 { font-size: 40px; }
  .categories-grid { grid-template-columns: repeat(5, 1fr); }
  .hot-games-grid { grid-template-columns: repeat(4, 1fr); }
  .games-grid { grid-template-columns: repeat(4, 1fr); }
  .game-frame-wrap { aspect-ratio: 16/9; }
  .hot-card { width: 160px; }
}
@media (min-width: 1024px) {
  body { max-width: 800px; margin: 0 auto; }
  .header { position: sticky; top: 0; }
  .bottom-nav { left: 50%; transform: translateX(-50%); max-width: 800px; }
  .categories-grid { grid-template-columns: repeat(6, 1fr); }
  .hot-games-grid { grid-template-columns: repeat(4, 1fr); }
  /* play page: fixed elements must be constrained independently */
  .play-header,
  .play-frame-wrap {
    left: 50%;
    transform: translateX(-50%);
    max-width: 800px;
    width: 100%;
  }
}

/* ===== Safe Area Support ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body { padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); }
  .bottom-nav { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-height) + env(safe-area-inset-bottom)); }
}

/* ===== Animations ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.cat-card, .game-card {
  animation: fadeUp 0.3s ease backwards;
}

/* ===== Game Detail Page (game.html) ===== */

/* Hero banner */
.game-hero {
  position: relative;
  background: linear-gradient(135deg, var(--primary) 0%, #9333ea 100%);
  overflow: hidden;
  padding: 32px 20px 28px;
  text-align: center;
}
.game-hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 75% 25%, rgba(255,255,255,0.14) 0%, transparent 55%),
    radial-gradient(ellipse at 20% 80%, rgba(255,90,95,0.18) 0%, transparent 50%);
  pointer-events: none;
}
.game-hero::before {
  content: '';
  position: absolute;
  top: -50px; right: -40px;
  width: 180px; height: 180px;
  background: rgba(255,255,255,0.07);
  border-radius: 50%;
}
.game-hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.game-hero-icon {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.2);
}
.game-hero h2 {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.25);
  margin: 0;
}
.game-hero-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.game-hero-cat {
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}
.game-hero-divider { color: rgba(255,255,255,0.45); font-size: 14px; }
.stars-small { color: #fbbf24; font-size: 14px; letter-spacing: 2px; }

/* Play entry — large centered CTA */
.play-entry {
  padding: 20px 20px 4px;
  display: flex;
  justify-content: center;
}
.play-now-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 400px;
  padding: 17px 24px;
  background: linear-gradient(135deg, #ff5a5f 0%, #e0414e 100%);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1px;
  border-radius: 18px;
  text-decoration: none;
  box-shadow: 0 6px 24px rgba(255,90,95,0.45), 0 2px 6px rgba(0,0,0,0.12);
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.play-now-btn svg { flex-shrink: 0; }
.play-now-btn:active {
  transform: scale(0.96);
  box-shadow: 0 3px 12px rgba(255,90,95,0.35);
}
