/* ============================================================
 * 尘蹊小游戏 · 大厅样式
 * 结构学 4399（大厅 → 分类 → 小游戏 → 回到大厅），视觉做现代化。
 * ============================================================ */
:root {
  --bg: #070b1e;
  --bg2: #0b1130;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-2: rgba(255, 255, 255, 0.075);
  --line: rgba(255, 255, 255, 0.10);
  --ink: #eef2ff;
  --dim: #93a3c9;
  --gold: #ffd166;

  --math: #5ac8fa;
  --chinese: #ff8fb1;
  --science: #b388ff;
  --logic: #ffa14a;

  --radius: 20px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  --font-num: "Segoe UI", "SF Pro Display", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(90,200,250,.18), transparent 62%),
    radial-gradient(760px 520px at 88% 4%, rgba(255,143,177,.14), transparent 60%),
    radial-gradient(900px 620px at 60% 108%, rgba(179,136,255,.14), transparent 62%),
    linear-gradient(180deg, #070b1e, #0a1030 55%, #0b1338);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .5;
  background-image:
    radial-gradient(1.4px 1.4px at 18% 24%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 72% 16%, #cfe6ff, transparent),
    radial-gradient(1.5px 1.5px at 42% 62%, #fff, transparent),
    radial-gradient(1.1px 1.1px at 86% 48%, #b9d4ff, transparent),
    radial-gradient(1.3px 1.3px at 8% 78%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 64% 88%, #ffe6c7, transparent);
}

button { font-family: inherit; }

.hall {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 22px calc(28px + var(--safe-b));
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 6px 0 18px;
}
.brand { display: flex; align-items: center; gap: 13px; flex: 1; min-width: 0; }
.brand-mark {
  width: 52px; height: 52px; flex: none; border-radius: 16px;
  display: grid; place-items: center; font-size: 26px; color: #fff;
  background: linear-gradient(150deg, #7dd3fc, #3b82f6 52%, #7c3aed);
  box-shadow: 0 8px 0 rgba(20, 40, 120, .55), 0 14px 30px rgba(59, 130, 246, .35), inset 0 2px 0 rgba(255,255,255,.55);
}
.brand-text h1 {
  margin: 0; font-size: 24px; font-weight: 900; letter-spacing: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: linear-gradient(180deg, #fff, #a9d8ff 60%, #6aa9ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-text p { margin: 3px 0 0; font-size: 12px; color: var(--dim); letter-spacing: 1px; font-weight: 700; }

.top-actions { display: flex; align-items: center; gap: 8px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 14px 0 8px; border-radius: 999px;
  background: var(--panel); border: 1.5px solid var(--line);
  color: var(--ink); font-size: 14px; font-weight: 800; cursor: pointer;
  transition: .15s;
}
.chip-btn:hover { background: var(--panel-2); border-color: rgba(90,200,250,.5); }
.chip-ava {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(160deg, #5ac8fa, #2563eb); font-size: 15px;
}
.icon-btn {
  width: 42px; height: 42px; border-radius: 13px; cursor: pointer;
  background: var(--panel); border: 1.5px solid var(--line); color: var(--ink);
  font-size: 17px; display: grid; place-items: center; transition: .15s;
}
.icon-btn:hover { background: var(--panel-2); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.94); }

/* ---------------- 分类 ---------------- */
.tabs {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  background: var(--panel); border: 1.5px solid var(--line);
  color: var(--dim); font-size: 14px; font-weight: 800; transition: .16s;
}
.tab:hover { color: var(--ink); border-color: rgba(255,255,255,.22); }
.tab.on { color: #06122b; background: linear-gradient(180deg, #ffffff, #cfe6ff); border-color: #fff; }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .8; }
.tab.on .dot { opacity: 1; }

/* ---------------- 主推 ---------------- */
.hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px;
  border-radius: 26px; padding: 24px 26px;
  background:
    radial-gradient(520px 300px at 88% 20%, rgba(90,200,250,.24), transparent 70%),
    linear-gradient(135deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  border: 1.5px solid rgba(255,255,255,.12);
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  margin-bottom: 26px;
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px;
  border-radius: 50%; background: radial-gradient(circle, rgba(90,200,250,.35), transparent 68%);
  filter: blur(20px); pointer-events: none;
}
.hero-left { display: flex; flex-direction: column; justify-content: center; gap: 10px; position: relative; z-index: 1; }
.hero-badge {
  align-self: flex-start; padding: 5px 12px; border-radius: 999px;
  font-size: 11px; font-weight: 900; letter-spacing: 1px;
  background: linear-gradient(180deg, #ffe08a, #f5a623); color: #3d2500;
}
.hero-title { margin: 0; font-size: 34px; font-weight: 900; letter-spacing: 1px; }
.hero-desc { margin: 0; font-size: 14px; color: var(--dim); line-height: 1.7; max-width: 34em; }
.hero-meta { display: flex; gap: 14px; font-size: 12px; color: var(--dim); font-weight: 700; margin-top: 2px; }
.hero-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.hero-art { position: relative; z-index: 1; display: grid; place-items: center; }
.hero-art svg { width: 100%; height: auto; max-height: 210px; filter: drop-shadow(0 16px 30px rgba(0,0,0,.45)); }

.btn-main {
  height: 52px; padding: 0 30px; border: 0; border-radius: 16px; cursor: pointer;
  font-size: 17px; font-weight: 900; letter-spacing: 1px; color: #fff;
  background: linear-gradient(180deg, #83d8ff, #2f7cf6 62%, #2563eb);
  box-shadow: 0 6px 0 #1d3f8f, 0 14px 26px rgba(47,124,246,.35), inset 0 2px 0 rgba(255,255,255,.5);
  transition: .08s;
}
.btn-main:active { transform: translateY(5px); box-shadow: 0 1px 0 #1d3f8f; }
.btn-ghost {
  height: 52px; padding: 0 22px; border-radius: 16px; cursor: pointer;
  background: rgba(255,255,255,.07); border: 1.5px solid var(--line);
  color: var(--ink); font-size: 15px; font-weight: 800; transition: .15s;
}
.btn-ghost:hover { background: rgba(255,255,255,.12); }

/* ---------------- 列表头 ---------------- */
.grid-head { display: flex; align-items: baseline; gap: 12px; margin: 4px 2px 14px; }
.grid-head h2 { margin: 0; font-size: 19px; font-weight: 900; letter-spacing: 1px; }
.muted { color: var(--dim); font-size: 12.5px; margin: 0; }

/* ---------------- 卡片 ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 16px;
}
.card {
  position: relative; overflow: hidden; cursor: pointer;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.03));
  border: 1.5px solid rgba(255,255,255,.09);
  box-shadow: 0 10px 28px rgba(0,0,0,.32);
  transition: transform .18s cubic-bezier(.2,1,.4,1), box-shadow .18s, border-color .18s;
}
.card:hover {
  transform: translateY(-6px);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 18px 40px rgba(0,0,0,.45), 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.card:active { transform: translateY(-2px) scale(.995); }
.card-thumb { position: relative; aspect-ratio: 16 / 9.2; overflow: hidden; background: #0b1130; }
.card-thumb svg, .card-img { width: 100%; height: 100%; display: block; }
.card-img { object-fit: cover; position: absolute; inset: 0; z-index: 1; }
.thumb-wrap {
  position: absolute; inset: 0; z-index: 0;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 90% at 70% 10%, color-mix(in srgb, var(--card-accent, #5ac8fa) 45%, transparent), transparent 62%),
    linear-gradient(160deg, #16204d, #080d24);
}
.thumb-letter {
  font-size: 52px; font-weight: 900; letter-spacing: 4px;
  color: #fff; opacity: .28; text-shadow: 0 6px 30px rgba(0, 0, 0, .5);
}
.card-ribbon {
  position: absolute; left: 12px; top: 12px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 11px; font-weight: 900; letter-spacing: .5px;
  color: #06122b; background: var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
}
.card-hot {
  position: absolute; right: 12px; top: 12px; z-index: 2;
  padding: 4px 9px; border-radius: 8px; font-size: 10px; font-weight: 900;
  color: #fff; background: linear-gradient(180deg, #ff6b6b, #d92b2b);
  box-shadow: 0 4px 12px rgba(217,43,43,.45);
}
.card-body { padding: 13px 15px 15px; }
.card-title { display: flex; align-items: center; gap: 8px; margin: 0 0 5px; font-size: 17px; font-weight: 900; }
.card-desc { margin: 0 0 11px; font-size: 12.5px; line-height: 1.55; color: var(--dim); min-height: 2.9em; }
.card-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 800; color: var(--dim); }
.card-stars { color: var(--gold); letter-spacing: 1px; }
.card-stars i { font-style: normal; color: rgba(255,255,255,.16); }
.card-stars i.on { color: var(--gold); text-shadow: 0 0 10px rgba(255,209,102,.7); }
.card-go {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 13px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  font-size: 12px; font-weight: 900;
}
.card:hover .card-go { background: var(--accent); color: #06122b; }

/* ---------------- 每日挑战 ---------------- */
.daily {
  margin-top: 26px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px 20px; border-radius: 20px;
  background: linear-gradient(100deg, rgba(255,209,102,.16), rgba(255,255,255,.03));
  border: 1.5px dashed rgba(255,209,102,.42);
}
.daily-icon { font-size: 26px; }
.daily-text { flex: 1; min-width: 200px; }
.daily-text b { font-size: 15px; }
.daily-text p { margin: 3px 0 0; font-size: 12.5px; color: var(--dim); }
.daily .btn-main { height: 44px; font-size: 15px; padding: 0 22px; box-shadow: 0 5px 0 #8a5b00; background: linear-gradient(180deg, #ffe08a, #f5a623); color: #3d2500; }
.daily .btn-main:active { box-shadow: 0 1px 0 #8a5b00; }

.foot { margin-top: 30px; text-align: center; }
.foot p { margin: 4px 0; font-size: 12px; color: var(--dim); }

/* ---------------- 游戏舞台 ---------------- */
.stage {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: #070b1e;
}
.stage[hidden] { display: none; }
.stage-bar {
  height: 54px; flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: rgba(10, 16, 44, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.stage-back {
  height: 36px; padding: 0 14px; border-radius: 11px; cursor: pointer;
  background: rgba(255,255,255,.07); border: 1.5px solid var(--line);
  color: var(--ink); font-size: 13px; font-weight: 800;
}
.stage-back:hover { background: rgba(255,255,255,.13); }
.stage-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.stage-title span { font-size: 15px; font-weight: 900; letter-spacing: .5px; }
.stage-title small { font-size: 11px; color: var(--dim); }
.stage-actions { display: flex; align-items: center; gap: 8px; }
.stage-score { font-size: 12.5px; font-weight: 800; color: var(--gold); }
#stage-frame { flex: 1; width: 100%; border: 0; background: #070b1e; }

/* ---------------- 弹层 ---------------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 18px;
  background: rgba(4,7,22,.72); backdrop-filter: blur(8px);
}
.sheet-wrap[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 420px; padding: 22px;
  border-radius: 24px;
  background: linear-gradient(180deg, #141c44, #0d1330);
  border: 1.5px solid rgba(255,255,255,.1);
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
  max-height: 88vh; overflow: auto;
}
.sheet h2 { margin: 0 0 6px; font-size: 22px; font-weight: 900; text-align: center; letter-spacing: 1px; }
.sheet .sub { margin: 0 0 16px; text-align: center; font-size: 12.5px; color: var(--dim); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.set-row:last-of-type { border-bottom: 0; }
.set-label { font-size: 14px; font-weight: 800; }
.set-hint { font-size: 11px; color: var(--dim); margin-top: 3px; }
.switch { position: relative; width: 52px; height: 30px; flex: none; border-radius: 999px; background: rgba(255,255,255,.13); border: 1px solid var(--line); cursor: pointer; transition: .18s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .18s; }
.switch.on { background: linear-gradient(180deg, #7dd3fc, #2563eb); }
.switch.on::after { left: 25px; }
.sheet-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }
.sheet-actions .btn-main { width: 100%; height: 48px; font-size: 16px; }

.player-pick { display: flex; gap: 10px; margin-bottom: 8px; }
.player-card {
  flex: 1; display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 12px; border-radius: 16px;
  background: rgba(255,255,255,.05); border: 1.5px solid var(--line);
}
.player-card.on { background: rgba(90,200,250,.14); border-color: rgba(90,200,250,.6); }
.player-card .pa { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; background: linear-gradient(160deg, #24305c, #121a3d); }
.player-card.on .pa { background: linear-gradient(160deg, #5ac8fa, #2563eb); }
.player-card .pn { font-size: 14px; font-weight: 800; }
.player-card .pm { font-size: 11px; color: var(--dim); margin-top: 2px; }
.name-input {
  width: 100%; margin-top: 6px;
  background: rgba(255,255,255,.07); border: 1.5px solid var(--line);
  border-radius: 12px; color: var(--ink); padding: 10px 12px; font-size: 14px; font-family: inherit; outline: none;
}
.name-input:focus { border-color: rgba(90,200,250,.7); }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 14px);
  background: rgba(12,18,46,.96); border: 1px solid rgba(255,255,255,.14);
  color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700; opacity: 0; pointer-events: none;
  transition: .22s; z-index: 90; white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 860px) {
  .hall { padding: 14px 14px calc(24px + var(--safe-b)); }
  .brand-text h1 { font-size: 19px; letter-spacing: 1px; }
  .brand-text p { display: none; }
  .brand-mark { width: 44px; height: 44px; font-size: 22px; border-radius: 14px; }
  .hero { grid-template-columns: 1fr; padding: 20px; }
  .hero-art { order: -1; }
  .hero-art svg { max-height: 150px; }
  .hero-title { font-size: 26px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
  .card-desc { display: none; }
  .tabs { flex-wrap: nowrap; padding-bottom: 2px; }
  .stage-bar { padding: 0 10px; }
  .stage-back { padding: 0 10px; font-size: 12px; }
  #stage-full { display: none; }
}
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .card-thumb { aspect-ratio: 16 / 7.6; }
  .card-desc { display: block; min-height: 0; }
  .chip-btn { padding: 0 10px 0 6px; font-size: 13px; }
  .hero-meta { flex-wrap: wrap; row-gap: 4px; }
}

/* 超窄屏（320—380px，老手机 / 小折叠外屏） */
@media (max-width: 380px) {
  .hall { padding: 10px 10px calc(20px + var(--safe-b)); }
  .topbar { gap: 8px; padding-bottom: 12px; }
  .brand { gap: 8px; min-width: 0; }
  .brand-mark { width: 38px; height: 38px; font-size: 19px; border-radius: 12px; }
  .brand-text { min-width: 0; }
  .brand-text h1 { font-size: 16px; letter-spacing: 0; }
  .brand-text p { display: none; }
  .top-actions { gap: 6px; }
  .chip-btn { height: 44px; padding: 0 8px; }
  .chip-btn .chip-ava { width: 26px; height: 26px; font-size: 13px; }
  #chip-name { display: none; }
  .icon-btn { width: 44px; height: 44px; font-size: 16px; border-radius: 12px; }
  .tab { height: 44px; padding: 0 12px; font-size: 13px; }
  .hero { padding: 16px; border-radius: 20px; }
  .hero-title { font-size: 22px; }
  .hero-art svg { max-height: 120px; }
  .btn-main, .btn-ghost { height: 46px; font-size: 15px; padding: 0 16px; }
  .card { border-radius: 18px; }
  .card-title { font-size: 16px; }
  .sheet { padding: 18px; border-radius: 20px; }
  .stage-bar { gap: 6px; }
  .stage-title span { font-size: 13px; }
  .stage-title small { font-size: 10px; }
  .stage-back { height: 44px; }
  .stage-actions .icon-btn { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
html.still * { transition: none !important; animation: none !important; }
