/* ==========================================================================
   TOÁN VUI LỚP 3 — SÂN CHƠI TOÁN HỌC 1 MÀN HÌNH (HERO SIZE & SPOTLIGHT FX)
   Thiết kế Zero-Scroll · Chữ số cỡ lớn · Đèn rọi Spotlight · Mũi tên chỉ dẫn động
   ========================================================================== */

:root {
  --bg-game: #f4f7fe;
  --panel-bg: #ffffff;
  --purple-main: #6c5ce7;
  --purple-deep: #5443d4;
  --purple-soft: #f0edff;
  --yellow-star: #ffb703;
  --yellow-deep: #d97706;
  --yellow-soft: #fffbeb;
  --sky-bright: #00b4d8;
  --sky-soft: #e0f2fe;
  --mint-green: #06d6a0;
  --mint-soft: #ecfdf5;
  --coral-pop: #ff6b8b;
  --coral-soft: #fff1f2;
  --orange-play: #fb8500;

  /* Hàng giá trị chữ số */
  --color-unit: #ffb703;
  --color-ten: #00b4d8;
  --color-hundred: #06d6a0;
  --color-thousand: #6c5ce7;
  --color-ten-thousand: #fb8500;

  --text-main: #2d3436;
  --text-soft: #636e72;
  --text-muted: #8c98a4;
  --border-light: #e5e9f2;

  --radius-xl: 22px;
  --radius-btn: 14px;
  --radius-pill: 50px;
  --radius-sm: 10px;

  --shadow-game: 0 8px 24px rgba(108, 92, 231, 0.08);
  --font-family: 'Nunito', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-game);
  color: var(--text-main);
  font-family: var(--font-family);
  font-weight: 750;
  line-height: 1.4;
  user-select: none;
  -webkit-user-select: none;
}

.confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99999;
}

.game-console-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
}

/* ==========================================================================
   1. TOP GAME BAR
   ========================================================================== */
.game-top-bar {
  height: 48px;
  flex: 0 0 48px;
  background: var(--panel-bg);
  border-bottom: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(8px, 2vw, 18px);
  gap: 8px;
  z-index: 50;
}

.game-brand-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--yellow-soft);
  border: 1.5px solid #fde68a;
  border-radius: var(--radius-pill);
  padding: 3px 10px 3px 4px;
  cursor: pointer;
  flex: 0 0 auto;
}

.svg-mascot-tiny {
  width: 26px;
  height: 26px;
}

.brand-name-tag {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--purple-deep);
  white-space: nowrap;
}

.game-mode-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0;
  flex: 1;
  min-width: 0;
}

.game-mode-chips::-webkit-scrollbar {
  display: none;
}

.game-mode-chip {
  flex: 0 0 auto;
  background: #f1f3f9;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-pill);
  padding: 4px 11px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 850;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.game-mode-chip:hover {
  background: var(--purple-soft);
  color: var(--purple-main);
}

.game-mode-chip.active {
  background: var(--purple-main);
  border-color: var(--purple-deep);
  color: #fff;
  box-shadow: 0 2px 6px rgba(108, 92, 231, 0.35);
}

.game-mode-chip.tab-chip {
  background: #fff8e6;
  border-color: #fde68a;
  color: #92400e;
}

.game-mode-chip.tab-chip.active {
  background: var(--yellow-star);
  border-color: var(--yellow-deep);
  color: #451a03;
}

.top-util-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.util-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1.5px solid var(--border-light);
  display: grid;
  place-items: center;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.util-btn:active {
  transform: scale(0.92);
}

.util-btn.is-active {
  background: var(--purple-soft);
  border-color: var(--purple-main);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
}

.util-btn.is-speaking {
  animation: speakingPulse 0.7s ease-in-out infinite alternate;
}

@keyframes speakingPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.2); }
  100% { transform: scale(1.14); box-shadow: 0 0 12px rgba(108, 92, 231, 0.5); }
}

.streak-badge-mini {
  display: flex;
  align-items: center;
  gap: 3px;
  background: #fff3e0;
  border: 1.5px solid #ffcc80;
  border-radius: 14px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 900;
  color: #e65100;
}

/* ==========================================================================
   2. QUICK MATH RIBBON
   ========================================================================== */
.quick-math-ribbon {
  height: 46px;
  flex: 0 0 46px;
  background: linear-gradient(135deg, #fbfaff, #f7f6fe);
  border-bottom: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 clamp(8px, 2vw, 18px);
  position: relative;
}

.ribbon-form {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.ribbon-input-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
  max-width: 380px;
  display: flex;
  align-items: center;
}

.ribbon-prefix {
  position: absolute;
  left: 10px;
  font-size: 14px;
  pointer-events: none;
}

.ribbon-input-wrap input {
  width: 100%;
  height: 36px;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-pill);
  background: #fff;
  padding: 0 32px 0 34px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 900;
  color: var(--text-main);
  letter-spacing: 0.5px;
  outline: none;
  transition: all 0.15s ease;
}

.ribbon-input-wrap input:focus {
  border-color: var(--purple-main);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.18);
}

.ribbon-clear {
  position: absolute;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #edf0f7;
  color: #64748b;
  border: none;
  font-size: 11px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.ribbon-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.game-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 850;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  white-space: nowrap;
}

.game-btn:active {
  transform: translateY(2px);
}

.game-btn-dice {
  background: #fff8e6;
  border: 1.5px solid #fde68a;
  color: #92400e;
  box-shadow: 0 3px 0 #fcd34d;
}

.game-btn-keypad {
  background: var(--purple-soft);
  border: 1.5px solid #ddd6fe;
  color: var(--purple-deep);
  box-shadow: 0 3px 0 #c4b5fd;
}

.game-btn-go {
  background: linear-gradient(180deg, #7c6cfb, #6c5ce7);
  color: #fff;
  box-shadow: 0 3px 0 var(--purple-deep);
}

.game-btn-play {
  background: linear-gradient(180deg, #ffc021, #ffb703);
  color: #451a03;
  box-shadow: 0 3px 0 var(--yellow-deep);
}

.game-btn-next {
  background: linear-gradient(180deg, #10e7b0, #06d6a0);
  color: #034232;
  box-shadow: 0 3px 0 #05b386;
}

.game-btn-small {
  height: 30px;
  font-size: 11px;
  padding: 0 8px;
}

.ribbon-error {
  position: absolute;
  top: 48px;
  left: 12px;
  right: 12px;
  background: #fff1f2;
  border: 1.5px solid #fecdd3;
  color: #e11d48;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 8px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.15);
}

/* ==========================================================================
   3. SÂN KHẤU TRÒ CHƠI TRUNG TÂM (CENTRAL GAME STAGE)
   ========================================================================== */
.game-stage-viewport {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 6px clamp(8px, 2vw, 18px);
  position: relative;
}

.screen-stage {
  display: none;
  height: 100%;
  flex-direction: column;
}

.screen-stage.active-stage {
  display: flex;
  animation: stageFadeIn 0.25s ease;
}

@keyframes stageFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   LIVE ACTION FORMULA BUBBLE (Bong bóng công thức hành động - Hero Size)
   ========================================================================== */
.live-action-bubble {
  flex: 0 0 auto;
  background: linear-gradient(135deg, #fff9e6 0%, #fff0c7 100%);
  border: 2.5px solid #ffb703;
  border-radius: 16px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 6px 20px rgba(255, 183, 3, 0.25);
  margin-bottom: 6px;
  animation: bubblePopIn 0.35s cubic-bezier(0.15, 1.4, 0.45, 1);
  position: relative;
}

@keyframes bubblePopIn {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.bubble-mascot-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
  background: #ffffff;
  display: grid;
  place-items: center;
  font-size: 22px;
  box-shadow: 0 3px 8px rgba(255, 183, 3, 0.3);
}

.action-bubble-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.math-action-equation {
  font-size: clamp(22px, 3.8vw, 30px);
  font-weight: 900;
  color: #78350f;
  letter-spacing: 0.8px;
  line-height: 1.2;
}

.math-action-sub {
  font-size: clamp(12.5px, 2.2vw, 15px);
  font-weight: 850;
  color: #92400e;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-phase-pill {
  font-size: 11px;
  font-weight: 900;
  background: var(--purple-main);
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 10px;
  white-space: nowrap;
  flex: 0 0 auto;
}

/* ==========================================================================
   SÂN ĐẤU BẢNG TÍNH THẦN KỲ TÍCH HỢP HƯỚNG DẪN (ZERO-SCROLL ARENA)
   ========================================================================== */
.magic-stage-arena {
  flex: 1;
  min-height: 0;
  background: #ffffff;
  border: 2.5px solid var(--border-light);
  border-radius: 18px;
  box-shadow: var(--shadow-game);
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  overflow: hidden;
  position: relative;
}

.number-board-arena {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  overflow-y: auto;
  padding: 4px;
  position: relative;
}

/* Lớp SVG vẽ Mũi tên chỉ dẫn động */
.motion-arrow-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
}

.motion-arrow-path {
  fill: none;
  stroke: #ff9f43;
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-dasharray: 8 6;
  animation: dashFlow 1s linear infinite;
  filter: drop-shadow(0 2px 4px rgba(255, 159, 67, 0.4));
}

@keyframes dashFlow {
  to { stroke-dashoffset: -28; }
}

/* ==========================================================================
   BỐ CỤC TÍCH HỢP HƯỚNG DẪN SƯ PHẠM NGAY TRONG BẢNG TÍNH
   Desktop: 2 Cột song đôi · Mobile: Xếp dọc trên - dưới
   ========================================================================== */
.board-interactive-layout {
  display: grid;
  grid-template-columns: minmax(340px, 1.25fr) minmax(290px, 1fr);
  gap: 16px;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.board-calc-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.board-guide-col {
  width: 100%;
}

/* KHUNG HƯỚNG DẪN SƯ PHẠM THẦN KỲ (Tích hợp trong Number Board) */
.board-guide-card {
  background: linear-gradient(145deg, #ffffff 0%, #fffdf0 100%);
  border: 2px solid #fde047;
  border-radius: 20px;
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.16);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: cardPop 0.35s ease both;
}

@keyframes cardPop {
  0% { transform: scale(0.96); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.guide-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.guide-step-badge {
  font-size: 11px;
  font-weight: 900;
  color: #ffffff;
  background: var(--purple-main);
  padding: 3px 10px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}

.guide-phase-pill {
  font-size: 11px;
  font-weight: 900;
  color: #b45309;
  background: #fef3c7;
  padding: 3px 10px;
  border-radius: 8px;
  text-transform: uppercase;
}

.guide-step-title {
  font-size: clamp(16px, 2.4vw, 19px);
  font-weight: 900;
  color: var(--purple-deep);
  margin: 0;
  line-height: 1.25;
}

.guide-action-box {
  background: #ffffff;
  border: 2px solid #fef08a;
  border-radius: 14px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.03);
}

.guide-action-emoji {
  font-size: 28px;
  flex: 0 0 auto;
  animation: emojiHop 1.6s infinite ease-in-out;
}

@keyframes emojiHop {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.12); }
}

.guide-equation-wrap {
  flex: 1;
  min-width: 0;
}

.guide-equation-text {
  font-size: clamp(20px, 3.2vw, 26px);
  font-weight: 900;
  color: #78350f;
  line-height: 1.2;
}

.guide-sub-text {
  font-size: clamp(12.5px, 2vw, 14.5px);
  font-weight: 850;
  color: #92400e;
  margin-top: 2px;
  line-height: 1.35;
}

.guide-step-desc {
  font-size: 13.5px;
  font-weight: 700;
  color: #475569;
  line-height: 1.4;
  margin: 0;
}

/* ==========================================================================
   BẢNG TÍNH THẦN KỲ "ĐẶT TÍNH RỒI TÍNH" CỠ JUMBO HERO
   ========================================================================== */
.math-sgk-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  width: auto;
  max-width: 100%;
}

.sgk-grid-row {
  display: grid;
  grid-template-columns: 52px repeat(var(--cols), minmax(52px, 74px));
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.sgk-place-pill {
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  padding: 5px 2px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--text-soft);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sgk-place-pill:hover {
  transform: translateY(-2px);
  border-color: var(--purple-main);
}

.sgk-place-pill[data-place="0"] { color: #b45309; background: #fef3c7; }
.sgk-place-pill[data-place="1"] { color: #0369a1; background: #e0f2fe; }
.sgk-place-pill[data-place="2"] { color: #047857; background: #d1fae5; }
.sgk-place-pill[data-place="3"] { color: #5b21b6; background: #ede9fe; }
.sgk-place-pill[data-place="4"] { color: #c2410c; background: #ffedd5; }

.sgk-place-pill.spotlight-active {
  transform: scale(1.12);
  background: #fef08a !important;
  color: #854d0e !important;
  border-color: #facc15 !important;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.sgk-place-pill.spotlight-dim {
  opacity: 0.45;
}

.sgk-row-label {
  font-size: 28px;
  font-weight: 900;
  color: var(--purple-main);
  text-align: right;
  padding-right: 8px;
}

.sgk-carry-box {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  color: #b45309;
}

.carry-star-badge {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #78350f;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
  animation: starPop 0.4s ease both;
}

.borrow-pill-badge {
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  color: #ffffff;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
  animation: starPop 0.4s ease both;
}

/* Ô CHỮ SỐ CỠ JUMBO HERO (KHÔNG VIỀN THÔ, HIỆU ỨNG 3D CANDY) */
.sgk-digit-cell {
  height: clamp(54px, 8.5vw, 68px);
  border-radius: 16px;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(34px, 5.5vw, 44px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  position: relative;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  cursor: pointer;
}

.sgk-digit-cell:hover {
  border-color: var(--purple-main);
  transform: translateY(-2px);
}

/* HIỆU ỨNG NHÍ NHỐ: CỘT ĐANG TÍNH NẢY TƯNG TƯNG & BỪNG SÁNG DỊU DÀNG (KHÔNG VIỀN THÔ CỨNG) */
.sgk-digit-cell.spotlight-active,
.sgk-digit-cell.digit-playful-active {
  transform: scale(1.15) !important;
  z-index: 20;
  background: linear-gradient(180deg, #ffffff 0%, #fef9c3 100%) !important;
  border: 2.5px solid #facc15 !important;
  color: #78350f !important;
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.28), 0 2px 6px rgba(0, 0, 0, 0.04) !important;
  border-radius: 18px !important;
  animation: playfulWiggle 1.4s infinite cubic-bezier(0.28, 0.84, 0.42, 1) !important;
}

@keyframes playfulWiggle {
  0%, 100% { transform: scale(1.14) rotate(0deg); }
  20% { transform: scale(1.22, 1.05) rotate(-4deg); }
  40% { transform: scale(1.06, 1.2) rotate(4deg); }
  60% { transform: scale(1.18, 1.08) rotate(-2deg); }
  80% { transform: scale(1.1, 1.14) rotate(1deg); }
}

/* CÁC CỘT KHÁC MỜ DỊU ĐỂ NỔI BẬT CỘT ĐANG TÍNH */
.sgk-digit-cell.spotlight-dim {
  opacity: 0.38;
  filter: grayscale(25%);
  transform: scale(0.94);
}

.sgk-digit-cell.is-source {
  background: #fff1f2;
  border-color: #fda4af;
  color: #b91c1c;
}

.sgk-digit-cell.is-modified {
  background: #f0f9ff;
  border-color: #bae6fd;
  color: #0369a1;
}

.sgk-digit-cell.is-result:not(.is-hidden) {
  background: #ecfdf5;
  border-color: #06d6a0;
  color: #047857;
  animation: resultPopIn 0.35s both;
}

.sgk-digit-cell.is-hidden {
  background: transparent;
  border-color: transparent;
  color: #cbd5e1;
}

.strikethrough-old {
  position: absolute;
  top: -14px;
  right: 2px;
  font-size: 15px;
  font-weight: 900;
  color: #ef4444;
  text-decoration: line-through 2.5px #dc2626;
  opacity: 0.85;
  animation: strikeCross 0.4s ease both;
}

@keyframes strikeCross {
  0% { transform: scale(0.6) rotate(-15deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.math-calc-line {
  width: 100%;
  height: 4.5px;
  background: var(--purple-main);
  border-radius: 6px;
  margin: 4px 0 6px;
}

.arena-footer-bar {
  flex: 0 0 auto;
  border-top: 1.5px dashed var(--border-light);
  padding-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.arena-action-text {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 850;
  color: var(--purple-deep);
}

.arena-model-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   PHÉP CHIA 4 NHỊP SGK CỠ LỚN (HERO SIZE DIVISION)
   ========================================================================== */
.sgk-division-board {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.div-rhythm-compact {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #f8fafc;
  border: 2px solid var(--border-light);
  border-radius: 14px;
  padding: 6px 12px;
}

.rhythm-chip {
  padding: 5px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 900;
  color: var(--text-muted);
  background: #fff;
  border: 1.5px solid var(--border-light);
  transition: all 0.25s ease;
}

.rhythm-chip.active {
  background: var(--yellow-star);
  color: #451a03;
  border-color: #d97706;
  box-shadow: 0 3px 0 #b45309;
  transform: scale(1.08);
}

.div-bracket-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0 20px;
  background: #f8fafc;
  padding: 14px 22px;
  border-radius: 22px;
  border: 2.5px solid #e2e8f0;
  box-shadow: 0 10px 28px rgba(108, 92, 231, 0.1);
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

.div-work-column {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 140px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

.div-digits-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  font-size: clamp(32px, 4vw, 42px);
  font-weight: 900;
  letter-spacing: 3px;
  color: #1e293b;
  min-height: 46px;
}

.div-cell-char {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(28px, 3.5vw, 36px);
  height: clamp(38px, 4.5vw, 46px);
  text-align: center;
  border-radius: 8px;
  transition: all 0.25s ease;
}

.div-tier-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: 100%;
  gap: 2px;
  margin-top: 2px;
}

.div-sub-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  font-size: clamp(30px, 3.8vw, 38px);
  font-weight: 900;
  color: #7c3aed;
  position: relative;
}

.div-sub-sign {
  font-size: 24px;
  font-weight: 900;
  color: #ef4444;
  margin-right: 6px;
}

.div-sub-line {
  width: 100%;
  height: 3px;
  background: #94a3b8;
  border-radius: 2px;
  margin: 2px 0;
}

.div-rem-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  font-size: clamp(32px, 4vw, 40px);
  font-weight: 900;
  color: #047857;
}

.div-remainder-final-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fee2e2;
  border: 2px solid #ef4444;
  color: #b91c1c;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 900;
  margin-top: 8px;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.22);
}

.div-divisor-bracket {
  border-left: 4px solid #6c5ce7;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.div-divisor-val {
  font-size: clamp(32px, 4vw, 42px);
  font-weight: 900;
  color: #6c5ce7;
  border-bottom: 4px solid #6c5ce7;
  padding-bottom: 6px;
  line-height: 1;
}

.div-quotient-display {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: clamp(34px, 4.2vw, 44px);
  font-weight: 900;
  color: #047857;
  letter-spacing: 4px;
  min-height: 46px;
}

/* Hình học tương tác */
.geo-interactive-item {
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.geo-interactive-item:hover,
.geo-interactive-item.is-active {
  filter: drop-shadow(0 0 10px #ff9f43) drop-shadow(0 0 3px #f59e0b);
  stroke-width: 6.5px !important;
  opacity: 1 !important;
}
.geo-table-feature {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  line-height: 1.4;
}
.geo-feature-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #ffffff;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
}
.geo-feature-badge {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--purple-soft);
  color: var(--purple-deep);
}

.div-dividend-box {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: #f5f3ff;
  border: 2.5px solid #ddd6fe;
  border-right: none;
  border-radius: 14px 0 0 14px;
  font-size: 32px;
  font-weight: 900;
  color: var(--text-main);
}

.div-quotient-val {
  color: #047857;
  font-size: 30px;
  font-weight: 900;
}

/* ==========================================================================
   BẢNG SO SÁNH LỚN, BÉ, BẰNG (>, <, =) CHUẨN SƯ PHẠM
   ========================================================================== */
.compare-stage-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.compare-cards-arena {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.compare-side-card {
  flex: 1;
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border: 2.5px solid var(--border-light);
  border-radius: 18px;
  padding: 12px 10px;
  text-align: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.25s ease;
}

.compare-side-card.is-active {
  border-color: #6c5ce7;
  background: #f5f3ff;
  box-shadow: 0 8px 24px rgba(108, 92, 231, 0.2);
  transform: translateY(-2px);
}

.compare-side-title {
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.5px;
}

.compare-expr-text {
  font-size: clamp(20px, 4.5vw, 26px);
  font-weight: 900;
  color: var(--purple-deep);
  line-height: 1.2;
}

.compare-val-badge {
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 900;
  padding: 3px 12px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #334155;
  transition: all 0.3s ease;
}

.compare-val-badge.is-computed {
  background: #d1fae5;
  color: #047857;
  border: 1.5px solid #10b981;
}

.compare-sign-slot {
  width: clamp(54px, 13vw, 72px);
  height: clamp(54px, 13vw, 72px);
  border-radius: 50%;
  background: linear-gradient(135deg, #fef3c7 0%, #fde047 100%);
  border: 3.5px dashed #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(32px, 8vw, 44px);
  font-weight: 900;
  color: #b45309;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.25);
  flex: 0 0 auto;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.compare-sign-slot.is-filled {
  border-style: solid;
  border-color: #10b981;
  background: linear-gradient(135deg, #d1fae5 0%, #34d399 100%);
  color: #064e3b;
  transform: scale(1.1);
  animation: resultPopIn 0.4s ease both;
}

.compare-action-chips {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.compare-choice-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 900;
  background: #ffffff;
  border: 2px solid var(--border-light);
  color: var(--text-main);
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
  transition: all 0.15s ease;
}

.compare-choice-btn:hover {
  transform: translateY(-2px);
  border-color: #6c5ce7;
  color: #6c5ce7;
}

.compare-choice-btn.is-correct {
  background: #10b981;
  border-color: #059669;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.geo-interactive-tooltip {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.3px;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  animation: cardPop 0.2s ease;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   4. DOCKED GAME CONTROLLER DECK
   ========================================================================== */
.game-control-deck {
  flex: 0 0 auto;
  background: #ffffff;
  border-top: 2px solid var(--border-light);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
  padding: 4px clamp(8px, 1.8vw, 14px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 50;
}

.deck-progress-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.deck-progress-track {
  flex: 1;
  height: 8px;
  background: #eef2ff;
  border-radius: 10px;
  position: relative;
}

.deck-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #a78bfa, #6c5ce7);
  border-radius: 10px;
  position: relative;
  transition: width 0.3s ease;
}

.runner-star {
  position: absolute;
  right: -8px;
  top: -9px;
  font-size: 15px;
}

.deck-step-info {
  font-size: 11.5px;
  font-weight: 850;
  color: var(--purple-deep);
  white-space: nowrap;
}

.deck-step-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--purple-soft);
  border-radius: 10px;
  padding: 3px 10px;
}

.step-mini-badge {
  font-size: 9.5px;
  font-weight: 900;
  background: var(--purple-main);
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
}

.step-mini-title {
  font-size: 13.5px;
  font-weight: 900;
  color: var(--text-main);
  white-space: nowrap;
}

.step-mini-desc {
  font-size: 12.5px;
  font-weight: 750;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.deck-buttons-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.deck-btn {
  height: 42px;
  border-radius: var(--radius-btn);
  background: #ffffff;
  border: 2px solid var(--border-light);
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  padding: 0 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 3px 0 var(--border-light);
  transition: all 0.1s ease;
  white-space: nowrap;
}

.deck-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--border-light);
}

.deck-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.deck-btn-play {
  background: linear-gradient(180deg, #ffc021, #ffb703);
  color: #451a03;
  border-color: #d97706;
  box-shadow: 0 3px 0 #b45309;
  flex: 1.2;
}

.deck-btn-next {
  background: linear-gradient(180deg, #10e7b0, #06d6a0);
  color: #034232;
  border-color: #05b386;
  box-shadow: 0 3px 0 #047857;
  flex: 1.3;
}

.deck-result-pill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1.5px solid var(--border-light);
  border-radius: 10px;
  padding: 0 10px;
  height: 42px;
  font-size: 11px;
  color: var(--text-soft);
}

.deck-result-pill strong {
  font-size: 18px;
  color: var(--purple-main);
}

.deck-result-pill.is-done {
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.deck-result-pill.is-done strong {
  color: #047857;
}

.deck-speed-select {
  height: 42px;
  border-radius: 10px;
  border: 1.5px solid var(--border-light);
  background: #f8fafc;
  padding: 0 8px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 850;
  outline: none;
}

/* ==========================================================================
   HÌNH HỌC TƯƠNG TÁC
   ========================================================================== */
.geo-shapes-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: 6px;
  flex: 0 0 auto;
}

.geo-shape-chip {
  flex: 0 0 auto;
  background: #ffffff;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 850;
  cursor: pointer;
}

.geo-shape-chip.selected {
  background: var(--purple-main);
  color: #fff;
  border-color: var(--purple-deep);
}

.geo-stage-arena {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 10px;
  overflow: hidden;
}

.geo-viewport-box {
  background: radial-gradient(circle, #e2e8f0 1.2px, transparent 1.6px) 0 0 / 18px 18px, #ffffff;
  border: 2px solid var(--border-light);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.geometry-svg-compact {
  width: 100%;
  height: 100%;
  max-height: 320px;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.geometry-svg-compact:active {
  cursor: grabbing;
}

.geo-discovery-pill {
  position: absolute;
  bottom: 8px;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid #bbf7d0;
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 900;
  color: #166534;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.geo-side-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  overflow-y: auto;
}

.geo-lesson-box {
  background: #ffffff;
  border: 2px solid #ddd6fe;
  border-radius: 14px;
  padding: 8px 12px;
}

.geo-lesson-bar {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 900;
  color: var(--purple-main);
}

.geo-lesson-box h4 {
  font-size: 15px;
  font-weight: 900;
  color: var(--purple-deep);
  margin: 3px 0 2px;
}

.geo-lesson-box p {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.4;
  margin-bottom: 6px;
}

.geo-step-buttons {
  display: flex;
  gap: 6px;
}

.geo-controls-compact {
  background: #ffffff;
  border: 1.5px solid var(--border-light);
  border-radius: 12px;
  padding: 6px 10px;
}

.geo-formula-compact {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 6px 10px;
  font-size: 12px;
}

/* ==========================================================================
   GÓC THỬ TÀI & LUYỆN TẬP
   ========================================================================== */
.quiz-stage-arena {
  flex: 1;
  min-height: 0;
  background: #ffffff;
  border: 2px solid var(--border-light);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.quiz-game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.quiz-tag-pill {
  font-size: 10.5px;
  font-weight: 900;
  background: var(--purple-soft);
  color: var(--purple-deep);
  padding: 3px 8px;
  border-radius: 8px;
}

.quiz-topic-pill select {
  border: 1.5px solid var(--border-light);
  border-radius: 8px;
  padding: 3px 6px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--purple-deep);
}

.quiz-score-badge {
  font-size: 12px;
  font-weight: 900;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
  padding: 3px 8px;
  border-radius: 10px;
}

.quiz-arena-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}

.quiz-icon-mascot {
  font-size: 38px;
}

.quiz-question-heading {
  font-size: clamp(20px, 3.5vw, 26px);
  font-weight: 900;
  color: var(--text-main);
}

.quiz-help-note {
  font-size: 12.5px;
  color: var(--text-soft);
}

.quiz-play-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 320px;
}

.quiz-input-row {
  display: flex;
  gap: 8px;
}

.quiz-input-block input {
  width: 100%;
  height: 48px;
  border: 2.5px solid var(--border-light);
  border-radius: 12px;
  font-size: 24px;
  font-weight: 900;
  text-align: center;
  color: var(--purple-deep);
}

.full-btn {
  width: 100%;
}

.quiz-feedback-banner {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 850;
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  color: #92400e;
}

.quiz-feedback-banner.correct {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.quiz-foot-actions {
  display: flex;
  gap: 8px;
}

/* ==========================================================================
   BÀN PHÍM SỐ NHÍ MODAL
   ========================================================================== */
.keypad-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(45, 52, 54, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: overlayFadeIn 0.2s ease;
}

.keypad-modal-overlay[hidden] {
  display: none !important;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.keypad-modal-sheet {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  border-top: 3px solid var(--purple-main);
  padding: 14px 16px 24px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
  animation: sheetSlideUp 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.keypad-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 900;
  color: var(--purple-main);
}

.keypad-close-modal {
  background: #f1f5f9;
  border: none;
  font-size: 12px;
  font-weight: 850;
  color: var(--text-soft);
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.keypad-grid-touch {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.key-touch {
  height: 48px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  font-family: inherit;
  font-size: 20px;
  font-weight: 900;
  color: var(--text-main);
  box-shadow: 0 3px 0 #cbd5e1;
  cursor: pointer;
}

.key-touch:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #cbd5e1;
}

.key-touch.op-touch {
  background: var(--purple-soft);
  border-color: #ddd6fe;
  color: var(--purple-main);
  box-shadow: 0 3px 0 #c4b5fd;
}

.key-touch.var-touch {
  background: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}

.key-touch.back-touch {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #e11d48;
  font-size: 14px;
}

.key-touch.enter-touch {
  background: linear-gradient(180deg, #10e7b0, #06d6a0);
  border-color: #05b386;
  color: #034232;
  font-size: 14px;
  box-shadow: 0 3px 0 #047857;
}

/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */
@keyframes mascotBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes starPop {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes resultPopIn {
  0% { transform: scale(0.7); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 768px) {
  /* Ẩn tiện ích góc phải để menu chọn biểu thức và dạng bài chiếm trọn 100% bề ngang */
  .top-util-group {
    display: none !important;
  }

  .pc-sidebar-btn {
    display: none !important;
  }

  .mobile-sidebar-btn {
    display: inline-flex !important;
  }

  .sidebar-drawer-sheet {
    left: auto;
    right: 0;
    transform: translateX(100%);
  }

  .sidebar-drawer-overlay.is-active .sidebar-drawer-sheet {
    transform: translateX(0);
  }

  .game-brand-pill {
    padding: 2px 6px 2px 3px;
  }

  .brand-name-tag {
    font-size: 10px;
  }

  .game-mode-chips {
    width: 100%;
    padding: 2px 0;
    gap: 4px;
  }

  .game-mode-chip {
    padding: 4px 9px;
    font-size: 11px;
  }

  /* Bố cục xếp dọc: Bảng tính ở TRÊN - Hướng dẫn ở DƯỚI */
  .board-interactive-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    padding: 0 4px;
  }

  .board-calc-col {
    order: 1;
    width: 100%;
    margin-bottom: 2px;
  }

  .board-guide-col {
    order: 2;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
  }

  .board-guide-card {
    padding: 8px 12px;
    gap: 6px;
    border-radius: 16px;
  }

  .board-guide-title {
    font-size: clamp(14px, 3.8vw, 17px);
  }

  .board-guide-desc {
    font-size: clamp(12px, 3.4vw, 14px);
    line-height: 1.35;
  }

  .board-guide-action-box {
    padding: 6px 10px;
    border-radius: 12px;
    gap: 8px;
  }

  .board-guide-action-icon {
    font-size: 24px;
  }

  /* Căn chỉnh kích thước ô tính trên mobile */
  .sgk-grid-row {
    grid-template-columns: 36px repeat(var(--cols), minmax(36px, 50px));
    gap: 4px;
    justify-content: center;
  }

  .sgk-digit-cell {
    height: clamp(42px, 11vw, 50px);
    font-size: clamp(24px, 6.5vw, 30px);
  }

  .sgk-place-pill {
    font-size: 11px;
    padding: 2px 4px;
  }

  /* Phép chia trên mobile */
  .sgk-division-board {
    max-width: 100%;
    gap: 6px;
  }

  .div-bracket-layout {
    max-width: 100%;
    padding: 8px 14px;
    gap: 0 14px;
    border-radius: 18px;
  }

  .div-work-column {
    min-width: 120px;
  }

  .div-digits-row {
    font-size: clamp(26px, 6.5vw, 34px);
    min-height: 38px;
  }

  .div-cell-char {
    width: clamp(22px, 5.5vw, 28px);
    height: clamp(32px, 8vw, 38px);
  }

  .div-sub-row {
    font-size: clamp(24px, 6vw, 30px);
  }

  .div-rem-row {
    font-size: clamp(26px, 6.5vw, 32px);
  }

  .div-divisor-val {
    font-size: clamp(26px, 6.5vw, 34px);
    padding-bottom: 4px;
  }

  .div-quotient-display {
    font-size: clamp(28px, 7vw, 36px);
    min-height: 38px;
  }

  .div-remainder-final-pill {
    font-size: 14px;
    padding: 3px 10px;
  }

  .geo-stage-arena { grid-template-columns: 1fr; }
  .deck-buttons-row { flex-wrap: wrap; }
  .deck-result-pill { order: 6; width: 100%; flex: 1 1 100%; }
}

@media (max-height: 580px) {
  .game-top-bar { height: 40px; }
  .quick-math-ribbon { height: 40px; }
  .live-action-bubble { padding: 4px 10px; }
  .math-action-equation { font-size: 20px; }
  .sgk-digit-cell { height: 40px; font-size: 22px; }
  .deck-btn { height: 36px; font-size: 12px; }
  .game-control-deck { padding: 4px 8px; }
}

/* ==========================================================================
   SIDEBAR DRAWER MENU CHO PC VÀ MOBILE (v5.0)
   ========================================================================== */
.sidebar-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 800;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.sidebar-toggle-btn:active {
  transform: scale(0.96);
}

.hamburger-icon {
  font-size: 15px;
  line-height: 1;
}

.pc-sidebar-btn {
  display: inline-flex;
}

.mobile-sidebar-btn {
  display: none;
  padding: 6px 10px;
  font-size: 16px;
}

.sidebar-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.sidebar-drawer-overlay.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.sidebar-drawer-sheet {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(380px, 88vw);
  background: #ffffff;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  z-index: 10001;
}

.sidebar-drawer-overlay.is-active .sidebar-drawer-sheet {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 2px solid #e2e8f0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-mascot-icon {
  font-size: 28px;
}

.sidebar-title {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
  color: #1e293b;
}

.sidebar-subtitle {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
}

.sidebar-close-btn {
  background: #e2e8f0;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 900;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.sidebar-close-btn:hover {
  background: #fee2e2;
  color: #dc2626;
  transform: scale(1.08);
}

.sidebar-body-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-group-title {
  margin: 0 0 8px 4px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: #64748b;
  text-transform: uppercase;
}

.sidebar-menu-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.sidebar-item:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  transform: translateX(4px);
}

.sidebar-item.is-current {
  background: #e0e7ff;
  border-color: #6366f1;
}

.sidebar-item-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item-info strong {
  font-size: 14px;
  font-weight: 800;
  color: #1e293b;
}

.sidebar-item-info small {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
}

/* ==========================================================================
   NÚT TỐC ĐỘ 1 CHẠM KHÔNG POPUP (v5.0)
   ========================================================================== */
.deck-speed-btn {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 14px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 800;
  color: #334155;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
  white-space: nowrap;
}

.deck-speed-btn:hover {
  background: #e0f2fe;
  border-color: #38bdf8;
  color: #0369a1;
  transform: translateY(-1px);
}

.deck-speed-btn:active {
  transform: scale(0.94);
}

/* ==========================================================================
   3D ACTIONS CHO HÌNH HỌC (v5.0)
   ========================================================================== */
.geo-3d-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 20;
}

.geo-3d-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid #cbd5e1;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 800;
  color: #334155;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(6px);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.geo-3d-btn:hover {
  background: #ffffff;
  border-color: var(--purple-main);
  color: var(--purple-deep);
  transform: translateY(-1px);
}

.geo-3d-btn.is-active {
  background: #ede9fe;
  border-color: #8b5cf6;
  color: #5b21b6;
}

/* ==========================================================================
   ĐỔI ĐƠN VỊ, ĐỒNG HỒ & LỊCH NGÀY THÁNG (v5.0)
   ========================================================================== */
.units-stage-board, .clock-stage-board, .calendar-stage-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 6px;
}

.units-stage-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 6px;
}

.units-stage-badge {
  font-size: 12px;
  font-weight: 900;
  color: var(--purple-deep);
  letter-spacing: 0.5px;
  background: #f5f3ff;
  border: 1.5px solid #ddd6fe;
  padding: 3px 12px;
  border-radius: 10px;
}

.units-stage-hint {
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
}

.metric-ladder-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 620px;
  margin: 4px auto;
}

.metric-ladder-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 5px 4px;
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  transition: all 0.25s;
  position: relative;
}

.metric-ladder-step.is-bridge-step {
  opacity: 0.75;
  border-style: dashed;
}

.metric-step-rank {
  font-size: 9px;
  font-weight: 800;
  color: #94a3b8;
}

.metric-step-name {
  font-size: 16px;
  font-weight: 900;
  color: var(--purple-deep);
}

.metric-step-tag {
  position: absolute;
  top: -11px;
  font-size: 8px;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 6px;
  white-space: nowrap;
}

.metric-step-tag.src-tag {
  background: #0284c7;
  color: #ffffff;
}

.metric-step-tag.tgt-tag {
  background: #f59e0b;
  color: #ffffff;
}

.metric-ladder-step.is-source {
  background: #e0f2fe;
  border-color: #0284c7;
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
  z-index: 2;
}

.metric-ladder-step.is-target {
  background: #fef3c7;
  border-color: #f59e0b;
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
  z-index: 2;
}

.metric-ladder-step.is-in-path {
  background: #f0fdf4;
  border-color: #86efac;
}

.metric-step-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 1px;
}

.metric-conn-op {
  font-size: 9px;
  font-weight: 900;
  color: #64748b;
}

.metric-conn-arrow {
  font-size: 13px;
  font-weight: 900;
  color: #94a3b8;
}

.metric-step-connector.is-active-conn .metric-conn-op {
  color: #047857;
  font-weight: 900;
  transform: scale(1.1);
}

.metric-step-connector.is-active-conn .metric-conn-arrow {
  color: #059669;
}

.units-result-banner {
  margin-top: 6px;
  font-size: clamp(17px, 4vw, 24px);
  font-weight: 900;
  color: #047857;
  background: #ecfdf5;
  border: 2px solid #a7f3d0;
  padding: 6px 18px;
  border-radius: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.units-result-lbl {
  font-size: 11px;
  font-weight: 800;
  color: #059669;
  text-transform: uppercase;
}

.metric-ladder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
}

.metric-step-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 8px 6px;
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  transition: all 0.3s;
}

.metric-step-box.is-source {
  background: #e0f2fe;
  border-color: #0284c7;
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.metric-step-box.is-target {
  background: #fef3c7;
  border-color: #f59e0b;
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.metric-step-arrow {
  font-size: 15px;
  color: #6366f1;
  font-weight: 900;
}

.clock-analog-wrap {
  position: relative;
  width: min(280px, 75vw);
  height: min(280px, 75vw);
  margin: 0 auto;
  user-select: none;
  touch-action: none;
  cursor: crosshair;
}

.clock-hand-handle {
  cursor: grab;
  transition: r 0.15s, stroke-width 0.15s;
}

.clock-hand-handle:hover,
.clock-hand-handle:active {
  cursor: grabbing;
  r: 12 !important;
  stroke-width: 3.5 !important;
}

.clock-hint-pill {
  font-size: 11px;
  font-weight: 800;
  color: #4338ca;
  background: #e0e7ff;
  padding: 3px 10px;
  border-radius: 10px;
  text-align: center;
}

.clock-quick-adjust-bar {
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  flex-wrap: wrap;
}

.clock-quick-btn {
  font-size: 11px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
}

.clock-quick-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.calendar-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 380px;
  background: #f8fafc;
  padding: 10px;
  border-radius: 16px;
  border: 2px solid #e2e8f0;
}

.calendar-day-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #334155;
  border-radius: 8px;
  transition: all 0.2s;
  user-select: none;
}

.calendar-day-cell.is-interactive {
  cursor: pointer;
}

.calendar-day-cell.is-interactive:hover {
  background: #f1f5f9;
  border: 1.5px solid #94a3b8;
  transform: scale(1.12);
  z-index: 2;
}

.calendar-day-cell.is-interactive:active {
  transform: scale(0.95);
}

.calendar-day-cell.is-target {
  background: #fef3c7;
  border: 2px solid #f59e0b;
  color: #b45309;
  font-size: 15px;
  font-weight: 900;
}

.calendar-day-cell.is-start {
  background: #e0f2fe;
  border: 2px solid #0284c7;
  color: #0369a1;
}

/* ==========================================================================
   TÙY CHỌN CHẾ ĐỘ MÁY NHẸ & TOGGLE SWITCH
   ========================================================================== */
.sidebar-setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: default !important;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e1;
  transition: 0.25s ease;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s ease;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .toggle-slider {
  background-color: var(--purple-main);
}

input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* ==========================================================================
   BẢNG NHÁP PHÉP TÍNH CON DƯỚI BOARD-GUIDE-CARD (v6.0)
   ========================================================================== */
.sub-calc-scratchpad {
  margin-top: 8px;
  background: #fffdf5;
  border: 2px dashed #facc15;
  border-radius: 16px;
  padding: 8px 12px;
  box-shadow: 0 4px 12px rgba(234, 179, 8, 0.12);
  animation: resultPopIn 0.22s ease-out;
}

.sub-calc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}

.sub-calc-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 900;
  color: #854d0e;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sub-calc-icon {
  font-size: 15px;
}

.sub-calc-zoom-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fef08a;
  border: 1.5px solid #eab308;
  border-radius: 10px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  color: #713f12;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.sub-calc-zoom-btn:hover {
  background: #fde047;
  transform: scale(1.05);
}

.sub-calc-zoom-btn:active {
  transform: scale(0.96);
}

.sub-calc-body {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  background: #ffffff;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid #fef08a;
}

/* Đặt tính cột dọc mini */
.sub-calc-mini-vertical {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: var(--font-digits);
  font-weight: 900;
  font-size: 20px;
  color: #1e293b;
  line-height: 1.15;
  padding: 2px 8px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.sub-calc-mini-op-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
}

.sub-calc-mini-op {
  font-size: 18px;
  color: var(--purple-main);
}

.sub-calc-mini-line {
  width: 100%;
  height: 2px;
  background: #334155;
  margin: 3px 0;
}

.sub-calc-mini-res {
  color: #047857;
  font-size: 22px;
}

/* Sơ đồ chia mini */
.sub-calc-mini-div {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-digits);
  font-weight: 900;
  font-size: 20px;
  background: #f8fafc;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.sub-calc-div-dividend {
  color: #1e293b;
}

.sub-calc-div-divisor-wrap {
  border-left: 2.5px solid var(--purple-main);
  padding-left: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.sub-calc-div-divisor {
  color: var(--purple-main);
  border-bottom: 2px solid var(--purple-main);
  padding-bottom: 2px;
  width: 100%;
}

.sub-calc-div-quotient {
  color: #047857;
  padding-top: 2px;
}

.sub-calc-hints {
  font-size: 12px;
  color: #475569;
  line-height: 1.45;
}

.sub-calc-hint-line {
  margin-bottom: 3px;
}

.sub-calc-hint-line strong {
  color: #0f172a;
}

.sub-calc-hint-badge {
  display: inline-block;
  background: #fef3c7;
  color: #b45309;
  font-weight: 800;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 6px;
  margin-left: 4px;
}

/* ==========================================================================
   POPUP MODAL PHÉP TÍNH CON CHI TIẾT (v6.0)
   ========================================================================== */
.sub-calc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  z-index: 10002;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  animation: overlayFadeIn 0.2s ease;
}

.sub-calc-modal-overlay[hidden] {
  display: none !important;
}

.sub-calc-modal-sheet {
  width: min(540px, 96vw);
  max-height: 90dvh;
  background: #ffffff;
  border-radius: 24px;
  border: 3px solid var(--purple-main);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sheetSlideUp 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.sub-calc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border-bottom: 2px solid #ddd6fe;
}

.sub-calc-modal-badge {
  font-size: 10px;
  font-weight: 900;
  color: var(--purple-main);
  letter-spacing: 0.5px;
}

.sub-calc-modal-heading {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
  color: var(--purple-deep);
}

.sub-calc-close-btn {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 900;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
}

.sub-calc-close-btn:hover {
  background: #fee2e2;
  border-color: #ef4444;
  color: #dc2626;
  transform: rotate(90deg);
}

.sub-calc-modal-body {
  padding: 14px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.sub-calc-full-stage {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
  background: #f8fafc;
  border-radius: 16px;
  padding: 12px;
  border: 1.5px solid #e2e8f0;
}

.sub-calc-guide-box {
  width: 100%;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sub-calc-guide-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.sub-calc-step-text {
  font-size: 13px;
  font-weight: 700;
  color: #1e3a8a;
  line-height: 1.4;
}

.sub-calc-modal-footer {
  padding: 10px 16px;
  background: #f8fafc;
  border-top: 1.5px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.sub-calc-deck-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sub-calc-deck-btn {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
}

.sub-calc-deck-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.sub-calc-play-btn {
  background: var(--yellow-star);
  border-color: #d97706;
  color: #78350f;
}

.sub-calc-play-btn:hover {
  background: #f59e0b;
}

.sub-calc-back-main-btn {
  background: #ecfdf5;
  border: 2px solid #10b981;
  border-radius: 10px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 900;
  color: #047857;
  cursor: pointer;
  transition: all 0.2s;
}

.sub-calc-back-main-btn:hover {
  background: #10b981;
  color: #ffffff;
}

/* ==========================================================================
   TỐI ƯU HÓA MÁY TÍNH BẢNG CẤU HÌNH YẾU (.low-power-mode)
   ========================================================================== */
.low-power-mode * {
  animation: none !important;
  transition: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

.low-power-mode .sidebar-drawer-overlay,
.low-power-mode .keypad-modal-overlay,
.low-power-mode .sub-calc-modal-overlay {
  background: rgba(15, 23, 42, 0.85) !important;
}

.low-power-mode .digit-playful-active {
  transform: none !important;
}

/* ==========================================================================
   BÚT VẼ TỰ DO (DRAWING CANVAS OVERLAY & FLOATING TOOLBAR)
   ========================================================================== */
.drawing-canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 25;
  touch-action: none;
}

.is-drawing-mode .drawing-canvas-overlay {
  pointer-events: auto;
  cursor: crosshair;
}

.drawing-floating-bar {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-pill);
  padding: 4px 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
}

.drawing-toggle-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #f1f5f9;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 900;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s;
}

.drawing-toggle-btn:hover {
  background: #e2e8f0;
}

.drawing-toggle-btn.is-active {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #b45309;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.35);
}

.drawing-palette-box {
  display: flex;
  align-items: center;
  gap: 6px;
}

.draw-color-chip {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--chip-c, #ef4444);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.2s;
}

.draw-color-chip:hover {
  transform: scale(1.2);
}

.draw-color-chip.is-active {
  transform: scale(1.3);
  border: 2.5px solid #0f172a;
  box-shadow: 0 0 0 2px #ffffff, 0 2px 6px rgba(0, 0, 0, 0.3);
}

.draw-clear-action-btn {
  background: #fee2e2;
  border: 1.5px solid #f87171;
  border-radius: var(--radius-pill);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  color: #b91c1c;
  cursor: pointer;
  transition: all 0.2s;
}

.draw-clear-action-btn:hover {
  background: #ef4444;
  color: #ffffff;
}

/* ==========================================================================
   DÃY PHÍM ĐƠN VỊ ĐO TRONG KEYPAD MODAL (.keypad-units-bar)
   ========================================================================== */
.keypad-units-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #f1f5f9;
  border-radius: 12px;
  border: 1.5px solid #e2e8f0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.keypad-units-bar::-webkit-scrollbar {
  display: none;
}

.keypad-units-title {
  font-size: 11px;
  font-weight: 900;
  color: #64748b;
  white-space: nowrap;
}

.keypad-units-scroll {
  display: flex;
  align-items: center;
  gap: 6px;
}

.unit-touch {
  font-size: 13px !important;
  font-weight: 900 !important;
  padding: 5px 12px !important;
  min-width: 44px;
  height: 36px;
  border-radius: 10px !important;
  background: #e0e7ff !important;
  color: #4338ca !important;
  border: 2px solid #a5b4fc !important;
  white-space: nowrap;
}

.unit-touch.unit-mass {
  background: #ecfdf5 !important;
  color: #047857 !important;
  border-color: #a7f3d0 !important;
}

.unit-touch:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

.unit-touch:active {
  transform: scale(0.95);
}



