:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #111827;
  --text-soft: #4b5563;
  --muted: #8a94a6;
  --line: rgba(17, 24, 39, 0.08);
  --brand: #07c160;
  --brand-deep: #06a954;
  --brand-2: #00b8a9;
  --accent: #6366f1;
  --amber: #f59e0b;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 11px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04), 0 6px 20px rgba(17, 24, 39, 0.05);
  --shadow-md: 0 18px 44px rgba(17, 24, 39, 0.12);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

body {
  margin: 0;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(7, 193, 96, 0.09), transparent 60%),
    radial-gradient(1000px 500px at -10% 20%, rgba(99, 102, 241, 0.08), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.page-shell {
  min-height: 100vh;
  overflow: clip;
}

.container {
  width: min(1120px, 100% - 40px);
  margin: 0 auto;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 10px 0;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  width: min(1120px, 100% - 40px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 21px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 20px rgba(7, 193, 96, 0.28);
}

.brand-text {
  font-size: 17px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topnav a {
  padding: 9px 14px;
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  transition: 0.2s ease;
}

.topnav a:hover {
  color: var(--brand-deep);
  background: rgba(7, 193, 96, 0.08);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(56px, 9vw, 112px) 20px clamp(24px, 4vw, 48px);
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(245, 247, 251, 0.2));
}

.hero-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(10px);
  opacity: 0.85;
  animation: float 12s ease-in-out infinite;
}

.hero-glow-a {
  width: 420px;
  height: 420px;
  left: 8%;
  top: -120px;
  background: radial-gradient(circle, rgba(7, 193, 96, 0.32), transparent 68%);
}

.hero-glow-b {
  width: 480px;
  height: 480px;
  right: 4%;
  top: -80px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.28), transparent 68%);
  animation-delay: -6s;
}

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(22px) scale(1.06); }
}

.hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(17, 24, 39, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 24, 39, 0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 60% 60% at 50% 40%, black, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 40%, black, transparent 75%);
}

.hero-content {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
}

.hero-eyebrow,
.section-eyebrow {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--brand-deep);
}

.hero h1 {
  margin: 0;
  font-size: clamp(42px, 8vw, 76px);
  line-height: 1.06;
  letter-spacing: -0.045em;
  font-weight: 900;
}

.hero h1 span {
  background: linear-gradient(110deg, var(--brand), var(--brand-2) 45%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  max-width: 520px;
  margin: 22px auto 0;
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 30px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 14px 30px rgba(7, 193, 96, 0.32);
}

.btn-primary:hover {
  box-shadow: 0 18px 38px rgba(7, 193, 96, 0.4);
}

.btn-ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.btn-ghost:hover {
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.hero-tip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 26px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 0 rgba(7, 193, 96, 0.5);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(7, 193, 96, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(7, 193, 96, 0); }
  100% { box-shadow: 0 0 0 0 rgba(7, 193, 96, 0); }
}

/* ---------- Sections ---------- */
.section {
  padding: 44px 0 56px;
}

.games-section {
  padding-top: 10px;
}

.hall-section {
  padding-top: 22px;
}

.section-head {
  margin-bottom: 24px;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(26px, 4vw, 34px);
  letter-spacing: -0.03em;
  font-weight: 850;
}

.section-desc {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Category hall ---------- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.category-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.category-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: transparent;
}

.category-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 23px;
  border-radius: 14px;
  background: rgba(7, 193, 96, 0.14);
}

.category-meta {
  min-width: 0;
}

.category-name {
  font-size: 15px;
  font-weight: 750;
}

.category-count {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.category-arrow {
  margin-left: auto;
  color: #c3c9d4;
  transition: transform 0.2s ease;
}

.category-card:hover .category-arrow {
  transform: translateX(3px);
  color: var(--brand);
}

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 14px;
  margin-bottom: 8px;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 650;
  transition: 0.18s ease;
}

.filter-chip:hover {
  border-color: var(--brand);
  color: var(--brand-deep);
}

.filter-chip.active {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(7, 193, 96, 0.24);
}

/* ---------- Game grid ---------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 20px;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: cardIn 0.5s both;
}

.game-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.game-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: linear-gradient(135deg, #e7f8ef, #eef1ff);
}

.game-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.game-card:hover .game-cover img {
  transform: scale(1.06);
}

.cover-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  position: relative;
}

.cover-fallback::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 80% 10%, rgba(255, 255, 255, 0.5), transparent 45%),
    radial-gradient(90% 70% at 10% 90%, rgba(255, 255, 255, 0.26), transparent 50%);
}

.cover-char {
  position: relative;
  z-index: 1;
  font-size: 54px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #ff8a00, #f43f5e);
  box-shadow: 0 8px 18px rgba(244, 63, 94, 0.3);
}

.game-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 16px 16px 16px;
}

.game-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 22px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(148, 163, 184, 0.14);
  color: #475569;
}

.tag .icon-img,
.tag .icon-letter {
  width: 14px;
  height: 14px;
  border-radius: 5px;
  font-size: 9px;
}

.game-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.game-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.1);
}

.game-icon .icon-img,
.game-icon .icon-letter {
  width: 100%;
  height: 100%;
  border-radius: 14px;
}

.icon-img {
  display: block;
  object-fit: cover;
}

.icon-letter {
  display: grid;
  place-items: center;
  font-weight: 850;
}

.game-head-text {
  min-width: 0;
  flex: 1;
}

.game-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.game-title-row .game-title {
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
}

.game-title-row .game-tags {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  min-height: 0;
}

.game-title {
  margin: 8px 0 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-desc {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.game-meta {
  margin-top: auto;
  padding-top: 14px;
  color: #b3bac6;
  font-size: 11px;
}

.play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  min-height: 44px;
  border: 0;
  border-radius: 13px;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 12px 24px rgba(7, 193, 96, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.play-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(7, 193, 96, 0.34);
  filter: brightness(1.02);
}

.play-btn:active {
  transform: translateY(0);
}

/* ---------- Empty state ---------- */
.empty-state {
  padding: 72px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-emoji {
  font-size: 48px;
}

.empty-state h3 {
  margin: 16px 0 6px;
  color: var(--text);
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

/* ---------- Footer ---------- */
.footer {
  padding: 36px 0 48px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}

.footer-inner {
  text-align: center;
}

.footer-brand {
  margin: 0;
  font-weight: 800;
}

.footer-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  z-index: 100;
  transform: translate(-50%, 16px);
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Bottom category tags ---------- */
.bottom-cats {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}

.bottom-cats-inner {
  width: min(1120px, 100% - 28px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.bottom-cats-inner::-webkit-scrollbar {
  display: none;
}

.bottom-cat {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
  transition: 0.18s ease;
}

.bottom-cat:hover {
  border-color: var(--brand);
  color: var(--brand-deep);
}

.bottom-cat.active {
  color: #fff;
  background: var(--cat, var(--brand));
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.12);
}

.bottom-cat-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
}

.bottom-cat-icon .icon-img,
.bottom-cat-icon .icon-letter {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  font-size: 11px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .category-layout {
    gap: 8px;
  }

  .cat-sidebar {
    flex-basis: 88px;
  }

    .cat-tag {
    width: 84px;
    height: 46px;
    padding: 0 4px;
    font-size: 12px;
  }

  .cat-content .cat-list {
    grid-template-columns: repeat(auto-fill, minmax(210px, 260px));
  }
}

@media (max-width: 640px) {
  .container,
  .topbar-inner {
    width: min(1120px, 100% - 28px);
  }

  .brand-text {
    font-size: 15px;
  }

  .topnav a {
    padding: 8px 11px;
    font-size: 13px;
  }

  .hero {
    padding-top: 44px;
  }

  .category-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .game-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .game-cover {
    aspect-ratio: 16 / 9;
  }

  .category-layout {
    gap: 6px;
  }

  .cat-sidebar {
    flex-basis: 72px;
    gap: 5px;
  }

    .cat-tag {
    width: 68px;
    height: 44px;
    padding: 0 4px;
    font-size: 12px;
    border-radius: 10px;
  }

  .cat-content .cat-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .cat-sidebar {
    flex-basis: 62px;
    gap: 4px;
  }

    .cat-tag {
    width: 58px;
    height: 42px;
    padding: 0 3px;
    font-size: 11px;
    border-radius: 9px;
  }
}

/* ---------- Brand logo & theme toggle ---------- */
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--surface-soft);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-logo.empty {
  display: none;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: 0.18s ease;
}

.theme-toggle:hover {
  border-color: var(--brand);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* ---------- Search box ---------- */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 520px;
  margin: 26px auto 0;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.search-box svg.search-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.search-box input::placeholder {
  color: var(--muted);
}

.search-box #searchClear {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  padding: 0 2px;
}

.search-box input[type="search"]::-webkit-search-cancel-button,
.search-box input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search-box input::-ms-clear {
  display: none;
  width: 0;
  height: 0;
}

.search-box-link {
  text-decoration: none;
  cursor: pointer;
}

.search-box-placeholder {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 15px;
  text-align: left;
}

/* ---------- Home groups ---------- */
.group-section {
  margin-bottom: 42px;
}

.group-section:last-child {
  margin-bottom: 8px;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 850;
  letter-spacing: -0.02em;
}

.group-title::before {
  content: "";
  width: 5px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.group-grid + .group-list,
.group-list + .group-grid {
  margin-top: 20px;
}

.group-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.small-game {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.small-game:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: transparent;
}

.small-game .game-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
}

.small-game-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.small-game-name {
  display: block;
  max-width: 100%;
  font-size: 15px;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.small-game-desc {
  display: block;
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.small-game-play {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 8px 14px;
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  font-weight: 750;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 16px rgba(7, 193, 96, 0.22);
}

/* ---------- Dark theme ---------- */
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #131c2e;
  --surface-soft: #1b2740;
  --text: #e8edf6;
  --text-soft: #aeb8c9;
  --muted: #7f8ba0;
  --line: rgba(255, 255, 255, 0.1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 18px 44px rgba(0, 0, 0, 0.42);
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(7, 193, 96, 0.12), transparent 60%),
    radial-gradient(1000px 500px at -10% 20%, rgba(99, 102, 241, 0.14), transparent 60%),
    var(--bg);
}

:root[data-theme="dark"] .topbar {
  background: rgba(11, 18, 32, 0.76);
}

:root[data-theme="dark"] .bottom-cats {
  background: rgba(11, 18, 32, 0.82);
}

:root[data-theme="dark"] .hero {
  background: linear-gradient(180deg, rgba(11, 18, 32, 0.35), rgba(11, 18, 32, 0));
}

:root[data-theme="dark"] .hero-grid {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
}

:root[data-theme="dark"] .btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

:root[data-theme="dark"] .footer {
  background: rgba(11, 18, 32, 0.5);
}

:root[data-theme="dark"] .bottom-nav {
  background: rgba(11, 18, 32, 0.84);
}

/* ---------- Category page ---------- */
.category-page {
  padding: 24px 0 64px;
  min-height: 60vh;
}

.category-body {
  padding-bottom: 0;
}

.cat-browse-page {
  height: 100vh;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 24px 0 0;
  overflow: hidden;
}

.cat-browse-page .container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.cat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  flex: 0 0 auto;
}

.cat-head h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 30px);
  letter-spacing: -0.03em;
  font-weight: 850;
}

.cat-search-btn {
  flex: 0 0 auto;
}

.search-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.search-back {
  flex: 0 0 auto;
}

.search-page .search-box {
  flex: 1;
  margin: 0;
  max-width: none;
}

.search-results .search-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.back-link {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.back-link:hover {
  color: var(--brand-deep);
}

.category-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  gap: 12px;
  overflow: hidden;
}

.cat-sidebar {
  flex: 0 0 96px;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 2px calc(76px + env(safe-area-inset-bottom));
  scrollbar-width: thin;
}

.cat-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.cat-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 92px;
  height: 46px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: 0.18s ease;
}

.cat-tag.active {
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.12);
}

.cat-tag-count {
  margin-left: 3px;
  font-size: 0.88em;
  font-weight: 650;
  opacity: 0.82;
}

.cat-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 300px));
  gap: 12px;
}

.load-status {
  padding: 24px 0 4px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.cat-list-footer {
  padding-top: 6px;
  text-align: center;
}

.list-footer-bottomline {
  padding-top: 26px;
  text-align: center;
}

/* ---------- Top action ---------- */
.top-action {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: 0.18s ease;
}

.top-action:hover {
  border-color: var(--brand);
}

.top-action svg {
  width: 20px;
  height: 20px;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}

.bottom-nav-item {
  flex: 1;
  max-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 10px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  transition: 0.18s ease;
}

.bottom-nav-item:hover {
  color: var(--brand-deep);
}

.bottom-nav-item.active {
  color: var(--brand-deep);
  background: rgba(7, 193, 96, 0.1);
}

.bottom-nav-icon {
  font-size: 21px;
  line-height: 1;
}

/* ---------- Footer bottom line ---------- */
.footer-bottomline {
  margin: 0;
  color: #b3bac6;
  font-size: 13px;
}

/* ---------- Settings page ---------- */
.settings-page {
  padding: 24px 0 40px;
  min-height: 60vh;
}

.settings-title {
  margin: 18px 0 22px;
  font-size: 28px;
  letter-spacing: -0.03em;
  font-weight: 850;
}

.public-settings-card {
  max-width: 520px;
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
}

.setting-row strong {
  font-size: 15px;
}

.setting-row p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex: 0 0 auto;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
  transition: 0.2s ease;
}

.slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(17, 24, 39, 0.2);
  transition: 0.2s ease;
}

.switch input:checked + .slider {
  background: var(--brand);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* ---------- Planet page ---------- */
.planet-page {
  padding: 60px 0 80px;
  min-height: 60vh;
}

.planet-placeholder {
  padding: 70px 20px;
  text-align: center;
}

.planet-emoji {
  font-size: 60px;
}

.planet-placeholder h1 {
  margin: 18px 0 8px;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.planet-placeholder p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- SPA shell ---------- */
.app-body {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  padding-bottom: 0;
}

.app-body .page-shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-body .topbar {
  position: static;
  flex: 0 0 auto;
}

.app-body .app-views {
  flex: 1;
  min-height: 0;
  position: relative;
}

.app-body .view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.app-body .view.is-active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.app-body .bottom-nav {
  position: static;
  flex: 0 0 auto;
}

.app-body .toast {
  bottom: calc(76px + env(safe-area-inset-bottom) + 14px);
}

.app-body .view-category {
  overflow: hidden;
}

.app-body .view-category .cat-browse-page {
  height: 100%;
  padding: 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-body .view-category .cat-browse-page .container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app-body .view-category .cat-sidebar,
.app-body .view-category .cat-content {
  padding-bottom: 24px;
}

.app-body .view-search .search-page {
  padding-bottom: 24px;
}

.app-body .view-planet .planet-page {
  min-height: 100%;
  display: flex;
  align-items: center;
}

/* ---------- Clickable card media ---------- */
.game-cover[data-url],
.game-icon[data-url] {
  cursor: pointer;
}

/* ---------- Topbar only on home ---------- */
.app-body:not(.is-home) .topbar {
  display: none;
}
