/* ==========================================================================
   Стили тренажёра «Абакус онлайн» — Школа ментальной арифметики «Интеллектус»
   ========================================================================== */

:root {
  --primary-forest: #105C28;       /* Primary Forest Green из Брендбука */
  --secondary-leaf: #4B894A;       /* Secondary Leaf Green */
  --accent-coral: #D32F2F;         /* Berry Coral */
  --surface-wood: #FAD48B;         /* Honey Wood */
  --outline-bark: #5D4037;         /* Bark Brown */
  --mascot-amber: #C27835;         /* Owl Amber */
  --sky-blue: #7EC8E3;             /* Sky Blue */
  --clean-paper: #F8FBF7;          /* Clean Paper */
  
  --frame-wood-dark: #3E2723;
  --frame-wood-mid: #5D4037;
  --beam-color: #ECEFF1;
  --rod-metal: #78909C;
  --card-bg: rgba(255, 255, 255, 0.94);
  --text-dark: #2C3E50;
  --text-muted: #5D4037;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-soft: 0 10px 30px rgba(16, 92, 40, 0.14);
  --shadow-frame: 0 16px 36px rgba(0,0,0,0.32), 0 8px 12px rgba(0,0,0,0.22);
}

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

body {
  font-family: 'Nunito', sans-serif;
  background: url('assets/forest_bg.jpg') no-repeat center center fixed;
  background-size: cover;
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  position: relative;
}

/* Мягкая подсветка фона */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at center, rgba(248, 251, 247, 0.45) 0%, rgba(16, 92, 40, 0.25) 100%);
  pointer-events: none;
  z-index: 0;
}

.app-container {
  width: 100%;
  max-width: 1100px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
  z-index: 1;
}

/* Шапка */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  padding: 16px 26px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 2px solid rgba(75, 137, 74, 0.25);
}

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

.brand-logo {
  font-size: 34px;
  background: #E8F5E9;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--primary-forest);
}

.brand-info h1 {
  font-family: 'Comfortaa', cursive;
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-forest);
  letter-spacing: 1px;
}

.brand-info span {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Переключатели режимов */
.mode-selector {
  display: flex;
  gap: 8px;
  background: #F1F5F1;
  padding: 6px;
  border-radius: 30px;
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 8px 18px;
  border-radius: 20px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  color: var(--primary-forest);
}

.mode-btn.active {
  background: var(--primary-forest);
  color: #FFFFFF;
  box-shadow: 0 4px 10px rgba(45, 90, 39, 0.25);
}

/* Панель инструментов */
.toolbar-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  padding: 14px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  flex-wrap: wrap;
  gap: 16px;
}

.rods-config {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text-dark);
}

.rods-config select {
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #CFD8DC;
  background: #FAFAFA;
  color: var(--text-dark);
  cursor: pointer;
  outline: none;
}

.rods-config select:focus {
  border-color: var(--primary-forest);
}

.value-display-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #F9FBE7;
  padding: 6px 20px;
  border-radius: 30px;
  border: 1.5px solid #DCEDC8;
}

.value-label {
  font-size: 14px;
  font-weight: 700;
  color: #33691E;
}

.value-number {
  font-family: 'Comfortaa', cursive;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-forest);
  min-width: 60px;
  text-align: right;
}

.action-btn {
  border: none;
  background: #FFF3E0;
  color: #E65100;
  border: 1.5px solid #FFE0B2;
  padding: 8px 18px;
  border-radius: 20px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: #FFE0B2;
  transform: translateY(-1px);
}

.action-btn:active {
  transform: translateY(1px);
}

/* ==========================================================================
   ПАНЕЛЬ ТРЕНИРОВКИ (ШАГ 3.2: ПРЯМОЙ СЧЁТ)
   ========================================================================== */
.trainer-panel {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 18px 24px;
  box-shadow: var(--shadow-soft);
  border: 2px solid #E8F5E9;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.trainer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.trainer-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.trainer-badge {
  background: #E8F5E9;
  color: var(--primary-forest);
  font-weight: 800;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 20px;
}

.trainer-title h3 {
  font-size: 18px;
  color: var(--text-dark);
}

.trainer-settings {
  display: flex;
  align-items: center;
  gap: 14px;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.setting-item select {
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #CFD8DC;
  background: #FAFAFA;
  cursor: pointer;
}

.score-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #FFF8E1;
  border: 1px solid #FFE082;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  color: #F57F17;
}

.score-streak {
  color: #E65100;
}

.problem-display-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: url('assets/wood_plank.jpg') no-repeat center center;
  background-size: cover;
  border: 3px solid var(--outline-bark);
  padding: 22px 32px;
  border-radius: var(--radius-lg);
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: 0 8px 18px rgba(93, 64, 55, 0.2);
}

.problem-sequence {
  font-family: 'Comfortaa', cursive;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #3E2723;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.85);
  padding: 6px 18px;
  border-radius: 30px;
  border: 2px solid #D7CCC8;
}

.problem-actions {
  display: flex;
  gap: 10px;
}

.btn-primary {
  background: var(--primary-forest);
  color: #FFFFFF;
  border: none;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 15px;
  padding: 10px 22px;
  border-radius: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(45, 90, 39, 0.25);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: #23471e;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #ECEFF1;
  color: #455A64;
  border: none;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #CFD8DC;
}

.trainer-feedback {
  font-size: 15px;
  font-weight: 800;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  display: none;
  text-align: center;
}

.trainer-feedback.success {
  display: block;
  background: #E8F5E9;
  color: #2E7D32;
  border: 1px solid #A5D6A7;
}

.trainer-feedback.error {
  display: block;
  background: #FFEBEE;
  color: #C62828;
  border: 1px solid #FFCDD2;
}

/* ==========================================================================
   ПАНЕЛЬ ФЛЕШ-КАРТ (ШАГ 3.3)
   ========================================================================== */
.flashcard-panel {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 18px 24px;
  box-shadow: var(--shadow-soft);
  border: 2px solid #FFF3E0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeIn 0.3s ease;
}

.flash-badge {
  background: #FFF3E0;
  color: #E65100;
}

.flash-action-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  justify-content: center;
  background: #FFFDE7;
  border: 2px dashed #FFE082;
  border-radius: var(--radius-md);
  padding: 20px;
}

.flash-countdown-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

.btn-flash {
  background: #F57F17;
  font-size: 16px;
  width: 100%;
}

.btn-flash:hover {
  background: #E65100;
}

.flash-timer-bar {
  width: 100%;
  height: 8px;
  background: #ECEFF1;
  border-radius: 4px;
  overflow: hidden;
  display: none;
}

.flash-timer-progress {
  height: 100%;
  width: 100%;
  background: #E65100;
  border-radius: 4px;
  transition: width linear;
}

.flash-input-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: fadeIn 0.2s ease;
}

.flash-input-box label {
  font-size: 15px;
  font-weight: 800;
  color: #5D4037;
}

.flash-input-row {
  display: flex;
  gap: 10px;
}

.flash-input-row input {
  font-family: 'Comfortaa', cursive;
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  width: 160px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid #FFA000;
  background: #FFFFFF;
  outline: none;
}

.flash-input-row input:focus {
  border-color: #E65100;
  box-shadow: 0 0 8px rgba(230, 81, 0, 0.3);
}

/* ==========================================================================
   АНИМАЦИИ И ЭФФЕКТЫ (ШАГ 3.4: ЗВЁЗДЫ И КОНФЕТТИ)
   ========================================================================== */
.star-particle {
  position: fixed;
  pointer-events: none;
  font-size: 26px;
  z-index: 99999;
  animation: flyUpAndFade 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes flyUpAndFade {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.6) rotate(0deg);
  }
  50% {
    transform: translate(var(--dx), -80px) scale(1.3) rotate(180deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), -160px) scale(0.9) rotate(360deg);
  }
}

/* ==========================================================================
   ПРАЗДНИЧНЫЙ МОДАЛЬНЫЙ ОВЕРЛЕЙ: САВА ХЛОПАЕТ КРЫЛЬЯМИ
   ========================================================================== */
.celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(16, 92, 40, 0.45);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeInModal 0.25s ease-out;
}

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

.celebration-popup {
  background: #FFFFFF;
  border: 4px solid var(--primary-forest);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  border-radius: 28px;
  padding: 30px 40px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: popUpBounce 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

@keyframes popUpBounce {
  0% { transform: scale(0.6) translateY(50px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.clapping-sawa-box {
  position: relative;
  width: 240px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clapping-sawa-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* Анимация хлопанья крыльями и радости */
  animation: wingClapAnimation 0.35s ease-in-out infinite alternate;
  transform-origin: bottom center;
}

@keyframes wingClapAnimation {
  0% {
    transform: scale(1) rotate(-3deg);
  }
  100% {
    transform: scale(1.08) rotate(3deg);
  }
}

.wing-claps-sound {
  position: absolute;
  top: 10px;
  right: -10px;
  font-size: 28px;
  animation: pulseClap 0.35s ease-in-out infinite alternate;
}

@keyframes pulseClap {
  0% { transform: scale(0.9); }
  100% { transform: scale(1.3); }
}

.celebration-text-box h2 {
  font-family: 'Comfortaa', cursive;
  font-size: 26px;
  font-weight: 800;
  color: var(--primary-forest);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.celebration-text-box p {
  font-size: 15px;
  color: #5D4037;
  font-weight: 700;
  margin-bottom: 14px;
}

.celebration-btn {
  font-size: 17px;
  padding: 12px 32px;
  border-radius: 30px;
}

.mascot-avatar {
  position: relative;
  transition: transform 0.25s ease;
}

.mascot-avatar.bounce {
  animation: mascotHappy 0.6s ease;
}

@keyframes mascotHappy {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.15) rotate(-6deg); }
  60% { transform: scale(1.15) rotate(6deg); }
}

/* ==========================================================================
   АБАКУС (РАМА И КОСТОЧКИ)
   ========================================================================== */
.abacus-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.abacus-outer-frame {
  width: 100%;
  background: linear-gradient(to bottom, var(--frame-wood-dark), #2c1a16);
  padding: 14px;
  border-radius: 20px;
  box-shadow: var(--shadow-frame);
  border: 4px solid #1a0e0b;
  position: relative;
}

/* Металлические медные уголки на раме */
.abacus-outer-frame::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  bottom: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  pointer-events: none;
}

.abacus-inner-frame {
  background: #FDFBF7;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 4px 10px rgba(0,0,0,0.4);
}

.abacus-board {
  display: flex;
  justify-content: center;
  align-items: stretch;
  height: 380px;
  background: radial-gradient(circle at center, #FFFDF9 0%, #F5EFEB 100%);
  position: relative;
  overflow-x: auto;
  padding: 0 10px;
}

/* Спица */
.abacus-rod {
  flex: 1;
  max-width: 90px;
  min-width: 65px;
  display: flex;
  flex-direction: column;
  position: relative;
  align-items: center;
  box-sizing: border-box;
  border-right: 1px dashed rgba(0,0,0,0.06);
}

.abacus-rod:last-child {
  border-right: none;
}

/* Металлический стержень спицы */
.abacus-rod::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  background: linear-gradient(to right, #607D8B, #B0BEC5 50%, #455A64);
  box-shadow: 1px 0 3px rgba(0,0,0,0.25);
  z-index: 1;
}

/* Верхняя секция (Небесная косточка) */
.rod-upper-deck {
  height: 90px;
  width: 100%;
  position: relative;
  z-index: 2;
}

/* Разделительная планка */
.rod-beam {
  height: 18px;
  width: 100%;
  background: linear-gradient(to bottom, #FAFAFA, #CFD8DC);
  border-top: 2px solid #37474F;
  border-bottom: 2px solid #263238;
  position: relative;
  z-index: 3;
  box-shadow: 0 3px 6px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Маркировочная точка разряда на планке (каждые 3 разряда) */
.unit-dot {
  width: 7px;
  height: 7px;
  background: #D32F2F;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Нижняя секция (4 Земные косточки) */
.rod-lower-deck {
  height: 220px;
  width: 100%;
  position: relative;
  z-index: 2;
}

/* Панель значения под спицей */
.rod-value-box {
  height: 40px;
  width: 100%;
  background: #EFEBE9;
  border-top: 2px solid #8D6E63;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 4;
}

.rod-digit {
  font-family: 'Comfortaa', cursive;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-forest);
}

.rod-rank-label {
  font-size: 10px;
  font-weight: 700;
  color: #795548;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   КОСТОЧКИ АБАКУСА (Би-коническая форма Соробан)
   ========================================================================== */
.abacus-bead {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 58px;
  height: 32px;
  cursor: pointer;
  z-index: 2;
  transition: top 0.16s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Реалистичная форма японской деревянной косточки с текстурой */
.bead-body {
  width: 100%;
  height: 100%;
  background-image: url('assets/bead_texture.png');
  background-size: cover;
  background-position: center;
  border-radius: 4px;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.35));
  position: relative;
  transition: all 0.15s ease;
}

.abacus-bead:hover .bead-body {
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4)) brightness(1.1);
}

.abacus-bead:active .bead-body {
  transform: scale(0.96);
}

/* Активная косточка (прижатая к планке) подсвечивается мягким солнечным янтарным ореолом */
.abacus-bead.active .bead-body {
  filter: drop-shadow(0 0 6px rgba(250, 212, 139, 0.95)) brightness(1.15);
}

.abacus-hints {
  display: flex;
  gap: 24px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.abacus-hints b {
  color: var(--primary-forest);
}

/* Карточка маскота */
.mascot-card {
  display: flex;
  align-items: center;
  gap: 18px;
  background: #FFFFFF;
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(45, 90, 39, 0.12);
}

.mascot-avatar img {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 3px solid #E8F5E9;
  box-shadow: 0 6px 14px rgba(0,0,0,0.15);
  object-fit: cover;
}

.mascot-speech h4 {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary-forest);
  margin-bottom: 4px;
}

.mascot-speech p {
  font-size: 14px;
  color: var(--text-dark);
  line-height: 1.4;
}

/* ==========================================================================
   Тема «Золотой абакус» (Ярмарка Савы)
   ========================================================================== */
.abacus-outer-frame.theme-gold {
  background: linear-gradient(135deg, #FFE082 0%, #FFB300 35%, #FFA000 60%, #FF8F00 100%);
  border: 4px solid #FFD54F;
  box-shadow: 0 16px 42px rgba(255, 179, 0, 0.4), 0 0 25px rgba(255, 215, 0, 0.35);
}

.abacus-outer-frame.theme-gold::before {
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.4);
}

.abacus-outer-frame.theme-gold .abacus-inner-frame {
  background: #FFFDE7;
  box-shadow: inset 0 4px 12px rgba(184, 134, 11, 0.3);
}

.abacus-outer-frame.theme-gold .abacus-board {
  background: radial-gradient(circle at center, #FFFFFB 0%, #FFF9C4 100%);
}

.abacus-outer-frame.theme-gold .abacus-rod::before {
  background: linear-gradient(to right, #FFA000, #FFE082 50%, #FF8F00);
  box-shadow: 1px 0 4px rgba(212, 175, 55, 0.4);
}

.abacus-outer-frame.theme-gold .rod-beam {
  background: linear-gradient(to bottom, #FFFDE7, #FFE082);
  border-top: 2px solid #FFB300;
  border-bottom: 2px solid #FFA000;
  box-shadow: 0 3px 8px rgba(184, 134, 11, 0.35);
}

.abacus-outer-frame.theme-gold .unit-dot {
  background: #E65100;
  box-shadow: 0 0 6px #FF8F00;
}

.abacus-outer-frame.theme-gold .bead-body {
  filter: sepia(0.5) saturate(2.4) hue-rotate(-10deg) drop-shadow(0 4px 8px rgba(184, 134, 11, 0.4));
}

.abacus-outer-frame.theme-gold .abacus-bead:hover .bead-body {
  filter: sepia(0.3) saturate(2.8) brightness(1.15) drop-shadow(0 6px 12px rgba(255, 215, 0, 0.6));
}

.abacus-outer-frame.theme-gold .abacus-bead.active .bead-body {
  filter: drop-shadow(0 0 12px #FFD700) brightness(1.28) saturate(2.2);
}

/* ==========================================================================
   Интерактивный экипированный аватар Совёнка Савы
   ========================================================================== */
.sawa-equipped-avatar {
  position: relative;
  display: inline-block;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sawa-equipped-avatar .sawa-base-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid #E8F5E9;
  box-shadow: 0 6px 14px rgba(0,0,0,0.15);
  object-fit: cover;
  display: block;
  background: #FFFFFF;
}

/* Золотая сияющая аура */
.sawa-equipped-avatar.has-gold-aura .sawa-base-img {
  border-color: #FFD54F;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.65), 0 6px 14px rgba(0,0,0,0.15);
}

.sawa-layer-aura {
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 215, 0, 0.7);
  pointer-events: none;
  animation: rotateAura 12s linear infinite;
  display: none;
}

.sawa-equipped-avatar.has-gold-aura .sawa-layer-aura {
  display: block;
}

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

/* Слой 1: Шапочка магистра */
.sawa-layer-hat {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 34px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.35));
  animation: hatBob 3s ease-in-out infinite alternate;
  display: none;
  z-index: 5;
}

.sawa-equipped-avatar.has-hat .sawa-layer-hat {
  display: block;
}

@keyframes hatBob {
  0% { transform: translateX(-50%) translateY(0) rotate(-2deg); }
  100% { transform: translateX(-50%) translateY(-2px) rotate(2deg); }
}

/* Слой 2: Очки (круглые или золотые турбо) */
.sawa-layer-glasses {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 26px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  display: none;
  z-index: 4;
}

.sawa-equipped-avatar.has-glasses .sawa-layer-glasses {
  display: block;
}

/* Слой 3: Походный рюкзачок за правым плечом */
.sawa-layer-backpack {
  position: absolute;
  bottom: -4px;
  right: -8px;
  font-size: 30px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.35));
  animation: backpackBounce 2.5s ease-in-out infinite alternate;
  display: none;
  z-index: 6;
}

.sawa-equipped-avatar.has-backpack .sawa-layer-backpack {
  display: block;
}

@keyframes backpackBounce {
  0% { transform: rotate(-4deg) translateY(0); }
  100% { transform: rotate(4deg) translateY(-3px); }
}

/* Подвал */
.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px 0;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .toolbar-section {
    flex-direction: column;
    align-items: stretch;
  }
  .abacus-board {
    height: 350px;
  }
  .abacus-bead {
    width: 46px;
    height: 28px;
  }
}
