/**
 * BEElio — Pre-Reader Studio V2.0 Stylesheet (Chỉ kích hoạt cho Tiền Tiểu Học · `data-grade="0"`)
 *
 * - Font học đường 1 tầng ('Quicksand' offline-first): Chữ `a, ă, â, g` hiển thị 1 tầng chuẩn Vở Tập Tô Bộ GD&ĐT.
 * - Sân khấu Đa giác quan: Thẻ Chữ/Số chạm phát âm + Khay Chạm-Để-Đếm 1–1 + Bảng Tô Chữ SVG Cảm Ứng (`touch-action: none`).
 * - Lưới đáp án 2×2 không nhãn A/B/C/D + Huy hiệu 2-Chạm chốt đáp án (`👆 Chạm lần nữa để chốt!`).
 */

/* ==========================================================================
   1. FONT CHỮ HỌC ĐƯỜNG 1 TẦNG (SINGLE-STORY SCHOOLBOOK GLYPHS)
   ========================================================================== */
.g0-schoolbook-glyph {
  font-family: 'Quicksand', 'Nunito', sans-serif !important;
  font-weight: 700 !important;
  letter-spacing: 0.02em;
  font-variant-numeric: lining-nums tabular-nums;
}

/* Ẩn Vở nháp ô li cấp Tiểu học ở thanh đáy của Tiền Tiểu Học để giao diện thoáng sạch cho bé 5 tuổi */
.beelio-lesson-viewport[data-grade="0"] #btn-toggle-scratchpad,
.beelio-lesson-viewport[data-grade="0"] .bls-scratchpad-panel {
  display: none !important;
}

/* Tăng kích thước & độ rõ ràng của nút Loa đọc đề bài ở Tiền Tiểu Học */
.beelio-lesson-viewport[data-grade="0"] .beelio-speaker-btn {
  padding: 8px 14px !important;
  font-size: 14px !important;
  font-weight: 800 !important;
  border-radius: 999px !important;
}

.beelio-lesson-viewport[data-grade="0"] #beelio-prompt-text {
  font-size: 19px;
  line-height: 1.5;
  font-weight: 700;
}

/* ==========================================================================
   2. SÂN KHẤU ĐA GIÁC QUAN TRƯỚC BÀI HỌC (.g0-prereader-stage-card)
   ========================================================================== */
.g0-prereader-stage-card {
  background: linear-gradient(180deg, #FFFDF7 0%, #FFFFFF 100%) !important;
  border: 2.5px solid #FDE68A !important;
  border-radius: 26px !important;
  box-shadow: 0 12px 32px rgba(245, 158, 11, 0.12) !important;
}

.g0-stage-badge {
  background: #FEF3C7 !important;
  color: #B45309 !important;
  border: 1.5px solid #FCD34D !important;
  font-weight: 800 !important;
}

.g0-stage-title {
  font-family: 'Quicksand', 'Nunito', sans-serif !important;
  font-weight: 700 !important;
}

.g0-showcase-hint {
  margin: 10px 0 12px;
  padding: 8px 14px;
  border-radius: 14px;
  background: #EFF6FF;
  border: 1.5px solid #BFDBFE;
  color: #1D4ED8;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.g0-showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.g0-showcase-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 12px 14px;
  background: #FFFFFF;
  border: 2.5px solid #E2E8F0;
  border-bottom-width: 5px;
  border-radius: 22px;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  text-align: center;
}

.g0-showcase-card:hover,
.g0-showcase-card:focus-visible {
  border-color: #38BDF8;
  background: #F0F9FF;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(14, 165, 233, 0.15);
}

.g0-showcase-card:active,
.g0-showcase-card.is-popping {
  transform: scale(0.96);
  border-color: #F59E0B;
  background: #FFFBEB;
}

.g0-card-speaker-chip {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #FEF3C7;
  border: 1px solid #FDE68A;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.g0-showcase-card .g0-schoolbook-glyph {
  font-size: 46px;
  line-height: 1.08;
  color: #0F172A;
  padding: 2px 10px;
  border-radius: 14px;
  background: #FFFBEB;
  border: 1.5px dashed #FCD34D;
}

.g0-showcase-emoji {
  font-size: 36px;
  line-height: 1.15;
}

.g0-showcase-word {
  font-family: 'Quicksand', 'Nunito', sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: #1E293B;
  line-height: 1.25;
}

.g0-letter-hl {
  background: transparent;
  color: #DC2626;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2.5px;
  text-underline-offset: 3px;
}

.g0-showcase-sub {
  font-size: 13px;
  font-weight: 700;
  color: #64748B;
}

/* ==========================================================================
   3. KHAY CHẠM ĐỂ ĐẾM 1–1 & BẢNG TÔ CHỮ SVG CẢM ỨNG (.g0-interactive-panel)
   ========================================================================== */
.g0-interactive-panel {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 22px;
  background: #F8FAFC;
  border: 2px solid #E2E8F0;
}

.g0-count-playground {
  background: linear-gradient(180deg, #FFFBEB 0%, #FEF3C7 100%);
  border-color: #FCD34D;
}

.g0-trace-playground {
  background: linear-gradient(180deg, #F0FDF4 0%, #DCFCE7 100%);
  border-color: #86EFAC;
}

.g0-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.g0-panel-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 800;
  color: #1E293B;
  flex: 1 1 200px;
}

.g0-count-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: #FFFFFF;
  border: 1.5px solid #F59E0B;
  font-size: 14px;
  font-weight: 800;
  color: #92400E;
}

.g0-count-live-num {
  font-family: 'Quicksand', 'Nunito', sans-serif;
  font-size: 20px;
  color: #D97706;
}

.g0-mini-reset-btn {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1.5px solid #CBD5E1;
  background: #FFFFFF;
  color: #334155;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.g0-mini-reset-btn:hover {
  background: #F1F5F9;
}

.g0-count-tokens-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.85);
  border: 2px dashed #FBBF24;
}

.g0-count-token {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  border: 2.5px solid #E2E8F0;
  border-bottom-width: 4px;
  background: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.g0-token-emoji {
  font-size: 34px;
  line-height: 1;
}

.g0-token-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  border-radius: 999px;
  background: #E2E8F0;
  color: #64748B;
  font-family: 'Quicksand', 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #FFFFFF;
}

.g0-count-token.is-counted {
  border-color: #10B981;
  background: #ECFDF5;
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 6px 14px rgba(16, 185, 129, 0.2);
}

.g0-count-token.is-counted .g0-token-badge {
  background: #10B981;
  color: #FFFFFF;
  font-size: 14px;
}

.g0-empty-basket-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 2px dashed #F59E0B;
  background: #FFFFFF;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  color: #92400E;
}

.g0-empty-basket-icon {
  font-size: 38px;
}

/* Bảng tập tô SVG */
.g0-trace-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.g0-trace-tabs {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.g0-trace-tab {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1.5px solid #86EFAC;
  background: #FFFFFF;
  color: #166534;
  font-family: 'Quicksand', 'Nunito', sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.g0-trace-tab.is-active {
  background: #16A34A;
  border-color: #15803D;
  color: #FFFFFF;
}

.g0-trace-stage-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.g0-trace-canvas-box {
  width: 180px;
  height: 180px;
  margin: 0 auto;
  border-radius: 22px;
  background: #FFFFFF;
  border: 3px solid #4ADE80;
  box-shadow: inset 0 2px 8px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.g0-trace-svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

.g0-grid-line {
  stroke: #E0F2FE;
  stroke-width: 1.5;
}

.g0-grid-line.is-mid {
  stroke-dasharray: 4 4;
}

.g0-grid-line.is-base {
  stroke: #BAE6FD;
  stroke-width: 2.2;
}

.g0-trace-track-bg {
  fill: none;
  stroke: #E2E8F0;
  stroke-width: 22;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.g0-trace-track-dashed {
  fill: none;
  stroke: #94A3B8;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 7 8;
}

.g0-user-trace-stroke {
  fill: none;
  stroke: #F59E0B;
  stroke-width: 16;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.92;
}

.g0-start-halo {
  fill: #FEF3C7;
  stroke: #F59E0B;
  stroke-width: 2;
}

.g0-trace-status-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid #BBF7D0;
}

.g0-trace-glyph-preview {
  font-size: 26px;
  color: #15803D;
  margin-bottom: 6px;
}

.g0-trace-status-msg {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.45;
  font-weight: 700;
  color: #334155;
}

.g0-trace-status-msg.is-complete {
  color: #15803D;
}

.g0-btn-big-play {
  font-size: 16.5px !important;
  padding: 14px 24px !important;
  border-radius: 18px !important;
  font-weight: 800 !important;
}

.g0-footer-note {
  font-size: 14px;
  font-weight: 800;
  color: #15803D;
}

/* ==========================================================================
   4. KHAY ĐẾM ĐỒ VẬT CỠ LỚN NGAY DƯỚI ĐỀ BÀI (.g0-prompt-visual-tray)
   ========================================================================== */
.g0-prompt-visual-tray {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 20px;
  background: linear-gradient(180deg, #FFFDF5 0%, #FEF3C7 100%);
  border: 2px solid #FCD34D;
  text-align: center;
}

.g0-prompt-tray-caption {
  font-size: 13.5px;
  font-weight: 800;
  color: #B45309;
  margin-bottom: 8px;
}

.g0-prompt-tray-groups {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.g0-prompt-plate {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 18px;
  background: #FFFFFF;
  border: 2px solid #FDE68A;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.1);
}

.g0-prompt-group-plus {
  font-size: 24px;
  font-weight: 900;
  color: #D97706;
}

.g0-prompt-count-item {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 2px solid #E2E8F0;
  border-bottom-width: 4px;
  background: #FFFBEB;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.g0-prompt-item-emoji {
  font-size: 32px;
  line-height: 1;
}

.g0-prompt-item-num {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #10B981;
  color: #FFFFFF;
  font-family: 'Quicksand', 'Nunito', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid #FFFFFF;
}

.g0-prompt-count-item.is-counted {
  border-color: #10B981;
  background: #ECFDF5;
  transform: scale(1.06);
}

.g0-prompt-count-item.is-counted .g0-prompt-item-num {
  display: inline-flex;
}

.g0-prompt-tray-items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.g0-pattern-chip {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: #FFFFFF;
  border: 2px solid #FDE68A;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.g0-pattern-chip.is-mystery {
  background: #EFF6FF;
  border: 2.5px dashed #3B82F6;
  color: #1D4ED8;
  font-family: 'Quicksand', 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 26px;
}

/* ==========================================================================
   5. LƯỚI ĐÁP ÁN 2×2 KHÔNG NHÃN A/B/C/D (.g0-options-grid-2x2)
   ========================================================================== */
.beelio-options-grid.g0-options-grid-2x2 {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 12px !important;
}

.g0-prereader-choice-card {
  position: relative !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 112px !important;
  padding: 18px 14px 20px !important;
  border-radius: 22px !important;
  text-align: center !important;
  gap: 6px !important;
}

.g0-opt-speaker-chip,
.g0-opt-look-chip {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.g0-opt-look-chip {
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  opacity: 0.75;
}

.g0-opt-body {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.g0-opt-hero-glyph.is-numeral {
  font-size: 50px;
  line-height: 1.05;
  color: #0F172A;
}

.g0-opt-hero-glyph.is-numeral-sm {
  font-size: 40px;
  line-height: 1.05;
  color: #0F172A;
}

.g0-opt-hero-glyph.is-letter {
  font-size: 48px;
  line-height: 1.08;
  color: #0F172A;
}

.g0-opt-num-qty-wrap,
.g0-opt-letter-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.g0-opt-sub-caption {
  font-size: 13.5px;
  font-weight: 700;
  color: #475569;
  line-height: 1.25;
}

/* Chấm số lượng Ten-Frame (tối đa 5 chấm/hàng) */
.g0-qty-dots {
  display: inline-grid;
  grid-template-columns: repeat(5, 10px);
  gap: 4px;
  justify-content: center;
  padding: 3px 6px;
}

.g0-qty-dots.is-zero {
  display: inline-flex;
}

.g0-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #EF4444;
}

.g0-dot.is-row2 {
  background: #F59E0B;
}

.g0-dot-empty {
  font-size: 13px;
  color: #94A3B8;
  line-height: 1;
}

/* Cụm emoji trực quan trên thẻ */
.g0-opt-emoji-cluster {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 170px;
}

.g0-cluster-item {
  font-size: 32px;
  line-height: 1.1;
}

.g0-opt-emoji-cluster[data-count="1"] .g0-cluster-item {
  font-size: 42px;
}

/* Thẻ chữ dài kèm Biểu tượng Ngữ nghĩa */
.g0-opt-pictorial-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding-right: 10px;
}

.g0-opt-pictogram {
  font-size: 34px;
  line-height: 1.1;
}

.g0-opt-readable-text {
  font-size: 15px !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
  color: #1E293B;
  word-break: break-word;
}

/* Huy hiệu nhắc Chạm lần 2 để chốt ngay trên thẻ đang chọn */
.g0-doubletap-pill {
  display: none;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #16A34A;
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(22, 163, 74, 0.28);
}

.g0-prereader-choice-card.selected .g0-doubletap-pill {
  display: inline-flex;
  align-items: center;
}

.beelio-choice-card.correct-answer .g0-doubletap-pill,
.beelio-choice-card.wrong-answer .g0-doubletap-pill {
  display: none !important;
}

/* Tương thích màn hình hẹp 320px–520px */
@media (max-width: 540px) {
  .g0-trace-stage-row {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .beelio-options-grid.g0-options-grid-2x2.g0-long-options {
    grid-template-columns: 1fr !important;
  }

  .g0-options-grid-2x2.g0-long-options .g0-opt-pictorial-row {
    flex-direction: row;
    text-align: left;
    gap: 12px;
    padding-right: 26px;
  }

  .g0-prereader-choice-card {
    min-height: 98px !important;
    padding: 14px 10px 16px !important;
  }

  .g0-opt-hero-glyph.is-numeral {
    font-size: 42px;
  }

  .g0-opt-hero-glyph.is-letter {
    font-size: 42px;
  }
}
