:root {
  --primary: #338AF8;
  --primary-dark: #2376E0;
  --bg: #ECF5FF;
  --card: #FCFDFF;
  --text: #001837;
  --text-muted: #4872A6;
  --border: #D3E6FF;
  --accent: #FFAA09;
  --max: 480px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
body { max-width: var(--max); margin: 0 auto; position: relative; }
.hidden { display: none !important; }

.header { position: relative; padding-bottom: 12px; }
.header-bg {
  position: absolute; inset: 0 0 40px;
  background: linear-gradient(180deg, #4094FF 0%, #2376E0 55%, var(--bg) 100%);
}
.header-inner {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 8px; color: #fff;
}
.logo { font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.btn-login-sm {
  background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.45);
  color: #fff; border-radius: 20px; padding: 6px 16px; font-size: 13px;
}
.user-chip { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.user-chip .coin b { color: #FFE566; }

.banner { position: relative; z-index: 2; padding: 0 16px; }
.banner-slide {
  border-radius: 14px; overflow: hidden; min-height: 96px;
  background: linear-gradient(135deg, #5eb3ff, #338AF8 50%, #1a5fd4);
  box-shadow: 0 8px 24px rgba(51,138,248,.35);
  display: flex; align-items: center; padding: 20px;
}
.banner-text h2 { color: #fff; font-size: 18px; margin-bottom: 6px; }
.banner-text p { color: rgba(255,255,255,.85); font-size: 13px; }

.tabs {
  display: flex; gap: 4px; padding: 12px 16px 8px; overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0; border: none; background: transparent; color: var(--text-muted);
  font-size: 15px; padding: 8px 14px; border-radius: 20px; cursor: pointer;
}
.tab.active { background: var(--primary); color: #fff; font-weight: 600; }

.content { padding: 0 12px 88px; }
.search-bar { padding: 4px 4px 12px; }
.search-bar input {
  width: 100%; border: 1px solid var(--border); border-radius: 22px;
  padding: 10px 16px; background: var(--card); font-size: 14px; outline: none;
}
.search-bar input:focus { border-color: var(--primary); }

.game-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 10px;
}

.game-card {
  background: transparent; border-radius: 0; overflow: visible;
  cursor: pointer; transition: transform .15s;
  text-decoration: none; color: inherit; display: block;
}
.game-card:active { transform: scale(.96); }
.game-thumb {
  position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden;
  background: #eef4ff; box-shadow: 0 2px 10px rgba(51,138,248,.12);
}
.game-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.game-thumb .fallback-ico {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 28px; opacity: .9;
}
.game-thumb .star {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px;
  background: rgba(255,255,255,.82); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  color: #8aa8cc; box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.game-name {
  padding: 8px 2px 4px; text-align: center; font-size: 13px; font-weight: 500;
  color: #4872A6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--max);
  display: flex; background: #fff; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); z-index: 50;
}
.tabbar-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 0 6px; text-decoration: none; color: var(--text-muted); font-size: 11px;
}
.tabbar-item.active { color: var(--primary); }
.tabbar-item .ico { font-size: 20px; margin-bottom: 2px; }
.tabbar-mid {
  flex: 1; margin-top: -18px;
  background: linear-gradient(180deg, #4094FF, #2376E0);
  color: #fff !important; border-radius: 50%; width: 56px; height: 56px;
  max-width: 56px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; box-shadow: 0 4px 12px rgba(51,138,248,.45);
}

.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal-box {
  position: relative; background: #fff; border-radius: 16px; padding: 24px 20px;
  width: 88%; max-width: 340px; z-index: 1;
}
.modal-close { position: absolute; right: 12px; top: 8px; border: none; background: none; font-size: 24px; color: #999; }
.modal-box h3 { text-align: center; margin-bottom: 16px; }
.modal-box input {
  width: 100%; padding: 12px; margin-bottom: 10px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 15px;
}
.btn-primary {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: linear-gradient(180deg, #4094FF, #2376E0); color: #fff; font-size: 16px; font-weight: 700;
}
.btn-link { width: 100%; margin-top: 10px; border: none; background: none; color: var(--primary); font-size: 14px; }
.hint { text-align: center; font-size: 12px; color: #999; margin-top: 12px; }

.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 10px 20px; border-radius: 20px;
  font-size: 14px; z-index: 200; white-space: nowrap;
}

@media (min-width: 481px) {
  body { box-shadow: 0 0 40px rgba(0,0,0,.08); }
}
