/* ========================================================
   HỌA SĨ NHÍ PHÉP MÀU - PIXAR STYLE FOR GALAXY TAB A9
   ======================================================== */

:root {
  --primary-coral: #FF5A5F;
  --primary-coral-dark: #D93B40;
  --primary-yellow: #FFD13B;
  --primary-yellow-dark: #D4A710;
  --primary-blue: #00A6FB;
  --primary-blue-dark: #0077B6;
  --primary-green: #06D6A0;
  --primary-green-dark: #049A73;
  --primary-purple: #7209B7;
  
  --bg-gradient-start: #E0F2FE;
  --bg-gradient-end: #FCE7F3;
  
  --panel-bg: rgba(255, 255, 255, 0.92);
  --panel-border: #D0E1FD;
  --panel-shadow: 0 10px 30px rgba(0, 70, 150, 0.12);
  
  --text-dark: #1E293B;
  --text-muted: #64748B;
  
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, #EDE9FE 50%, var(--bg-gradient-end) 100%);
  color: var(--text-dark);
  min-height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ================= HEADER ================= */
.app-header {
  height: 66px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid #E2E8F0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
  z-index: 100;
  gap: 12px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 28px;
  animation: floatEmoji 3s ease-in-out infinite;
}

.app-title {
  font-size: clamp(15px, 2vw, 20px);
  font-weight: 900;
  background: linear-gradient(45deg, #FF5A5F, #7209B7, #00A6FB);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
  white-space: nowrap;
}


.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #CBD5E1;
  background: white;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 0 #CBD5E1;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-icon:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #CBD5E1;
}

/* ================= MAIN LAYOUT (TỐI ƯU TAB A9: 5:3) ================= */
.main-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 16px;
  padding: 12px 18px;
  height: calc(100vh - 66px);
  overflow: hidden;
}

/* ================= CỘT TRÁI: BẢNG VẼ & NỀN ================= */
.canvas-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-width: 0;
}

/* Chọn nền mẫu */
.bg-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-bg);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 2px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
  flex-shrink: 0;
}

.panel-label {
  font-weight: 800;
  font-size: 15px;
  color: #334155;
  white-space: nowrap;
}

.bg-selector {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px;
  scrollbar-width: none;
}

.bg-selector::-webkit-scrollbar {
  display: none;
}

.bg-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 30px;
  border: 2px solid #E2E8F0;
  background: white;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 0 #CBD5E1;
  transition: all 0.15s ease;
  min-height: 48px;
}

.bg-btn .bg-emoji {
  font-size: 18px;
}

.bg-btn:hover, .bg-btn:active {
  background: #F8FAFC;
  transform: translateY(-1px);
}

.bg-btn.active {
  background: #EFF6FF;
  border-color: var(--primary-blue);
  color: var(--primary-blue-dark);
  box-shadow: 0 4px 0 var(--primary-blue-dark);
  transform: translateY(-2px);
}

/* Khung Canvas chính */
.canvas-container {
  flex: 1;
  position: relative;
  background: #111827;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25), inset 0 0 0 3px rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  touch-action: none; /* Rất quan trọng cho Galaxy Tab A9 */
}

#mainCanvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: grab;
  touch-action: none;
}

#mainCanvas:active {
  cursor: grabbing;
}

/* Lời nhắc khi chưa có hình */
.canvas-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 18px 24px;
  border-radius: 20px;
  text-align: center;
  pointer-events: none;
  border: 3px dashed var(--primary-yellow-dark);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  max-width: 80%;
  transition: opacity 0.3s;
}

.canvas-hint.hidden {
  opacity: 0;
  visibility: hidden;
}

.hint-bounce {
  font-size: 32px;
  margin-bottom: 6px;
  animation: bounceHint 1.2s infinite ease-in-out;
}

.canvas-hint p {
  font-size: 16px;
  font-weight: 800;
  color: #334155;
  line-height: 1.4;
}

/* Thanh công cụ Layer nổi khi chạm vào nhân vật */
.layer-floating-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  padding: 8px 16px;
  border-radius: 40px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10;
}

.layer-floating-bar.show {
  transform: translateX(-50%) translateY(0);
}

.layer-indicator {
  color: #F8FAFC;
  font-size: 13px;
  font-weight: 700;
}

.layer-buttons {
  display: flex;
  gap: 8px;
}

.btn-layer-action {
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 20px;
  border: none;
  background: #3B82F6;
  color: white;
  cursor: pointer;
  box-shadow: 0 3px 0 #1D4ED8;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-layer-action:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #1D4ED8;
}

.btn-layer-action.btn-danger {
  background: var(--primary-coral);
  box-shadow: 0 3px 0 var(--primary-coral-dark);
}

.btn-layer-action.btn-danger:active {
  box-shadow: 0 1px 0 var(--primary-coral-dark);
}

/* Hướng dẫn và nút tải tranh trên header */
.status-tip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}

.tip-icon {
  font-size: 16px;
}

.btn-export {
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--primary-green) 0%, #05B386 100%);
  color: white;
  border: none;
  border-radius: 40px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--primary-green-dark), 0 6px 14px rgba(6, 214, 160, 0.35);
  min-height: 44px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-export:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--primary-green-dark);
}

/* ================= CỘT PHẢI: GIỌNG NÓI & AI TẠO ẢNH ================= */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-width: 0;
  overflow-y: auto;
  scrollbar-width: none;
}

.control-panel::-webkit-scrollbar {
  display: none;
}

/* Hộp Micro & Lời nói */
.voice-box {
  background: var(--panel-bg);
  border-radius: var(--radius-lg);
  border: 2px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ================= THANH CHUYỂN BƯỚC SƯ PHẠM ================= */
.step-nav-bar {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.95);
  padding: 4px;
  border-radius: 30px;
  border: 2px solid #E2E8F0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.step-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  border-radius: 20px;
  border: none;
  background: transparent;
  color: #64748B;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #E2E8F0;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  transition: all 0.2s;
}

.step-tab.active {
  background: linear-gradient(135deg, #0284C7 0%, #00A6FB 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 166, 251, 0.35);
  transform: scale(1.02);
}

.step-tab.active .step-num {
  background: white;
  color: #0284C7;
}

.tab-badge {
  background: rgba(0, 0, 0, 0.15);
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 900;
}

.step-tab.active .tab-badge {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

/* ================= 3 CHIP THEO DÕI TRẠNG THÁI VẬT THỂ (DÀN 1 HÀNG NGANG) ================= */
.cluster-chips-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: white;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #E2E8F0;
}

.chips-label {
  font-size: 11px;
  font-weight: 800;
  color: #64748B;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cluster-chips-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cluster-chip {
  flex: 1 1 calc(33.333% - 6px);
  min-width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 6px;
  border-radius: 14px;
  font-size: 11.5px;
  font-weight: 800;
  cursor: default;
  transition: all 0.25s ease;
  min-height: 32px;
  user-select: none;
  text-align: center;
  white-space: nowrap;
}

.cluster-chip .chip-status-mark {
  font-size: 12px;
  flex-shrink: 0;
}

.cluster-chip .chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Trạng thái chưa tô (trắng đen) */
.cluster-chip.uncolored {
  border: 1.5px dashed #94A3B8;
  background: #F8FAFC;
  color: #64748B;
}

/* Trạng thái đã tô (lên màu) */
.cluster-chip.colored {
  border: 2px solid #10B981;
  background: #ECFDF5;
  color: #065F46;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

/* ================= 2 NÚT ĐIỀU KHIỂN BƯỚC 1 (CÙNG 1 HÀNG NGANG: NÚT TÔ MÀU DÀI, NÚT QUA PHẢI VUÔNG) ================= */
.step1-btn-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 10px;
}

/* Nút Tô Màu Nền (Màu tím, icon 🎨 - dài hơn, chiếm phần lớn hàng ngang) */
.btn-color-bg {
  flex: 1;
  height: 78px;
  min-height: 78px;
  border-radius: 22px;
  border: none;
  font-size: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
  box-shadow: 0 6px 0 #4F46E5, 0 10px 20px rgba(99, 102, 241, 0.35);
  color: white;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-color-bg:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #4F46E5;
}

/* Nút Sang Bước Tạo Nhân Vật (Màu xanh lá, icon mũi tên SVG thuần túy không viền) */
.btn-goto-step2 {
  width: 78px;
  height: 78px;
  min-width: 78px;
  min-height: 78px;
  flex-shrink: 0;
  border-radius: 22px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  box-shadow: 0 6px 0 #047857, 0 10px 20px rgba(16, 185, 129, 0.35);
  color: white;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-goto-step2 svg {
  width: 40px;
  height: 40px;
  stroke: white;
  stroke-width: 3.5;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  transition: transform 0.15s ease;
}

.btn-goto-step2:hover svg {
  transform: translateX(3px);
}

.btn-goto-step2:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #047857;
}

/* Header Bước 2 */
.step2-header-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.char-counter-badge {
  background: #FEF3C7;
  border: 1.5px solid #FCD34D;
  color: #92400E;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 800;
}

.char-counter-badge b {
  font-size: 15px;
  font-weight: 900;
  color: #B45309;
}

.char-counter-badge.full {
  background: #FEE2E2;
  border-color: #FCA5A5;
  color: #B91C1C;
}

.char-counter-badge.full b {
  color: #DC2626;
}

#txtPromptStep1 {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 2px solid #CBD5E1;
  background: #F8FAFC;
  padding: 10px 38px 10px 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #1E293B;
  outline: none;
  resize: none;
  transition: border-color 0.2s, background 0.2s;
  user-select: text;
}

#txtPromptStep1:focus {
  border-color: var(--primary-purple);
  background: white;
}

.section-badge {
  font-size: 16px;
  font-weight: 900;
  color: #1E293B;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Nút Micro tối ưu cho Tab A9 */
.mic-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 0 2px;
  position: relative;
}

.btn-mic {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid white;
  background: linear-gradient(135deg, #FF6B6B 0%, #FF416C 100%);
  color: white;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 0 #C92A2A, 0 10px 20px rgba(255, 65, 108, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 2;
}

.btn-mic:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #C92A2A;
}

.mic-icon {
  font-size: 32px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.mic-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 65, 108, 0.4);
  opacity: 0;
  z-index: 1;
  pointer-events: none;
}

/* Khi Micro đang nghe */
.btn-mic.listening {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  box-shadow: 0 6px 0 #047857, 0 10px 20px rgba(16, 185, 129, 0.45);
  animation: micBounce 1s infinite alternate ease-in-out;
}

.btn-mic.listening + .mic-status-label {
  color: #059669;
  font-weight: 900;
}

.btn-mic.listening .mic-pulse {
  animation: pulseRipple 1.4s infinite cubic-bezier(0.25, 1, 0.5, 1);
}

.mic-status-label {
  margin-top: 6px;
  font-size: 12.5px;
  font-weight: 800;
  color: #475569;
  text-align: center;
}

/* Sóng âm khi nói */
.mic-waves {
  display: none;
  position: absolute;
  bottom: -4px;
  gap: 3px;
  align-items: flex-end;
  height: 20px;
}

.btn-mic.listening .mic-waves {
  display: flex;
}

.mic-waves span {
  width: 4px;
  height: 6px;
  background: white;
  border-radius: 4px;
  animation: waveSound 0.8s infinite ease-in-out;
}

.mic-waves span:nth-child(2) { animation-delay: 0.15s; }
.mic-waves span:nth-child(3) { animation-delay: 0.3s; }
.mic-waves span:nth-child(4) { animation-delay: 0.45s; }
.mic-waves span:nth-child(5) { animation-delay: 0.6s; }

/* Hộp nhập văn bản */
.speech-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-label {
  font-size: 13px;
  font-weight: 800;
  color: #64748B;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#txtPrompt {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 2px solid #CBD5E1;
  background: #F8FAFC;
  padding: 10px 38px 10px 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #1E293B;
  outline: none;
  resize: none;
  transition: border-color 0.2s, background 0.2s;
  user-select: text;
}

#txtPrompt:focus {
  border-color: var(--primary-blue);
  background: white;
}

.btn-clear {
  position: absolute;
  right: 10px;
  top: 10px;
  background: #E2E8F0;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748B;
}

/* Gợi ý nhân vật cho bé */
.suggestions-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sugg-title {
  font-size: 12px;
  font-weight: 800;
  color: #64748B;
}

.sugg-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  border-radius: 20px;
  padding: 6px 10px;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 36px;
  display: flex;
  align-items: center;
}

.pill-btn:active {
  background: #E2E8F0;
  transform: scale(0.96);
}

/* Nút Hô Biến Phép Màu */
.btn-magic {
  font-family: inherit;
  width: 100%;
  min-height: 48px;
  border-radius: 26px;
  border: none;
  background: linear-gradient(135deg, #FFB703 0%, #FB8500 100%);
  color: white;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 5px 0 #D46B00, 0 8px 18px rgba(251, 133, 0, 0.35);
  transition: all 0.15s ease;
  margin-top: 6px;
  margin-bottom: 12px;
}

.btn-magic:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #D46B00;
}

.btn-magic:disabled {
  background: #CBD5E1;
  box-shadow: 0 4px 0 #94A3B8;
  cursor: not-allowed;
  transform: none;
}

.magic-stars {
  animation: rotateStar 2.5s infinite linear;
}

/* Khung xem trước & Loading */
.preview-box {
  flex: 1;
  background: var(--panel-bg);
  border-radius: var(--radius-lg);
  border: 2px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-height: 140px;
}

.preview-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.preview-placeholder {
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
}

.preview-placeholder span {
  font-size: 36px;
  opacity: 0.6;
}

.preview-placeholder p {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  max-width: 220px;
}

.preview-img {
  max-width: 100%;
  max-height: 160px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.15));
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.preview-img.hidden {
  display: none;
}

/* Lớp Loading Phép Thuật */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 10;
  text-align: center;
  padding: 16px;
}

.loading-overlay.active {
  display: flex;
}

.magic-wand {
  font-size: 44px;
  animation: wandWave 1.2s infinite ease-in-out;
  filter: drop-shadow(0 4px 10px rgba(251, 191, 36, 0.4));
}

.loading-text {
  font-size: 17px;
  font-weight: 800;
  color: #1E293B;
  letter-spacing: 0.5px;
}

/* ================= MODAL CHÚC MỪNG ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-backdrop.show {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  background: white;
  border-radius: 28px;
  padding: 28px;
  width: 90%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.modal-icon {
  font-size: 54px;
  animation: bounceHint 1s infinite;
}

.modal-title {
  font-size: 22px;
  font-weight: 900;
  color: #0F172A;
}

.modal-desc {
  font-size: 15px;
  font-weight: 700;
  color: #475569;
  line-height: 1.5;
}

.btn-modal-ok {
  font-family: inherit;
  background: linear-gradient(135deg, var(--primary-green) 0%, #05B386 100%);
  color: white;
  border: none;
  border-radius: 40px;
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--primary-green-dark);
  min-height: 52px;
}

.btn-modal-ok:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--primary-green-dark);
}

/* ================= KEYFRAMES ANIMATIONS ================= */
@keyframes floatEmoji {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px) rotate(6deg); }
}

@keyframes bounceHint {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes micBounce {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

@keyframes pulseRipple {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
}

@keyframes waveSound {
  0%, 100% { height: 4px; }
  50% { height: 18px; }
}

@keyframes rotateStar {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes wandWave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-20deg) scale(1.1); }
  75% { transform: rotate(15deg) scale(1.1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

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

@keyframes scaleUp {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ================= RESPONSIVE ĐẶC BIỆT CHO GALAXY TAB A9 & MÀN HÌNH XOAY ================= */

/* Khi xoay dọc (Portrait: 800 x 1340) */
@media (orientation: portrait), (max-width: 860px) {
  body {
    overflow-y: auto;
  }
  
  .main-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    overflow-y: visible;
    padding: 10px;
    gap: 12px;
  }

  .canvas-panel {
    height: 52vh;
  }

  .canvas-container {
    min-height: 320px;
  }

  .control-panel {
    height: auto;
    overflow-y: visible;
  }
}

/* Khi màn hình Galaxy Tab A9 nằm ngang (1340 x 800) */
@media (min-width: 1100px) and (orientation: landscape) {
  .main-layout {
    grid-template-columns: 1fr 430px;
  }
  
  .btn-mic {
    width: 96px;
    height: 96px;
  }
}

@media (max-width: 980px) {
  .status-tip {
    display: none;
  }
}
