/* 網站體檢：一台深色的闖關機台。
   上面是跑道：起點 → 五道關卡 → 終點「AI 推薦你」，你的網站是一顆紅色光珠；
   答一題，關卡亮起（過關：紅色實心＋爆一圈；要補：紅叉、整台震一下；跳過：虛線），光珠衝到下一關；
   中間蓋一個「+20 過關」的章；最後蓋下 A～F 的大字等級。沒有程式時，五題直接列出來。 */

.game {
  --pos: 0;
  --ink: #F2F1EE; --ink-2: rgba(242, 241, 238, .8); --mute: rgba(242, 241, 238, .56); --line: rgba(255, 255, 255, .1); --line-2: rgba(255, 255, 255, .2); --red-text: #FF6A6E;
  position: relative; isolation: isolate; overflow: hidden; color: var(--ink);
  border-radius: 24px; padding: clamp(24px, 3.4vw, 52px);
  background:
    linear-gradient(rgba(255, 255, 255, .03) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px) 0 0 / 44px 44px,
    radial-gradient(120% 90% at 50% 0%, #1E1418 0%, #0E0E11 60%);
  box-shadow: 0 70px 130px -70px rgba(237, 28, 36, .55), inset 0 0 0 1px rgba(255, 255, 255, .07);
}
/* 過關時從光珠的位置亮一下 */
.game::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0; background: radial-gradient(42% 70% at calc(var(--pos) * 100%) 8%, rgba(255, 74, 79, .38), transparent 70%); }
.game.flash::after { animation: gm-flash .8s ease-out; }
@keyframes gm-flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.game.hit { animation: gm-shake .45s cubic-bezier(.36, .07, .19, .97); }
@keyframes gm-shake { 15%, 55% { translate: -9px 0; } 35%, 75% { translate: 8px 0; } 90% { translate: -3px 0; } }

/* ---------- 跑道 ---------- */
.gm-board { display: none; }
.game.run .gm-board { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px clamp(28px, 4vw, 72px); align-items: center; padding-bottom: clamp(22px, 3vh, 34px); border-bottom: 1px solid var(--line); }
.gm-track { position: relative; height: 92px; margin: 0 40px 0 14px; }
.gm-rail { position: absolute; left: 0; right: 0; top: 29px; height: 2px; background: rgba(255, 255, 255, .13); }
.gm-fill { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(var(--pos)); background: linear-gradient(90deg, rgba(237, 28, 36, .2), #FF4A4F); box-shadow: 0 0 14px rgba(255, 74, 79, .7); transition: transform .9s cubic-bezier(.65, 0, .35, 1); }
.gm-start { position: absolute; left: 0; top: 24px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .4); }
.gm-start b { position: absolute; top: 34px; left: 50%; translate: -50% 0; font: 400 10.5px/1 var(--mono); letter-spacing: .16em; color: var(--mute); }

.g-dots { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; }
.g-dots li { position: absolute; top: 0; width: 0; }
.g-dots li:nth-child(1) { left: 16.667%; } .g-dots li:nth-child(2) { left: 33.333%; } .g-dots li:nth-child(3) { left: 50%; } .g-dots li:nth-child(4) { left: 66.667%; } .g-dots li:nth-child(5) { left: 83.333%; }
.gm-node { position: absolute; left: -19px; top: 11px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid rgba(255, 255, 255, .28); background: #131316; transition: background-color .4s var(--ease), border-color .4s var(--ease), box-shadow .4s var(--ease); }
.gm-node b { font: 400 11px/1 var(--mono); letter-spacing: .06em; color: var(--mute); }
.gm-node::before { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid #FF4A4F; opacity: 0; pointer-events: none; }
.gm-node::after { position: absolute; inset: 0; display: grid; place-items: center; font: 700 17px/1 var(--zh); }
.gm-lb { position: absolute; top: 60px; left: 0; translate: -50% 0; white-space: nowrap; font: 500 13.5px/1.2 var(--zh); color: var(--mute); transition: color .3s var(--ease); }
.g-dots li.now .gm-node { border-color: #fff; animation: gm-now 1.6s ease-out infinite; }
.g-dots li.now .gm-lb { color: #fff; }
@keyframes gm-now { 0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .35); } 100% { box-shadow: 0 0 0 14px rgba(255, 255, 255, 0); } }
.g-dots li.ok .gm-node, .g-dots li.half .gm-node { border-color: #FF4A4F; background: #E01A22; box-shadow: 0 0 22px rgba(255, 74, 79, .65); }
.g-dots li.half .gm-node { background: linear-gradient(0deg, #E01A22 50%, #2A0E11 50%); }
.g-dots li.ok .gm-node b, .g-dots li.half .gm-node b, .g-dots li.no .gm-node b, .g-dots li.skip .gm-node b { opacity: 0; }
.g-dots li.ok .gm-node::after { content: "✓"; color: #fff; }
.g-dots li.half .gm-node::after { content: "½"; color: #fff; font-family: var(--mono); font-size: 14px; }
.g-dots li.ok .gm-node::before, .g-dots li.half .gm-node::before { animation: gm-ring .8s ease-out; }
@keyframes gm-ring { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(2.6); } }
.g-dots li.ok .gm-node, .g-dots li.half .gm-node { animation: gm-pass .55s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes gm-pass { 0% { scale: .6; } 100% { scale: 1; } }
.g-dots li.ok .gm-lb, .g-dots li.half .gm-lb { color: var(--ink); }
.g-dots li.no .gm-node { border-color: #FF4A4F; background: #2A0E11; animation: gm-no .5s cubic-bezier(.36, .07, .19, .97); }
.g-dots li.no .gm-node::after { content: "✕"; color: #FF4A4F; }
.g-dots li.no .gm-lb { color: #FF6A6E; }
@keyframes gm-no { 20%, 60% { translate: -5px 0; } 40%, 80% { translate: 5px 0; } }
.g-dots li.skip .gm-node { border-style: dashed; }
.g-dots li.skip .gm-node::after { content: "–"; color: var(--mute); }

/* 終點：AI 推薦你。總分 75 以上時亮起來 */
.gm-goal { position: absolute; left: 100%; top: 0; width: 0; }
.gm-goal-o { position: absolute; left: -24px; top: 6px; width: 48px; height: 48px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .3); background: radial-gradient(circle, rgba(255, 255, 255, .06), transparent 70%); transition: border-color .6s var(--ease), box-shadow .6s var(--ease), background-color .6s var(--ease); }
.gm-goal-o::before, .gm-goal-o::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .22); }
.gm-goal-o::after { inset: 18px; background: rgba(255, 255, 255, .25); border: 0; }
.gm-goal b { position: absolute; top: 62px; right: -24px; white-space: nowrap; font: 700 13.5px/1.2 var(--zh); color: var(--mute); }
.game.win .gm-goal-o { border-color: #FF4A4F; background-color: rgba(255, 74, 79, .2); box-shadow: 0 0 0 10px rgba(255, 74, 79, .12), 0 0 46px rgba(255, 74, 79, .8); animation: gm-goal 1.8s ease-out .6s infinite; }
.game.win .gm-goal-o::after { background: #fff; }
.game.win .gm-goal b { color: #fff; }
@keyframes gm-goal { 0% { box-shadow: 0 0 0 0 rgba(255, 74, 79, .5), 0 0 46px rgba(255, 74, 79, .8); } 100% { box-shadow: 0 0 0 26px rgba(255, 74, 79, 0), 0 0 46px rgba(255, 74, 79, .8); } }

/* 光珠＝你的網站 */
.gm-bead { position: absolute; z-index: 3; top: 30px; left: calc(var(--pos) * 100%); width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff 0, #FF6A6E 38%, #B80F17 100%); box-shadow: 0 0 0 6px rgba(255, 74, 79, .16), 0 0 26px 6px rgba(255, 74, 79, .7); transition: left .9s cubic-bezier(.65, 0, .35, 1); }
.gm-bead::after { content: ""; position: absolute; right: 50%; top: 50%; width: 70px; height: 2px; margin-top: -1px; background: linear-gradient(90deg, transparent, rgba(255, 106, 110, .9)); opacity: 0; transition: opacity .3s; }
.game.moving .gm-bead::after { opacity: 1; }

/* 分數 */
.g-head { text-align: right; }
.g-k { font: 400 11.5px/1.4 var(--mono); letter-spacing: .14em; color: var(--mute); }
.g-big { display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.g-num { display: inline-block; font-family: var(--wide); font-stretch: 125%; font-variation-settings: "wdth" 125; font-weight: 800; font-size: clamp(56px, 5.6vw, 96px); line-height: .85; letter-spacing: -.04em; color: #fff; }
.g-num.bump { animation: gm-bump .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes gm-bump { 0% { scale: 1.25; color: #FF6A6E; } 100% { scale: 1; } }
.g-big span { font: 400 14px/1 var(--mono); color: var(--mute); }

/* ---------- 題目 ---------- */
.g-stage { position: relative; counter-reset: q; }
.game.run .g-stage { min-height: 330px; padding-top: clamp(28px, 4.4vh, 48px); }
.g-intro { display: none; }
.g-q { counter-increment: q; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: clamp(20px, 3vw, 52px); align-items: start; }
.g-q > * { grid-column: 2; }
.g-q::before { content: attr(data-n); grid-column: 1; grid-row: 1 / span 4; font-family: var(--wide); font-stretch: 125%; font-variation-settings: "wdth" 125; font-weight: 800; font-size: clamp(64px, 7.4vw, 128px); line-height: .78; letter-spacing: -.05em; color: #FF4A4F; text-shadow: 0 0 40px rgba(255, 74, 79, .35); }
.g-tag { font: 400 12px/1 var(--mono); letter-spacing: .14em; color: var(--red-text); margin-bottom: 14px; }
.g-q h3, .g-intro h3, .g-end h3 { font-size: clamp(22px, 2.3vw, 36px); line-height: 1.4; font-weight: 700; color: #fff; }
.g-why { margin-top: 12px; font-size: 16px; line-height: 1.75; color: var(--ink-2); max-width: 46em; }
.g-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 26px; }
.g-opts button {
  position: relative; overflow: hidden; isolation: isolate; display: flex; align-items: center; gap: 14px; text-align: left;
  font: 700 16px/1.4 var(--zh); color: var(--ink); background: rgba(255, 255, 255, .045); border: 1px solid rgba(255, 255, 255, .17); border-radius: 14px;
  padding: 16px 18px; min-height: 72px; cursor: pointer; transition: border-color .3s var(--ease), translate .3s var(--ease), opacity .3s var(--ease);
}
.g-opts button::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, #C8141B, #FF4A4F); transform: scaleX(0); transform-origin: 0 50%; transition: transform .45s cubic-bezier(.7, 0, .2, 1); }
.g-opts button:hover, .g-opts button:focus-visible { border-color: #FF4A4F; translate: 0 -3px; outline: none; }
.g-opts button:hover::before, .g-opts button:focus-visible::before, .g-opts button.picked::before { transform: scaleX(1); }
.g-opts kbd { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .3); background: rgba(0, 0, 0, .25); font: 400 12px/1 var(--mono); color: rgba(255, 255, 255, .85); }
.g-q.done .g-opts button:not(.picked) { opacity: .3; }
.g-q.done .g-opts button { pointer-events: none; }
.gm-go { margin-top: 30px; width: 300px; max-width: 100%; }

.game.run .g-q, .game.run .g-end, .game.run .g-intro { display: none; }
.game.run .g-q.cur, .game.run .g-intro.cur { display: grid; animation: gm-in .55s var(--ease) both; }
.game.run .g-intro.cur { display: block; }
@keyframes gm-in { from { opacity: 0; translate: 40px 0; } to { opacity: 1; translate: 0 0; } }
.game:not(.run) .g-end { display: none; }
.game:not(.run) .g-q + .g-q { margin-top: 32px; padding-top: 32px; border-top: 1px solid var(--line); }

/* 蓋章：+20 過關／+0 要補 */
.gm-pop { position: absolute; z-index: 6; left: 50%; top: 56%; margin: 0; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 8px; translate: -50% -50%; opacity: 0; }
.gm-pop::before { content: ""; position: absolute; z-index: -1; inset: -55% -45%; background: radial-gradient(closest-side, rgba(14, 14, 17, .95) 40%, rgba(14, 14, 17, 0)); }
.gm-pop.fail small { background: #160A0C; }
.gm-pop b { font-family: var(--wide); font-stretch: 125%; font-variation-settings: "wdth" 125; font-weight: 800; font-size: clamp(56px, 7vw, 120px); line-height: .9; letter-spacing: -.03em; }
.gm-pop small { font: 900 clamp(18px, 1.8vw, 26px)/1 var(--zh); letter-spacing: .2em; padding: 8px 16px; border: 2px solid currentColor; border-radius: 6px; }
.gm-pop.pass, .gm-pop.half { color: #fff; text-shadow: 0 0 40px rgba(255, 74, 79, .9); }
.gm-pop.pass small, .gm-pop.half small { background: #E01A22; border-color: #E01A22; text-shadow: none; }
.gm-pop.fail { color: #FF4A4F; text-shadow: 0 0 30px rgba(0, 0, 0, .9); }
.gm-pop.skip { color: rgba(242, 241, 238, .75); }
.gm-pop.on { animation: gm-stamp .95s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes gm-stamp { 0% { opacity: 0; scale: 2.4; rotate: -12deg; } 22% { opacity: 1; scale: 1; rotate: -4deg; } 72% { opacity: 1; scale: 1; rotate: -4deg; } 100% { opacity: 0; scale: .96; rotate: -4deg; translate: -50% -80%; } }
/* 章蓋下去時，題目暫時退到後面 */
.g-q.done { transition: opacity .3s var(--ease); opacity: .35; }

/* ---------- 結算：A～F 大字等級 ---------- */
.game.run .g-end.cur { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(24px, 4vw, 72px); align-items: center; animation: gm-in .55s var(--ease) both; }
.gm-grade { margin: 0; font-family: var(--wide); font-stretch: 125%; font-variation-settings: "wdth" 125; font-weight: 800; font-size: clamp(140px, 15vw, 250px); line-height: .78; letter-spacing: -.05em; color: #FF4A4F; text-shadow: 0 0 70px rgba(255, 74, 79, .5); }
.gm-grade.good { color: #fff; text-shadow: 0 0 70px rgba(255, 74, 79, .85); }
.g-end.cur .gm-grade { animation: gm-slam .8s cubic-bezier(.2, 1.4, .4, 1) .25s both; }
@keyframes gm-slam { 0% { opacity: 0; scale: 3; rotate: -14deg; } 60% { opacity: 1; } 100% { opacity: 1; scale: 1; rotate: -6deg; } }
.g-list { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.g-list li { font-size: 14px; padding: 8px 14px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--ink-2); }
.g-list .ok { background: #E01A22; border-color: #E01A22; color: #fff; }
.g-list .no { border-color: rgba(255, 74, 79, .6); color: #FF6A6E; }
.g-act { display: flex; flex-wrap: wrap; gap: 22px; align-items: center; margin-top: 26px; }
.g-again { background: none; border: 0; padding: 6px 0; color: var(--ink-2); font: 500 15px/1 var(--zh); cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.g-again:hover { color: #fff; }

/* ---------- 減少動態：照樣能玩，只是不衝、不震、不蓋章 ---------- */
@media (prefers-reduced-motion: reduce) {
  .game.hit, .game.flash::after, .gm-pop.on, .g-dots li .gm-node, .g-dots li .gm-node::before, .g-num.bump, .g-end.cur .gm-grade, .game.win .gm-goal-o, .game.run .cur { animation: none; }
  .gm-fill, .gm-bead { transition: none; }
}

/* ---------- 手機 ---------- */
@media (max-width: 760px) {
  .game { border-radius: 18px; padding: 22px 18px 26px; }
  .game.run .gm-board { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .g-head { order: -1; display: flex; align-items: baseline; justify-content: space-between; text-align: left; }
  .g-big { margin-top: 0; }
  .g-num { font-size: 48px; }
  .gm-track { margin: 0 26px 0 8px; height: 84px; }
  .gm-node { left: -15px; top: 14px; width: 30px; height: 30px; }
  .gm-lb { display: none; top: 54px; font-size: 12.5px; }
  .g-dots li.now .gm-lb { display: block; }
  .gm-goal-o { left: -18px; top: 11px; width: 36px; height: 36px; }
  .gm-goal-o::before { inset: 7px; } .gm-goal-o::after { inset: 13px; }
  .gm-goal b { top: 54px; right: -18px; font-size: 12px; }
  .gm-start b { display: none; }
  .game.run .g-stage { min-height: 0; padding-top: 24px; }
  .g-q { grid-template-columns: minmax(0, 1fr); }
  .g-q > * { grid-column: 1; }
  .g-q::before { grid-row: auto; font-size: 52px; margin-bottom: 14px; }
  .g-opts { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .g-opts button { min-height: 60px; }
  .gm-go { width: 100%; }
  .gm-pop { top: 50%; }
  .game.run .g-end.cur { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .gm-grade { font-size: 120px; }
}
