:root {
  --bg: #070914;
  --bg-2: #0e1326;
  --panel: #141a32;
  --line: #2a3358;
  --text: #eef3ff;
  --muted: #93a0c4;
  --cyan: #3cefff;
  --pink: #ff4d9d;
  --gold: #ffd166;
  --green: #4ade80;
  --violet: #8b7cff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font: "Noto Sans SC", "PingFang SC", sans-serif;
  --display: "ZCOOL QingKe HuangYou", "Noto Sans SC", sans-serif;
}

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

html, body {
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(60, 239, 255, 0.12), transparent 50%),
    radial-gradient(900px 500px at 110% 0%, rgba(255, 77, 157, 0.14), transparent 46%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body { overflow-x: hidden; }

button, input { font-family: inherit; }

.app { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  background: rgba(7, 9, 20, 0.78);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  cursor: pointer;
}

.logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--cyan), var(--violet) 55%, var(--pink));
  font-size: 22px;
  box-shadow: 0 0 20px rgba(60, 239, 255, 0.35);
}

.brand h1 {
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 1px;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.search {
  flex: 1;
  position: relative;
}

.search input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  background: #0c1224;
  color: var(--text);
  border-radius: 999px;
  padding: 0 18px 0 42px;
  outline: none;
}

.search input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(60, 239, 255, 0.12); }

.search::before {
  content: "⌕";
  position: absolute;
  left: 16px;
  top: 8px;
  color: var(--muted);
  font-size: 20px;
}

.stats {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.site-home {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  text-decoration: none;
}

.site-home:hover { color: var(--cyan); }

.hero {
  padding: 28px 22px 8px;
  max-width: 1280px;
  margin: 0 auto;
}

.hero h2 {
  font-family: var(--display);
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1.15;
}

.hero p { color: var(--muted); margin-top: 10px; max-width: 640px; }

.cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px 22px 8px;
  max-width: 1280px;
  margin: 0 auto;
}

.chip {
  border: 1px solid var(--line);
  background: #10162c;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

.chip.active, .chip:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(60, 239, 255, 0.1);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  padding: 16px 22px 48px;
  max-width: 1280px;
  margin: 0 auto;
}

.card {
  background: linear-gradient(180deg, #171e38, #12182d);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  min-height: 168px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.card:hover {
  transform: translateY(-4px);
  border-color: #4a5aa0;
  box-shadow: var(--shadow);
}

.card .icon { font-size: 32px; }
.card h3 { font-size: 18px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge-new {
  font-size: 11px;
  font-weight: 700;
  color: #071018;
  background: linear-gradient(135deg, #ffd166, #ff4d9d);
  border-radius: 999px;
  padding: 2px 8px;
  letter-spacing: 0.5px;
}
.card p { color: var(--muted); font-size: 13px; line-height: 1.45; flex: 1; }
.card .meta { display: flex; justify-content: space-between; color: var(--gold); font-size: 12px; }

.play-view { display: none; min-height: 100vh; }
.play-view.show { display: block; }
.home.hide { display: none; }

.play-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.btn {
  border: 0;
  background: linear-gradient(135deg, var(--cyan), #6d7bff);
  color: #071018;
  font-weight: 700;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
}

.btn.ghost {
  background: #171e38;
  color: var(--text);
  border: 1px solid var(--line);
}

.play-title { font-family: var(--display); font-size: 22px; }
.play-desc { color: var(--muted); font-size: 13px; }

.play-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px;
}

.play-chrome { display: grid; gap: 12px; }

.play-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
}

.play-hud b { color: var(--gold); }

.play-stage {
  position: relative;
  background: #0a1022;
  border: 1px solid var(--line);
  border-radius: 20px;
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 12px;
  box-shadow: var(--shadow);
}

.play-stage canvas { display: block; background: #070b16; border-radius: 8px; }

.game-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 18, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
}

.overlay-box {
  width: min(420px, 100%);
  background: #151c36;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  text-align: center;
}

.overlay-box h3 { font-family: var(--display); font-size: 28px; margin-bottom: 8px; }
.overlay-box p { color: var(--muted); line-height: 1.6; }
.overlay-actions { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }

.board-ui {
  width: min(100%, 640px);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.board-ui > div:not(.grid-board) {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.grid-board {
  display: grid;
  gap: 6px;
}

.cell {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: #1a2344;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.cell:hover { filter: brightness(1.12); }
.cell:disabled { opacity: 0.7; cursor: default; }

.cell.on { background: var(--cyan); color: #071018; }
.cell.good { background: #14532d; }
.cell.bad { background: #7f1d1d; }

.help { color: var(--muted); font-size: 13px; line-height: 1.5; text-align: center; }

.play-stage canvas { touch-action: none; }

.cell.good { background: #166534; color: #dcfce7; }
.cell.bad { background: #7f1d1d; color: #fecaca; }
.cell.on { background: #0e7490; color: #ecfeff; }

@media (max-width: 720px) {
  .cell { min-height: 34px; font-size: 16px; }
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .brand, .search { min-width: 100%; }
  .stats { display: none; }
  .grid { grid-template-columns: repeat(2, 1fr); padding: 12px; }
}
