/* Trò chơi nhóm 2: Đấu trùm, Ghép cặp, Mưa từ, Đua với kỷ lục, Giải mã từ – phần giao diện thêm (tiền tố g2-) */
.g2-card { display: flex; align-items: flex-start; gap: 10px; margin: 12px auto 0; max-width: 560px; padding: 10px 12px; border: 2px solid var(--gm-ink, #121212); border-radius: 14px; background: var(--gm-cream, #F7F0DF); color: var(--gm-ink, #121212); font-size: 15px; line-height: 1.5; text-align: left; animation: g2-in .25s ease-out; }
.g2-card-bad { border-color: var(--gm-bad, #B4413B); background: var(--gm-bad-t, #F6D4C4); }
.g2-card b { font-family: "Lora", serif; font-size: 17px; }
.g2-ex { display: block; margin-top: 2px; font-size: 13.5px; font-style: italic; opacity: .85; line-height: 1.45; }
.g2-ex:empty { display: none; }
.g2-exline { margin: 8px auto 0; max-width: 560px; min-height: 0; font-size: 13.5px; font-style: italic; text-align: center; opacity: .85; }
.g2-exline:empty { display: none; }
.g2-card-slot:empty { display: none; }
.g2-dim { opacity: .65; font-size: 13.5px; }
@keyframes g2-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* thanh mục tiêu */
.g2-goalbar { display: flex; align-items: center; gap: 10px; margin: 2px 0 8px; font-size: 13px; font-weight: 700; }
.g2-goalbar > span { white-space: nowrap; }
.g2-goalbar i { display: block; flex: 1; height: 10px; border: 2px solid var(--gm-ink, #121212); border-radius: 999px; background: var(--gm-cream, #F7F0DF); overflow: hidden; }
.g2-goalbar u { display: block; height: 100%; width: 100%; background: var(--v3-cta, #F07A3C); text-decoration: none; transition: width .3s; }
.g2-goalbar i.low u { background: var(--gm-bad, #B4413B); }
.g2-storm .g2-goalbar u { width: 0; background: var(--gm-ok, #3F7D4E); }

/* Đấu trùm: chấm chuỗi tới đòn chí mạng */
.g2-pips { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 6px 0 4px; font-size: 13px; font-weight: 700; flex-wrap: wrap; }
.g2-pipdots { display: inline-flex; gap: 5px; }
.g2-pipdots i { width: 12px; height: 12px; border: 2px solid var(--gm-ink, #121212); border-radius: 50%; background: transparent; transition: background .2s, transform .2s; }
.g2-pipdots i.mark { border-radius: 3px; }
.g2-pipdots i.on { background: var(--v3-cta, #F07A3C); transform: scale(1.15); }
.g2-pips.hot { color: var(--gm-bad, #B4413B); }
.g2-pips.hot .g2-pipdots i.on { background: var(--gm-bad, #B4413B); }

/* Mưa từ: ba lựa chọn nghĩa */
.g2-ch { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 12px; }
.g2-ch-q { font-weight: 800; font-size: 15px; text-align: center; }
.g2-ch-q span { font-family: "Lora", serif; font-size: 18px; }
.g2-ch-wait { padding: 14px; text-align: center; opacity: .6; }
.g2-ch .g2-ch-b { min-height: 52px; text-align: center; }
@media (min-width: 700px) { .g2-ch { grid-template-columns: repeat(3, 1fr); } .g2-ch-q, .g2-ch-wait { grid-column: 1 / -1; } }

/* Đua: chênh lệch với bóng */
.g2-gap { margin: 4px 0 0; min-height: 22px; text-align: center; font-size: 14px; font-weight: 800; }
.g2-gap.up { color: var(--gm-ok, #3F7D4E); } .g2-gap.down { color: var(--gm-bad, #B4413B); }

/* Ghép cặp: dòng câu ví dụ dưới bàn */
.g2-mex { margin-top: 12px; min-height: 44px; text-align: center; font-size: 15px; line-height: 1.5; }
.g2-match .gm-tiles { grid-template-columns: repeat(var(--cols, 4), 1fr); }
@media (max-width: 640px) { .g2-match .gm-tiles { grid-template-columns: repeat(3, 1fr); } .g2-match .gm-tile { min-height: 64px; } }

/* Giải mã từ */
.g2-dna-top { justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.g2-clue-top { margin: 4px 0 10px; }
.g2-dna .gm-kb button { min-height: 46px; }
.g2-dna .gm-kb .r { gap: 4px; }
@media (max-width: 640px) { .g2-dna .gm-kb button { min-height: 44px; font-size: 14px; padding: 0; } }
.g2-pop .gm-cell { animation: g2-flip .45s ease-out both; animation-delay: calc(var(--i, 0) * .08s); }
@keyframes g2-flip { 0% { transform: rotateX(90deg); } 100% { transform: none; } }
.g2-win .gm-cell { animation: g2-jump .5s ease-out both; animation-delay: calc(var(--i, 0) * .07s); }
@keyframes g2-jump { 0%, 100% { transform: none; } 40% { transform: translateY(-9px); } }
@media (prefers-reduced-motion: reduce) { .g2-card, .g2-pop .gm-cell, .g2-win .gm-cell { animation: none !important; } }

/* nút trợ giúp và thẻ nghĩa có khung rõ hơn */
.gm-arena .gm-pw { border: 2px solid var(--gm-ink, #121212); border-radius: 12px; background: var(--gm-paper, #FFFDF8); }
.gm-arena .gm-pw:disabled { opacity: .55; }
.g2-match .gm-tile.vi { border: 2px solid var(--gm-ink, #121212); background: var(--gm-paper, #FFFDF8); }
.g2-match .gm-tile.sel { box-shadow: 0 0 0 3px var(--tc-navy, #2F4A62); }
/* 18/11: vùng từ rơi co theo chiều cao màn hình để vùng rơi + ô chọn nghĩa/gõ nghĩa nằm trọn trong một màn (1280×590, 1366×768, 375×812, 375×667);
   trước đây cao cố định 340/250px nên màn thấp phải cuộn và thanh tên trò dính che từ đang rơi. Tốc độ rơi bù theo chiều cao trong games.js. */
.g2-storm .gm-sky { height: clamp(150px, calc(100vh - 400px), 340px); height: clamp(150px, calc(100dvh - 400px), 340px); }
@media (max-width: 640px) { .g2-storm .gm-sky { height: clamp(150px, calc(100vh - 475px), 250px); height: clamp(150px, calc(100dvh - 475px), 250px); } }
/* Giải mã từ trên máy tính (18/11): lưới đoán bên trái, manh mối + bàn phím bên phải để ở 1280×760 không phải cuộn mới thấy hết bàn phím;
   phím cao 44px. Điện thoại giữ một cột. */
@media (min-width: 900px) {
  .g2-dna-cols { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px; align-items: start; }
  .g2-dna-cols .gm-grid5 { margin: 4px 0 0; }
  .g2-dna-r .g2-clue-top { margin-top: 4px; }
  .g2-dna-r .gm-kb { margin-top: 8px; }
  .g2-dna .gm-kb button { min-height: 44px; }
}
.g2-dna .gm-hints .gm-btn { min-height: 44px; }
/* màn hẹp: một cột, manh mối vẫn nằm trên lưới đoán như trước */
@media (max-width: 899px) { .g2-dna-cols { display: flex; flex-direction: column; } .g2-dna-r { display: contents; } .g2-dna-r .g2-clue-top { order: -1; } .g2-dna-cols .gm-kb { width: 100%; } }
@media (max-width: 640px) { .g2-dna .gm-kb button.wide { font-size: 10.5px; letter-spacing: 0; } .g2-dna .gm-grid5 .r { grid-template-columns: repeat(5, 46px); } .g2-dna .gm-cell { height: 44px; } }

/* 18/11 thử điện thoại: vùng chạm ≥44px cho liên kết "đổi ở sảnh" và bàn phím ảo của Chữ DNA rộng hơn */
@media (hover: none), (max-width: 640px) {
  .gm-deckline a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; margin: -10px 0; }
  .g2-dna .gm-kb { margin-left: -14px; margin-right: -14px; width: auto; max-width: none; }
  .g2-dna .gm-kb .r { gap: 3px; }
  .g2-dna .gm-kb button { max-width: 46px; min-height: 48px; }
}
/* người kiểm 18/11: màn dọc bàn phím chỉ rộng 333/375px (phím 30,6px) → trải gần hết bề ngang, chừa 4px mỗi bên: phím 34px ở 375, 32,5px ở 360 (khe 3px) */
@media (max-width: 640px) {
  .g2-dna .gm-kb { width: calc(100vw - 8px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)); margin-left: calc(50% - 50vw + 4px + env(safe-area-inset-left, 0px)); margin-right: 0; }
}
@media (hover: none) { #gmStage .gm-say, .gm-stage .gm-say { width: 44px; height: 44px; } #gmStage .gm-say svg { width: 20px; height: 20px; } }
/* màn ngang điện thoại (rộng > 640px) vẫn cần chip lựa chọn cao ≥ 44px */
@media (hover: none) { #gmStage .gm-chip { min-height: 44px; } }
@media (hover: none) { #gmStage .gm-blank input, #gmStage .gm-input input { font-size: 16px; } }

/* 18/11 điện thoại dọc (dt2): bàn phím Giải mã từ 4 hàng × 7 phím, mỗi phím ≥ 44px rộng và cao */
@media (max-width: 640px) {
  .g2-dna .gm-kb { gap: 3px; }
  .g2-dna .gm-kb .r { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
  .g2-dna .gm-kb button, .g2-dna .gm-kb button.wide { max-width: none; flex: none; min-height: 44px; height: 44px; font-size: 16px; padding: 0; letter-spacing: 0; }
  .g2-dna .gm-kb button.wide { font-size: 13px; }
}
/* điện thoại dọc: ô chữ thấp hơn, hai nút gợi ý chung một hàng, để lưới + bàn phím 44px + gợi ý gần vừa một màn (ô chữ không phải vùng chạm) */
@media (max-width: 640px) {
  .g2-dna .gm-cell { height: 34px; font-size: 18px; }
  .g2-dna .gm-grid5 { gap: 3px; margin: 2px 0 4px; }
  .g2-dna .gm-grid5 .r { grid-template-columns: repeat(5, 44px); gap: 4px; }
  .g2-dna .gm-fb { min-height: 20px; margin-top: 2px; font-size: 14px; }
  .g2-dna .gm-hints { flex-wrap: nowrap; gap: 6px; margin-top: 6px; }
  .g2-dna .gm-hints .gm-btn { flex: 1 1 0; min-width: 0; padding: 0 4px; font-size: 13px; line-height: 1.15; }
  .g2-dna .gm-kb { margin-top: 2px; }
}
/* điện thoại dọc màn thấp (≤ 700px, ví dụ 360×640): không phải cuộn – dòng thông tin và hai nút gợi ý chung một hàng trên cùng,
   manh mối giới hạn chiều cao (cuộn trong ô), bàn phím dính đáy khung nhìn để luôn thấy dù manh mối dài */
@media (max-width: 640px) and (max-height: 700px) {
  .g2-dna { display: flex; flex-wrap: wrap; align-items: center; column-gap: 6px; padding-top: 6px; padding-bottom: 0; }
  .g2-dna .g2-dna-cols, .g2-dna .g2-dna-r { display: contents; }
  .g2-dna > * { order: 5; width: 100%; }
  .g2-dna .g2-dna-top { order: 0; width: auto; flex: 0 1 auto; max-width: 104px; margin: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 0; font-size: 12.5px; line-height: 1.3; }
  .g2-dna .g2-dna-top .g2-tong { display: none; }
  .g2-dna .gm-hints { order: 1; width: auto; flex: 1 1 0; margin: 0; }
  .g2-dna .g2-clue-top { order: 2; width: 100%; margin: 4px 0 3px; gap: 4px; max-height: 84px; overflow-y: auto; }
  .g2-dna .g2-clue-top div { padding: 4px 10px; font-size: 13.5px; line-height: 1.35; }
  .g2-dna:has(.gm-actions) .g2-clue-top { max-height: none; }
  .g2-dna .g2-dna-l { order: 3; width: 100%; }
  .g2-dna .gm-fb { order: 4; width: 100%; min-height: 18px; margin: 0; font-size: 13.5px; line-height: 1.3; }
  .g2-dna .g2-card-slot { order: 5; width: 100%; }
  .g2-dna .gm-kb { order: 6; position: sticky; bottom: 0; z-index: 3; flex: none; background: var(--gm-paper); padding: 4px 0 calc(6px + env(safe-area-inset-bottom, 0px)); }
  .g2-dna .gm-actions { order: 7; width: 100%; padding-bottom: 12px; }
  .g2-dna .gm-cell { height: 28px; font-size: 16px; }
  .g2-dna .gm-grid5 { gap: 2px; margin: 0 0 2px; }
}
