/* เกม 24 (js/games.js) — ใช้สี/ตัวอักษรชุดเดียวกับส่วนอื่นของเว็บ (ตัวแปรใน styles/main.css) */
.g24{display:block;}
.g24-card{background:var(--card); border:1px solid var(--line); border-radius:21px; padding:16px; margin-bottom:14px;}
.g24-card-h{font-weight:800; font-size:var(--fs-md); margin-bottom:10px; color:var(--ink);}
.g24-top{display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px;}
.g24-segs{display:inline-flex; background:var(--paper); border:1px solid var(--line); border-radius:999px; padding:3px;}
.g24-seg{font:inherit; font-size:var(--fs-sm); font-weight:700; color:var(--muted); background:transparent; border:none; border-radius:999px; padding:7px 18px; cursor:pointer;}
.g24-seg.active{background:var(--black); color:#fff;}
.g24-clock{font-weight:800; font-size:var(--fs-lg); font-variant-numeric:tabular-nums; color:var(--ink);}
.g24-rule{margin:0 0 12px; font-size:var(--fs-sm); line-height:1.7; color:var(--ink);}
.g24-muted{color:var(--muted); font-size:var(--fs-xs);}
p.g24-muted{font-size:var(--fs-sm); line-height:1.7; margin:0 0 12px;}

.g24-tiles{display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin-bottom:12px;}
.g24-tile{font:inherit; font-size:var(--fs-3xl); font-weight:800; color:var(--black); background:var(--yellow); border:2px solid var(--black); border-radius:18px; height:76px; cursor:pointer; transition:transform 120ms var(--ease-pop), opacity 120ms;}
.g24-tile:active:not(:disabled){transform:scale(.95);}
.g24-tile:disabled{opacity:.28; cursor:default;}

.g24-expr{min-height:52px; display:flex; flex-wrap:wrap; align-items:center; gap:6px; padding:10px 12px; background:var(--paper); border:1px dashed var(--line); border-radius:16px; font-size:var(--fs-xl); font-weight:700; color:var(--ink);}
.g24-placeholder{font-size:var(--fs-sm); font-weight:500; color:var(--muted);}
.g24-tok-op{color:var(--coral);}
.g24-live{min-height:22px; margin:6px 2px 10px; font-size:var(--fs-sm); font-weight:700; color:var(--muted); font-variant-numeric:tabular-nums;}

.g24-ops{display:grid; grid-template-columns:repeat(6,1fr); gap:8px; margin-bottom:8px;}
.g24-edit{display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:12px;}
.g24-key,.g24-sec,.g24-main{font:inherit; font-weight:700; border-radius:14px; cursor:pointer;}
.g24-op{font-size:var(--fs-xl); height:48px; background:var(--card); color:var(--ink); border:1.5px solid var(--black);}
.g24-sec{font-size:var(--fs-sm); height:44px; padding:0 16px; background:var(--card); color:var(--ink); border:1.5px solid var(--line);}
.g24-main{font-size:var(--fs-base); height:48px; padding:0 20px; background:var(--black); color:#fff; border:none;}
.g24-actions{display:grid; grid-template-columns:2fr 1fr; gap:8px;}
.g24-key:disabled,.g24-sec:disabled,.g24-main:disabled{opacity:.35; cursor:default;}
.g24-key:active:not(:disabled),.g24-sec:active:not(:disabled),.g24-main:active:not(:disabled){transform:scale(.97);}

.g24-result{border-width:2px;}
.g24-res-ok{border-color:var(--success); background:var(--success-bg);}
.g24-res-no{border-color:var(--danger);}
.g24-res-skip{border-color:var(--line);}
.g24-res-head{font-weight:800; font-size:var(--fs-md); line-height:1.5; margin-bottom:10px; color:var(--ink);}
.g24-reveal{background:var(--card); border:1px solid var(--line); border-radius:16px; padding:12px 14px; margin-bottom:12px;}
.g24-reveal-title{font-weight:800; font-size:var(--fs-sm); margin-bottom:6px; color:var(--ink);}
.g24-reveal-sub{font-size:var(--fs-sm); line-height:1.7; margin-bottom:6px; color:var(--ink);}
.g24-reveal-expr{font-size:var(--fs-lg); font-weight:700; color:var(--ink); word-break:break-word;}
.g24-note{font-size:var(--fs-xs); color:var(--muted); margin-bottom:10px;}
.g24-result .g24-main{width:100%;}

.g24-stats{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
.g24-stat-col{background:var(--paper); border:1px solid var(--line); border-radius:16px; padding:12px;}
.g24-stat-h{font-weight:800; font-size:var(--fs-sm); margin-bottom:8px; color:var(--ink);}
.g24-stat-row{display:flex; justify-content:space-between; gap:8px; font-size:var(--fs-xs); padding:3px 0; color:var(--muted);}
.g24-stat-row b{color:var(--ink); text-align:right;}
.g24-stat-empty{font-size:var(--fs-xs); color:var(--muted);}

@media (max-width:360px){
  .g24-tile{height:64px; font-size:var(--fs-2xl);}
  .g24-stats{grid-template-columns:1fr;}
}
@media (min-width:900px){
  .g24{max-width:560px;}
}

/* ---------- เกมหาสูตรสมการ (js/formula-hunt.js) — ใช้คลาส g24-* ร่วมกับเกม 24 ---------- */
@media (min-width:900px){ .g24.fh{max-width:760px;} }
.fh-prompt{display:flex; flex-direction:column; gap:2px; background:var(--yellow); border:2px solid var(--black); border-radius:16px; padding:10px 14px; margin-bottom:8px;}
.fh-prompt-l{font-size:var(--fs-xs); font-weight:700; color:var(--ink); opacity:.75;}
.fh-prompt-n{font-size:var(--fs-lg); font-weight:800; line-height:1.4; color:var(--black);}
.fh-progress{min-height:20px; margin:0 2px 8px; font-size:var(--fs-xs); font-weight:700; color:var(--muted); font-variant-numeric:tabular-nums; white-space:pre;}
.fh-frame{position:relative; width:100%; min-height:200px; overflow:hidden; border:2px solid var(--black); border-radius:21px; background-color:var(--card);
  background-image:radial-gradient(var(--line) 1px, transparent 1.4px); background-size:18px 18px;}
.fh-measure{position:absolute; left:-99999px; top:0; visibility:hidden; pointer-events:none; line-height:1.2;}
.fh-m{display:block; width:max-content; white-space:nowrap;}
.fh-measure .katex,.fh-f .katex{font-size:1em;}
.fh-msg{display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; min-height:200px; padding:20px; text-align:center; color:var(--muted); font-size:var(--fs-sm);}
.fh-msg p{margin:0;}

.fh-f{position:absolute; display:flex; align-items:center; justify-content:center; box-sizing:border-box; margin:0; padding:0; line-height:1.2; white-space:nowrap;
  font:inherit; color:var(--ink); background:var(--paper); border:1.5px solid var(--line); border-radius:12px; cursor:pointer; touch-action:manipulation; -webkit-tap-highlight-color:transparent;
  transition:transform 120ms var(--ease-pop), border-color 120ms, background-color 160ms;}
.fh-f:hover:not(:disabled){border-color:var(--black); transform:scale(1.04);}
.fh-f:active:not(:disabled){transform:scale(.97);}
.fh-f:focus-visible{outline:2px solid var(--black); outline-offset:3px;}
.fh-f:disabled{opacity:1; color:var(--ink); cursor:default;}
.fh-f.is-ok{background:var(--success-bg); border-color:var(--success);}
.fh-f.is-wrong{background:rgba(var(--danger-rgb),.08); border-color:var(--danger);}
.fh-f.is-miss{border-color:var(--yellow-deep);}
.fh-mark{position:absolute; inset:0; pointer-events:none;}
.fh-ring{position:absolute; inset:-8px -10px; border:3px solid var(--success); border-radius:999px; animation:fh-pop 260ms var(--ease-pop);}
.fh-ring-miss{border:2.5px dashed var(--yellow-deep); animation:fh-fade 260ms ease-out;}
.fh-badge{position:absolute; top:-15px; right:-15px; width:25px; height:25px; padding:4px; box-sizing:border-box; border-radius:50%; color:#fff; background:var(--success); animation:fh-pop 300ms var(--ease-pop);}
.fh-xmark{position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:var(--danger); animation:fh-shake 360ms ease-out;}
.fh-xmark svg{width:min(70%, 44px); height:min(100%, 44px); filter:drop-shadow(0 0 3px rgba(255,255,255,.9));}
.fh-actions{margin-top:12px; display:flex; justify-content:flex-end;}
.fh-actions .g24-sec{min-width:96px;}
.fh-miss-row{display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:6px 14px; padding:8px 0; border-top:1px solid var(--line);}
.fh-miss-row:first-of-type{border-top:none;}
.fh-miss-name{font-size:var(--fs-sm); line-height:1.5; color:var(--ink); flex:1 1 180px;}
.fh-miss-tex{font-size:var(--fs-md); color:var(--ink); overflow-x:auto; max-width:100%;}
.fh-miss-tex .katex{font-size:1em;}

@keyframes fh-pop{0%{transform:scale(.6); opacity:0;} 100%{transform:scale(1); opacity:1;}}
@keyframes fh-fade{from{opacity:0;} to{opacity:1;}}
@keyframes fh-shake{0%{transform:translateX(0);} 20%{transform:translateX(-6px);} 40%{transform:translateX(6px);} 60%{transform:translateX(-4px);} 80%{transform:translateX(3px);} 100%{transform:translateX(0);}}
@media (prefers-reduced-motion:reduce){ .fh-ring,.fh-ring-miss,.fh-badge,.fh-xmark{animation:none;} .fh-f{transition:none;} }
