/* --- ГЛОБАЛЬНЫЕ СТИЛИ И ШРИФТЫ --- */
body {
  background-color: black;
}

header {
  padding: 40px 20px;
  text-align: center;
}

.main-title {
  font-family: "Cinzel Decorative", serif;
  font-size: 5rem;
  color: #fff;
  text-transform: uppercase;
  text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 20px #ffae42, 0 0 40px #ffae42,
    0 0 60px #ffae42, 0 0 80px #ffae42;
  transition: all 0.5s ease-in-out; /* Добавляем плавный переход цвета */
}

/* Стиль заголовка в пробужденном режиме */
body.is-awakened .main-title {
  color: #f8f8f2;
  text-shadow: 0 0 5px #fff, 0 0 15px #ff79c6, 0 0 30px #ff79c6,
    0 0 50px #bd93f9, 0 0 80px #bd93f9;
}

/* Стиль для подзаголовка */
.subtitle {
  font-family: "Cinzel Decorative", serif;
  font-size: 2rem;
  text-transform: uppercase;
  margin-top: -15px; /* Придвигаем ближе к заголовку */
  color: #f8f8f2;
  text-shadow: 0 0 5px #fff, 0 0 15px #ff79c6, 0 0 30px #ff79c6,
    0 0 50px #bd93f9, 0 0 80px #bd93f9;

  /* Скрываем по умолчанию */
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.5s ease-in-out;
}

/* Показываем подзаголовок в пробужденном режиме */
body.is-awakened .subtitle {
  opacity: 1;
  transform: translateY(0);
}

/* --- КОНТЕЙНЕР ДЛЯ КАРТ --- */
.objects {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  padding: 40px;
  justify-content: center;
}

/* --- СТИЛИ КАРТОЧКИ: ОСНОВА --- */

.item-card {
  background-color: transparent;
  border: none;
  cursor: pointer;
  perspective: 1500px;
  width: 300px;
  height: 400px;
}

.item-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
  transform-style: preserve-3d;
  will-change: transform;
  border-radius: 15px;
  box-shadow: 0 0 15px rgba(255, 174, 66, 0.5), 0 0 30px rgba(255, 140, 0, 0.5),
    inset 0 0 20px rgba(255, 140, 0, 0.4);
}

.item-card-inner.is-flipped {
  transform: rotateY(180deg);
}

/* --- ОБЩИЕ СТИЛИ ДЛЯ ОБЕИХ СТОРОН КАРТЫ --- */
.item-card-front,
.item-card-back {
  position: absolute; /* ИСПРАВЛЕНО: Было position: relative только у front */
  overflow: hidden; /* ИСПРАВЛЕНО: Скрываем все, что выходит за рамки */
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 15px;
  box-sizing: border-box;
  padding: 25px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  z-index: 2;
}

/* --- СТИЛИ ПЕРЕДНЕЙ СТОРОНЫ --- */
.item-card-front {
  background: linear-gradient(145deg, #4a148c, #2c0b50);
  color: #f0f0f0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.item-card-front img {
  max-height: 55%;
  border-radius: 8px;
  margin-bottom: 15px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.item-card-front h3 {
  font-family: "MedievalSharp", cursive;
  color: #ffffff;
  font-size: 2em;
  text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.5);
  margin: 0;
}

.item-card-front p {
  font-family: "Cormorant Garamond", serif;
  color: #d1c4e9;
  font-size: 1.1em;
  font-style: italic;
  margin: 8px 0 0 0;
}

/* --- СТИЛИ ЗАДНЕЙ СТОРОНЫ --- */
.item-card-back {
  transform: rotateY(180deg);
  padding: 15px; /* Уточнено */
  background-color: #1a0923;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 800'%3e%3crect fill='%231a0923' width='800' height='800'/%3e%3cg stroke-width='1' fill='none'%3e%3cg stroke='%23daa520' stroke-opacity='0.6'%3e%3cpath d='M 0 100 Q 200 150 400 100 T 800 100' /%3e%3cpath d='M 0 250 Q 150 200 300 250 T 600 250 T 900 250' /%3e%3cpath d='M 800 350 Q 600 400 400 350 T 0 350' /%3e%3cpath d='M 0 500 Q 250 450 500 500 T 1000 500' /%3e%3cpath d='M 800 650 Q 550 700 300 650 T -200 650' /%3e%3cpath d='M 0 750 Q 100 700 200 750 T 400 750 T 600 750 T 800 750' /%3e%3c/g%3e%3cg stroke='%23b8860b' stroke-opacity='0.8'%3e%3cpath d='M 0 50 Q 180 100 380 50 T 780 50' /%3e%3cpath d='M 0 150 Q 160 100 310 150 T 610 150 T 910 150' /%3e%3cpath d='M 800 200 Q 620 250 420 200 T 20 200' /%3e%3cpath d='M 0 450 Q 230 400 480 450 T 980 450' /%3e%3cpath d='M 800 550 Q 570 600 320 550 T -180 550' /%3e%3cpath d='M 0 800 Q 120 750 220 800 T 420 800 T 620 800 T 820 800' /%3e%3c/g%3e%3c/g%3e%3c/svg%3e");
  background-size: 250% 250%;
  color: #f0f0f0;
  border: 1px solid #b8860b;
  animation: wave-animation 40s linear infinite;
}

.back-top {
  display: flex;
  align-items: baseline;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 215, 0, 0.3);
  margin-bottom: 10px;
  width: 100%;
}

.rank-circle {
  font-family: "Metal Mania", cursive;
  font-size: 3.5em;
  color: #ff4500;
  text-shadow: 0 0 5px #fff, 0 0 10px #ff4500, 0 0 15px #ff8c00;
  line-height: 1;
  margin-right: 15px;
  flex-shrink: 0;
}

.back-top h3 {
  font-family: "MedievalSharp", cursive;
  font-size: 1.5em;
  color: #ffffff;
  text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.5);
  margin: 0;
  text-align: left;
}

.back-middle {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
}

.stats-list ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.stats-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 215, 0, 0.2);
  font-family: "Cormorant Garamond", serif;
  font-size: 1.1em;
}

.stats-list li:last-child {
  border-bottom: none;
}

.stat-name {
  color: #e0e0e0;
}
.stat-value {
  color: #ffd700;
  font-weight: bold;
  font-size: 1.2em;
}
.stat-name.stat-strength {
  color: #ff5555;
}
.stat-name.stat-agility {
  color: #50fa7b;
}
.stat-name.stat-intellect {
  color: #55aaff;
}
.stat-name.stat-stamina {
  color: #8be9fd;
}
.stat-name.stat-health {
  color: #f1fa8c;
}
.stat-name.stat-hax {
  background: linear-gradient(45deg, #bd93f9, #ff79c6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: bold;
}

/* --- КНОПКА УПРАВЛЕНИЯ --- */
.controls-container {
  text-align: center;
  padding: 40px 20px;
}

.awake-btn {
  font-family: "Metal Mania", cursive;
  font-size: 2em;
  padding: 15px 40px;
  color: #f8f8f2;
  background-color: #6272a4;
  border: 2px solid #bd93f9;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-shadow: 0 0 5px #ff79c6;
}

.awake-btn:hover {
  background-color: #bd93f9;
  color: #1a0923;
  box-shadow: 0 0 20px #bd93f9;
}

/* --- СТИЛИ КНОПКИ НА ЗАДНЕЙ СТОРОНЕ --- */
.view-more-btn {
  font-family: "MedievalSharp", cursive;
  color: #ffd700; /* Ярко-желтый */
  font-size: 1.2em;
  background: transparent;
  border: 1px solid rgba(255, 215, 0, 0.3);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 5px;
  transition: all 0.3s ease;
  opacity: 1; /* ИЗМЕНЕНО с 0 на 1 - показываем всегда */
  text-shadow: 0 0 3px rgba(255, 215, 0, 0.3); /* Базовое свечение */
}

/* Эффекты при наведении - усиленное свечение */
.view-more-btn:hover {
  color: #ffea00; /* Более яркий желтый */
  text-shadow: 0 0 5px rgba(255, 215, 0, 0.5), 0 0 10px rgba(255, 215, 0, 0.5),
    0 0 15px rgba(255, 215, 0, 0.5);
  background: transparent;
  transform: scale(1.05);
  border-color: rgba(255, 215, 0, 0.6);
}

/* Эффект при клике */
.view-more-btn:active {
  transform: scale(0.95);
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
}

/* --- ЭФФЕКТЫ ПРОБУЖДЕННЫХ КАРТ --- */

.is-awakened .item-card-inner {
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.is-awakened .item-card-inner::before {
  content: "";
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  z-index: 1;
  background: linear-gradient(45deg, #ff79c6, #bd93f9, #ff4500);
  border-radius: 18px;
  filter: blur(12px);
  opacity: 0.75;
  transition: opacity 0.5s;
}

/* Псевдо-элемент для анимации вспышки */
.item-card-inner::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  border-radius: 15px;
  z-index: 10; /* Выше всего остального контента */
  opacity: 0; /* Изначально невидим */
  pointer-events: none; /* Не мешает кликам */
}

.is-awakened .item-card-front::before {
  background: radial-gradient(
    circle,
    rgba(255, 121, 198, 0.4) 0%,
    rgba(255, 121, 198, 0) 60%
  );
  animation: float-particles 15s infinite linear;
}

.is-awakened .item-card-front::after {
  width: 300px;
  height: 300px;
  background: radial-gradient(
    circle,
    rgba(189, 147, 249, 0.3) 0%,
    rgba(189, 147, 249, 0) 60%
  );
  animation: float-particles 20s infinite linear;
  animation-delay: -5s;
}

.is-awakened .item-card-front::before,
.is-awakened .item-card-front::after {
  opacity: 1;
}

.is-awakened .item-card:hover .item-card-front h3 {
  transform: translateY(-3px);
  text-shadow: 0 0 10px rgba(255, 121, 198, 0.7),
    0 0 20px rgba(255, 121, 198, 0.4);
}

.is-awakened .item-card:hover .item-card-front p {
  transform: translateY(-2px);
  text-shadow: 0 0 8px rgba(189, 147, 249, 0.7);
}

/* Дополнительный свечение по краям */
.is-awakened .item-card-front::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 15px;
  box-shadow: inset 0 0 20px rgba(189, 147, 249, 0.5);
  opacity: 0.5;
  z-index: 1;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.is-awakened .item-card:hover .item-card-front::after {
  opacity: 0.8;
}

/* --- АНИМАЦИИ --- */
@keyframes wave-animation {
  0% {
    background-position: 0% 0%;
  }
  50% {
    background-position: 100% 100%;
  }
  100% {
    background-position: 0% 0%;
  }
}

/* --- СТИЛИ И АНИМАЦИИ ПЕРЕХОДА --- */

#transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #ffffff;
  opacity: 0;
  z-index: 9999; /* Выше всех элементов */
  pointer-events: none; /* Не мешает кликам */
}

/* Класс-триггер для запуска анимации */
#transition-overlay.is-flashing {
  animation: screen-flash 4s ease-in-out !important; /* УВЕЛИЧЕНО до 4с */
}

.is-transitioning .item-card-inner {
  animation: shake-animation 2s ease-in-out;
}

/* Анимация яростной тряски, которая останавливается на полпути */
@keyframes shake-animation {
  /* Фаза тряски (первая половина анимации) */
  0% {
    transform: translateX(0);
  }
  10%,
  30% {
    transform: translateX(-8px) rotate(-2deg);
  }
  20%,
  40% {
    transform: translateX(8px) rotate(2deg);
  }

  /* Фаза покоя (вторая половина анимации) */
  50%,
  100% {
    transform: translateX(0) rotate(0);
  }
}

/* Улучшенная анимация вспышки для оверлея */
@keyframes screen-flash {
  0% {
    opacity: 0;
  }
  10% {
    opacity: 0.7;
  }
  20% {
    opacity: 1; /* Быстрее достигаем полной белизны */
  }
  60% {
    opacity: 0.8; /* ОЧЕНЬ долго держим белый экран */
  }
  80% {
    opacity: 0.7; /* Медленное затухание */
  }
  90% {
    opacity: 0.3;
  }
  95% {
    opacity: 0.2;
  }
  98% {
    opacity: 0.1;
  }
  100% {
    opacity: 0;
  }
}

/* --- МОДАЛЬНОЕ ОКНО --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  backdrop-filter: blur(5px);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  position: relative;
  background: linear-gradient(145deg, #1a0923, #2c0b50);
  width: 80%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 15px;
  border: 2px solid #bd93f9;
  box-shadow: 0 0 30px rgba(189, 147, 249, 0.7),
    0 0 60px rgba(255, 121, 198, 0.4);
  padding: 30px;
  color: #f8f8f2;
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: none;
  font-size: 24px;
  color: #bd93f9;
  cursor: pointer;
  z-index: 2;
}

.modal-close:hover {
  color: #ff79c6;
  transform: scale(1.2);
}

.modal-header {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  align-items: center;
}

.modal-header img {
  width: 150px;
  height: 150px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid #bd93f9;
  box-shadow: 0 0 15px rgba(189, 147, 249, 0.5);
}

.modal-title-section {
  flex: 1;
}

.modal-title-section h2 {
  font-family: "Metal Mania", cursive;
  font-size: 2.5em;
  margin: 0 0 10px 0;
  color: #ff79c6;
  text-shadow: 0 0 10px rgba(255, 121, 198, 0.5);
}

.modal-title-section p {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.2em;
  font-style: italic;
  margin: 0;
  color: #f1fa8c;
}

.modal-body {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
}

.modal-content-right {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.modal-skills {
  margin-top: 20px;
}

.modal-skills h3 {
  font-family: "MedievalSharp", cursive;
  color: #bd93f9;
  margin-top: 0;
  border-bottom: 1px solid rgba(189, 147, 249, 0.3);
  padding-bottom: 10px;
}

/* Scrollable skills container */
.skills-container {
  max-height: 200px;
  overflow-y: auto;
  padding-right: 10px;
  margin-bottom: 15px;

  /* Fancy scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #bd93f9 rgba(30, 10, 50, 0.5);
}

.skills-container::-webkit-scrollbar {
  width: 8px;
}

.skills-container::-webkit-scrollbar-track {
  background: rgba(30, 10, 50, 0.5);
  border-radius: 4px;
}

.skills-container::-webkit-scrollbar-thumb {
  background-color: #bd93f9;
  border-radius: 4px;
}

/* Individual skill styling */
.skill-item {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(30, 10, 50, 0.4);
  transition: all 0.2s ease;
}

.skill-item:hover {
  background: rgba(40, 15, 65, 0.6);
  transform: translateX(3px);
  box-shadow: -3px 0 0 #ff79c6;
}

.skill-icon {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  margin-right: 12px;
  border: 1px solid #bd93f9;
  box-shadow: 0 0 5px rgba(189, 147, 249, 0.7);
  flex-shrink: 0;
}

.skill-details {
  flex: 1;
}

.skill-details h4 {
  margin: 0 0 5px 0;
  color: #ff79c6;
  font-family: "Metal Mania", cursive;
  font-size: 1.1em;
}

.skill-details p {
  margin: 0;
  font-size: 0.9em;
  color: #f8f8f2;
  line-height: 1.4;
}

/* --- МОДАЛЬНЫЕ ОКНА --- */
/* Исправления для модальных окон с характеристиками и предысторией */
.modal-stats {
  margin-right: 20px;
}

.modal-stats h3 {
  font-family: "MedievalSharp", cursive;
  color: #bd93f9;
  margin-top: 0;
  border-bottom: 1px solid rgba(189, 147, 249, 0.3);
  padding-bottom: 10px;
  font-size: 1.4em;
}

.modal-stats ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
  font-size: 1.1em;
}

.modal-stats li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(189, 147, 249, 0.2);
}

.modal-stats li:last-child {
  border-bottom: none;
}

.modal-lore h3 {
  font-family: "MedievalSharp", cursive;
  color: #bd93f9;
  margin-top: 0;
  border-bottom: 1px solid rgba(189, 147, 249, 0.3);
  padding-bottom: 10px;
  font-size: 1.4em;
}

.modal-lore p {
  line-height: 1.6;
  color: #f8f8f2;
}

/* --- АНИМАЦИЯ ПОДЪЕМА ЭКРАНА --- */
/* Гораздо более выраженный подъем */
body.is-awakening header {
  animation: header-rise 1.8s cubic-bezier(0.15, 0.85, 0.36, 1) !important;
  animation-fill-mode: both !important;
  transform-origin: center bottom !important;
  will-change: transform !important;
}

body.is-awakening .objects {
  animation: objects-rise 1.8s cubic-bezier(0.15, 0.85, 0.36, 1) !important;
  animation-fill-mode: both !important;
  transform-origin: center bottom !important;
  will-change: transform !important;
}

@keyframes header-rise {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  5% {
    transform: translate3d(0, -10px, 0) scale(1.01);
  } /* Начальный рывок */
  35% {
    transform: translate3d(0, -120px, 0) scale(1.08);
  } /* ЭКСТРЕМАЛЬНО УСИЛЕНО */
  65% {
    transform: translate3d(0, -60px, 0) scale(1.04);
  }
  85% {
    transform: translate3d(0, -20px, 0) scale(1.01);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes objects-rise {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  5% {
    transform: translate3d(0, -8px, 0) scale(1.01);
  } /* Начальный рывок */
  35% {
    transform: translate3d(0, -100px, 0) scale(1.06);
  } /* ЭКСТРЕМАЛЬНО УСИЛЕНО */
  65% {
    transform: translate3d(0, -50px, 0) scale(1.03);
  }
  85% {
    transform: translate3d(0, -15px, 0) scale(1.01);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
}

/* --- УЛУЧШЕННЫЙ ПОДЪЕМ ЭКРАНА --- */
.screen-rising {
  transition: transform 0ms linear !important; /* Отключаем плавность для начала */
}

@keyframes extreme-rise {
  0% {
    transform: translateY(0);
  }
  15% {
    transform: translateY(-150px);
  } /* Резкий подъем вверх */
  30% {
    transform: translateY(-200px);
  } /* Пик подъема */
  50% {
    transform: translateY(-150px);
  } /* Небольшое падение */
  70% {
    transform: translateY(-100px);
  } /* Продолжение падения */
  85% {
    transform: translateY(-50px);
  } /* Медленное возвращение */
  100% {
    transform: translateY(0);
  } /* Полное возвращение */
}

/* --- ИСПРАВЛЕНИЕ ГОРИЗОНТАЛЬНОГО СКРОЛЛА --- */
html,
body {
  overflow-x: hidden !important;
  max-width: 100vw;
}

/* Предотвращаем скролл во время анимации */
body.is-awakening {
  overflow: hidden !important;
}

/* --- МЕДЛЕННЫЙ ПЕРЕВОРОТ ПРИ AWAKE --- */
/* Медленный и плавный переворот карт при AWAKE */
.slow-flip-back {
  transition: transform 4s cubic-bezier(0.4, 0, 0.2, 1) !important;
  transform-origin: center center !important;
  will-change: transform !important;
  animation: none !important; /* Отключаем другие анимации */
}

/* Обычный переворот карт при клике */
.item-card-inner {
  transition: transform 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Важно: отключаем тряску для медленно переворачивающихся карт */
.is-transitioning .item-card-inner.slow-flip-back {
  animation: none !important;
}
