:root {
  --primary: #ff6b35;
  --primary-2: #ff9a3c;
  --teal: #0f9d8f;
  --ink: #16202f;
  --muted: #667085;
  --bg: #f5f7fb;
  --card: #ffffff;
  --line: #e6e9f0;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(22, 32, 47, .08);
  --max: 1180px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }

/* —— 顶部导航 —— */
.site-header {
  position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.88);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-size: 18px;
}
/* 两个字符的字母标记：缩字号并去掉字距，避免在 34px 方块里溢出 */
.brand .logo-ai {
  font-size: 13px; font-weight: 800; letter-spacing: 0; font-family: var(--font-num, inherit);
}
.nav-links { display: flex; gap: 4px; margin-left: 8px; }
.nav-links a { padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 14px; }
.nav-links a:hover, .nav-links a.active { background: #fff1eb; color: var(--primary); }
.nav-spacer { flex: 1; }
.nav-auth { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: #eef2f8; font-size: 14px; font-weight: 600; }
.user-chip .avatar { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, var(--teal), #3dd6c4); color: #fff; display: grid; place-items: center; font-size: 13px; }

/* —— 按钮 —— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; transition: .18s;
  white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(255,107,53,.3); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
/* 表格内联控件（如用户管理的角色下拉）：默认 .select 是整宽块级，塞进表格会把行撑爆 */
/* 表格内联控件（如用户管理的角色下拉）：默认 .select 是 width:100% 的块级，塞进表格会把操作列撑爆。
   用 .select.select-sm 提高优先级，避免被后面定义的 .select 覆盖。 */
.select.select-sm { width: auto; min-width: 108px; flex: 0 0 auto; padding: 5px 8px; font-size: 12px; border-radius: 8px; }
/* 角色徽章 */
.badge-role-admin { background: #eef2ff; color: #3538cd; }
.badge-role-therapist { background: #e7f7f2; color: #087a6c; }
.badge-role-player { background: #eef2f8; color: #475467; }
.btn-danger { background: #fff0f0; color: #d92d20; border-color: #ffd6d6; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* —— 通用 —— */
.section { padding: 34px 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* —— 轮播 —— */
.carousel { position: relative; border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); background: #0f172a; }

/* —— 动态宣传横幅（替换原轮播位） —— */
.banner-slot { margin-top: 4px; }
.banner-frame {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  background: #06090e;
  border: 1px solid rgba(122, 176, 255, .14);
  box-shadow: var(--shadow);
}
.banner-frame iframe {
  display: block;
  width: 100%;
  height: clamp(300px, 26vw, 420px);
  border: 0;
  background: #06090e;
}
@media (max-width: 700px) {
  .banner-frame { border-radius: 18px; }
  .banner-frame iframe { height: 300px; }
}
[hidden] { display: none !important; }
.carousel-track { position: relative; height: 320px; }
.carousel-slide { position: absolute; inset: 0; opacity: 0; transition: opacity .6s; display: flex; align-items: flex-end; }
.carousel-slide.active { opacity: 1; }
.carousel-slide img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.carousel-caption { position: relative; padding: 24px; color: #fff; width: 100%;
  background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.carousel-caption h3 { margin: 0; font-size: 26px; }
.carousel-dots { position: absolute; right: 18px; bottom: 16px; display: flex; gap: 8px; z-index: 2; }
.carousel-dots button { width: 9px; height: 9px; border-radius: 50%; border: 0; background: rgba(255,255,255,.45); cursor: pointer; }
.carousel-dots button.active { background: #fff; width: 22px; border-radius: 6px; }

/* —— 英雄区 —— */
.hero { padding: 26px 0 8px; }
.hero h1 { margin: 0 0 8px; font-size: 32px; letter-spacing: -.02em; }
.hero p { margin: 0 0 16px; color: var(--muted); font-size: 16px; }

/* —— 分类 chips —— */
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { padding: 8px 16px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* —— 游戏卡片 —— */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.game-card { overflow: hidden; display: flex; flex-direction: column; transition: .2s; }
.game-card:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(22,32,47,.14); }
.game-cover { aspect-ratio: 16/9; position: relative; background: #eef2f8; }
.game-cover img { width: 100%; height: 100%; object-fit: cover; }
.game-cover .badge { position: absolute; left: 10px; top: 10px; }
.game-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.game-body h3 { margin: 0; font-size: 17px; }
.game-body p { margin: 0; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.game-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); margin-top: auto; }
.game-actions { display: flex; gap: 8px; padding: 0 16px 16px; }
.game-actions .btn { flex: 1; }
.fav-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 17px; }
.fav-btn.on { color: #e5484d; border-color: #ffd0d0; background: #fff5f5; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-pub { background: #e7f7f2; color: #087a6c; }
.badge-pending { background: #fff4e5; color: #b25e00; }
.badge-rejected { background: #fff0f0; color: #d92d20; }
.badge-official { background: #fff1eb; color: var(--primary); }

/* —— 通知 / 反馈 —— */
.two-col { display: grid; grid-template-columns: 1.3fr .9fr; gap: 22px; align-items: start; }
.panel { padding: 20px; }
.panel h3 { margin: 0 0 14px; font-size: 18px; }
.notice-item { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.notice-item:last-child { border-bottom: 0; }
.notice-item h4 { margin: 0 0 4px; font-size: 15px; }
.notice-item p { margin: 0; color: var(--muted); font-size: 13px; white-space: pre-wrap; }
.notice-item time { font-size: 12px; color: #98a2b3; }

/* —— 表单 —— */
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #344054; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  font: inherit; font-size: 14px; background: #fff; color: var(--ink); outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,107,53,.12); }
.textarea { min-height: 96px; resize: vertical; }
.inline { display: flex; gap: 10px; }
.inline > * { flex: 1; }

/* —— 登录页 —— */
.auth-wrap { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 30px 20px; }
.auth-card { width: min(440px, 100%); padding: 26px; }
.auth-card h2 { margin: 0 0 4px; }
.tabs { display: flex; gap: 4px; background: #f1f3f8; padding: 4px; border-radius: 12px; margin: 16px 0; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; font: inherit; font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer; }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.social { display: flex; gap: 10px; margin-top: 14px; }
.social .btn { flex: 1; }
.divider { display: flex; align-items: center; gap: 10px; color: #98a2b3; font-size: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* —— 游戏播放页 —— */
.play-wrap { width: 100%; height: calc(100vh - 64px); background: #0b1020; position: relative; }
.play-frame { width: 100%; height: 100%; border: 0; display: block; }
.play-bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 16px; display: flex; gap: 10px; align-items: center;
  background: linear-gradient(transparent, rgba(0,0,0,.6)); color: #fff; font-size: 13px; }
.play-hud { position: absolute; left: 16px; top: 14px; background: rgba(0,0,0,.55); color: #fff; padding: 8px 14px; border-radius: 12px; font-size: 13px; }
.result-toast { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  background: rgba(15,23,42,.94); color: #fff; border-radius: 18px; padding: 22px 26px; text-align: center; z-index: 5; min-width: 260px; }

/* —— 个人中心 —— */
.profile-grid { display: grid; grid-template-columns: 1fr; gap: 22px; }
.record-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.record-row:last-child { border: 0; }
.record-row .score { font-weight: 800; color: var(--primary); font-size: 18px; min-width: 64px; }
.record-row .meta { flex: 1; }
.record-row .meta strong { font-size: 14px; }
.record-row .meta div { font-size: 12px; color: var(--muted); }
.mini-cover { width: 54px; height: 40px; border-radius: 8px; object-fit: cover; background: #eef2f8; }

/* —— 管理后台 —— */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 22px; padding: 24px 0 60px; }
.admin-side { position: sticky; top: 84px; align-self: start; padding: 12px; }
.admin-side button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 10px 12px; border: 0; background: transparent;
  border-radius: 10px; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; text-align: left; }
.admin-side button.active, .admin-side button:hover { background: #fff1eb; color: var(--primary); }
.admin-main { min-width: 0; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.admin-head h2 { margin: 0; font-size: 22px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { padding: 16px; }
.stat .num { font-size: 26px; font-weight: 800; }
.stat .lbl { font-size: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { color: var(--muted); font-weight: 700; font-size: 12px; background: #fafbfe; white-space: nowrap; }
table.data tr:hover td { background: #fafbfe; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar .input, .toolbar .select { width: auto; }
.tag-risk { background: #fff0f0; color: #d92d20; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.empty { padding: 30px; text-align: center; color: var(--muted); font-size: 14px; }
/* 空状态/加载中在网格里要横跨整行，否则只占一格，看着像「页面空了」 */
.game-grid > .empty { grid-column: 1 / -1; }
.empty p { margin: 0; }
.empty p + p { margin-top: 6px; }
.empty-hint { font-size: 13px; opacity: .8; }
.empty .btn { margin-top: 14px; }

/* —— 模态框 —— */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { width: min(560px, 100%); max-height: 88vh; overflow: auto; padding: 22px; }
.modal h3 { margin: 0 0 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* —— toast —— */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #16202f; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); animation: slide .2s ease; }
.toast.err { background: #b42318; }
.toast.ok { background: #087a6c; }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }

/* —— 页脚 —— */
.footer { border-top: 1px solid var(--line); padding: 26px 0; color: var(--muted); font-size: 13px; text-align: center; }

/* —— 响应式 —— */
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-side { position: static; display: flex; gap: 6px; overflow-x: auto; }
  .admin-side button { white-space: nowrap; width: auto; }
  .carousel-track { height: 220px; }
  .hero h1 { font-size: 26px; }
}
@media (max-width: 640px) {
  .nav { gap: 10px; height: 58px; }
  .nav-links { display: none; }
  .brand { font-size: 16px; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .game-body p { display: none; }
  .carousel-track { height: 180px; }
  .carousel-caption h3 { font-size: 18px; }
  .section { padding: 24px 0; }
  .play-wrap { height: calc(100vh - 58px); }
}
