/* khmermath.org — «ប៊ីងហ្គោគណិតវិទ្យា» (play/bingo.html, static/js/bingo.js) */
.bg { max-width: 1180px; margin: 0 auto; }
.bg [hidden] { display: none !important; }
.bg-box { padding: 16px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.bg-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; }
.bg-head b { font-size: 19px; color: var(--teal-strong); }
.bg-hint { margin: 0; font-size: 14px; line-height: 1.7; color: var(--ink-3); }
.bg-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bg .btn { min-height: 44px; }
.bg input[type="number"], .bg select { min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--line-2); background: var(--bg); color: var(--ink); font: inherit; font-size: 16px; }
.bg input[type="number"] { width: 110px; }
.bg-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.bg-opts label { display: flex; flex-direction: column; gap: 4px; font-size: 15px; color: var(--ink-2); }
.bg-lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.bg-lesson { display: grid; grid-template-columns: 22px auto 1fr; gap: 2px 8px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line-2); background: var(--surface-2); cursor: pointer; }
.bg-lesson.on { border-color: var(--teal); background: var(--teal-soft); }
.bg-lesson input { width: 20px; height: 20px; }
.bg-lesson span { font-weight: 600; }
.bg-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }

/* the printed cards */
.bg-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.bg-card { background: #fff; border: 3px solid #1f6f66; border-radius: 16px; padding: 12px; break-inside: avoid; color: #111; }
.bg-chead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; padding: 6px 12px; border-radius: 10px; background: #1f6f66; color: #fff; font-size: 17px; }
.bg-no { font-weight: 800; font-size: 20px; }
.bg-grid { display: grid; gap: 4px; }
.bg-grid.g3 { grid-template-columns: repeat(3, 1fr); } .bg-grid.g4 { grid-template-columns: repeat(4, 1fr); } .bg-grid.g5 { grid-template-columns: repeat(5, 1fr); }
.bg-cell { aspect-ratio: 1; display: grid; place-items: center; text-align: center; border: 2px solid #1f6f66; border-radius: 8px; padding: 2px; font-size: 18px; font-weight: 700; line-height: 1.2; overflow: hidden; background: #fff; overflow-wrap: anywhere; }
.bg-grid.g5 .bg-cell { font-size: 14px; } .bg-grid.g3 .bg-cell { font-size: 22px; }
.bg-cell.free { background: #ffe066; font-size: 28px; }
.bg-cell.hit { background: #d3f9d8; border-color: #2f9e44; }
.bg-cell.win { background: #51cf66; color: #fff; }
.bg-foot { margin-top: 8px; font-size: 12px; text-align: center; color: #555; }

/* the caller (projector) */
html.bg-noscroll, html.bg-noscroll body { overflow: hidden; }
.bg.bg-live { position: fixed; inset: 0; z-index: 70; max-width: none; margin: 0; background: var(--bg); padding: 10px clamp(10px, 2vw, 24px); box-sizing: border-box; display: flex; flex-direction: column; }
.bg-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; font-size: 20px; }
.bg-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); grid-template-rows: minmax(0, 1fr); gap: 14px; }
.bg-left { min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.bg-q { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); text-align: center; }
.bg-qt { font-size: clamp(22px, 4.6vh + .8vw, 48px); font-weight: 700; line-height: 1.6; color: var(--ink); }
.bg-fig svg { height: clamp(120px, 30vh, 320px); width: auto; max-width: 100%; background: #fff; border-radius: 14px; border: 2px solid var(--line-2); padding: 4px; margin-top: 8px; }
.bg-fig svg text { font-family: "KaTeX_Math", serif; font-style: italic; } .bg-fig svg text.up { font-style: normal; }
.bg-opts2, .bg-opts { }
.bg-q .bg-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; text-align: left; }
.bg-o { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border: 2px solid var(--line-2); border-radius: 12px; font-size: clamp(16px, 2.6vh + .5vw, 28px); font-weight: 600; background: var(--surface-2); }
.bg-o b { width: 1.6em; height: 1.6em; display: grid; place-items: center; border-radius: 50%; background: var(--teal); color: #fff; font-size: .8em; flex: none; }
.bg-answer { padding: 12px 16px; border-radius: 16px; background: var(--teal-soft); border: 2px dashed var(--teal); font-size: clamp(22px, 4vh + .6vw, 44px); font-weight: 800; color: var(--teal-strong); text-align: center; }
.bg-sol { margin-top: 6px; font-size: .5em; font-weight: 500; color: var(--ink-2); }
.bg-ctl { justify-content: center; }
.bg-ctl .btn { min-height: 52px; font-size: 18px; padding: 8px 24px; }
.bg-right { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.bg-hist { display: flex; flex-wrap: wrap; gap: 6px; }
.bg-chip { padding: 4px 12px; border-radius: 999px; background: var(--surface-2); border: 1.5px solid var(--line-2); font-weight: 700; font-size: 16px; }
.bg-chip.now { background: #ffe066; border-color: #f08c00; }
.bg-checkbox { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.bg-verdict { padding: 8px 12px; border-radius: 12px; font-weight: 800; font-size: 20px; text-align: center; }
.bg-verdict.ok { background: #d3f9d8; color: #14532d; } .bg-verdict.no { background: #fff3bf; color: #7a5a00; }
.bg-checkbox .bg-card { padding: 8px; } .bg-checkbox .bg-cell { font-size: 13px; }
@media (max-width: 800px) {
  .bg-main { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1.4fr) minmax(0, 1fr); }
  .bg-q .bg-opts { grid-template-columns: 1fr; }
  .bg-qt { font-size: clamp(18px, 5vw, 26px); }
}

/* printing: one card per cell, 2 per A4 page for 4x4/5x5 and 4 for 3x3, nothing else */
@media print {
  @page { size: A4; margin: 10mm; }
  body * { visibility: hidden; }
  .bg-cards, .bg-cards * { visibility: visible; }
  .bg-cards { position: absolute; left: 0; top: 0; width: 100%; grid-template-columns: 1fr 1fr; gap: 6mm; }
  .bg-cards.s5, .bg-cards.s4 { grid-template-columns: 1fr; }
  .bg-card { page-break-inside: avoid; border-width: 2px; }
  .bg-cards.s5 .bg-card, .bg-cards.s4 .bg-card { max-height: 135mm; }
  .bg-cards.s4 .bg-cell, .bg-cards.s5 .bg-cell { aspect-ratio: auto; height: 22mm; }
  .bg-cards.s5 .bg-cell { height: 19mm; }
  .bg-cards.s3 .bg-cell { height: 26mm; }
}
.bg.bg-live #bg-v-call { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.bg-cell.long { font-size: 13px !important; line-height: 1.25; }

/* ===== simple setup (static/js/bgui.js) ===== */
.bgx { display: flex; flex-direction: column; gap: 16px; padding-bottom: 90px; }
.bgx-step { padding: 18px clamp(14px, 2.4vw, 24px); border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(16, 42, 67, .06); display: flex; flex-direction: column; gap: 12px; }
.bgx-step h2 { margin: 0; font-size: 20px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bgx-step h2 small { font-weight: 400; font-size: 14px; color: var(--ink-3); }
.bgx-n { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--teal); color: #fff; font-size: 16px; font-weight: 800; }
.bgx-sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.bgx-sizes button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; border-radius: 16px; border: 3px solid var(--line-2); background: var(--surface-2); cursor: pointer; font: inherit; color: inherit; }
.bgx-sizes button.on { border-color: var(--teal); background: var(--teal-soft); box-shadow: 0 0 0 3px var(--teal-soft); }
.bgx-sizes b { font-size: 22px; } .bgx-sizes small { color: var(--ink-3); font-size: 13px; text-align: center; }
.bgx-mini { width: 56px; height: 56px; border-radius: 8px; background: #fff; border: 2px solid var(--teal); display: block; }
.bgx-mini.g3 { background-image: linear-gradient(var(--teal) 2px, transparent 2px), linear-gradient(90deg, var(--teal) 2px, transparent 2px); background-size: 33.3% 33.3%; }
.bgx-mini.g4 { background-image: linear-gradient(var(--teal) 2px, transparent 2px), linear-gradient(90deg, var(--teal) 2px, transparent 2px); background-size: 25% 25%; }
.bgx-mini.g5 { background-image: linear-gradient(var(--teal) 2px, transparent 2px), linear-gradient(90deg, var(--teal) 2px, transparent 2px); background-size: 20% 20%; }
.bgx-row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.bgx-chips { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.bgx-chips button { min-width: 56px; height: 46px; padding: 0 14px; border-radius: 99px; border: 2px solid var(--line-2); background: var(--surface-2); font: inherit; font-weight: 700; cursor: pointer; color: var(--ink-2); }
.bgx-chips button.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.bgx-or { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink-2); }
.bgx-more { border-radius: 16px; border: 1px dashed var(--line-2); padding: 4px 14px 12px; }
.bgx-more > summary { cursor: pointer; font-weight: 700; padding: 12px 0; }
.bgx-bar { position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-radius: 18px 18px 0 0; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; box-shadow: 0 -8px 24px rgba(16, 42, 67, .14); }
.bgx-sum { font-weight: 700; color: var(--ink-2); }
.bgx-bar .btn-primary { font-size: 20px; padding: 12px 34px; border-radius: 99px; }
@media (max-width: 640px) { .bgx-sizes { gap: 8px; } .bgx-mini { width: 40px; height: 40px; } .bgx-sizes b { font-size: 18px; } .bgx-bar { gap: 6px; padding: 8px 12px; } .bgx-sum { width: 100%; text-align: center; font-size: 13px; } .bgx-bar .bg-row { width: 100%; flex-wrap: nowrap; } .bgx-bar .btn { flex: 1; } }
