:root {
  --bg: #0b1020;
  --bg-2: #111a30;
  --card: rgba(255,255,255,.045);
  --card-hover: rgba(255,255,255,.08);
  --border: rgba(255,255,255,.10);
  --text: #eef3ff;
  --muted: #9aa7c2;
  --accent: #6ea8ff;
  --accent-2: #a67bff;
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 600px at 15% -10%, #1b2a52 0%, transparent 55%),
              radial-gradient(1000px 500px at 100% 0%, #2a1b4d 0%, transparent 50%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(600px 300px at 50% 100%, rgba(110,168,255,.08), transparent 70%);
}
.wrap { width: min(1120px, calc(100% - 40px)); margin: 0 auto; position: relative; z-index: 1; }

.topbar { border-bottom: 1px solid var(--border); background: rgba(10,14,28,.55); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 50; }
.topbar-inner { height: 64px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 18px; letter-spacing: .5px; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 13px; box-shadow: 0 6px 18px rgba(110,168,255,.35); }
.topbar-actions { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #47e0a0; box-shadow: 0 0 0 4px rgba(71,224,160,.15); }

.hero { padding: 60px 0 30px; text-align: center; }
.hero-badge { display: inline-block; padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 12px; letter-spacing: 1px; background: var(--card); }
.hero h1 { margin: 18px 0 10px; font-size: clamp(30px, 6vw, 52px); line-height: 1.15; letter-spacing: -1px; }
.hero h1 span { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { max-width: 640px; margin: 0 auto; color: var(--muted); font-size: 15px; line-height: 1.8; }
.hero-stats { display: flex; justify-content: center; gap: 46px; margin-top: 28px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 26px; background: linear-gradient(90deg, #fff, #bcd4ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat span { color: var(--muted); font-size: 12px; }

.controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin: 18px 0 24px; }
.searchbox { position: relative; flex: 1 1 260px; max-width: 340px; }
.searchbox svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; }
.searchbox input { width: 100%; height: 42px; padding: 0 14px 0 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); outline: none; font-size: 14px; }
.searchbox input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(110,168,255,.15); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter { padding: 8px 15px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--muted); font-size: 13px; cursor: pointer; transition: .18s; }
.filter:hover { color: var(--text); background: var(--card-hover); }
.filter.active { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 18px rgba(110,168,255,.25); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; padding-bottom: 50px; }
.card {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); overflow: hidden; cursor: pointer; transition: transform .2s, border-color .2s, background .2s;
  min-height: 220px; display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-6px); border-color: rgba(110,168,255,.5); background: var(--card-hover); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-art { height: 118px; display: grid; place-items: center; font-size: 54px; position: relative; }
.card-art::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120px 60px at 50% 100%, rgba(255,255,255,.12), transparent 70%); }
.card-body { padding: 16px 18px 18px; flex: 1; display: flex; flex-direction: column; }
.card-title { font-size: 17px; font-weight: 700; margin: 0 0 6px; }
.card-desc { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0 0 14px; flex: 1; }
.card-foot { display: flex; align-items: center; justify-content: space-between; }
.tag { font-size: 11px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--muted); }
.play-btn { font-size: 13px; font-weight: 700; color: var(--accent); display: inline-flex; align-items: center; gap: 4px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

.footer { border-top: 1px solid var(--border); padding: 22px 0 34px; display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; flex-wrap: wrap; gap: 8px; }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4,8,18,.78); backdrop-filter: blur(8px); }
.modal-panel { position: relative; width: min(1000px, 100%); height: min(760px, 92vh); border-radius: 20px; border: 1px solid var(--border); background: var(--bg-2); box-shadow: 0 30px 90px rgba(0,0,0,.55); display: flex; flex-direction: column; overflow: hidden; animation: pop .22s ease-out; }
@keyframes pop { from { transform: scale(.96) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.03); }
.modal-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.modal-icon { font-size: 30px; }
.modal-title h2 { margin: 0; font-size: 17px; }
.modal-title p { margin: 2px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.modal-tools { display: flex; gap: 8px; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 18px; cursor: pointer; transition: .18s; }
.icon-btn:hover { background: var(--card-hover); border-color: var(--accent); }
.icon-btn.close:hover { border-color: #ff6b6b; color: #ff6b6b; }
.modal-body { flex: 1; min-height: 0; background: #0a0f1e; }
#gameFrame { width: 100%; height: 100%; border: 0; display: block; background: #0a0f1e; }

@media (max-width: 640px) {
  .hero { padding: 40px 0 20px; }
  .hero-stats { gap: 24px; }
  .controls { flex-direction: column; align-items: stretch; }
  .searchbox { max-width: none; }
  .modal { padding: 8px; }
  .modal-panel { height: 94vh; border-radius: 14px; }
  .modal-title p { display: none; }
}
