/* Game4Words - New Layout with Single Background */
/* Canvas: 354x641 px (reduced by 10%) */

/* === FONT === */

/* Подключение шрифта Airfool */
@font-face {
  font-family: 'MolliWrites-Script';
  src: url('assets/MolliWrites-Script.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif;
  overflow: hidden;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100vw;
}

/* Main game container with single background */
.game-container {
  position: relative;
  width: 354px;
  height: 641px;
  background: url('assets/fon01.png') no-repeat center center;
  background-size: 100% 100%;
  margin: 0 auto;
  overflow: visible;
  
  /* Adaptive scaling */
  transform-origin: center center;
}

/* Responsive scaling and centering */
@media (max-width: 354px) {
  .game-container {
    transform: scale(calc(100vw / 354));
  }
}

@media (max-height: 641px) {
  .game-container {
    transform: scale(calc(100vh / 641));
  }
}

/* Ensure horizontal centering on all devices */
@media (min-width: 354px) {
  .game-container {
    margin: 0 auto;
  }
}

/* Mobile landscape orientation */
@media (max-height: 641px) and (orientation: landscape) {
  body {
    align-items: flex-start;
    padding-top: 20px;
  }
}

/* --- HEADER ELEMENTS --- */

.player-name {
  position: absolute;
  left: 1.27%;
  top: 1.40%;
  width: 45.80%;
  height: 9.13%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 1.27%;
  /* font-size устанавливается динамически через JavaScript */
  font-weight: bold;
  color: #C9811B;
  z-index: 10;
  text-align: left;
  line-height: 1.1;
  overflow: hidden;
  white-space: nowrap;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif;
}

.rate {
  position: absolute;
  left: 53.44%;
  top: 1.40%;
  width: 45.80%;
  height: 9.13%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 2.54%;
  /* font-size устанавливается динамически через JavaScript */
  font-weight: bold;
  color: #C9811B;
  z-index: 10;
  text-align: right;
  line-height: 1.2;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif;
}

.rating-day-container {
  margin-left: 4px;
  color: #666;
}

/* --- TIMER --- */

.timer-bar {
  position: absolute;
  left: 1.27%;
  top: 12.64%;
  width: 94.15%;
  height: 7.02%;
  display: none; /* Скрыт - используется только круговая анимация */
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: bold;
  color: #ff6600;
  z-index: 15;
  text-align: center;
  line-height: 1;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif;
}

/* --- WORD FIELDS --- */

.word-field {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  /* font-size устанавливается динамически через JavaScript */
  font-weight: 600;
  color: #C9811B;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  z-index: 20;
  transition: transform 0.2s;
  text-align: center;
  line-height: 1.2;
  padding: 5px;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif;
}


/* Контролируем touch-события для свайпов */
.word-field {
  touch-action: manipulation;
}

.game-container {
  touch-action: pan-x pan-y;
}

body {
  touch-action: manipulation;
}

.word-field:active {
  cursor: grabbing;
}

.word-field.dragging {
  opacity: 0.7;
  z-index: 100;
}

.word-field-1 {
  left: 3.82%;
  top: 16.85%;
  width: 41.98%;
  height: 7.02%;
}

.word-field-2 {
  left: 54.71%;
  top: 16.85%;
  width: 41.98%;
  height: 7.02%;
}

.word-field-3 {
  left: 3.82%;
  top: 73.03%;
  width: 41.98%;
  height: 7.02%;
}

.word-field-4 {
  left: 54.71%;
  top: 73.03%;
  width: 41.98%;
  height: 7.02%;
}

/* Свайп-эффекты для слов */
/* Drag & Drop эффекты */
.word-field[draggable="true"] {
  cursor: grab;
}

.word-field[draggable="true"]:active {
  cursor: grabbing;
}

/* Подсветка круга отключена */

.word-field.dragging {
  opacity: 0.5;
  transform: scale(1.1);
  z-index: 1000;
}


/* --- CIRCLE AREA --- */

.circle-area {
  position: absolute;
  left: 20.36%;
  top: 32.30%;
  width: 58.52%;
  height: 32.30%;
  z-index: 22;
  cursor: pointer;
  background: url('assets/krug.png') no-repeat center center;
  background-size: 100% 100%;
}


.timer-circle {
  position: absolute;
  /* Позиция устанавливается через JavaScript */
  /* По умолчанию в позиции 12 часов */
  left: 43.48%;
  top: -6.52%;
  width: 13.04%;
  height: 13.04%;
  z-index: 1;
  pointer-events: none;
  transition: left 0.1s linear, top 0.1s linear;
}

/* Description text inside circle */
.description {
  position: absolute;
  left: 8.26%;
  top: 8.26%;
  width: 83.48%;
  height: 83.48%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #666;
  line-height: 1.0;
  padding: 6.52%;
  word-wrap: break-word;
  overflow: hidden;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif;
}

/* Instruction overlay (NACHAT button) */
.instruction-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  z-index: 30;
}

.instruction-text {
  font-size: 24px;
  color: #C9811B;
  text-align: center;
  margin-bottom: 15px;
  padding: 0 10px;
  line-height: 1.2;
  max-width: 250px;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif;
}

.button-start {
  position: absolute;
  left: 20.36%;
  top: 63.25%;
  width: 58.52%;
  height: 7.02%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #007bff;
  border: none;
  border-radius: 8px;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  z-index: 31;
  transition: color 0.2s;
  text-align: center;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif;
}

.button-start:hover {
  color: #0056b3;
}

.button-start:active {
  transform: scale(0.98);
}

/* Result overlay */
.result-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  z-index: 30;
}

/* Star add button */
.star-add {
  position: absolute;
  left: 51%;
  top: 22%;
  transform: translateX(-50%);
  width: auto;
  height: 5.90%;
  max-width: 12.21%;
  object-fit: contain;
  cursor: pointer;
  z-index: 35;
  display: none;
}


.text-result {
  position: absolute;
  left: 20.36%;
  top: 41.43%;
  width: 58.52%;
  height: 7.02%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  color: #C9811B;
  z-index: 31;
  text-align: center;
  line-height: 1.2;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif;
}

.text-guessed {
  position: absolute;
  left: 20.36%;
  top: 48.45%;
  width: 58.52%;
  height: 7.02%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: #10b981;
  text-transform: uppercase;
  z-index: 31;
  text-align: center;
  line-height: 1.2;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif;
}

.button-continue {
  position: absolute;
  left: 20.36%;
  top: 63.25%;
  width: 58.52%;
  height: 7.02%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #007bff;
  border: none;
  border-radius: 8px;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  z-index: 31;
  transition: color 0.2s;
  text-align: center;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif;
}

.button-continue:hover {
  color: #0056b3;
}

.button-continue:active {
  transform: scale(0.98);
}

/* --- FOOTER --- */

.footer-clickable {
  position: absolute;
  left: 0%;
  top: 85.67%;
  width: 100%;
  height: 14.33%;
  cursor: pointer;
  z-index: 10;
}

/* Footer click zones (invisible, for touch/click handling) */
.footer-zone {
  position: absolute;
  top: 0;
  height: 100%;
  cursor: pointer;
}

.footer-zone-1 { left: 0%; width: 25%; }      /* 0-25% - Favorites */
.footer-zone-2 { left: 25%; width: 25%; }     /* 25-50% - Ratings */
.footer-zone-3 { left: 50%; width: 25%; }     /* 50-75% - Last Games */
.footer-zone-4 { left: 75%; width: 25%; }     /* 75-100% - Profile */

/* --- MODALS (keep existing styles from inline HTML) --- */

/* Basic modal styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background-image: url('assets/modal.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 24px;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #666;
}

.modal-close:hover {
  color: #C9811B;
}

.modal-close-zone {
  position: absolute !important;
  top: 0 !important;
  right: 0 !important;
  width: 10% !important; /* 90-100% по горизонтали = 10% ширины справа */
  height: 10% !important; /* 0-10% по вертикали = 10% высоты сверху */
  cursor: pointer !important;
  z-index: 100 !important;
}

.modal-body {
  padding: 16px;
  overflow: auto;
  flex: 1;
}

/* --- UTILITY --- */

.hidden {
  display: none !important;
}

.visible {
  display: flex !important;
}

/* Drag & Drop */
.drop-zone-active {
  /* Visual feedback when dragging */
}

/* Touch/Mouse support */
@media (hover: none) {
  .word-field:active {
    transform: scale(1.05);
  }
}

/* --- SMALL NOTIFICATION MODAL (Added to Favorites) --- */

.favorites-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3000;
  background: rgba(0, 0, 0, 0.7);
  padding: 20px 30px;
  border-radius: 8px;
}

.favorites-modal-content {
  position: relative;
  color: white;
  font-size: 16px;
  text-align: center;
}

.favorites-modal-close {
  position: absolute;
  top: -1.75%;
  right: -4.78%;
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
}

.favorites-modal-text {
  padding: 10px 20px;
}

/* --- FAVORITES MODAL (scaled to fon01.png) --- */

/* Модальное окно избранного: 80% от fon01.png (354x641) = 283x513px */
#favoritesModal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: rgba(0, 0, 0, 0.5) !important;
  z-index: 2000 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
}

.favorites-modal-box {
  position: relative !important;
  background-image: url('assets/modal.png') !important;
  background-size: 100% 100% !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
  width: 283px !important;  /* 80% от 354px */
  max-width: 283px !important;
  height: 513px !important; /* 80% от 641px */
  max-height: 513px !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.favorites-modal-header {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  padding: 10px 12px !important;
  border-bottom: none !important;
  height: 8.77% !important;
  flex-shrink: 0 !important;
  background: transparent !important;
  z-index: 10 !important;
}

.favorites-modal-header > div {
  position: absolute !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  font-weight: 700 !important;
  font-size: 22px !important;  /* Оптимизирован под новый размер */
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif !important;
}

#favoritesModalClose {
  background: transparent !important;
  border: none !important;
  font-size: 20px !important;  /* Оптимизирован под новый размер */
  cursor: pointer !important;
}

#favoritesModalBody {
  padding: 12px !important;  /* Оптимизирован под новый размер */
  overflow: auto !important;
  font-size: 12px !important;  /* Оптимизирован под новый размер */
  flex: 1 !important;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif !important;
}

/* --- HISTORY/FAVORITES TABLE STYLES (оптимизированы под новый размер) --- */

.history-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: transparent;
  border-radius: 0;
  border: none;
  margin-bottom: 6px;
}

.history-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  min-height: 28px;
}

.history-cell-text {
  /* font-size устанавливается динамически через JavaScript (стандарт 28px) */
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif;
}

.history-cell-left {
  justify-content: flex-end;
  padding-right: 8px;  /* Уменьшено */
}

.history-cell-right {
  justify-content: flex-start;
  padding-left: 8px;  /* Уменьшено */
}

/* --- STATS MODAL (scaled to fon01.png) --- */

/* Модальное окно статистики: 80% от fon01.png (354x641) = 283x513px */
#statsModal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: rgba(0, 0, 0, 0.5) !important;
  z-index: 2000 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
}

.stats-modal-box {
  position: relative !important;
  background-image: url('assets/modal.png') !important;
  background-size: 100% 100% !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
  width: 283px !important;  /* 80% от 354px */
  max-width: 283px !important;
  height: 513px !important; /* 80% от 641px */
  max-height: 513px !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.stats-modal-header {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  padding: 10px 12px !important;
  border-bottom: none !important;
  height: 8.77% !important;
  flex-shrink: 0 !important;
  background: transparent !important;
  z-index: 10 !important;
}

.stats-modal-header > div {
  position: absolute !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  font-weight: 700 !important;
  font-size: 22px !important;  /* Оптимизирован под новый размер */
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif !important;
}

#statsModalClose {
  background: transparent !important;
  border: none !important;
  font-size: 20px !important;  /* Оптимизирован под новый размер */
  cursor: pointer !important;
}

#statsModalBody {
  padding: 12px !important;  /* Оптимизирован под новый размер */
  overflow: auto !important;
  font-size: 12px !important;  /* Оптимизирован под новый размер */
  flex: 1 !important;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif !important;
}

/* --- RATINGS MODAL (scaled to fon01.png) --- */

/* Модальное окно рейтингов: 80% от fon01.png (354x641) = 283x513px */
#ratingsModal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: rgba(0, 0, 0, 0.5) !important;
  z-index: 2000 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
}

.ratings-modal-box {
  position: relative !important;
  background-image: url('assets/modal.png') !important;
  background-size: 100% 100% !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
  width: 283px !important;  /* 80% от 354px */
  max-width: 283px !important;
  height: 513px !important; /* 80% от 641px */
  max-height: 513px !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.ratings-modal-header {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  padding: 10px 12px !important;
  border-bottom: none !important;
  height: 8.77% !important;
  flex-shrink: 0 !important;
  background: transparent !important;
  z-index: 10 !important;
}

.ratings-modal-header > div {
  position: absolute !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  font-weight: 700 !important;
  font-size: 22px !important;  /* Оптимизирован под новый размер */
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif !important;
}

#ratingsModalClose {
  background: transparent !important;
  border: none !important;
  font-size: 20px !important;  /* Оптимизирован под новый размер */
  cursor: pointer !important;
}

#ratingsModalBody {
  padding: 12px !important;  /* Оптимизирован под новый размер */
  overflow: auto !important;
  font-size: 12px !important;  /* Оптимизирован под новый размер */
  flex: 1 !important;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif !important;
}

/* --- RATING PERIOD BUTTONS (оптимизированы под новый размер) --- */

.rating-period-btn {
  padding: 8px 16px !important;
  border: none !important;
  background: transparent !important;
  cursor: pointer !important;
  font-size: 20px !important;
  color: #C9811B !important;
  transition: all 0.2s !important;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif !important;
}

.rating-period-btn:hover {
  opacity: 0.7 !important;
}

.rating-period-btn.active {
  background: transparent !important;
  color: #C9811B !important;
  font-weight: bold !important;
  text-decoration: underline !important;
}

/* --- PROFILE MODAL --- */

.profile-modal-box {
  position: relative !important;
  background-image: url('assets/modal.png') !important;
  background-size: 100% 100% !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
  width: 314px !important;
  max-width: 314px !important;
  height: 570px !important;
  max-height: 570px !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.profile-modal-header {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  padding: 10px 12px !important;
  border-bottom: none !important;
  height: 8.77% !important;
  flex-shrink: 0 !important;
  background: transparent !important;
  z-index: 10 !important;
}

.profile-modal-header > div {
  position: absolute !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  font-weight: 700 !important;
  font-size: 22px !important;
  font-family: 'MolliWrites-Script', 'Noto Sans', sans-serif !important;
}

