/* ==========================================================================
   1. БАЗОВАЯ СЦЕНА И СМЕНА ТЕМЫ
   ========================================================================== */
body {
  margin: 0; padding: 0;
  display: flex; justify-content: center; align-items: center;
  min-height: 100vh;
  background-color: #e0e8f5; 
  font-family: 'Segoe UI', Roboto, sans-serif;
  transition: background-color 0.4s ease;
}

.app-screen {
  width: 100%; max-width: 400px;
  height: 100vh; max-height: 800px;
  display: flex; flex-direction: column;
  overflow: hidden;
  background-color: #e0e8f5; 
  transition: background-color 0.4s ease;
}

/* Переключатель фона для всего экрана */
.app-screen.dark-theme {
  background-color: #1b202e;
}

.label {
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: #a3b1c6;
  transition: color 0.4s ease;
}
.dark-theme .label { color: #5a667c; }

/* ==========================================================================
   2. ВЕРХНЯЯ ПАНЕЛЬ (Теперь с жестким фоном и слоем)
   ========================================================================== */
.top-bar {
  position: relative; 
  z-index: 10; /* Волны гарантированно под баром */
  width: 100%;
  padding: 25px 20px 10px 20px;
  box-sizing: border-box;
  
  /* Плотный дефолтный фон для светлой темы */
  background-color: #e0e8f5; 
  transition: background-color 0.4s ease;
}
.dark-theme .top-bar {
  background-color: #1b202e; /* Плотный фон для темной темы */
}

.global-status {
  padding: 15px; border-radius: 20px;
  box-shadow: inset 5px 5px 12px rgba(163,177,198,0.5), inset -5px -5px 12px #fff;
  transition: box-shadow 0.4s ease;
}
.dark-theme .global-status {
  box-shadow: inset 5px 5px 12px rgba(10,12,18,0.7), inset -5px -5px 12px rgba(255,255,255,0.04);
}

.tug-of-war-bar {
  height: 20px; display: flex; border-radius: 10px; overflow: hidden; margin-bottom: 15px;
  box-shadow: 2px 2px 5px rgba(163,177,198,0.3);
}
.dark-theme .tug-of-war-bar { box-shadow: 2px 2px 5px rgba(10,12,18,0.4); }

.progress-fill-black { background: linear-gradient(90deg, #11141d, #2c3545); transition: width 0.3s ease; }
.progress-fill-white { background: linear-gradient(90deg, #ffffff, #dbe3f0); transition: width 0.3s ease; }

.global-counters { display: flex; justify-content: space-between; }
.counter-box { text-align: center; width: 48%; }
.value { font-size: 18px; font-weight: 800; margin-top: 4px; transition: color 0.4s ease; }

.black-text { color: #2c3545; }
.white-text { color: #7f8fa6; text-shadow: 1px 1px 0 #fff; }
.dark-theme .black-text { color: #a3b1c6; text-shadow: 1px 1px 0 rgba(0,0,0,0.5); }
.dark-theme .white-text { color: #ffffff; text-shadow: none; }

/* ==========================================================================
   3. ЦЕНТРАЛЬНАЯ ЗОНА (Здесь живут и летают волны)
   ========================================================================== */
.main-area {
  display: flex; justify-content: center; align-items: center; 
  flex-grow: 1; /* Жадно забирает всё свободное место, фиксируя верстку */
  position: relative;
  z-index: 1; /* Слой волн самый нижний */
}

.button-ripple-wrapper {
  position: relative; width: 160px; height: 160px; font-size: 16px; flex-shrink: 0;
}

.water-button {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  border: none; border-radius: 50%; cursor: pointer; outline: none;
  z-index: 3; display: flex; justify-content: center; align-items: center;
  -webkit-tap-highlight-color: transparent; user-select: none;
  transition: transform 0.1s ease, background-color 0.4s ease, box-shadow 0.4s ease;
  
  background-color: #e0e8f5;
  box-shadow: 9px 9px 20px rgba(163, 177, 198, 0.7), -9px -9px 20px rgba(255, 255, 255, 0.9);
}
.dark-theme .water-button {
  background-color: #1b202e;
  box-shadow: 9px 9px 20px rgba(10, 12, 18, 0.8), -9px -9px 20px rgba(255, 255, 255, 0.06);
}

.btn-top {
  font-size: 1.2em; font-weight: 800; letter-spacing: 2px; color: #6d7f99;
  transition: transform 0.1s ease, color 0.4s ease;
}
.dark-theme .btn-top { color: #e0e8f5; }

/* Клик (Вдавливание) */
.water-button:active {
  box-shadow: inset 6px 6px 12px rgba(163, 177, 198, 0.7), inset -6px -6px 12px rgba(255, 255, 255, 0.9);
}
.dark-theme .water-button:active {
  box-shadow: inset 6px 6px 12px rgba(10, 12, 18, 0.9), inset -6px -6px 12px rgba(255, 255, 255, 0.04);
}
.water-button:active .btn-top { transform: scale(0.9); }

/* Дышащее сияние кнопки */
.water-button::before {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 50%;
  z-index: -1; pointer-events: none;
}
.white-faction .water-button::before { animation: whiteGlow 3s infinite ease-in-out; }
.black-faction .water-button::before { animation: blackGlow 3s infinite ease-in-out; }

@keyframes whiteGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(0,0,0,0); }
  50% { box-shadow: -10px -10px 25px rgba(255,255,255,0.9), 10px 10px 25px rgba(163,177,198,0.5); }
}
@keyframes blackGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(0,0,0,0); }
  50% { box-shadow: -10px -10px 25px rgba(255,255,255,0.04), 10px 10px 25px rgba(10,12,18,0.7); }
}
.water-button:active::before { animation: none; box-shadow: none !important; }

/* ==========================================================================
   4. НИЖНЯЯ ПАНЕЛЬ (Жесткий фон и слой)
   ========================================================================== */
.bottom-bar {
  position: relative; 
  z-index: 10; /* Волны гарантированно под панелью */
  width: 100%; 
  display: flex; flex-direction: column; gap: 20px;
  padding: 10px 20px 25px 20px;
  box-sizing: border-box;
  
  background-color: #e0e8f5;
  transition: background-color 0.4s ease;
}
.dark-theme .bottom-bar {
  background-color: #1b202e;
}

.personal-counters {
  display: flex; justify-content: space-between; padding: 12px; border-radius: 18px;
  box-shadow: inset 4px 4px 10px rgba(163,177,198,0.5), inset -4px -4px 10px #fff;
  transition: box-shadow 0.4s ease;
}
.dark-theme .personal-counters {
  box-shadow: inset 4px 4px 10px rgba(10,12,18,0.7), inset -4px -4px 10px rgba(255,255,255,0.03);
}

.personal-box { text-align: center; width: 48%; }
.personal-box .value { color: #6d7f99; transition: color 0.4s ease;}
.dark-theme .personal-box .value { color: #a3b1c6; }

/* ==========================================================================
   ИСПРАВЛЕННЫЙ БЛОК ТУМБЛЕРА
   ========================================================================== */
.toggle-container { display: flex; flex-direction: column; gap: 8px; align-items: center; }

/* ДОБАВЛЯЕМ СЮДА ПРОПАВШИЙ КЛАСС: */
.toggle-label { 
  font-family: inherit; 
  font-size: 11px; 
  font-weight: 800; 
  color: #6d7f99; 
  letter-spacing: 1px; 
  transition: color 0.4s ease; 
}
.dark-theme .toggle-label { 
  color: #5a667c; 
}

.faction-toggle {
  position: relative; width: 100%; height: 50px; border-radius: 25px; background-color: #e0e8f5;
  cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  box-shadow: inset 5px 5px 10px rgba(163,177,198,0.6), inset -5px -5px 10px #fff;
  -webkit-tap-highlight-color: transparent; user-select: none;
  transition: background-color 0.4s ease, box-shadow 0.4s ease;
}
.dark-theme .faction-toggle {
  background-color: #1b202e;
  box-shadow: inset 5px 5px 10px rgba(10,12,18,0.8), inset -5px -5px 10px rgba(255,255,255,0.04);
}

.toggle-bg-text {
  width: 50%; text-align: center; font-size: 12px; font-weight: 800; z-index: 2; pointer-events: none; 
  transition: color 0.4s ease; color: #a3b1c6;
}
.faction-toggle.white-active .toggle-bg-text.right { color: #6d7f99; }
.dark-theme .toggle-bg-text.left { color: #e0e8f5; }
.dark-theme .toggle-bg-text.right { color: #5a667c; }

.toggle-handle {
  position: absolute; top: 4px; left: 4px; width: calc(50% - 4px); height: 42px; border-radius: 21px; z-index: 1; 
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.2);
}
.faction-toggle.white-active .toggle-handle {
  transform: translateX(100%); background-color: #e0e8f5;
  box-shadow: 4px 4px 10px rgba(163,177,198,0.5), -4px -4px 10px #fff;
}
.faction-toggle.black-active .toggle-handle {
  transform: translateX(0); background-color: #1b202e;
  box-shadow: 4px 4px 10px rgba(10,12,18,0.6), -2px -2px 6px rgba(255,255,255,0.1);
}

/* ==========================================================================
   5. ШЁЛКОВЫЕ ВОЛНЫ
   ========================================================================== */
.wave {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: transparent; border-radius: 50%; z-index: 1; pointer-events: none;
  animation: smoothSilkCircle 2.2s cubic-bezier(0.1, 0.4, 0.4, 1) forwards;
}
.white-wave { box-shadow: 0 0 15px 3px rgba(255, 255, 255, 0.85); }
.black-wave { box-shadow: 0 0 15px 4px rgba(10, 12, 18, 0.9); }

@keyframes smoothSilkCircle {
  0% { transform: scale(0.9); opacity: 1; }
  70% { opacity: 0; }
  100% { transform: scale(4.5); opacity: 0; }
}
