/**
 * 打字游戏独立样式（typing-game.css）
 * —— 从 tools.css 拆出（2026-10-25）：打字游戏（列表/挑战/赛车/文字消除）专用，
 *    不再混在全局工具样式里。页面通过 typing/game/typing_game_css.html 引用。
 * 依赖：tools.css 里的 --tgw-* 色彩变量（两文件同时加载）。
 * 升缓存号：改 template/.../typing/game/typing_game_css.html 一处。
 */

/* ── 游戏列表卡片 ── */
.tg-game-card { transition: transform .15s ease, box-shadow .15s ease; }
.tg-game-card:hover { transform: translateY(-2px); }
.tg-game-icon { width: 48px; height: 48px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.tg-game-soon { opacity: .88; }

/* ── 全屏游戏页框架（100dvh：手机浏览器地址栏收起时不把底部顶出屏幕） ── */
.tg-fullscreen { height: 100vh; height: 100dvh; overflow: hidden; background: var(--bs-body-bg); }
.tg-fullscreen .tg-game { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.tg-topbar { display: flex; align-items: center; gap: .5rem; padding: .6rem 1rem; border-bottom: 1px solid var(--bs-border-color); }
/* h1 语义但保持原导航栏视觉：尺寸回到正文级，避免 Bootstrap h1 默认大字号 */
.tg-topbar .tg-title { font-weight: 600; margin: 0 auto; font-size: 1rem; line-height: 1.4; font-family: inherit; }
.tg-btn { border: 1px solid transparent; background: transparent; border-radius: .5rem; padding: .35rem .6rem; color: var(--bs-body-color); cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; }
.tg-btn-ghost:hover { background: var(--bs-tertiary-bg); }

.tg-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.tg-panel-card { width: 100%; max-width: 420px; border: 1px solid var(--bs-border-color); border-radius: 1rem; padding: 1.5rem; background: var(--bs-body-bg); box-shadow: var(--bs-box-shadow-sm); }

/* ── 比赛区：HUD / 文章 / 输入 ── */
.tg-play { flex: 1; display: flex; flex-direction: column; padding: .75rem; gap: .6rem; min-height: 0; }
.tg-hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.tg-stat { text-align: center; border: 1px solid rgba(43,47,58,.18); border-radius: .75rem; padding: .45rem .25rem; background: linear-gradient(180deg, rgba(43,47,58,.05), rgba(43,47,58,.12)); box-shadow: inset 0 1px 0 rgba(255,255,255,.45); }
.tg-stat-val { display: block; font-size: 1.7rem; font-weight: 800; line-height: 1.05; color: #2b2f3a; font-variant-numeric: tabular-nums; }
.tg-stat-label { font-size: .7rem; color: #5b5f6b; text-transform: uppercase; letter-spacing: .04em; }
.tg-progress { height: .5rem; }
.tg-passage { position: relative; flex: 0 1 auto; overflow-y: auto; scroll-behavior: smooth; border: 1px solid var(--bs-border-color); border-radius: .75rem; padding: 1rem; font-size: 1.25rem; line-height: 2rem; background: var(--bs-tertiary-bg); height: 9rem; -webkit-user-select: none; user-select: none; }
.tg-char { transition: color .05s; }
.tg-char.ok { color: var(--bs-success); }
.tg-char.bad { color: var(--bs-danger); text-decoration: underline; }
.tg-char.cur { background: var(--tools-primary); color: var(--bs-white); border-radius: .2rem; }
.tg-input { font-size: 1.1rem; padding: .6rem .75rem; border: 1px solid var(--bs-border-color); border-radius: .5rem; width: 100%; }
.tg-input:focus { outline: none; border-color: var(--tools-primary); box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }

.tg-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; overflow-y: auto; }
/* 卡片 margin:auto：正常时居中；卡片高于视口时容器可滚动、顶部不被裁切 */
.tg-overlay-card { position: relative; width: 100%; max-width: 460px; margin: auto; border-radius: 1rem; padding: 1.5rem; background: var(--bs-body-bg); text-align: center; box-shadow: var(--bs-box-shadow); }
/* 浮层关闭按钮：右上角，点遮罩或此按钮均可关（等同「继续」语义） */
.tg-close-x { position: absolute; top: .7rem; right: .8rem; width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: transparent; color: inherit; opacity: .5; font-size: 1.05rem; line-height: 1; cursor: pointer; transition: opacity .15s, background .15s; }
.tg-close-x:hover { opacity: 1; background: rgba(128,128,128,.15); }
.tg-challenge .tg-close-x { color: #e8ecff; }

/* ── 玩法说明浮层（顶栏 ? 按钮打开，服务端渲染文字） ── */
.tg-help-card { max-height: calc(100% - 2rem); overflow-y: auto; }
.tg-help-list p { margin: 0 0 .5rem; font-size: .92rem; line-height: 1.55; color: var(--bs-body-color); }
.tg-help-list p:last-child { margin-bottom: 0; }
.tg-help-list b { color: var(--tgw-accent); margin-right: .4rem; }
/* 数据库富文本（cms_tool_data_1.content）渲染区 */
.tg-help-rich { text-align: left; font-size: .92rem; line-height: 1.6; color: var(--bs-body-color); }
.tg-help-rich h3 { font-size: 1.15rem; font-weight: 700; margin: 0 0 .6rem; }
.tg-help-rich h4 { font-size: 1rem; font-weight: 700; margin: .8rem 0 .4rem; }
.tg-help-rich p { margin: 0 0 .55rem; }
.tg-help-rich p:last-child { margin-bottom: 0; }
.tg-help-rich b, .tg-help-rich strong { color: var(--tgw-accent); }
.tg-help-rich img { max-width: 100%; height: auto; }
.tg-help-rich ul, .tg-help-rich ol { padding-left: 1.25rem; margin: 0 0 .55rem; }

/* ── 打字赛车：暗色竞速结算页（Nitro 风格：红色名次横幅 + 深色面板 + 明细行） ── */
.tg-result-card {
  position: relative;
  width: 100%; max-width: 480px;
  border-radius: 20px;
  padding: 1.6rem 1.5rem 1.4rem;
  background: linear-gradient(180deg, #2c3242 0%, #232838 100%);
  border: 3px solid #171b26;
  box-shadow: 0 .9rem 2.4rem rgba(10,14,24,.5);
  text-align: center;
  color: #e8ecff;
}
.tg-result-banner {
  display: block;
  background: linear-gradient(90deg, #e63946, #c1121f);
  color: #fff;
  font-weight: 800; letter-spacing: .04em;
  padding: .55rem 1.2rem; border-radius: .8rem;
  font-size: 1.2rem; margin: 0 0 .7rem;
  box-shadow: 0 .35rem 1rem rgba(198,40,40,.35);
}
.tg-result-banner.lose { background: linear-gradient(90deg, #4a5568, #2d3748); color: #cbd5e0; box-shadow: none; }
.tg-result-newbest {
  display: inline-block; margin-bottom: .65rem;
  background: linear-gradient(90deg, #ffb703, #fb8500); color: #1c2230; font-weight: 800;
  padding: .2rem .85rem; border-radius: 999px; font-size: .82rem;
  border: 2px solid rgba(255,255,255,.55);
  box-shadow: 0 .25rem .7rem rgba(251,133,0,.4);
}
.tg-result-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem;
  margin: 0 0 .8rem;
}
.tg-chip {
  background: rgba(255,255,255,.07);
  border: 2px solid rgba(255,255,255,.12);
  border-radius: 12px; padding: .55rem .2rem;
}
.tg-chip-val { display: block; font-size: 1.35rem; font-weight: 800; color: #fff; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tg-chip-label { font-size: .7rem; color: #9aa3b8; }
/* 速度单位（WPM/CPM）与统计值同行，小号弱化 */
.tg-stat-unit { font-size: .58em; font-weight: 700; margin-left: .18rem; opacity: .7; letter-spacing: .02em; }
/* 明细行（进度/正确字符/错误次数/对比最佳） */
.tg-result-rows {
  text-align: left;
  background: rgba(0,0,0,.22);
  border-radius: .9rem;
  padding: .5rem .9rem;
  margin: 0 0 1.1rem;
}
.tg-rrow {
  display: flex; justify-content: space-between; align-items: center;
  padding: .34rem 0;
  border-bottom: 1px solid rgba(255,255,255,.07);
  font-size: .9rem;
}
.tg-rrow:last-child { border-bottom: 0; }
.tg-rrow span { color: #9aa3b8; }
.tg-rrow b { color: #fff; font-variant-numeric: tabular-nums; font-weight: 700; }
.tg-rrow b.good { color: #4ade80; }
.tg-rrow b.bad { color: #ff6b6b; }
.tg-result-btns { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.tg-result-card .btn { font-weight: 700; }
/* Race Again：红色主按钮（Nitro 风） */
.tg-again {
  background: linear-gradient(90deg, #e63946, #c1121f);
  border: none; color: #fff; font-weight: 800;
  padding: .55rem 1.4rem;
  box-shadow: 0 .35rem .9rem rgba(198,40,40,.35);
}
.tg-again:hover { filter: brightness(1.08); color: #fff; }
.tg-result-card .btn-outline-primary { color: #9fc3ff; border-color: rgba(159,195,255,.4); }
.tg-result-card .btn-outline-primary:hover { color: #fff; background: rgba(159,195,255,.15); }
.tg-result-card .btn-outline-secondary { color: #9aa3b8; border-color: rgba(154,163,184,.4); }
.tg-result-card .btn-outline-secondary:hover { color: #fff; border-color: #9aa3b8; }

/* ── 打字赛车：进度条赛道 ── */
.tg-track { display: flex; flex-direction: column; gap: .4rem; }
.tg-track-row { display: flex; align-items: center; gap: .5rem; }
.tg-track-label { width: 3.5rem; flex: none; font-size: .8rem; color: var(--bs-secondary-color); text-align: right; }
.tg-track-bar { position: relative; flex: 1; height: 1.1rem; background: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color); border-radius: 999px; overflow: visible; }
.tg-track-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; transition: width .12s linear; }
.tg-track-fill.you { background: var(--tools-primary, #0d6efd); }
.tg-track-fill.ghost { background: var(--bs-secondary-color); opacity: .6; }
.tg-car { position: absolute; top: 50%; transform: translate(-50%, -50%); font-size: 1.1rem; transition: left .12s linear; }

/* ── 打字赛车：Canvas 2D 赛道表现层 —— 画布作为主视觉中心（常驻，开始面板浮在其上） ── */
.tg-racer { position: relative; border-radius: 1rem; overflow: hidden; box-shadow: 0 .4rem 1rem rgba(58,67,96,.18); background: #bfe3ff; flex: 0 0 auto; }
.tg-canvas { display: block; width: 100%; height: 46vh; min-height: 260px; max-height: 460px; }
.tg-start-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: rgba(23,32,56,.30);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.tg-start-overlay[hidden] { display: none; }
.tg-start-overlay .tg-panel-card { max-width: 400px; box-shadow: 0 1rem 2.5rem rgba(20,28,52,.35); }
.tg-racer-legend { display: flex; justify-content: space-between; padding: .4rem .7rem .55rem; font-size: .82rem; font-weight: 700; }
.tg-dot.you { color: var(--tgw-accent); }
.tg-dot.ghost { color: #5b6478; }
.tg-type-hint { text-align: center; font-size: .85rem; color: var(--tgw-ink); opacity: .82; }
.tg-type-hint .fa { margin-right: .3rem; }
.tg-passage { scrollbar-width: none; }
.tg-passage::-webkit-scrollbar { display: none; }
.tg-passage .tg-char { border-radius: .4rem; transition: background .1s, color .1s; }
.tg-passage .tg-char.dim { opacity: .4; }

/* 跟打模式：自然段落排版（当前字由 JS 平滑居中） */
.tg-passage { scrollbar-width: none; }
.tg-passage::-webkit-scrollbar { display: none; }

/* 真实输入框幕后接管按键（视觉由各行的输入槽呈现） */
.tg-play #tg_input { position: absolute; width: 1px; height: 1px; opacity: 0; padding: 0; border: 0; pointer-events: none; }
.tg-passage .tg-char.ok { color: var(--bs-success, #198754); background: rgba(25,135,84,.12); }
.tg-passage .tg-char.bad { color: #fff; background: var(--bs-danger, #dc3545); text-decoration: line-through; }
.tg-passage .tg-char.cur { background: var(--tgw-accent); color: #fff; box-shadow: 0 0 0 .18rem rgba(108,140,255,.35); }

/* ── 移动端：HUD 不遮挡赛道、输入框易操作 ── */
@media (max-width: 600px) {
  .tg-canvas { height: 38vh; min-height: 200px; max-height: 320px; }
  .tg-hud { grid-template-columns: repeat(2, 1fr); }
  .tg-stat-val { font-size: 1.4rem; }
  .tg-input { font-size: 1.15rem; padding: .8rem 1rem; }
  .tg-passage { font-size: 1.1rem; line-height: 1.8rem; padding: .8rem; height: 7.5rem; }
  .tg-racer-legend { font-size: .75rem; }
  .tg-type-hint { font-size: .78rem; }
}

/* ── 文字消除：柔和背景（仅文字消除游戏页） ── */
.tg-game#tg_game { background: linear-gradient(160deg, var(--tgw-grad-a) 0%, var(--tgw-grad-b) 100%); }

/* ── 共享：开始面板卡片更柔和 ── */
.tg-panel-card { box-shadow: 0 1rem 2.5rem rgba(58,67,96,.12); border-color: transparent; }

/* ── 共享：HUD 胶囊统计 ── */
.tg-hud { gap: .6rem; }
.tg-stat { border: none; border-radius: 1rem; background: var(--tgw-accent-soft); box-shadow: 0 .25rem .6rem rgba(58,67,96,.08); padding: .6rem .25rem; }
.tg-stat-val { color: var(--tgw-accent); }
.tg-stat-label { color: var(--tgw-ink); opacity: .7; }

/* ── 共享：输入框胶囊 ── */
.tg-input { border-radius: 999px; padding: .7rem 1.1rem; font-weight: 600; box-shadow: 0 .2rem .5rem rgba(58,67,96,.06); }

/* ── 共享：结算卡片 ── */
.tg-overlay-card { box-shadow: 0 1.5rem 4rem rgba(58,67,96,.25); border: none; }

/* ── 文字消除：下落区（明亮卡通场景：静态硬边地形 + 动态 2D 特效层） ── */
/* position:relative 必需：.tg-word 是绝对定位，缺了会以页面为基准从 HUD 顶部开始落；
   flex:1 让容器撑满 HUD 与输入框之间（否则高度为 0，白色面板不可见）；
   overflow:hidden 把云/草地裁进圆角。静态地形（山丘/草地/虚线）画在 ::before，
   动态特效（飘云/太阳光芒/上升光点）是模板里 #tg_fall 内的 .tg-fx 真实元素 ——
   词块由 JS 追加在其后、按树序必然画在上层，游戏逻辑只认 .tg-word，装饰层互不干扰；
   底部白色虚线与 JS 触底线（clientHeight - 28px）对齐，草地即「落区」。 */
.tg-fall {
  position: relative; flex: 1 1 auto; min-height: 0;
  border: none; border-radius: 1.25rem; overflow: hidden;
  background: linear-gradient(180deg, #bfe4ff 0%, #d3edff 36%, #e9f7ff 62%, #f2fbff 100%);
  box-shadow: inset 0 .25rem 1rem rgba(58,67,96,.06);
}
/* 静态地形：全部硬边色块（扁平卡通，不要模糊渐隐） */
.tg-fall::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background:
    /* 触底警戒虚线（与 JS 死亡线 h-28 对齐，画在最上层） */
    repeating-linear-gradient(90deg, rgba(255,255,255,0) 0 14px, rgba(255,255,255,.55) 14px 26px) 0 calc(100% - 28px) / 100% 3px no-repeat,
    /* 草丛小圆 ×3（硬边，抬在虚线上方的草地上） */
    radial-gradient(circle at center, #79b74e 0 62%, rgba(121,183,78,0) 62.5%) 10% calc(100% - 44px) / min(30px,7%) min(30px,7%) no-repeat,
    radial-gradient(circle at center, #79b74e 0 62%, rgba(121,183,78,0) 62.5%) 24% calc(100% - 52px) / min(24px,6%) min(24px,6%) no-repeat,
    radial-gradient(circle at center, #79b74e 0 62%, rgba(121,183,78,0) 62.5%) 78% calc(100% - 40px) / min(28px,6.5%) min(28px,6.5%) no-repeat,
    /* 前景草地条（落区），硬顶边 */
    linear-gradient(180deg, #96cb5c 0%, #86bd4b 100%) 0 100% / 100% min(90px,24%) no-repeat,
    /* 远处两座缓坡山丘（硬边圆顶） */
    radial-gradient(ellipse at center, #d9f2c0 0 66%, rgba(217,242,192,0) 66.6%) 14% 100% / min(56%,640px) min(46%,210px) no-repeat,
    radial-gradient(ellipse at center, #cfeeb2 0 66%, rgba(207,238,178,0) 66.6%) 88% 100% / min(48%,540px) min(40%,180px) no-repeat;
}

/* ── 文字消除：动态 2D 特效层（模板 #tg_fall 内 .tg-fx：飘云/太阳/光点） ── */
.tg-fx { position: absolute; inset: 0; display: block; pointer-events: none; }

/* 太阳：双色硬边圆 + 缓慢旋转的射线环 */
.fx-sun {
  position: absolute; top: 6%; right: 5%;
  width: min(110px, 18vw); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #ffec9d 0 44%, #ffd24d 45% 100%);
  box-shadow: 0 6px 0 rgba(240,180,60,.28);
}
.fx-rays {
  position: absolute; inset: -30%; border-radius: 50%;
  background: repeating-conic-gradient(rgba(255,205,70,.5) 0 6deg, rgba(255,205,70,0) 6deg 22.5deg);
  -webkit-mask: radial-gradient(circle, rgba(0,0,0,0) 0 52%, #000 53% 86%, rgba(0,0,0,0) 87%);
  mask: radial-gradient(circle, rgba(0,0,0,0) 0 52%, #000 53% 86%, rgba(0,0,0,0) 87%);
  animation: fx-spin 36s linear infinite;
}
@keyframes fx-spin { to { transform: rotate(360deg); } }

/* 云：胶囊 + 两团圆瓣，纯白硬边 + 硬投影，横向匀速飘过（负延迟错开相位） */
.fx-cloud {
  position: absolute; left: 0; width: 84px; height: 30px; border-radius: 999px;
  background: #fff; box-shadow: 0 5px 0 rgba(125,175,225,.3);
}
.fx-cloud::before, .fx-cloud::after {
  content: ''; position: absolute; background: #fff; border-radius: 50%; aspect-ratio: 1;
}
.fx-cloud::before { height: 130%; left: 14%; bottom: 32%; }
.fx-cloud::after  { height: 95%;  right: 15%; bottom: 28%; }
.fx-cloud.c1 { top: 13%; animation: fx-drift 70s linear infinite; animation-delay: -12s; }
.fx-cloud.c2 { top: 31%; width: 62px; height: 24px; animation: fx-drift 95s linear infinite; animation-delay: -60s; }
.fx-cloud.c3 { top: 5%;  width: 98px; height: 33px; animation: fx-drift 55s linear infinite; animation-delay: -33s; }
@keyframes fx-drift {
  from { transform: translateX(-170px); }
  to   { transform: translateX(calc(100vw + 60px)); }
}

/* 上升光点：白色小圆带光环，边升边淡出（花粉/萤光感） */
.fx-spark {
  position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.4);
  opacity: 0; animation: fx-rise 6s ease-in infinite;
}
.fx-spark.s1 { left: 12%; top: 58%; }
.fx-spark.s2 { left: 28%; top: 66%; animation-delay: -2s; }
.fx-spark.s3 { left: 55%; top: 62%; animation-delay: -3.2s; }
.fx-spark.s4 { left: 70%; top: 55%; animation-delay: -1.4s; }
.fx-spark.s5 { left: 88%; top: 64%; animation-delay: -4.5s; }
.fx-spark.s6 { left: 42%; top: 70%; animation-delay: -5.2s; }
@keyframes fx-rise {
  0%   { transform: translate(0, 0) scale(.6); opacity: 0; }
  15%  { opacity: .95; }
  60%  { opacity: .75; }
  100% { transform: translate(14px, -70px) scale(1); opacity: 0; }
}

/* ── 移动端顶栏：允许换行，按钮只留图标，优先保留 暂停/声音/帮助 ── */
@media (max-width: 480px) {
  .tg-topbar { flex-wrap: wrap; gap: .3rem; padding: .5rem .6rem; }
  .tg-topbar .tg-btn span { display: none; }
  .tg-topbar .tg-title { font-size: .9rem; margin: 0; }
  .tg-result-stats { grid-template-columns: repeat(2, 1fr); }
}

/* 系统减动效：关掉所有场景动画，静态画面保持可读 */
@media (prefers-reduced-motion: reduce) {
  .tg-fx .fx-cloud, .tg-fx .fx-rays, .tg-fx .fx-spark { animation: none; }
  .tg-fx .fx-spark { opacity: .45; }
  .tg-pop-bit { display: none; }   /* 爆裂粒子直接不生成动画 */
}

/* ── 文字消除：输入框可见（覆盖跟打模式的共享隐藏规则） ──
   跟打页 .tg-play #tg_input 把真实输入框藏进幕后（视觉由各行输入槽呈现）；
   文字消除页没有逐字槽，输入框必须以正常流显示在落字区下方，
   玩家才知道光标在哪、正在打什么。 */
.tg-wordpage .tg-play #tg_input {
  position: static; width: min(520px, 100%); height: auto; opacity: 1;
  pointer-events: auto; display: block; margin: .55rem auto 0;
  padding: .65rem 1.2rem;
  text-align: center; font-weight: 700; letter-spacing: .04em;
  background: rgba(255,255,255,.92);
  border: 2px solid rgba(108,140,255,.4);
  color: var(--tgw-ink); caret-color: var(--tgw-accent);
  border-radius: 999px;
  box-shadow: 0 .3rem .8rem rgba(58,67,96,.12);
}
.tg-wordpage .tg-play #tg_input::placeholder { color: #8b93ab; font-weight: 600; }
.tg-wordpage .tg-play #tg_input:focus {
  outline: none;
  border-color: var(--tgw-accent);
  box-shadow: 0 0 0 .28rem rgba(108,140,255,.25), 0 .3rem .8rem rgba(58,67,96,.12);
}
.tg-wordpage .tg-play #tg_input:disabled { opacity: .6; }

/* ── 文字消除：全屏自适应 ── */
/* 矮屏（横屏手机等）：压缩顶栏/HUD/输入框，HUD 改单行 6 列，把高度尽量留给落字区 */
@media (max-height: 480px) {
  .tg-topbar { padding: .2rem .6rem; }
  .tg-wordpage .tg-hud { grid-template-columns: repeat(6, 1fr); gap: .35rem; }
  .tg-stat { padding: .2rem .15rem; border-radius: .6rem; }
  .tg-stat-val { font-size: 1rem; }
  .tg-stat-label { font-size: .55rem; }
  .tg-wordpage .tg-play #tg_input { margin-top: .35rem; padding: .4rem .9rem; font-size: 1rem; }
  .tg-fall { border-radius: .9rem; }
}
/* 超大屏（≥1600px）：HUD 数字/词牌/输入框适度放大，避免铺满后显得空洞 */
@media (min-width: 1600px) {
  .tg-wordpage .tg-stat-val { font-size: 2.2rem; }
  .tg-wordpage .tg-stat { padding: .8rem .25rem; }
  .tg-wordpage .tg-word { font-size: 1.45rem; }
  .tg-wordpage .tg-play #tg_input { font-size: 1.15rem; padding: .8rem 1.4rem; }
}

/* ── 文字消除：圆润字母块（LetterEase 风） ── */
.tg-word {
  position: absolute; top: 0;
  padding: .4rem .95rem;
  border-radius: 999px;
  font-size: 1.25rem; font-weight: 700;
  background: linear-gradient(180deg, #ffffff, var(--tgw-cream));
  border: 1.5px solid #eadfe6;
  color: var(--tgw-ink);
  box-shadow: 0 .3rem .7rem rgba(58,67,96,.12);
  white-space: nowrap; will-change: top, transform;
  transform: rotate(var(--tilt, 0deg));   /* JS 每词注入随机微倾角 */
  animation: tgw-pop .28s cubic-bezier(.18,.89,.32,1.28);
}
.tg-word.target {
  border-color: var(--tgw-accent);
  color: var(--tgw-accent);
  background: var(--tgw-accent-soft);
  box-shadow: 0 0 0 .28rem rgba(108,140,255,.28);
  transform: scale(1.05) rotate(var(--tilt, 0deg));
}
/* ── 文字消除：词牌随机皮肤 ×5（JS 生成时随机加 .v1~.v5，图案各异、墨色字不变） ── */
.tg-word.v1 {   /* 奶油底 + 淡金圆点 */
  background: radial-gradient(circle, rgba(255,205,90,.5) 0 3px, rgba(255,205,90,0) 3.5px) 0 0 / 14px 14px, linear-gradient(180deg, #ffffff, var(--tgw-cream));
  border-color: #f3e2c8; box-shadow: 0 .3rem .7rem rgba(196,150,70,.18);
}
.tg-word.v2 {   /* 薄荷底 + 白色斜纹 */
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.65) 0 6px, rgba(255,255,255,0) 6px 12px), linear-gradient(180deg, #e9faf1, #d7f5e6);
  border-color: #b9e6cd; box-shadow: 0 .3rem .7rem rgba(74,160,110,.18);
}
.tg-word.v3 {   /* 柠檬底 + 白色细横纹 */
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.55) 0 4px, rgba(255,255,255,0) 4px 10px), linear-gradient(180deg, #fff9dc, #ffefad);
  border-color: #f2dd8a; box-shadow: 0 .3rem .7rem rgba(200,165,60,.2);
}
.tg-word.v4 {   /* 樱花粉 + 白色竖糖条纹 */
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.6) 0 5px, rgba(255,255,255,0) 5px 11px), linear-gradient(180deg, #fff1f6, #ffdde9);
  border-color: #f6c3d8; box-shadow: 0 .3rem .7rem rgba(214,110,155,.18);
}
.tg-word.v5 {   /* 天空蓝 + 白色棋盘小格 */
  background: repeating-conic-gradient(rgba(255,255,255,.55) 0 25%, rgba(255,255,255,0) 0 50%) 0 0 / 12px 12px, linear-gradient(180deg, #eef5ff, #dbe9ff);
  border-color: #bcd4ff; box-shadow: 0 .3rem .7rem rgba(90,130,210,.18);
}
.tg-word.hit { animation: tgw-hit .4s cubic-bezier(.3,1.4,.5,1) forwards; }
@keyframes tgw-pop { from { transform: scale(.6) rotate(var(--tilt, 0deg)); opacity: 0; } to { transform: scale(1) rotate(var(--tilt, 0deg)); opacity: 1; } }
/* 消除：先弹大再缩没（回弹曲线，配合爆裂粒子） */
@keyframes tgw-hit {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.25) rotate(-5deg); }
  100% { transform: scale(0) rotate(10deg); opacity: 0; }
}

/* ── 文字消除：接近底部的词语红色警戒（JS 在 y > 70% 高度时加 .danger） ── */
.tg-word.danger {
  border-color: #e5484d;
  color: #c92a2a;
  background: linear-gradient(180deg, #fff, #ffe3e3);
  box-shadow: 0 0 0 .25rem rgba(229, 72, 77, .16);
}
.tg-word.danger { animation: tgw-pop .28s cubic-bezier(.18,.89,.32,1.28), tgw-danger-pulse .7s ease-in-out .28s infinite; }
@keyframes tgw-danger-pulse { 50% { transform: scale(1.07) rotate(var(--tilt, 0deg)); } }
/* 红色警戒中的词被消除：hit 动画要盖过 danger 的循环脉冲（同优先级靠后声明） */
.tg-word.danger.hit { animation: tgw-hit .4s cubic-bezier(.3,1.4,.5,1) forwards; }

/* ── 文字消除：词语触底时的落区红闪（画在 ::before 上，否则被场景层盖住） ── */
.tg-fall.miss::before { box-shadow: inset 0 0 0 3px rgba(229, 72, 77, .5); }

/* ── 文字消除：触底的词沉进草地消失（下坠 + 淡出，配合红闪） ── */
.tg-word.sunk { animation: tgw-sink .33s ease-in forwards; }
@keyframes tgw-sink { to { transform: translateY(70px) scale(.7); opacity: 0; } }

/* ── 文字消除：消除爆裂粒子（命中词中心向外炸开的小圆点，JS 注入 --dx/--dy） ── */
.tg-pop-bit {
  position: absolute; width: 8px; height: 8px; border-radius: 50%;
  pointer-events: none; z-index: 2;
  animation: tgw-burst .6s cubic-bezier(.16,.84,.44,1) forwards;
}
@keyframes tgw-burst {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  70%  { opacity: .9; }
  100% { transform: translate(var(--dx, 0px), var(--dy, -30px)) scale(.25); opacity: 0; }
}

/* ── 文字消除：消除处飘分（+N） ── */
.tg-score-pop {
  position: absolute;
  font-size: 1rem;
  font-weight: 800;
  color: var(--tgw-accent);
  pointer-events: none;
  white-space: nowrap;
  animation: tgw-rise .6s ease-out forwards;
}
@keyframes tgw-rise { to { transform: translateY(-30px); opacity: 0; } }

/* ── 文字消除：HUD 六项（得分/等级/生命/连击/准确率/时间）与连击跳动 ── */
#tg_play .tg-hud { grid-template-columns: repeat(6, 1fr); }
.tg-stat-val.bump { animation: tgw-bump .25s ease; }
@keyframes tgw-bump { 40% { transform: scale(1.28); } }

/* 时间进度条：位于 HUD 下方，不占用词语下落区 */
.tg-timelinerow {
  height: 6px; border-radius: 999px; overflow: hidden;
  background: rgba(108,140,255,.16);
  box-shadow: inset 0 0 0 1px rgba(108,140,255,.12);
}
.tg-timelinerow-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #6c8cff, #46c08a);
  transition: width .12s linear;
}
.tg-timelinerow-fill.low { background: linear-gradient(90deg, #ff8a4c, #ff5a5f); }

/* .danger 的常驻脉冲不得盖过消除动画：后置重申 .hit */
.tg-word.hit { animation: tgw-hit .26s ease forwards; }

@media (max-width: 575.98px) {
  /* 六项统计在两列网格里：第五、六项（准确率/时间）各占满一行，避免半宽孤行 */
  #tg_play .tg-stat:nth-child(5),
  #tg_play .tg-stat:nth-child(6) { grid-column: 1 / -1; }
}

/* ── 太空射击：明亮卡通场景主题（仅作用于 .tg-space；
      带 #tg_game 提升优先级，压过「文字消除柔和背景」的 .tg-game#tg_game 渐变） ── */
.tg-game.tg-space#tg_game { background: #bfe4ff; color: #16324f; }
.tg-space .tg-topbar { border-bottom: 1px solid rgba(21,60,110,.12); background: rgba(255,255,255,.85); }
.tg-space .tg-btn { color: #2b517d; }
.tg-space .tg-btn-ghost:hover { background: rgba(43,81,125,.10); }

/* 开始 / 暂停 / 结算卡片：沿用浅色白卡，仅加天空色描边 */
.tg-space .tg-panel-card,
.tg-space .tg-overlay-card { border: 1px solid rgba(43,81,125,.14); }

/* 比赛区：画布铺满，HUD 与输入框悬浮其上 */
.tg-space .tg-play { position: relative; padding: .6rem; }
.tg-space .tg-canvas-wrap {
  position: absolute; inset: .6rem; overflow: hidden;
  border-radius: 1rem;
  background: #bfe4ff;
  box-shadow: 0 .5rem 1.6rem rgba(31,71,120,.25);
}
.tg-space .tg-canvas-wrap canvas { width: 100%; height: 100%; display: block; }

/* HUD：白色悬浮胶囊条 */
.tg-space .tg-hud {
  position: absolute; top: 1.15rem; left: 50%; transform: translateX(-50%);
  z-index: 3; display: flex; gap: 1.1rem; align-items: center;
  padding: .45rem 1.2rem; border-radius: 999px;
  background: rgba(255,255,255,.82);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.95);
  box-shadow: 0 .35rem 1.1rem rgba(31,71,120,.22);
}
.tg-space .tg-stat { display: flex; align-items: baseline; gap: .35rem; text-align: left; border: 0; background: none; box-shadow: none; padding: 0; }
.tg-space .tg-stat-val { font-size: 1.15rem; color: #16324f; }
.tg-space .tg-stat-label { font-size: .68rem; color: #5a7ea6; }
.tg-space .tg-stat-val.bump { animation: tgw-bump .25s ease; }

/* 时间进度线：嵌在 HUD 胶囊底部，不遮挡游戏区 */
.tg-space .tg-timebar {
  position: absolute; left: .9rem; right: .9rem; bottom: .3rem;
  height: 3px; border-radius: 999px;
  background: rgba(43,81,125,.15); overflow: hidden;
}
.tg-space .tg-timebar-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #6c8cff, #46c08a);
  transition: width .12s linear;
}
.tg-space .tg-timebar-fill.low { background: linear-gradient(90deg, #ff8a4c, #ff5a5f); }

/* 输入框：白色悬浮胶囊（必须带 #tg_input 提升优先级，
   否则被「跟打模式隐藏输入框」的 .tg-play #tg_input 规则隐藏） */
.tg-space .tg-play #tg_input {
  position: absolute; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  z-index: 3; width: min(520px, calc(100% - 2.4rem)); height: auto; opacity: 1;
  background: rgba(255,255,255,.88);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1.5px solid rgba(43,81,125,.25);
  color: #16324f; border-radius: 999px; padding: .7rem 1.2rem; text-align: center;
  box-shadow: 0 .35rem 1.1rem rgba(31,71,120,.22);
  pointer-events: auto;
}
.tg-space .tg-play #tg_input::placeholder { color: #7d97b5; }
.tg-space .tg-play #tg_input:focus {
  outline: none;
  border-color: var(--tgw-accent);
  box-shadow: 0 0 0 .25rem rgba(108,140,255,.30), 0 .35rem 1.1rem rgba(31,71,120,.22);
}

@media (max-width: 600px) {
  .tg-space .tg-hud { gap: .6rem; padding: .35rem .8rem; max-width: calc(100% - 1.6rem); flex-wrap: wrap; justify-content: center; }
  .tg-space .tg-stat-val { font-size: 1rem; }
  .tg-space .tg-stat-label { font-size: .6rem; }
  .tg-space .tg-play #tg_input { bottom: .8rem; padding: .75rem 1rem; font-size: 1.1rem; }
}

/* ── 游戏战绩页：身份概览 / 筛选 / 表格 ── */
.tg-records-body { flex: 1; overflow-y: auto; padding: 1rem; }
.tg-records-identity {
  border: 1px solid rgba(108,140,255,.18); border-radius: 1rem;
  background: var(--tgw-accent-soft); padding: .9rem 1rem;
}
.tg-records-id { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .6rem; }
.tg-records-id-label { font-size: .75rem; color: var(--tgw-ink); opacity: .7; }
.tg-records-id-name { font-weight: 700; font-size: 1.05rem; color: var(--tgw-ink); }
.tg-records-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.tg-records-filters { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; }
.tg-records-filter { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.tg-records-filter-label { font-size: .75rem; color: var(--tgw-ink); opacity: .7; }
.tg-records-card {
  border: 1px solid rgba(108,140,255,.16); border-radius: 1rem;
  background: var(--bs-body-bg); box-shadow: var(--bs-box-shadow-sm); overflow: hidden;
}
.tg-records-card-head {
  padding: .7rem 1rem; font-weight: 700; font-size: 1rem;
  border-bottom: 1px solid rgba(108,140,255,.14); background: rgba(108,140,255,.06);
}
.tg-records-table { font-size: .9rem; }
.tg-records-table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--tgw-ink); opacity: .65; font-weight: 600; white-space: nowrap; }
.tg-records-table tbody td { vertical-align: middle; }
.tg-records-table th, .tg-records-table td { padding-left: .7rem; padding-right: .7rem; white-space: nowrap; }
.tg-records-my-rank { color: var(--tgw-accent); font-weight: 600; }
.tg-records-pager { display: flex; align-items: center; justify-content: center; gap: .5rem; padding: .6rem; }
.tg-records-page-now { font-size: .85rem; color: var(--tgw-ink); opacity: .75; font-variant-numeric: tabular-nums; }
@media (max-width: 575.98px) {
  .tg-records-stats { grid-template-columns: repeat(2, 1fr); }
  .tg-records-body { padding: .75rem; }
}

/* 修改昵称/设置身份弹窗：表单左对齐（覆盖 .tg-overlay-card 的居中） */
.tg-name-card { text-align: left; }
.tg-name-card .form-label, .tg-name-card .form-text { text-align: left; margin-bottom: .35rem; }
/* 性别单选：完全自定义结构，不依赖 Bootstrap form-check（避免绝对定位级联冲突导致堆叠） */
.tg-gender-row { display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; }
.tg-gender-opt { display: inline-flex; align-items: center; gap: .45rem; margin: 0; cursor: pointer; }
.tg-gender-opt input[type="radio"] {
  appearance: auto; -webkit-appearance: radio;
  position: static; float: none; margin: 0; flex: none;
  width: 1rem; height: 1rem; accent-color: var(--tools-primary, #0d6efd);
}
.tg-gender-opt span { white-space: nowrap; line-height: 1.6; }

/* 顶栏难度徽标：自动开局后一眼看到当前档位 */
.tg-badge {
  display: inline-block; margin-left: .4rem; padding: .05rem .5rem;
  border-radius: 999px; font-size: .7rem; font-weight: 600;
  background: var(--tgw-accent-soft); color: var(--tgw-accent);
  vertical-align: middle;
}

/* ── 限时挑战：深色竞技主题（仅作用于 .tg-challenge） ── */
.tg-game.tg-challenge#tg_game {
  position: relative;
  background:
    /* 星点（错落小光点） */
    radial-gradient(1.5px 1.5px at 8% 18%, rgba(255,255,255,.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 42%, rgba(255,255,255,.35) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 35% 12%, rgba(255,255,255,.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 30%, rgba(255,255,255,.3) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 68% 16%, rgba(255,255,255,.45) 50%, transparent 51%),
    radial-gradient(1px 1px at 82% 38%, rgba(255,255,255,.3) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 92% 12%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 44% 55%, rgba(255,255,255,.25) 50%, transparent 51%),
    /* 星云光晕（紫色只做氛围，不铺满） */
    radial-gradient(55% 42% at 80% 6%, rgba(122,82,255,.26), transparent 70%),
    radial-gradient(45% 38% at 10% 90%, rgba(76,111,255,.16), transparent 70%),
    /* 深海军蓝底 + 底部地平光 */
    linear-gradient(180deg, #070b1d 0%, #0a1030 55%, #131c4a 100%);
  color: #e8ecff;
}
/* 装饰行星（右上角，纯 CSS，不加载图片） */
.tg-game.tg-challenge#tg_game::before {
  content: ''; position: absolute; top: -140px; right: -100px;
  width: 380px; height: 380px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #31408f 0%, #1a2560 55%, #0c1236 100%);
  box-shadow: 0 0 90px rgba(96,116,255,.28), inset -26px -26px 70px rgba(0,0,0,.55);
  pointer-events: none;
}
.tg-challenge > * { position: relative; z-index: 1; }
/* 浮层例外：设置/暂停/结算需要全屏 fixed 居中，不能被子元素规则压回文档流 */
.tg-challenge > .tg-overlay { position: fixed; }
.tg-challenge .tg-topbar { border-bottom: 1px solid rgba(108,140,255,.16); background: rgba(8,12,32,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.tg-challenge .tg-topbar .tg-title { color: #e8ecff; }
.tg-challenge .tg-btn { color: #c7cdea; }
.tg-challenge .tg-btn-ghost:hover { background: rgba(108,140,255,.14); color: #fff; }

/* 开始卡片：深色面板 */
.tg-challenge .tg-panel-card {
  background: linear-gradient(180deg, rgba(22,31,66,.95), rgba(13,19,44,.95));
  color: #e8ecff;
  border: 1px solid rgba(108,140,255,.22);
  box-shadow: 0 1.4rem 3rem rgba(3,6,20,.6);
}
.tg-challenge .tg-panel-card .text-muted { color: #8b93c4 !important; }
.tg-challenge .form-label { color: #c7cdea; }
.tg-challenge-tag {
  display: inline-block; margin-bottom: .5rem; padding: .2rem .7rem;
  border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  color: #fff; background: linear-gradient(90deg, #4c6fff, #8a5cff);
}
.tg-challenge .btn-outline-primary { color: #8b93c4; border-color: rgba(108,140,255,.35); }
.tg-challenge .btn-outline-primary:hover { color: #fff; background: rgba(76,99,255,.25); border-color: rgba(108,140,255,.5); }
.tg-challenge .btn-check:checked + .btn-outline-primary {
  color: #fff; border-color: transparent;
  background: linear-gradient(90deg, #4c6fff, #8a5cff);
}
/* 时长三选一：卡片式大按钮 */
.tg-dur-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.tg-dur-chip {
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  padding: .6rem .2rem; border-radius: .85rem; cursor: pointer;
  border: 2px solid rgba(108,140,255,.25);
  background: rgba(76,99,255,.08); color: #e8ecff;
  font-weight: 700; transition: all .12s ease;
}
.tg-dur-chip b { font-size: 1.25rem; line-height: 1; }
.tg-dur-chip small { font-size: .68rem; opacity: .7; font-weight: 600; }
.tg-dur-chip:hover { border-color: rgba(108,140,255,.6); }
.tg-dur-row .btn-check:checked + .tg-dur-chip {
  border-color: transparent;
  background: linear-gradient(135deg, #4c6fff, #8a5cff); color: #fff;
  box-shadow: 0 .35rem .9rem rgba(76,99,255,.4);
}
.tg-dur-row .btn-check:checked + .tg-dur-chip small { opacity: .85; }
.tg-challenge-start {
  background: linear-gradient(90deg, #4c6fff, #8a5cff);
  border: none; color: #fff; font-weight: 700;
  box-shadow: 0 .5rem 1.2rem rgba(76,99,255,.4);
}
.tg-challenge-start:hover { filter: brightness(1.1); color: #fff; }

/* 比赛区：一条紧凑 HUD + 独立深色文字面板 */
.tg-challenge .tg-play { gap: .7rem; }
.tg-challenge-top { display: flex; align-items: stretch; gap: .6rem; }
/* 计时卡：环 + 剩余时间 */
.tg-tcard {
  display: flex; align-items: center; gap: .6rem; flex: none;
  padding: .35rem .9rem .35rem .35rem;
  background: linear-gradient(180deg, rgba(23,32,68,.92), rgba(14,21,48,.92));
  border: 1px solid rgba(108,140,255,.2); border-radius: .9rem;
  box-shadow: 0 .4rem 1.2rem rgba(3,6,20,.4);
}
.tg-timering { position: relative; width: 52px; height: 52px; flex: none; }
.tg-timer-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.tg-timer-bg { fill: none; stroke: rgba(76,99,255,.22); stroke-width: 7; }
.tg-timer-arc {
  fill: none; stroke: #4cc3ff; stroke-width: 7; stroke-linecap: round;
  stroke-dasharray: 213.628; stroke-dashoffset: 0;
  transition: stroke-dashoffset .12s linear, stroke .2s ease;
}
.tg-timer-arc.low { stroke: #ff5a6a; }
.tg-timer-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .92rem; font-variant-numeric: tabular-nums; color: #e8ecff;
}
.tg-tlabel { font-size: .68rem; color: #8b93c4; white-space: nowrap; }
/* 统计卡：图标 + 数值压缩成一行 */
.tg-challenge #tg_play .tg-hud { flex: 1; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.tg-challenge .tg-stat {
  display: flex; align-items: center; gap: .55rem; text-align: left;
  padding: .5rem .75rem;
  background: linear-gradient(180deg, rgba(23,32,68,.92), rgba(14,21,48,.92));
  border: 1px solid rgba(108,140,255,.2); border-radius: .9rem;
  box-shadow: 0 .4rem 1.2rem rgba(3,6,20,.4);
}
.tg-sico {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .85rem; color: #6f8bff;
  background: rgba(76,99,255,.16);
  box-shadow: inset 0 0 0 1px rgba(108,140,255,.25);
}
.tg-challenge .tg-stat-val { font-size: 1.3rem; color: #fff; line-height: 1.05; }
.tg-challenge .tg-stat-label { font-size: .66rem; color: #8b93c4; white-space: nowrap; }
.tg-sbody { min-width: 0; }

/* 文字面板：头部「正在输入」+ 目标文字 + 进度，聚焦感 */
.tg-textpanel {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  position: relative;   /* 幽灵输入框与飘分弹层的定位锚点 */
  background: linear-gradient(180deg, rgba(20,28,60,.94), rgba(12,18,42,.94));
  border: 1px solid rgba(108,140,255,.22); border-radius: 1rem;
  padding: .85rem 1.1rem .95rem;
  box-shadow: 0 .6rem 1.6rem rgba(3,6,20,.45), inset 0 1px 0 rgba(255,255,255,.05);
  transition: border-color .15s ease, box-shadow .15s ease;
}
/* 连击火热 / 错字反馈转移到面板本体（可见输入框已移除） */
.tg-textpanel.combo { border-color: rgba(76,195,255,.55); box-shadow: 0 0 24px rgba(76,195,255,.14), 0 .6rem 1.6rem rgba(3,6,20,.45); }
.tg-textpanel.err { border-color: rgba(255,90,106,.65); animation: tgc-shake .22s ease; }
@keyframes tgc-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.tg-text-head { display: flex; align-items: center; gap: .45rem; font-size: .78rem; color: #8b93c4; margin-bottom: .55rem; }
.tg-text-head .fa { color: #4cc3ff; }
.tg-counter { margin-left: auto; font-variant-numeric: tabular-nums; color: #6f8bff; font-weight: 700; }
.tg-challenge .tg-passage {
  flex: 0 1 auto; height: auto; min-height: 0; max-height: 14.4rem;   /* 自适应内容，封顶约 6 行：不再出现大片空白 */
  overflow-y: auto; overscroll-behavior: contain;
  background: transparent; border: none; box-shadow: none;
  color: #c7cdea; font-size: 1.45rem; line-height: 2.4rem; padding: .4rem .2rem;
  cursor: text;   /* 段落即输入面：点任意处回到输入 */
}
.tg-challenge .tg-passage::-webkit-scrollbar { width: 6px; }
.tg-challenge .tg-passage::-webkit-scrollbar-thumb { background: rgba(108,140,255,.35); border-radius: 999px; }
.tg-challenge .tg-passage .tg-char.ok { color: #4cc3ff; background: transparent; }
.tg-challenge .tg-passage .tg-char.bad { color: #ff5a6a; background: rgba(255,90,106,.12); text-decoration: none; }
.tg-challenge .tg-passage .tg-char.cur {
  background: #4cc3ff; color: #06102a;
  box-shadow: 0 0 12px rgba(76,195,255,.55);
}
.tg-progress-row { margin-top: auto; padding-top: .7rem; }   /* 进度条钉面板底脚，剩余空间留在段落与进度之间 */
.tg-challenge .tg-progress { height: .4rem; background: rgba(76,99,255,.18); border-radius: 999px; }
.tg-challenge .tg-progress .progress-bar {
  background: linear-gradient(90deg, #4cc3ff, #6f8bff); border-radius: 999px;
  transition: width .12s linear;
}

/* 输入框：面板内、紧贴段落正下方的发光胶囊（聚焦时青色描边） */
.tg-inputwrap {
  position: relative; flex: none;
  display: flex; align-items: center; gap: .6rem;
  margin-top: .8rem;
  padding: .75rem 1.1rem; border-radius: .9rem;
  background: rgba(15,22,50,.9);
  border: 1px solid rgba(76,195,255,.35);
  box-shadow: 0 .4rem 1.2rem rgba(3,6,20,.4);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.tg-inputwrap > .fa { color: #4cc3ff; font-size: .95rem; }
.tg-inputwrap:focus-within {
  border-color: #4cc3ff;
  box-shadow: 0 0 0 .18rem rgba(76,195,255,.18), 0 .4rem 1.2rem rgba(3,6,20,.4);
}
/* 幽灵输入框：真实焦点/IME 载体，视觉不可见；left/top 由 JS 按光标位置写入 */
.tg-challenge .tg-play #tg_input {
  position: absolute; width: 2px; height: 2.2rem; opacity: 0;
  margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none;
  pointer-events: none; caret-color: #4cc3ff;
}

/* 连击飘分：从面板底部（原输入框位置）弹出 +N ×倍率 */
.tg-combo-pop {
  position: absolute; left: 50%; bottom: 2.9rem; transform: translateX(-50%);
  font-weight: 800; font-size: 1.05rem; color: #4cc3ff; pointer-events: none;
  text-shadow: 0 2px 8px rgba(3,6,20,.8); white-space: nowrap; z-index: 3;
  animation: tgc-pop .55s ease-out forwards;
}
.tg-combo-pop .x { font-size: .8rem; color: #8a5cff; margin-left: .15rem; }
@keyframes tgc-pop {
  0% { transform: translate(-50%, 6px) scale(.8); opacity: 0; }
  25% { transform: translate(-50%, -2px) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -26px) scale(1); opacity: 0; }
}

/* HUD 数字跳动 */
.tg-challenge .tg-stat-val.bump { animation: tgw-bump .25s ease; }

/* 低压呼吸脉冲：最后 10% 计时数字放大呼吸，提示时间紧迫 */
.tg-timer-num.pulse { animation: tgc-pulse .5s ease-in-out infinite; color: #ff5a6a; }
@keyframes tgc-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.22); }
}

/* 暂停/结算浮层：深色面板 */
.tg-challenge .tg-overlay { background: rgba(4,7,20,.78); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.tg-challenge .tg-overlay-card {
  color: #e8ecff;
  background: linear-gradient(180deg, rgba(22,31,66,.97), rgba(13,19,44,.97));
  border: 1px solid rgba(108,140,255,.22);
  box-shadow: 0 1.5rem 4rem rgba(3,6,20,.6);
}
.tg-challenge .tg-overlay-card .text-muted { color: #8b93c4 !important; }
.tg-challenge .btn-outline-secondary { color: #8b93c4; border-color: rgba(139,147,196,.4); }
.tg-challenge .btn-outline-secondary:hover { color: #fff; border-color: #8b93c4; }
.tg-result-tag {
  display: inline-block; margin-bottom: .5rem; padding: .2rem .8rem;
  border-radius: 999px; font-size: .72rem; font-weight: 700;
  color: #fff; background: linear-gradient(90deg, #4c6fff, #8a5cff);
}
.tg-challenge .tg-result-newbest {
  display: inline-block; margin-bottom: .6rem; padding: .2rem .85rem;
  border-radius: 999px; font-size: .82rem; font-weight: 700; color: #fff;
  background: #1f9d55; border: 2px solid rgba(255,255,255,.35);
}
.tg-result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: 0 0 1.1rem; }
.tg-cstat {
  background: rgba(76,99,255,.12); border-radius: 12px; padding: .6rem .2rem;
  border: 1px solid rgba(108,140,255,.18);
}
.tg-cstat-val { display: block; font-size: 1.3rem; font-weight: 800; color: #4cc3ff; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tg-cstat-label { font-size: .66rem; color: #8b93c4; }

/* 矮屏：压缩 HUD，把高度留给文字面板 */
@media (max-height: 560px) {
  .tg-timering { width: 44px; height: 44px; }
  .tg-challenge #tg_play .tg-hud { grid-template-columns: repeat(2, 1fr); }
  .tg-challenge .tg-passage { font-size: 1.15rem; line-height: 2rem; max-height: 10rem; }
}
/* 窄屏：计时卡独占一行，统计改两列 */
@media (max-width: 720px) {
  .tg-challenge-top { flex-direction: column; align-items: stretch; }
  .tg-tcard { justify-content: center; }
  .tg-challenge #tg_play .tg-hud { grid-template-columns: repeat(2, 1fr); }
  .tg-challenge .tg-stat { padding: .45rem .65rem; }
  .tg-challenge .tg-stat-val { font-size: 1.1rem; }
  .tg-sico { width: 26px; height: 26px; font-size: .75rem; }
}
/* ── 限时挑战 UI 润色：视觉层级 / 光标聚焦 / 高压感 / 反馈 ── */
/* 时间环：青蓝主色 + 末段红色辉光 */
.tg-challenge .tg-timer-arc { stroke: #00d4ff; }
.tg-challenge .tg-timer-arc.low { stroke: #ff5a6a; filter: drop-shadow(0 0 6px rgba(255,90,106,.75)); }
.tg-challenge .tg-timering.low { filter: drop-shadow(0 0 10px rgba(255,90,106,.55)); }
.tg-challenge .tg-tcard.low { border-color: rgba(255,90,106,.45); box-shadow: 0 0 1.2rem rgba(255,90,106,.35), 0 .4rem 1.2rem rgba(3,6,20,.4); }

/* 低压脉冲：数字红 + 放大呼吸（代码在 rem<=10% 加 .pulse） */
.tg-timer-num.pulse { color: #ff5a6a; animation: tgc-pulse .5s ease-in-out infinite; }
@keyframes tgc-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.25); } }

/* 连击卡「火热」：combo≥10 橙色描边 + 微缩放脉动 */
.tg-challenge .tg-stat.hot {
  border-color: #fb923c;
  box-shadow: 0 0 0 1px #fb923c, 0 0 .9rem rgba(251,146,60,.45);
  animation: tgc-hot 1.1s ease-in-out infinite;
}
.tg-challenge .tg-stat.hot .tg-stat-val { color: #fb923c; }
.tg-challenge .tg-stat.hot .tg-sico { color: #fb923c; background: rgba(251,146,60,.16); box-shadow: inset 0 0 0 1px rgba(251,146,60,.4); }
@keyframes tgc-hot { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }

/* 文本面板：光标强聚焦（左侧高亮线 + 外发光）+ 已完成文字弱化，形成过去-现在-未来递进 */
.tg-challenge .tg-passage { font-size: 1.3rem; line-height: 2.5rem; scroll-behavior: smooth; }
.tg-challenge .tg-passage .tg-char.ok { color: #4ade80; opacity: .6; background: transparent; }
.tg-challenge .tg-passage .tg-char.bad { color: #ff5a6a; background: rgba(255,90,106,.14); text-decoration: none; }
.tg-challenge .tg-passage .tg-char.cur {
  color: #06102a; background: #00d4ff; font-weight: 700; border-radius: .25rem;
  box-shadow: inset 3px 0 0 #fff, 0 0 0 2px rgba(0,212,255,.6), 0 0 16px rgba(0,212,255,.75);
}
/* 标点/符号：跳过判定，灰显「无需输入」 */
.tg-challenge .tg-passage .tg-char.skip { color: #5b6486; opacity: .45; }

/* 结算速度评级徽标：入门灰 / 普通 绿 / 熟练 青 / 高手 金 */
.tg-tier-badge { display: inline-block; padding: .28rem 1rem; border-radius: 999px; font-weight: 700; font-size: 1rem; letter-spacing: .05em; }
.tg-tier-badge.lv0 { background: rgba(138,147,168,.18); color: #9aa3b8; }
.tg-tier-badge.lv1 { background: rgba(76,175,80,.18); color: #6fcf77; }
.tg-tier-badge.lv2 { background: rgba(0,212,255,.16); color: #00d4ff; }
.tg-tier-badge.lv3 { background: rgba(255,193,7,.2); color: #ffc82e; box-shadow: 0 0 14px rgba(255,193,7,.35); }
.tg-tier-desc { font-size: .85rem; margin-top: .35rem; color: #8a93a8; }

/* 输入区：毛玻璃 + 顶部细边框 + 连击/错误反馈 */
.tg-inputwrap {
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0,212,255,.5);
}
.tg-inputwrap.combo { border-color: #00d4ff; box-shadow: 0 0 0 .2rem rgba(0,212,255,.3), 0 .4rem 1.2rem rgba(3,6,20,.4); }
.tg-inputwrap.err { border-color: #ff5a6a; box-shadow: 0 0 0 .2rem rgba(255,90,106,.34), 0 .4rem 1.2rem rgba(3,6,20,.4); animation: tgc-err .28s ease; }
@keyframes tgc-err { 0%{transform:translateX(-3px)} 30%{transform:translateX(3px)} 60%{transform:translateX(-2px)} 100%{transform:translateX(0)} }
.tg-input-hint { font-size: .7rem; color: #8b93c4; white-space: nowrap; opacity: .85; display: inline-flex; align-items: center; gap: .25rem; }
.tg-text-head .tg-input-hint { margin-left: auto; }   /* 提示右对齐到「正在输入」标题行 */
.tg-input-hint .fa { color: #fb923c; }

/* 进度条 + 计数器 + 倍率徽标 */
.tg-progress-row { display: flex; align-items: center; gap: .6rem; margin-top: .7rem; }
.tg-challenge .tg-progress { flex: 1; height: .45rem; background: rgba(76,99,255,.18); border-radius: 999px; }
.tg-counter { font-size: .72rem; color: #6f8bff; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tg-mult {
  font-size: .72rem; font-weight: 800; color: #00d4ff; white-space: nowrap;
  padding: .05rem .45rem; border-radius: 999px; background: rgba(0,212,255,.12);
  border: 1px solid rgba(0,212,255,.3);
}
.tg-mult.bump { animation: tgc-bump .25s cubic-bezier(.2,1.6,.4,1); }
@keyframes tgc-bump { 40% { transform: scale(1.35); } }

/* HUD 数字更弹的跳动 */
.tg-challenge .tg-stat-val.bump { animation: tgc-bump .28s cubic-bezier(.18,1.5,.4,1); }

/* 暂停/结算浮层：更重的毛玻璃 */
.tg-challenge .tg-overlay { -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }

@media (max-width: 480px) {
  .tg-result-grid { grid-template-columns: repeat(2, 1fr); }
  .tg-challenge .tg-passage { font-size: 1.15rem; line-height: 2rem; max-height: 11rem; }
  .tg-timering { width: 46px; height: 46px; }
  /* 顶栏收窄：按钮只留图标，避免换行挤压标题 */
  .tg-challenge .tg-topbar { gap: .25rem; padding: .5rem .6rem; }
  .tg-challenge .tg-topbar .tg-btn span { display: none; }
  .tg-challenge .tg-topbar .tg-title { font-size: .9rem; }
  .tg-input-hint { display: none; }   /* 窄屏省空间，提示已写入 title 悬浮 */
}

/* ── 首次开赛引导层（暗色竞速风，置于暂停/结算之上） ── */
.tg-overlay.tg-onboard { z-index: 60; }
.tg-onboard-card {
  width: min(440px, 92vw);
  background: linear-gradient(180deg, #2c3242 0%, #232838 100%);
  border: 3px solid #171b26;
  border-radius: 18px; padding: 1.6rem 1.5rem 1.4rem;
  color: #e8ecff; text-align: center;
  box-shadow: 0 .9rem 2.4rem rgba(10,14,24,.5);
}
.tg-onboard-title { font-size: 1.3rem; font-weight: 800; margin: 0 0 .9rem; }
.tg-onboard-list { list-style: none; margin: 0 0 1.2rem; padding: 0; display: grid; gap: .6rem; text-align: left; }
.tg-onboard-list li { display: flex; gap: .6rem; align-items: flex-start; font-size: .92rem; color: #c7cee0; }
.tg-onboard-list i { color: #ffd166; margin-top: .15rem; flex: 0 0 auto; }
.tg-onboard-start { width: 100%; margin-bottom: .4rem; }
.tg-onboard-skip { color: #9aa3b8; font-size: .85rem; text-decoration: none; }
.tg-onboard-skip:hover { color: #fff; }

/* ── 轻量操作提示（打字区附近，可关闭） ── */
.tg-play-tip {
  display: flex; align-items: center; gap: .5rem;
  margin: 0 auto; max-width: 680px;
  background: rgba(108,140,255,.12); border: 1px solid rgba(108,140,255,.25);
  color: #c7cee0; border-radius: 10px; padding: .4rem .7rem; font-size: .82rem;
}
.tg-play-tip i { color: #9fc3ff; }
.tg-play-tip .tg-tip-close {
  margin-left: auto; background: none; border: none; color: #9aa3b8;
  font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0 .2rem;
}
.tg-play-tip .tg-tip-close:hover { color: #fff; }

/* ── 跳过当前字（生僻字/无法输入字符兜底）+ 轻提示 toast ── */
.tg-play { position: relative; }   /* 轻提示 toast 的定位锚点 */
.tg-input-row { display: flex; justify-content: center; margin-top: .1rem; }
.tg-skip-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem 1rem; border-radius: 999px;
  border: 1px solid var(--bs-border-color); background: var(--bs-body-bg);
  color: var(--bs-secondary-color); font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.tg-skip-btn:hover:not(:disabled) { color: var(--bs-body-color); border-color: var(--bs-secondary-color); }
.tg-skip-btn:disabled { opacity: .45; cursor: not-allowed; }
.tg-skip-btn .fa { font-size: .8rem; }
.tg-passage .tg-char.skip { color: #fff; background: var(--bs-danger, #dc3545); text-decoration: line-through; opacity: .85; }
.tg-overtake {
  position: absolute; top: .5rem; left: 50%; z-index: 5;
  transform: translateX(-50%) translateY(-8px);
  padding: .35rem .85rem; border-radius: 999px;
  font-size: .85rem; font-weight: 700; color: #fff;
  background: rgba(23,32,56,.82); box-shadow: 0 .35rem .9rem rgba(10,14,24,.35);
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease;
  max-width: 90%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tg-overtake.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.tg-overtake.ahead { background: rgba(25,135,84,.94); }
.tg-overtake.behind { background: rgba(220,53,69,.94); }
.tg-overtake.finish { background: rgba(255,193,7,.96); color: #231a00; }
@media (max-width: 600px) {
  .tg-skip-btn { padding: .6rem 1.2rem; font-size: .92rem; }   /* 触控目标 ≥44px */
  .tg-overtake { font-size: .8rem; top: .4rem; }
}

/* ── 失焦提示 + 当前字呼吸动效（monkeytype 式手感） ── */
/* 绝对定位悬浮 + 纯视觉（pointer-events:none）：绝不拦截/推挤任何可点元素，
   恢复聚焦由 document 捕获阶段的 mousedown 统一处理 */
.tg-focus-hint {
  position: absolute; left: 50%; bottom: .4rem; z-index: 6;
  transform: translateX(-50%);
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  max-width: 90%; white-space: nowrap; pointer-events: none;
  padding: .55rem 1rem; border-radius: 10px;
  background: rgba(255,193,7,.14); border: 1px solid rgba(255,193,7,.45);
  color: #8a6d00; font-size: .85rem; font-weight: 600;
  box-shadow: 0 .35rem .9rem rgba(58,67,96,.15);
  animation: tg-focus-pulse 1.6s ease-in-out infinite;
}
.tg-focus-hint i { color: #d39e00; }
.tg-focus-hint[hidden] { display: none; }
@keyframes tg-focus-pulse {
  0%, 100% { opacity: .75; }
  50% { opacity: 1; }
}
.tg-passage .tg-char.cur { animation: tg-cursor-breathe 1.2s ease-in-out infinite; }
@keyframes tg-cursor-breathe {
  0%, 100% { box-shadow: 0 0 0 .18rem rgba(108,140,255,.35); }
  50% { box-shadow: 0 0 0 .32rem rgba(108,140,255,.6); }
}
@media (prefers-reduced-motion: reduce) {
  .tg-focus-hint, .tg-passage .tg-char.cur { animation: none; }
}
