/* ============================================================
   闯关模式
   ------------------------------------------------------------
   布局：左边整面答题墙（上区大写 / 下区小写，大小写必须分开点两次），
   右边一列 HUD，题目小窗压在右下角（老师指定的位置）。
   小窗独占右侧栏底部，不浮在墙上面，避免孩子抬手时挡住自己要点的字母。
   ============================================================ */

/* ---------- 整屏布局 ----------
   用 grid，因为同屏双人要把三块重排成左中右，flex 做不到干净的换向。

   单人 / 轮流：      上区大写
                     下区小写      | 右侧 HUD + 题目窗
   同屏双人：  左边大写 | 中间题目窗 | 右边小写
   左右分区是硬要求：86 寸屏前两个孩子只能并排站，不可能一个站另一个上面。
   题目窗放正中间，两人到题目的距离一样，先看到题的那个不会占便宜。 */
/* 注意这里必须带 [data-active="true"]：
   base.css 里 .screen 默认 display:none，靠 [data-active] 切换显隐。
   写成 `.game { display: grid !important }` 会把隐藏规则顶掉，
   游戏屏就永远显示、切走之后还盖在别的屏上面 —— 出过这个事。 */
.game[data-active="true"] {
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: 1fr 1fr;
  gap: var(--sp-3) var(--sp-4);
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
}
.gzone__wrap[data-cs="upper"] { grid-column: 1; grid-row: 1; }
.gzone__wrap[data-cs="lower"] { grid-column: 1; grid-row: 2; }
.gside                         { grid-column: 2; grid-row: 1 / span 2; }

.game[data-duo="true"] {
  grid-template-columns: 1fr minmax(240px, 300px) 1fr;
  grid-template-rows: 1fr;
}
.game[data-duo="true"] .gzone__wrap[data-cs="upper"] { grid-column: 1; grid-row: 1; }
.game[data-duo="true"] .gside                        { grid-column: 2; grid-row: 1; }
.game[data-duo="true"] .gzone__wrap[data-cs="lower"] { grid-column: 3; grid-row: 1; }

.gzone {
  flex: 1 1 auto;
  display: flex; flex-wrap: wrap;
  align-content: center; justify-content: center;
  gap: var(--tile-gap, 10px);
  border-radius: var(--r-lg);
  padding: 10px;
  min-height: 0;
  position: relative;
  transition: background var(--t-mid) var(--ease-out), box-shadow var(--t-mid);
}
/* 该点哪一区就亮哪一区——不用文字说明，靠光带引导 */
.gzone[data-want="true"] {
  background: rgba(255, 255, 255, .62);
  box-shadow: inset 0 0 0 3px var(--c-lemon), 0 6px 20px rgba(240, 173, 0, .16);
}
.gzone[data-done="true"] { opacity: .38; }

.gtile {
  position: relative;
  width: var(--tile-w, 100px);
  height: var(--tile-h, 100px);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, #fff, var(--tone-soft));
  box-shadow: 0 4px 0 var(--tone-line), 0 8px 16px rgba(122, 92, 70, .09);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  transition: transform var(--t-fast) var(--ease-bounce), box-shadow var(--t-fast), opacity var(--t-mid);
  animation: pop-in .42s var(--ease-bounce) backwards;
}
.gtile img { height: 74%; width: auto; max-width: 78%; object-fit: contain;
  filter: drop-shadow(0 3px 4px rgba(122, 92, 70, .16)); transition: transform var(--t-mid) var(--ease-bounce); }
.gtile:active { transform: translateY(3px) scale(.94); }

.gtile[data-state="right"] {
  background: linear-gradient(180deg, #fff, #dcf7e4);
  box-shadow: 0 0 0 4px var(--c-success), 0 8px 0 var(--c-success-deep), 0 16px 28px rgba(47, 168, 81, .3);
  z-index: 2;
}
.gtile[data-state="right"] img { transform: scale(1.14); }
.gtile[data-state="bad"] {
  background: linear-gradient(180deg, #fff, #ffe2e2);
  box-shadow: 0 0 0 4px var(--c-wrong), 0 6px 0 var(--c-wrong-deep);
  animation: shake-x .42s var(--ease-out);
}
/* 连错三次后自动指出答案：呼吸光圈，不直接判对 */
.gtile[data-state="show"] {
  box-shadow: 0 0 0 4px var(--c-lemon), 0 8px 0 var(--c-lemon-deep);
  animation: breathe 1s var(--ease-out) infinite;
}
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.07); } }

.gtile__pop {   /* 点对时从格子里蹦出的星星 */
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 46px; pointer-events: none;
  animation: star-fly .7s var(--ease-out) forwards;
}
@keyframes star-fly {
  0%   { opacity: 0; transform: scale(.3) translateY(0) rotate(-30deg); }
  40%  { opacity: 1; transform: scale(1.25) translateY(-12px) rotate(10deg); }
  100% { opacity: 0; transform: scale(.9) translateY(-58px) rotate(0); }
}

/* ---------- 右侧栏 ---------- */
.gside { display: flex; flex-direction: column; gap: var(--sp-3); min-height: 0; min-width: 0; }

.ghud {
  background: var(--c-card); border-radius: var(--r-lg);
  padding: var(--sp-4); box-shadow: var(--sh-card);
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.ghud__who { display: flex; align-items: center; gap: 10px; }
.ghud__avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--c-lemon), var(--c-peach));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.ghud__name { font-size: 19px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 进度：几道题就几颗点 */
.dots { display: flex; gap: 8px; }
.dot {
  flex: 1 1 0; height: 12px; border-radius: var(--r-full);
  background: var(--c-cream-2);
  transition: background var(--t-mid) var(--ease-out), transform var(--t-mid) var(--ease-bounce);
}
.dot[data-v="right"] { background: var(--c-success); }
.dot[data-v="part"]  { background: var(--c-lemon); }
.dot[data-v="bad"]   { background: var(--c-wrong); }
.dot[data-v="now"]   { background: var(--c-ink-soft); transform: scaleY(1.7); }

.ghud__stats { display: flex; gap: var(--sp-3); }
.stat { flex: 1 1 0; text-align: center; background: var(--c-cream-2); border-radius: var(--r-md); padding: 10px 4px; }
.stat__v { font-family: var(--font-en); font-size: 30px; font-weight: 900; line-height: 1; color: var(--c-ink); }
.stat__v--score { color: var(--c-strawberry); }
.stat__v--time  { color: var(--c-sky-deep); font-variant-numeric: tabular-nums; }
.stat__k { font-size: 12px; color: var(--c-ink-soft); margin-top: 4px; }

/* 连击 */
.combo {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 46px; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--c-lemon), var(--c-peach));
  color: #fff; font-family: var(--font-en); font-size: 22px; font-weight: 900;
  box-shadow: 0 4px 0 var(--c-peach-deep);
  opacity: 0; transform: scale(.6);
  transition: opacity var(--t-mid), transform var(--t-mid) var(--ease-bounce);
}
.combo[data-on="true"] { opacity: 1; transform: scale(1); animation: wiggle .5s var(--ease-out); }

/* ---------- 题目小窗（右下角） ---------- */
.gask {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-3);
  border-radius: var(--r-xl);
  background: linear-gradient(160deg, #fff, var(--tone-soft, var(--c-cream-2)));
  box-shadow: var(--sh-pop);
  position: relative; overflow: hidden;
}
.gask::before {   /* 背后缓慢呼吸的光斑，让小窗成为视觉焦点 —— 不用 conic，
                     那个会在卡片上留一道生硬的斜边 */
  content: ""; position: absolute; inset: -20%;
  background: radial-gradient(circle at 50% 42%, hsl(var(--lh, 5) 90% 88%) 0%, rgba(255,255,255,0) 62%);
  animation: askpulse 3.6s var(--ease-out) infinite;
}
@keyframes askpulse {
  0%, 100% { opacity: .55; transform: scale(1); }
  50%      { opacity: .95; transform: scale(1.06); }
}

.gask__inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.gask__img { height: clamp(140px, 26vh, 320px); width: auto; animation: pop-in .5s var(--ease-bounce); }
.gask__q {
  font-family: var(--font-en); font-size: 120px; font-weight: 900; line-height: 1;
  color: var(--tone-base, var(--c-ink-soft)); opacity: .5;
}
.gask__speaker {
  width: 128px; height: 128px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-sky), var(--c-grape));
  color: #fff; font-size: 58px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 0 var(--c-grape-deep), 0 14px 28px rgba(139, 92, 246, .34);
  animation: float-y 2.2s var(--ease-out) infinite;
}
.gask__speaker:active { transform: translateY(4px) scale(.95); }

/* 已答对的部分：小窗底部长出一个绿色小标 */
.gask__got { display: flex; gap: 10px; height: 52px; }
.gask__slot {
  width: 52px; height: 52px; border-radius: var(--r-sm);
  border: 3px dashed var(--c-line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-en); font-size: 26px; font-weight: 900; color: var(--c-line);
  transition: all var(--t-mid) var(--ease-bounce);
}
.gask__slot[data-got="true"] {
  border-style: solid; border-color: var(--c-success);
  background: var(--c-success); color: #fff;
  transform: scale(1.08);
}

/* ---------- 开始 / 结算 ---------- */
.panel {
  position: absolute; inset: 0; z-index: 20;
  display: none; align-items: center; justify-content: center;
  background: rgba(255, 248, 239, .93); backdrop-filter: blur(4px);
}
.panel[data-on="true"] { display: flex; }
.panel__card {
  width: min(760px, 88%); padding: var(--sp-6);
  border-radius: var(--r-xl); background: var(--c-card);
  box-shadow: 0 12px 0 rgba(0,0,0,.05), 0 32px 64px rgba(122,92,70,.24);
  text-align: center;
  animation: pop-in var(--t-mid) var(--ease-bounce);
}

/* 关卡选择 */
.levels { display: flex; gap: var(--sp-3); justify-content: center; flex-wrap: wrap; }
.lvl {
  width: 150px; padding: var(--sp-4) var(--sp-3);
  border-radius: var(--r-lg); background: var(--c-cream-2);
  transition: all var(--t-fast) var(--ease-bounce);
}
.lvl[aria-pressed="true"] {
  background: linear-gradient(160deg, var(--c-sky), var(--c-grape)); color: #fff;
  box-shadow: 0 5px 0 var(--c-grape-deep), 0 12px 24px rgba(139,92,246,.3);
  transform: translateY(-3px);
}
.lvl:active { transform: scale(.95); }
.lvl__n { font-family: var(--font-en); font-size: 34px; font-weight: 900; line-height: 1; }
.lvl__t { font-size: 15px; font-weight: 800; margin-top: 6px; }

/* 花名册 */
.roster { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-height: 260px; overflow: auto; padding: 4px; }
.who {
  padding: 11px 18px; border-radius: var(--r-full);
  background: var(--c-cream-2); font-size: 17px; font-weight: 700;
  transition: all var(--t-fast) var(--ease-bounce);
}
.who:active { transform: scale(.94); }
.who[aria-pressed="true"] { background: var(--c-mint); color: #fff; box-shadow: 0 3px 0 var(--c-mint-deep); }

.namein {
  width: 100%; padding: 14px 18px; border-radius: var(--r-md);
  border: 3px solid var(--c-line); background: var(--c-cream);
  font-family: inherit; font-size: 20px; font-weight: 700; color: var(--c-ink);
  text-align: center; outline: none;
}
.namein:focus { border-color: var(--c-primary); }

.bigbtn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 18px 54px; border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--c-lemon), var(--c-strawberry));
  color: #fff; font-size: 26px; font-weight: 900;
  box-shadow: 0 6px 0 var(--c-strawberry-deep), 0 16px 32px rgba(232,74,128,.32);
}
.bigbtn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--c-strawberry-deep); }
.bigbtn[disabled] { opacity: .4; filter: grayscale(.5); }

/* 结算 */
.res__score { font-family: var(--font-en); font-size: 96px; font-weight: 900; line-height: 1; color: var(--c-strawberry); }
.res__row { display: flex; gap: var(--sp-4); justify-content: center; margin: var(--sp-5) 0; }
.res__cell { flex: 0 0 150px; background: var(--c-cream-2); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-2); }
.res__v { font-family: var(--font-en); font-size: 36px; font-weight: 900; line-height: 1; }
.res__k { font-size: 13px; color: var(--c-ink-soft); margin-top: 6px; }
.res__miss { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: var(--sp-4); }
.res__missb {
  width: 58px; height: 58px; border-radius: var(--r-sm);
  background: hsl(var(--lh) 72% 93%); box-shadow: 0 3px 0 hsl(var(--lh) 55% 82%);
  display: flex; align-items: center; justify-content: center;
}
.res__missb img { height: 76%; }

/* 星星评级 */
.stars { display: flex; gap: 10px; justify-content: center; font-size: 52px; margin: var(--sp-3) 0; }
.stars span {
  opacity: .22; transform: scale(.7);
  color: var(--c-line);
  transition: all .4s var(--ease-bounce);
}
.stars span[data-on="true"] {
  opacity: 1; transform: scale(1);
  color: var(--c-lemon);
  text-shadow: 0 4px 0 var(--c-lemon-deep), 0 10px 22px rgba(240, 173, 0, .4);
  animation: star-in .6s var(--ease-bounce);
}
@keyframes star-in { 0% { transform: scale(.2) rotate(-40deg); } 60% { transform: scale(1.3) rotate(12deg); } 100% { transform: scale(1) rotate(0); } }

/* 撒花 */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 95; overflow: hidden; }
.confetti i {
  position: absolute; width: 12px; height: 18px; border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  0%   { opacity: 1; transform: translateY(-8vh) rotate(0deg); }
  100% { opacity: .9; transform: translateY(108vh) rotate(720deg); }
}

/* ---------- 开始面板：赛制与选人 ---------- */
.startsegs { display: flex; gap: var(--sp-3); justify-content: center; margin: var(--sp-5) 0 var(--sp-4); }

.chosen { display: flex; gap: var(--sp-3); justify-content: center; margin-bottom: var(--sp-4); }
.slot {
  min-width: 168px; padding: 12px 20px;
  border-radius: var(--r-md);
  background: var(--c-cream-2);
  border: 3px dashed var(--c-line);
  transition: all var(--t-fast) var(--ease-bounce);
}
.slot[data-on="true"] { border-style: solid; border-color: var(--c-mint); background: #eafbfa; }
.slot__k { font-size: 12px; color: var(--c-ink-soft); font-weight: 800; }
.slot__v { font-size: 21px; font-weight: 800; margin-top: 2px; }
.slot:active { transform: scale(.96); }

/* ---------- 双人对比 ---------- */
.vs { display: flex; align-items: center; justify-content: center; gap: var(--sp-4); margin: var(--sp-4) 0; }
.vs__mid {
  font-family: var(--font-en); font-size: 30px; font-weight: 900;
  color: var(--c-ink-soft); flex: 0 0 auto;
}
.vs__card {
  flex: 1 1 0; max-width: 260px; padding: var(--sp-5) var(--sp-3);
  border-radius: var(--r-lg); background: var(--c-cream-2);
  position: relative;
}
.vs__card[data-win="true"] {
  background: linear-gradient(160deg, #fff6df, #ffeaf2);
  box-shadow: 0 6px 0 var(--c-lemon-deep), 0 16px 32px rgba(240, 173, 0, .28);
  transform: scale(1.06);
  animation: pop-in .5s var(--ease-bounce);
}
.vs__name { font-size: 19px; font-weight: 800; }
.vs__score {
  font-family: var(--font-en); font-size: 52px; font-weight: 900; line-height: 1.1;
  color: var(--c-strawberry);
}
.vs__meta { font-size: 13px; color: var(--c-ink-soft); font-variant-numeric: tabular-nums; }
.vs__crown { position: absolute; top: -26px; left: 50%; transform: translateX(-50%); font-size: 34px; }

@media (max-width: 900px) {
  .startsegs { margin: var(--sp-4) 0 var(--sp-3); }
  .slot { min-width: 0; flex: 1 1 0; padding: 10px 12px; }
  .slot__v { font-size: 17px; }
  .vs { gap: var(--sp-2); }
  .vs__card { padding: var(--sp-4) var(--sp-2); }
  .vs__score { font-size: 36px; }
  .vs__mid { font-size: 20px; }
}

/* ---------- 全班跟读 ----------
   判定后答案字母甩到屏幕中央，播一遍真人发音，全班齐读。
   台下 40 个孩子每题都能开口一次，而不是干看着台上那一个。 */
.chorus {
  position: absolute; inset: 0; z-index: 15;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(60% 60% at 50% 50%,
    hsl(var(--lh) 90% 96% / .97), hsl(var(--lh) 70% 92% / .92));
  animation: chorus-in .34s var(--ease-bounce);
}
.chorus[data-out="true"] { animation: chorus-out .3s var(--ease-out) forwards; }
@keyframes chorus-in  { 0% { opacity: 0; } 100% { opacity: 1; } }
@keyframes chorus-out { 0% { opacity: 1; } 100% { opacity: 0; transform: scale(1.06); } }

.chorus__pair { display: flex; align-items: flex-end; gap: 4%; }
.chorus__img {
  height: 44vh; width: auto;
  filter: drop-shadow(0 10px 18px rgba(122, 92, 70, .22));
  animation: chorus-pop .6s var(--ease-bounce) backwards;
}
.chorus__img--lower { height: 30vh; animation-delay: .1s; }
@keyframes chorus-pop {
  0%   { opacity: 0; transform: scale(.4) translateY(40px); }
  60%  { opacity: 1; transform: scale(1.08) translateY(-6px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 900px) {
  .chorus__img { height: 26vh; }
  .chorus__img--lower { height: 18vh; }
}

/* ---------- 同屏双人：分区名牌 ----------
   两个孩子同时上台时，各自负责哪半边必须一眼看清，
   否则会互相抢、互相怪。名牌只在 duo 模式露出来。 */
.gzone__wrap { display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }
.gzone__wrap .gzone { flex: 1 1 auto; }
.gzone__tag { display: none; }

.game[data-duo="true"] .gzone__tag {
  display: flex; align-items: baseline; gap: 12px;
  position: absolute; left: 14px; top: -4px; z-index: 4;
  padding: 5px 18px;
  border-radius: var(--r-full);
  color: #fff;
  box-shadow: 0 3px 0 rgba(0,0,0,.12);
}
.gtag__name  { font-size: 17px; font-weight: 800; }
.gtag__score { font-family: var(--font-en); font-size: 22px; font-weight: 900; }
.gtag__time  { font-family: var(--font-en); font-size: 15px; font-weight: 800; opacity: .82;
               font-variant-numeric: tabular-nums; min-width: 3.2em; }
/* 这一边答完了：表停住，牌子暗一档，另一边还在跑 */
.game[data-duo="true"] .gzone__tag[data-done="true"] { filter: saturate(.5) brightness(1.05); }
.game[data-duo="true"] .gzone__tag[data-done="true"] .gtag__time { opacity: .5; }
.game[data-duo="true"] .gzone__wrap[data-cs="upper"] .gzone__tag {
  background: linear-gradient(100deg, var(--c-sky), var(--c-grape));
}
.game[data-duo="true"] .gzone__wrap[data-cs="lower"] .gzone__tag {
  background: linear-gradient(100deg, var(--c-peach), var(--c-strawberry));
  left: auto; right: 14px;      /* 右半边的孩子站右边，名牌也贴右边 */
}
/* 名牌压在区顶，给它留出一点空间 */
.game[data-duo="true"] .gzone { padding-top: 22px; }
/* 同屏时名牌要大一点：两个孩子隔着一米多，得看得清自己管哪边 */
.game[data-duo="true"] .gzone__tag { font-size: 17px; padding: 5px 20px; }

/* ---------- 换掉 emoji 之后的几处收尾 ---------- */
.gask__speaker svg { width: 56px; height: 56px; }

.vs__crown { color: var(--c-lemon); filter: drop-shadow(0 3px 0 var(--c-lemon-deep)); }

/* 交棒：上一个人的头像淡出、下一个人的头像放大登场 */
.handoff { display: flex; align-items: center; justify-content: center; gap: var(--sp-4); margin-bottom: var(--sp-3); }
.handoff .ava:first-child { opacity: .35; }
.handoff .ava:last-child { box-shadow: 0 0 0 4px var(--c-mint), inset 0 -2px 0 hsl(var(--lh) 55% 84%); animation: pop-in .5s var(--ease-bounce); }
.handoff__arrow { color: var(--c-ink-soft); display: flex; }

/* 破纪录那一行 */
.pbline {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0 0 14px;
  padding: 6px 18px; border-radius: var(--r-full);
  background: #fff6df; color: var(--c-lemon-deep);
  font-size: 18px; font-weight: 800;
}


/* 同屏双人：中间栏只留进度点和题目窗。
   总分和正确率在各自的名牌上，中间再放一份只会让两个孩子去看别人的分。 */
.game[data-duo="true"] .ghud__stats,
.game[data-duo="true"] .combo { display: none; }
