/* «ល្បែងសិក្សា» (games.html, static/js/games.js) */
#gm { min-height: 420px; }
.gm-msg { padding: 30px; text-align: center; }
.gm-h { margin: 0; font-size: 24px; }
.gm-h small { font-size: 15px; font-weight: 500; color: var(--ink-3); }
.gm-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 16px; }
.gm-back { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.gm-back:hover { background: var(--surface-2); }
.gm-hud { display: flex; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.gm-hud span { background: var(--surface-2); border-radius: 999px; padding: 5px 14px; font-weight: 700; font-size: 15px; }
.gm-streak { background: #fff1e6 !important; color: #d9480f; }

/* lesson + game pickers */
.gm-lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 14px; }
.gm-lesson { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font: inherit; font-size: 15.5px; font-weight: 600; color: var(--ink); cursor: pointer; }
.gm-lesson:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(0,0,0,.06); }
.gm-n { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.gm-games { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.gm-game { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left; padding: 22px; border: 0; border-radius: 20px; color: #fff; font: inherit; cursor: pointer; transition: transform .15s; box-shadow: 0 8px 22px rgba(0,0,0,.12); }
.gm-game:hover { transform: translateY(-3px); }
.gm-game b { font-size: 22px; }
.gm-game span { font-size: 15px; line-height: 1.6; opacity: .95; }
.gm-game em { font-style: normal; font-weight: 700; background: rgba(255,255,255,.22); border-radius: 999px; padding: 3px 12px; }
.gm-game .gm-ico { font-size: 34px; line-height: 1; }
.gm-speed { background: linear-gradient(135deg, #46178f, #864cbf); }
.gm-match { background: linear-gradient(135deg, #1368ce, #45a3e5); }
.gm-tf { }
.gm-game.gm-tf { background: linear-gradient(135deg, #26890c, #66bf39); }

/* question + timer */
.gm-bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 14px; }
.gm-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #26890c, #d89e00, #e21b3c); transition: width .1s linear; }
.gm-q { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px 24px; font-size: 22px; font-weight: 600; line-height: 1.7; text-align: center; box-shadow: 0 4px 14px rgba(0,0,0,.05); }
.gm-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.gm-tile { display: flex; align-items: center; gap: 14px; min-height: 84px; padding: 14px 18px; border: 0; border-radius: 14px; color: #fff; font: inherit; font-size: 20px; font-weight: 700; text-align: left; cursor: pointer; box-shadow: 0 5px 0 rgba(0,0,0,.18); transition: transform .1s, opacity .2s; }
.gm-tile:hover:not(:disabled) { transform: translateY(-2px); }
.gm-tile .katex { color: #fff; }
.gm-shape { font-size: 26px; width: 30px; text-align: center; flex: none; }
.gm-c0 { background: #e21b3c; } .gm-c1 { background: #1368ce; } .gm-c2 { background: #d89e00; } .gm-c3 { background: #26890c; }
.gm-tile.gm-dim { opacity: .3; }
.gm-tile.gm-wrong { opacity: .55; outline: 4px solid #fff; outline-offset: -8px; }
.gm-tile.gm-right { outline: 5px solid #fff; outline-offset: -9px; box-shadow: 0 0 0 4px #26890c, 0 5px 0 rgba(0,0,0,.18); }
.gm-fb { display: flex; align-items: center; justify-content: center; gap: 16px; min-height: 64px; margin-top: 14px; font-size: 20px; }
.gm-okt { color: #26890c; } .gm-badt { color: #e21b3c; }

/* memory cards */
.gm-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.gm-card { position: relative; min-height: 130px; border: 0; padding: 0; border-radius: 16px; background: none; font: inherit; cursor: pointer; perspective: 800px; }
.gm-card > span { position: absolute; inset: 0; display: grid; place-items: center; padding: 10px 12px; border-radius: 16px; backface-visibility: hidden; transition: transform .35s; text-align: center; line-height: 1.55; }
.gm-back-face { background: linear-gradient(135deg, #46178f, #864cbf); color: #fff; font-size: 34px; box-shadow: 0 5px 0 rgba(0,0,0,.15); }
.gm-front { transform: rotateY(180deg); background: var(--surface); border: 2px solid var(--line); font-size: 15.5px; font-weight: 600; color: var(--ink); overflow: hidden; }
.gm-front.gm-a { background: #fff9db; border-color: #f2c94c; font-size: 18px; }
.gm-card.up .gm-back-face, .gm-card.done .gm-back-face { transform: rotateY(180deg); }
.gm-card.up .gm-front, .gm-card.done .gm-front { transform: rotateY(360deg); }
.gm-card.done .gm-front { border-color: #26890c; background: #ebfbee; }
.gm-hint { text-align: center; color: var(--ink-3); font-size: 14px; margin: 12px 0 0; }

/* true / false */
.gm-tf .gm-q { transition: background .2s; }
.gm-claim { margin-top: 12px; text-align: center; font-size: 22px; }
.gm-claim b { display: inline-block; margin-left: 6px; padding: 6px 18px; border-radius: 12px; background: #fff9db; border: 2px solid #f2c94c; }
.gm-flash-ok .gm-q { background: #d3f9d8; } .gm-flash-bad .gm-q { background: #ffe3e3; }
.gm-tfb { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.gm-tfb button { min-height: 76px; border: 0; border-radius: 16px; color: #fff; font: inherit; font-size: 24px; font-weight: 700; cursor: pointer; box-shadow: 0 5px 0 rgba(0,0,0,.18); }
.gm-yes { background: #26890c; } .gm-no { background: #e21b3c; }
.gm-tfb button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }

/* results */
.gm-end { text-align: center; padding: 10px 0 20px; }
.gm-stars { font-size: 52px; color: #f59f00; letter-spacing: 6px; }
.gm-stars span { color: var(--line); }
.gm-score { font-size: 64px; font-weight: 800; color: var(--primary); line-height: 1.2; }
.gm-line { margin: 6px 0; font-size: 17px; }
.gm-rec { font-size: 20px; font-weight: 700; color: #d9480f; }
.gm-actions { display: flex; justify-content: center; gap: 12px; margin: 16px 0; flex-wrap: wrap; }
.gm-review { max-width: 760px; margin: 20px auto 0; text-align: left; }
.gm-review h3 { font-size: 18px; }
.gm-rv { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; background: var(--surface); }
.gm-rv-a { margin-top: 4px; color: #26890c; font-weight: 700; }
.gm-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 99; overflow: hidden; }
.gm-confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 2px; animation: gm-fall 2.6s ease-in forwards; }
@keyframes gm-fall { to { top: 105%; transform: rotate(720deg); } }

@media (max-width: 760px) {
  .gm-tiles, .gm-tfb { grid-template-columns: 1fr; }
  .gm-cards { grid-template-columns: repeat(3, 1fr); }
  .gm-q { font-size: 18px; padding: 16px; }
  .gm-tile { font-size: 17px; min-height: 64px; }
  .gm-hud { margin-left: 0; }
}
@media (max-width: 480px) { .gm-cards { grid-template-columns: repeat(2, 1fr); } }

/* grade page: game links per lesson */
.game-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 10px; }
.game-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.game-row .n { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.game-row b { flex: 1 1 140px; font-size: 15px; }
.game-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.gbtn { padding: 5px 11px; border-radius: 999px; color: #fff !important; text-decoration: none !important; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.gbtn:hover { filter: brightness(1.1); }
.g-speed { background: #864cbf; } .g-match { background: #1368ce; } .g-tf { background: #26890c; }
.gm-hud span:empty { display: none; }

/* PIN box + play modes */
.gm-pinbox { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: 0 0 18px; padding: 12px 16px; border-radius: 14px; background: #fff9db; border: 1px solid #f2c94c; }
.gm-pinbox input { width: 160px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 20px; letter-spacing: 3px; text-align: center; }
.gm-game { cursor: default; }
.gm-modes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.gm-modes button { border: 0; border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 14.5px; font-weight: 700; cursor: pointer; background: #fff; color: #2b1d52; }
.gm-modes button + button { background: rgba(255,255,255,.22); color: #fff; outline: 2px solid rgba(255,255,255,.7); }
.gm-modes button:hover { filter: brightness(1.06); }
.gm-room-tag { background: #2b1d52; color: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 14px; }

/* matching */
.gm-howto { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
.gm-howto span { background: var(--surface); border: 1px dashed var(--primary); border-radius: 999px; padding: 6px 14px; font-size: 14.5px; }
.gm-howto.gm-nudge span { animation: gm-shake .4s; border-color: #e21b3c; }
.gm-pairs { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.gm-col { display: flex; flex-direction: column; gap: 10px; }
.gm-col h4 { margin: 0; text-align: center; color: var(--ink-3); }
.gm-mq, .gm-ma { --mc: var(--primary); display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); font: inherit; font-size: 16.5px; font-weight: 600; color: var(--ink); text-align: left; cursor: pointer; transition: border-color .15s, background .15s; }
.gm-ma { justify-content: center; font-size: 19px; }
.gm-mq:hover, .gm-ma:hover { border-color: var(--primary); }
.gm-mn { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.gm-mq.sel { border-color: #d89e00; background: #fff9db; box-shadow: 0 0 0 3px #f2c94c; }
.gm-mq.ok, .gm-ma.ok { border-color: var(--mc); background: color-mix(in srgb, var(--mc) 14%, #fff); cursor: default; }
.gm-mq.ok .gm-mn { background: var(--mc); color: #fff; }
.gm-ma.no { border-color: #e21b3c; background: #ffe3e3; animation: gm-shake .4s; }
@keyframes gm-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* teacher lobby */
.gm-lobby { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 22px; align-items: start; }
.gm-join { text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px; }
.gm-join-step { margin: 6px 0; font-weight: 600; }
.gm-qr { width: 230px; height: 230px; margin: 6px auto; }
.gm-qr svg { width: 100%; height: 100%; }
.gm-bigpin { font-size: 56px; font-weight: 800; letter-spacing: 6px; color: #2b1d52; line-height: 1.2; font-family: 'Montserrat', sans-serif; }
.gm-players { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px; min-height: 360px; }
.gm-pl-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 20px; }
.gm-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.gm-chip { background: #2b1d52; color: #fff; border-radius: 999px; padding: 7px 16px; font-weight: 700; animation: gm-pop .3s; }
@keyframes gm-pop { from { transform: scale(.4); } }

/* live ranking + podium */
.gm-board { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.gm-row { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: 17px; }
.gm-rank { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.gm-name { flex: 0 0 200px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-barw { flex: 1; height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.gm-barw i { display: block; height: 100%; background: linear-gradient(90deg, #864cbf, #1368ce); transition: width .4s; }
.gm-row b { min-width: 70px; text-align: right; margin-left: auto; }
.gm-podium { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin: 20px 0 10px; }
.gm-pod { width: 210px; text-align: center; }
.gm-pod-name { font-size: 21px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-pod-score { color: var(--ink-3); font-weight: 700; margin-bottom: 6px; }
.gm-pod-block { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px; padding-top: 12px; border-radius: 14px 14px 0 0; color: #fff; transform-origin: bottom; animation: gm-rise .8s ease-out; }
.gm-pod-block span { font-size: 40px; } .gm-pod-block b { font-size: 34px; }
.gm-pod1 .gm-pod-block { height: 230px; background: linear-gradient(#f2c94c, #d89e00); }
.gm-pod2 .gm-pod-block { height: 185px; background: linear-gradient(#cbd5e1, #94a3b8); }
.gm-pod3 .gm-pod-block { height: 150px; background: linear-gradient(#f0a868, #c2703d); }
@keyframes gm-rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.gm-rest { max-width: 640px; margin: 10px auto; }
.gm-me { text-align: center; font-size: 19px; font-weight: 700; color: var(--primary); }

/* student phone */
.gm-joinform { max-width: 420px; margin: 10px auto; text-align: center; }
.gm-joinform form { display: grid; gap: 12px; margin-top: 10px; }
.gm-joinform label { display: grid; gap: 6px; font-weight: 700; text-align: left; }
.gm-joinform input { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font: inherit; font-size: 20px; }
.gm-wait { text-align: center; padding: 40px 10px; }
.gm-spin { width: 54px; height: 54px; margin: 0 auto 16px; border-radius: 50%; border: 6px solid var(--primary-soft); border-top-color: var(--primary); animation: gm-rot 1s linear infinite; }
@keyframes gm-rot { to { transform: rotate(360deg); } }
.g-class { background: #2b1d52; }

@media (max-width: 760px) {
  .gm-pairs, .gm-lobby { grid-template-columns: 1fr; }
  .gm-name { flex-basis: 120px; }
  .gm-pod { width: 31%; } .gm-pod-name { font-size: 16px; }
  .gm-bigpin { font-size: 44px; }
}
body.gm-play .page-hero { display: none; }
@media (max-width: 760px) {
  .gm-pairs { grid-template-columns: 1.25fr 1fr; gap: 8px; }
  .gm-mq, .gm-ma { min-height: 56px; padding: 8px; font-size: 13.5px; gap: 6px; border-radius: 10px; }
  .gm-ma { font-size: 15px; }
  .gm-mn { width: 22px; height: 22px; border-radius: 6px; font-size: 12px; }
  .gm-howto span { font-size: 12.5px; padding: 4px 10px; }
}

/* class play: mode chooser, teams */
.gm-setup-h { text-align: center; margin: 4px 0 14px; }
.gm-setup { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.gm-mode { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 22px; border: 0; border-radius: 20px; color: #fff; font: inherit; text-align: left; background: linear-gradient(135deg, #46178f, #864cbf); box-shadow: 0 8px 22px rgba(0,0,0,.12); }
button.gm-mode { cursor: pointer; } button.gm-mode:hover { transform: translateY(-3px); }
.gm-mode b { font-size: 22px; } .gm-mode span { font-size: 15px; line-height: 1.6; } .gm-mode .gm-ico { font-size: 34px; }
.gm-mode-team { background: linear-gradient(135deg, #0c8599, #1368ce); }
.gm-nteams { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; font-weight: 700; }
.gm-nteams button { width: 46px; height: 46px; border: 0; border-radius: 12px; background: #fff; color: #1368ce; font: inherit; font-size: 20px; font-weight: 800; cursor: pointer; }
.gm-nteams button:hover { transform: scale(1.08); }
.gm-teamcols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.gm-teamcol { border: 2px solid var(--tc); border-radius: 14px; padding: 10px; background: color-mix(in srgb, var(--tc) 7%, #fff); }
.gm-teamcol h4 { margin: 0 0 8px; color: var(--tc); } .gm-teamcol h4 small { color: var(--ink-3); font-weight: 600; }
.gm-teamcol .gm-chip { display: inline-block; margin: 0 4px 6px 0; background: var(--tc); }
.gm-team-tag { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--tc); color: #fff; font-weight: 700; }
.gm-board-h { margin: 14px 0 4px; font-size: 18px; } .gm-board-h.gm-c { text-align: center; margin-top: 26px; }
.gm-name small { font-weight: 500; color: var(--ink-3); }
.gm-pickteam { display: flex; flex-wrap: wrap; gap: 8px; text-align: left; }
.gm-pickteam b { width: 100%; }
.gm-tbtn { --tc: #495057; flex: 1 1 45%; padding: 10px; border: 2px solid var(--tc); border-radius: 12px; background: #fff; color: var(--tc); font: inherit; font-weight: 700; cursor: pointer; }
.gm-tbtn.sel { background: var(--tc); color: #fff; }
.gm-podium-s .gm-pod { width: 170px; }
.gm-pod-s .gm-pod-name { font-size: 17px; }
.gm-pod-s .gm-pod-block { height: auto !important; padding: 8px 0; }
.gm-pod-s .gm-pod-block span { font-size: 26px; } .gm-pod-s .gm-pod-block b { font-size: 22px; }
.gm-podium-s .gm-pod1 .gm-pod-block { min-height: 110px; } .gm-podium-s .gm-pod2 .gm-pod-block { min-height: 85px; } .gm-podium-s .gm-pod3 .gm-pod-block { min-height: 65px; }
@media (max-width: 760px) { .gm-setup { grid-template-columns: 1fr; } .gm-podium-s .gm-pod { width: 31%; } }
.gm-joinform, .gm-joinform form, .gm-joinform label { min-width: 0; width: 100%; box-sizing: border-box; }
.gm-joinform input { width: 100%; min-width: 0; box-sizing: border-box; }
.gm-tbtn { flex: 1 1 calc(50% - 4px); min-width: 0; box-sizing: border-box; }
.gm-tbtn[data-t="-1"] { flex-basis: 100%; }
.gm-localwarn { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: #fff4e6; border: 1px solid #ffa94d; color: #d9480f; font-size: 14px; line-height: 1.6; text-align: left; }
.gm-sec { margin: 26px 0 0; }
.gm-span { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
