/* Brain Master · 布局：外壳 / 首页 / 游戏页 */
.shell {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 内容区：整体高度受控，首页在这里内部滚动 */
.shell__content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + var(--safe-t)) 18px 12px;
  backdrop-filter: blur(14px);
  background: linear-gradient(180deg, rgba(9, 13, 30, 0.92), rgba(9, 13, 30, 0.55));
  border-bottom: 1px solid var(--border);
}
.topbar__back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px 8px 10px;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 14px;
  transition: transform .15s, background .15s;
}
.topbar__back:hover { background: var(--panel-2); transform: translateX(-2px); }

/* 标题区：名称与类别同一行（类别以分隔点收尾），放不下时省略号 */
.topbar__titlebox { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.topbar__title { font-size: 17px; font-weight: 700; letter-spacing: .5px; white-space: nowrap; }
.topbar__sub {
  font-size: 12px; color: var(--ink-3); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.topbar__sub:not(:empty)::before { content: '·'; margin-right: 8px; color: var(--ink-3); }

/* 首页品牌区：logo + 名称 + 轻量 slogan，整体一行 */
.topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__slogan {
  font-size: 12px; color: var(--ink-3); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; gap: 8px; flex: none; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 16px;
  transition: background .15s, transform .15s;
}
.icon-btn:hover { background: var(--panel-2); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.is-off { opacity: .45; }

/* ---------- 首页 ---------- */
.home {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 14px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Hero：一行轻量状态条（品牌 + 关键数据），细节信息收进进度条/悬浮提示 */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  padding: 10px 16px 12px;
  background: linear-gradient(135deg, rgba(110, 231, 255, 0.12), rgba(180, 107, 255, 0.12));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
}
.hero::after {
  content: "";
  position: absolute;
  width: 240px; height: 240px;
  right: -90px; top: -120px;
  background: radial-gradient(circle, rgba(110, 231, 255, 0.3), transparent 65%);
  pointer-events: none;
}
/* 纯数据条：所有 chip 强制同一行，不换行 */
.hero__row {
  position: relative; z-index: 1;
  display: flex; align-items: center; flex-wrap: nowrap;
  gap: 6px; min-width: 0; overflow: hidden;
}
.hero__stat {
  flex: none;
  font-size: 12px; color: var(--ink-2);
  padding: 3px 10px; border-radius: 99px;
  background: rgba(8, 12, 28, .45);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.hero__stat b { color: #fff; font-size: 13px; font-weight: 800; }

/* 每日训练按钮：固定在数据行最右侧 */
.hero__daily {
  flex: none;
  margin-left: auto;
  padding: 4px 12px;
  font-size: 12.5px;
  white-space: nowrap;
}

.levelbar { position: relative; z-index: 1; margin-top: 9px; height: 4px; border-radius: 99px; background: rgba(132, 166, 255, .16); overflow: hidden; }
.levelbar__fill { height: 100%; border-radius: 99px; background: var(--grad-hero); transition: width .6s cubic-bezier(.22,1,.36,1); }

/* 分区标题 */
.section__head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.section__title { font-size: 18px; font-weight: 800; }
.section__hint { font-size: 12px; color: var(--ink-3); }

/* 游戏网格 */
.grid-games {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

/* 主题选择行 */
.themes {
  display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px;
  scrollbar-width: none;
}
.themes::-webkit-scrollbar { display: none; }

/* ---------- 游戏页 ---------- */
.stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 14px 16px calc(28px + var(--safe-b));
  gap: 14px;
}
.stage__hud, .stage__train { flex: none; }
.stage__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.game-root {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* 训练进度条 */
.trainbar { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.trainbar__chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 99px;
  font-size: 12px; color: var(--ink-3);
  background: var(--panel); border: 1px solid var(--border);
}
.trainbar__chip.is-done { color: var(--c-green); border-color: rgba(74, 222, 128, .4); }
.trainbar__chip.is-now { color: #06121f; background: var(--grad-hero); border-color: transparent; font-weight: 700; }

@media (max-width: 640px) {
  .home { padding: 10px 10px 40px; gap: 10px; }
  .hero { padding: 7px 10px 9px; border-radius: var(--r-lg); }
  .grid-games { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .topbar { padding: calc(8px + var(--safe-t)) 10px 8px; gap: 6px; }
  /* 右侧图标按钮：去掉圆角底色与边框，缩小一档，保证三个都完整显示 */
  .topbar__actions { gap: 2px; }
  .icon-btn {
    width: 34px; height: 34px;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    font-size: 17px;
  }
  .icon-btn:active { background: rgba(255, 255, 255, .08); }
  .stage { padding: 12px 10px calc(24px + var(--safe-b)); }

  /* 手机顶栏：首页只留 🧠 logo（名称与 slogan 收起）；Hero 数据 chip 紧凑化 */
  .topbar__title--brand, .topbar__slogan { display: none; }
  .topbar__back-label { display: none; }       /* 返回键只留 🏠 图标 */
  .topbar__title { font-size: 15px; }

  .hero__row { gap: 4px; }
  .hero__stat { padding: 3px 7px; font-size: 11px; }
  .hero__stat b { font-size: 12px; }
  .hero__daily { padding: 4px 10px; font-size: 12px; }
  .gcard__desc { display: none; }
  .gcard__cat { display: none; }
  .gcard { padding: 14px; gap: 8px; }
  .gcard__icon { width: 42px; height: 42px; font-size: 22px; }
  .gcard__name { font-size: 15px; }
  .gcard__foot { font-size: 11px; }
}

@media (max-width: 420px) {
  /* 超窄屏：收起“累计挑战”，给右侧训练按钮留位 */
  .hero__stat:nth-child(4) { display: none; }
}
