/*
 * 前台小游戏（/game、/game/{key}）：夜色 + 剪纸灯笼风格，每个游戏一个主色 --gx-c；画面都在 canvas 里用代码画（不用图片）
 * 不依赖主题变量（游戏区自己是深色），所有主题通用；动效遵守 prefers-reduced-motion
 */
.gx-hall, .gx-page {
  --gx-ink: #0d1230; --gx-ink2: #161d47; --gx-paper: #f6ecd9; --gx-dim: rgba(246, 236, 217, .62); --gx-line: rgba(246, 236, 217, .14);
  position: relative; padding: 48px 0 72px; color: var(--gx-paper);
  background:
    radial-gradient(900px 420px at 12% -10%, color-mix(in srgb, var(--gx-c, #ffb347) 28%, transparent), transparent 70%),
    radial-gradient(700px 380px at 100% 0%, rgba(90, 120, 255, .22), transparent 70%),
    linear-gradient(180deg, var(--gx-ink) 0%, #090c22 100%);
  overflow: hidden;
}
.gx-hall::before, .gx-page::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .35;
  background-image: radial-gradient(1px 1px at 20% 30%, #fff8 50%, transparent 51%), radial-gradient(1px 1px at 70% 20%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 80%, #fff5 50%, transparent 51%), radial-gradient(1px 1px at 85% 65%, #fff7 50%, transparent 51%);
  background-size: 220px 180px, 310px 260px, 260px 300px, 190px 210px;
}
.gx-hall .container, .gx-page .container { position: relative; }

/* ---------- 列表 ---------- */
.gx-hall-head { max-width: 640px; margin-bottom: 32px; }
.gx-hall-head h1 { font-size: clamp(30px, 5vw, 44px); letter-spacing: .04em; color: var(--gx-paper); }
.gx-hall-head p { margin-top: 10px; color: var(--gx-dim); font-size: 16px; }
.gx-cats { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 22px; }
.gx-cats button { border: 1px solid color-mix(in srgb, var(--gx-paper) 25%, transparent); background: transparent; color: var(--gx-paper); border-radius: 999px; padding: 8px 18px; font-size: 15px; cursor: pointer; }
.gx-cats button small { opacity: .6; margin-left: 2px; }
.gx-cats button.on { background: var(--gx-paper); color: var(--gx-ink); border-color: var(--gx-paper); font-weight: 700; }
.gx-cat { margin-bottom: 34px; }
.gx-subjects { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 16px; }
.gx-subjects button { border: 0; background: color-mix(in srgb, var(--gx-paper) 10%, transparent); color: var(--gx-dim); border-radius: 8px; padding: 6px 14px; font-size: 14px; cursor: pointer; }
.gx-subjects button.on { background: color-mix(in srgb, var(--gx-paper) 22%, transparent); color: var(--gx-paper); font-weight: 700; }
.gx-card[hidden] { display: none; }
.gx-card .gx-grade { margin: -2px 0 8px; font-size: 12px; color: var(--gx-c); }
.gx-card .gx-grade span { margin-left: 8px; color: var(--gx-dim); }
.gx-cat[hidden] { display: none; }
.gx-cat-title { font-size: 22px; margin: 0 0 14px; color: var(--gx-paper); }
.gx-cat-title small { margin-left: 12px; font-size: 14px; font-weight: 400; color: var(--gx-dim); }
.gx-subject { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 6px; font-size: 12px; vertical-align: middle; background: color-mix(in srgb, var(--gx-c) 25%, transparent); color: var(--gx-paper); }
.gx-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 22px; }
.gx-cards > *, .gx-layout > * { min-width: 0; }
.gx-card { position: relative; display: flex; flex-direction: column; border-radius: 22px 22px 22px 6px; overflow: hidden; background: var(--gx-ink2); color: var(--gx-paper);
  box-shadow: 0 0 0 1px var(--gx-line), 8px 8px 0 color-mix(in srgb, var(--gx-c) 35%, #000); transition: transform .25s, box-shadow .25s; }
.gx-card:hover { transform: translate(-3px, -3px); box-shadow: 0 0 0 1px var(--gx-c), 11px 11px 0 color-mix(in srgb, var(--gx-c) 45%, #000); }
/* 画布宽度只跟容器走，不能让画布像素宽度反过来撑开网格（手机上会越撑越宽） */
.gx-card canvas { display: block; width: 100%; max-width: 100%; aspect-ratio: 4 / 3; }
.gx-card-body { padding: 18px 20px 22px; }
.gx-card h2 { font-size: 22px; color: var(--gx-paper); }
.gx-card p { margin: 6px 0 16px; color: var(--gx-dim); font-size: 14px; line-height: 1.6; }

.gx-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 18px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--gx-c, #ffb347); color: #1a1206; font-weight: 700; font-size: 14px; box-shadow: 0 4px 0 color-mix(in srgb, var(--gx-c) 50%, #000); transition: transform .15s, box-shadow .15s; }
.gx-btn:hover { transform: translateY(-1px); }
.gx-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--gx-c) 50%, #000); }
.gx-btn.lg { height: 48px; padding: 0 34px; font-size: 16px; }

/* ---------- 游戏页 ---------- */
.gx-head { margin-bottom: 22px; }
.gx-back { color: var(--gx-dim); font-size: 14px; }
.gx-back:hover { color: var(--gx-paper); }
.gx-head h1 { margin-top: 8px; font-size: clamp(26px, 4vw, 36px); color: var(--gx-paper); }
.gx-head p { margin-top: 6px; color: var(--gx-dim); }
.gx-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.gx-stage { border-radius: 24px; padding: 12px; background: var(--gx-ink2); box-shadow: 0 0 0 1px var(--gx-line), 0 30px 60px -30px #000; }
.gx-hud { display: flex; align-items: center; gap: 16px; padding: 4px 8px 12px; }
.gx-hud > div { display: flex; flex-direction: column; min-width: 64px; }
.gx-hud small { color: var(--gx-dim); font-size: 12px; letter-spacing: .08em; }
.gx-hud b { font-size: 24px; font-variant-numeric: tabular-nums; color: var(--gx-paper); line-height: 1.15; }
.gx-hud [data-gx-extra] { flex: 1; align-items: center; color: var(--gx-c); font-weight: 700; font-size: 14px; text-align: center; }
.gx-icon { width: 34px; height: 34px; border: 1px solid var(--gx-line); border-radius: 50%; background: transparent; color: var(--gx-paper); cursor: pointer; font-size: 16px; }
.gx-icon.off { opacity: .4; text-decoration: line-through; }
.gx-canvas { position: relative; border-radius: 16px; overflow: hidden; aspect-ratio: 1 / 1; width: min(100%, 72vh); margin: 0 auto; background: #070a1c; touch-action: none; user-select: none; -webkit-user-select: none; }
.gx-canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; max-width: 100%; display: block; }
.gx-fx { pointer-events: none; }
.gx-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 14px; padding: 28px; text-align: center; overflow-y: auto; overscroll-behavior: contain;
  background: radial-gradient(circle at 50% 40%, rgba(13, 18, 48, .72), rgba(5, 7, 20, .92)); backdrop-filter: blur(2px); }
.gx-overlay[hidden] { display: none; }
.gx-overlay h2 { font-size: 30px; color: var(--gx-c); letter-spacing: .06em; }
.gx-overlay ol { max-width: 460px; margin: 0; padding-left: 20px; text-align: left; color: var(--gx-dim); font-size: 14px; line-height: 1.75; }
.gx-overlay small { color: var(--gx-dim); letter-spacing: .2em; }
.gx-final { font-size: clamp(48px, 9vw, 76px); font-weight: 800; line-height: 1; color: var(--gx-paper); font-variant-numeric: tabular-nums; text-shadow: 0 0 28px color-mix(in srgb, var(--gx-c) 60%, transparent); }
.gx-newbest { color: var(--gx-c); font-weight: 800; letter-spacing: .1em; animation: gx-pulse 1s ease-in-out infinite alternate; }
.gx-link { color: var(--gx-dim); font-size: 13px; text-decoration: underline; }
.gx-toast { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); max-width: 86%; padding: 10px 18px; border-radius: 999px; background: var(--gx-paper); color: #1a1206;
  font-weight: 700; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); animation: gx-drop .35s cubic-bezier(.2, 1.4, .5, 1); z-index: 3; text-align: center; }
.gx-toast a { color: inherit; text-decoration: underline; }
.gx-toast[hidden] { display: none; }

.gx-side { padding: 20px; border-radius: 22px; background: rgba(22, 29, 71, .72); box-shadow: 0 0 0 1px var(--gx-line); }
.gx-side h3 { font-size: 18px; color: var(--gx-paper); }
.gx-tabs { display: flex; gap: 4px; margin: 14px 0; padding: 4px; border-radius: 999px; background: rgba(0, 0, 0, .25); }
.gx-tabs button { flex: 1; height: 30px; border: 0; border-radius: 999px; background: transparent; color: var(--gx-dim); cursor: pointer; font-size: 13px; }
.gx-tabs button.on { background: var(--gx-c); color: #1a1206; font-weight: 700; }
.gx-rank { list-style: none; margin: 0; padding: 0; display: grid; align-content: start; gap: 4px; min-height: 120px; }
.gx-rank li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; font-size: 14px; }
.gx-rank li.me { background: color-mix(in srgb, var(--gx-c) 22%, transparent); }
.gx-rank li i { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 50%; font-style: normal; font-size: 12px; font-weight: 800; background: rgba(255, 255, 255, .08); }
.gx-rank li:nth-child(1) i { background: #ffd166; color: #3a2600; }
.gx-rank li:nth-child(2) i { background: #d9dde8; color: #22263a; }
.gx-rank li:nth-child(3) i { background: #e9a46a; color: #3a1d06; }
.gx-rank li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gx-rank li span em { margin-left: 4px; font-style: normal; font-size: 11px; color: var(--gx-dim); }
.gx-rank li b { font-variant-numeric: tabular-nums; }
.gx-rank .empty { color: var(--gx-dim); justify-content: center; padding: 30px 0; }
.gx-me { margin-top: 10px; color: var(--gx-c); font-size: 13px; font-weight: 600; min-height: 1em; }
.gx-note { margin-top: 10px; color: var(--gx-dim); font-size: 12.5px; line-height: 1.6; }
.gx-note a { color: var(--gx-paper); text-decoration: underline; }
.gx-more { display: grid; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--gx-line); }
.gx-more a { display: flex; align-items: center; gap: 8px; color: var(--gx-paper); font-size: 14px; }
.gx-more a i { width: 10px; height: 10px; border-radius: 3px; background: var(--gx-c); transform: rotate(45deg); }

@keyframes gx-pulse { from { opacity: .6; transform: scale(.98); } to { opacity: 1; transform: scale(1.04); } }
@keyframes gx-pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes gx-drop { from { opacity: 0; transform: translate(-50%, -14px) scale(.9); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

@media (max-width: 900px) {
  .gx-layout { grid-template-columns: minmax(0, 1fr); }
  .gx-hall, .gx-page { padding: 28px 0 48px; }
  .gx-stage { padding: 8px; border-radius: 18px; }
  .gx-hud b { font-size: 20px; }
  .gx-overlay ol { font-size: 13px; }
}
/* 手机：画布占满宽度（格子更大好点），说明文字收紧 */
@media (max-width: 600px) {
  .gx-page .container { padding-left: 10px; padding-right: 10px; }
  .gx-stage { padding: 6px; border-radius: 14px; }
  .gx-canvas { width: 100%; border-radius: 10px; }
  .gx-hud { gap: 8px; padding: 2px 4px 8px; }
  .gx-hud > div { min-width: 48px; }
  .gx-overlay { gap: 10px; padding: 16px 14px; }
  .gx-overlay h2 { font-size: 22px; }
  .gx-overlay ol { font-size: 12px; line-height: 1.6; padding-left: 16px; }
  .gx-btn.lg { height: 44px; padding: 0 28px; }
  .gx-final { font-size: 44px; }
  .gx-lines { font-size: 13px; gap: 2px; }
  .gx-lines b { font-size: 14px; }
  .gx-badge { padding: 6px 10px; }
  .gx-actions .gx-btn { height: 36px; padding: 0 14px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .gx-card, .gx-btn, .gx-newbest, .gx-toast { transition: none; animation: none; }
}

/* ---------- 留人：开始 / 结算浮层按钮、结算信息、成就徽章、我的面板 ---------- */
.gx-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.gx-btn.ghost { background: transparent; color: var(--gx-paper); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--gx-c) 70%, transparent); }
.gx-btn.ghost:active { box-shadow: inset 0 0 0 1.5px var(--gx-c); }
.gx-overlay small em { font-style: normal; color: var(--gx-c); letter-spacing: .1em; }
.gx-lines { display: grid; gap: 4px; color: var(--gx-dim); font-size: 14px; }
.gx-lines b { color: var(--gx-paper); font-size: 15px; }
.gx-reward { color: #ffd166; font-weight: 700; }
.gx-badges { display: grid; gap: 8px; width: min(100%, 360px); }
.gx-badges:empty { display: none; }
.gx-badge { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; text-align: left; background: color-mix(in srgb, var(--gx-c) 18%, rgba(0, 0, 0, .3)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gx-c) 50%, transparent); animation: gx-pop .5s cubic-bezier(.2, 1.4, .5, 1) both; }
.gx-badge i { font-style: normal; font-size: 22px; color: #ffd166; }
.gx-badge span { display: flex; flex-direction: column; }
.gx-badge small { color: var(--gx-dim); letter-spacing: 0; }
.gx-mine { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--gx-line); }
.gx-mine:empty { display: none; }
.gx-mine h4 { margin: 12px 0 8px; font-size: 14px; color: var(--gx-paper); }
.gx-mine h4 small { color: var(--gx-dim); font-weight: 400; }
.gx-streak { color: var(--gx-c); font-weight: 700; font-size: 14px; }
.gx-tiers { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.gx-tiers li { display: flex; justify-content: space-between; padding: 6px 10px; border-radius: 8px; background: rgba(0, 0, 0, .2); font-size: 13px; color: var(--gx-dim); }
.gx-tiers li b { color: #ffd166; }
.gx-tiers li.done { color: var(--gx-paper); text-decoration: line-through; opacity: .6; }
.gx-wall { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.gx-wall > div { display: flex; flex-direction: column; gap: 2px; padding: 8px; border-radius: 10px; background: rgba(0, 0, 0, .2); opacity: .5; }
.gx-wall > div.done { opacity: 1; background: color-mix(in srgb, var(--gx-c) 16%, rgba(0, 0, 0, .2)); }
.gx-wall i { font-style: normal; color: #ffd166; }
.gx-wall b { font-size: 13px; color: var(--gx-paper); }
.gx-wall small { font-size: 11px; color: var(--gx-dim); line-height: 1.4; }
.gx-tabs button { white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .gx-badge { animation: none; } }

/* 3D 游戏的 WebGL 画布（core.js 的 g.glCanvas()）：叠在 2D 画布上，触摸交给下面的画布 */
.gx-canvas .gx-gl { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; display: block; }

/* ---------- 科学小游戏：人群选择、知识卡（science.js） ---------- */
.gx-aud { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; font-size: 13px; color: var(--gx-dim); }
.gx-aud button { height: 30px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--gx-line); background: transparent; color: var(--gx-paper); cursor: pointer; font-size: 13px; }
.gx-aud button.on { background: var(--gx-c); border-color: var(--gx-c); color: #1a1206; font-weight: 700; }
.gx-sci { position: absolute; inset: 0; z-index: 4; display: flex; align-items: safe center; justify-content: center; padding: 16px; overflow-y: auto; background: rgba(5, 7, 20, .72); backdrop-filter: blur(3px); }
.gx-sci-card { width: min(100%, 440px); padding: 20px 20px 18px; border-radius: 18px; background: #fbf6ea; color: #1d1a16; box-shadow: 0 20px 50px rgba(0, 0, 0, .45); animation: gx-pop .35s cubic-bezier(.2, 1.4, .5, 1) both; }
.gx-sci-tag { display: inline-block; margin-bottom: 6px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--gx-c) 30%, #fff); font-size: 12px; font-weight: 700; color: #3a2a10; }
.gx-sci-card h3 { font-size: 19px; color: #1d1a16; }
.gx-sci-body { margin-top: 8px; font-size: 14.5px; line-height: 1.75; color: #4a4338; white-space: pre-line; }
.gx-sci-q { margin-top: 14px; padding-top: 12px; border-top: 1px dashed #d8ccb4; }
.gx-sci-q b { font-size: 12px; letter-spacing: .1em; color: #a0753a; }
.gx-sci-q p { margin: 4px 0 10px; font-weight: 700; font-size: 15px; }
.gx-sci-opts { display: grid; gap: 8px; }
.gx-sci-opts button { min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1.5px solid #e2d6bd; background: #fff; color: #1d1a16; text-align: left; font-size: 14px; cursor: pointer; }
.gx-sci-opts button:hover:not(:disabled) { border-color: var(--gx-c); }
.gx-sci-opts button.ok { border-color: #2f9e5b; background: #e6f6ec; }
.gx-sci-opts button.bad { border-color: #d0453a; background: #fdeceb; }
.gx-sci-why { margin-top: 10px; font-size: 13.5px; line-height: 1.7; color: #5a4b30; }
.gx-sci-next { margin-top: 14px; width: 100%; }
@media (prefers-reduced-motion: reduce) { .gx-sci-card { animation: none; } }
@media (max-width: 600px) {
  .gx-sci { padding: 8px; }
  .gx-sci-card { padding: 14px 14px 12px; border-radius: 14px; }
  .gx-sci-card h3 { font-size: 16px; }
  .gx-sci-body { margin-top: 4px; font-size: 13px; line-height: 1.6; }
  .gx-sci-q { margin-top: 10px; padding-top: 8px; }
  .gx-sci-q p { margin: 2px 0 8px; font-size: 13.5px; }
  .gx-sci-opts { gap: 6px; }
  .gx-sci-opts button { min-height: 36px; padding: 6px 10px; font-size: 13px; }
  .gx-sci-why { font-size: 12.5px; }
  .gx-sci-next { margin-top: 10px; height: 38px; }
}

/* ---------- 科学问答闯关（quiz.js）：下半屏题目面板 ---------- */
.gx-quiz { position: absolute; left: 0; right: 0; bottom: 0; top: 42%; z-index: 3; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; overflow-y: auto;
  background: linear-gradient(180deg, rgba(10, 15, 42, .55), rgba(10, 15, 42, .96) 18%); }
.gx-quiz-head { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.gx-quiz-sub { padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .1); color: var(--gx-paper); }
.gx-quiz-rev { padding: 2px 8px; border-radius: 999px; background: #5ad1ff; color: #06223a; font-weight: 700; }
.gx-quiz-lucky { padding: 2px 8px; border-radius: 999px; background: #ffd166; color: #3a2600; font-weight: 700; }
.gx-quiz-fuse { flex: 1; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.gx-quiz-fuse i { display: block; height: 100%; background: linear-gradient(90deg, #ff6b4a, #ffd166); }
.gx-quiz-q { margin: 2px 0; font-size: 16px; font-weight: 700; line-height: 1.55; color: var(--gx-paper); }
.gx-quiz-opts { display: grid; gap: 7px; }
.gx-quiz-opts button { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 12px; border-radius: 12px; border: 1.5px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .06); color: var(--gx-paper); text-align: left; font-size: 14.5px; cursor: pointer; }
.gx-quiz-opts button b { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .12); font-size: 12px; }
.gx-quiz-opts button:hover:not(:disabled) { border-color: var(--gx-c); }
.gx-quiz-opts button.ok { border-color: #3ccf7a; background: rgba(60, 207, 122, .18); }
.gx-quiz-opts button.bad { border-color: #ff6b6b; background: rgba(255, 107, 107, .16); }
.gx-quiz-why { font-size: 13.5px; line-height: 1.65; color: rgba(246, 236, 217, .85); }
.gx-quiz-next { align-self: stretch; }
.gx-quiz-tools { display: flex; gap: 8px; }
.gx-quiz-tools button { flex: 1; height: 34px; border-radius: 10px; border: 1px dashed rgba(255, 255, 255, .25); background: transparent; color: var(--gx-dim); font-size: 13px; cursor: pointer; }
.gx-quiz-tools button:disabled { opacity: .35; cursor: default; }
@media (max-width: 600px) {
  .gx-quiz { top: 36%; padding: 10px; gap: 6px; }
  .gx-quiz-q { font-size: 14.5px; }
  .gx-quiz-opts button { min-height: 38px; font-size: 13.5px; padding: 6px 10px; }
  .gx-quiz-why { font-size: 12.5px; }
}
.gx-grade-tag { margin: -6px 0 10px; text-align: center; font-size: 13px; color: var(--gx-c); }
