/* ==========================================
   RESET & BASE STYLES
   ========================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #111;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
}

/* ==========================================
   CONTAINERS & LAYERS
   ========================================== */

/* Main App Container (Req 9) */
#appContainer {  
  display: flex;
  flex-direction: column;
  width: 100vw;
  /* height: 100vh; */
  height: 100dvh;
  max-width: 100%;
  overflow: hidden;
}

/* Стили для экрана загрузки */
#app-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #221933c0; /* Цвет фона под тему вашей игры */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999; /* Чтобы перекрывать абсолютно всё */
  opacity: 1;
  transition: opacity 0.6s ease-in-out; /* Плавный фейдер (0.6 секунды) */
  pointer-events: none; /* Когда исчезнет, чтобы не мешал кликать */
}

/* Класс, который будет запускать исчезновение */
#app-loader.fade-out {
  opacity: 0;
}

.loader-content {
  text-align: center;
  color: #ffffff;
  font-family: sans-serif;
}

/* Простой красивый вращающийся кружок */
.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: #ffd700; /* Золотой цвет под ваши звездочки */
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* AD Screen (Req 10) */
#ADScreen {
  z-index: 50;
  width: 100%;
  max-height: 300px;
  background: #1a1a1a;
  border-bottom: 2px solid #333;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 14px;
  flex-shrink: 0;
}

/* Game Screen (Req 11) */
#gameScreen {
  position: relative;
  flex-grow: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Absolute Layers inside gameScreen (Req 8) */
.layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ==========================================
   LAYER 0: FIELD CANVAS
   ========================================== */
#layerField {
  z-index: 10;
}

#fieldCanvas {
  width: 100%;
  height: 100%;
  display: block;
}



/* ==========================================
   LAYER 1: USER INTERFACE (UI)
   ========================================== */
#layerUI {
  z-index: 50;
  pointer-events: none; /* Pass clicks to field */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

/* Enable pointer events for UI controls */
/* #layerUI * {
  pointer-events: auto;
} */

/* Верхняя панель: светлый полупрозрачный фон с легкой тенью */
/* Top Panel (Референс: плавающая панель с отступами и скруглением) */
#topPanel {
  width: calc(100% - 10px); /* Ширина экрана минус отступы по 20px слева и справа */
  margin-top: 5px;           /* Отступ сверху */
  height: 50px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  pointer-events: auto;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  border-radius: 20px;       /* Скругление краев самой панели */
}

/* Контейнер для кнопок слева в панели */
#topPanel > div {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Кнопки в верхней панели (бирюзовые таблетки) */
#topPanel button {
  background: #00cec9;
  color: #fff;
  border: none;
  padding: 8px 8px;
  cursor: pointer;
  border-radius: 12px; /* Скругление в стиле "pill" */
  font-size: 14px;
  font-weight: bold;
  font-family: inherit;
  transition: background 0.2s, transform 0.1s;
  box-shadow: 0 2px 6px rgba(0, 206, 201, 0.35);
}

#topPanel button:hover {
  background: #0bfffb;
}

#topPanel button:active {
  transform: scale(0.96);
}

/* Отдельный стиль для кнопки ← Back, когда она появляется */
#backBtn {
  background: #6c677d !important;
  box-shadow: 0 2px 6px rgba(108, 103, 125, 0.35) !important;
}

#backBtn:hover {
  background: #948dac !important;
}

/* Слой для основной UI-колонки (находится ПОД экстра-окнами) */
#layerUiColumn {
  z-index: 30;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

/* Central UI Column - 600px max width (Req 12) */
.uiColumn {
  
  width: calc(100% - 10px);
  max-width: 600px;
  /* height: calc(100% - 40px); */
  height: 100%;

  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.midPanel {
  flex-grow: 1;
  margin-top: 40px; /* Offset from top (Req 12) */
  pointer-events: none;
  position: relative;
}

/* Notification Logs Stack (Req 3) */
#logContainer {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 110px; /* Max 3 lines height */
  overflow: hidden;
  pointer-events: none;
}

.logItem {
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid #ffd700;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  animation: logSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes logSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================
   GAME LOGO (Поверх поля, под верхней панелью)
   ========================================== */
#gameLogo {
  position: absolute;
  top: 65px;          /* Высота верхней панели (50px) + отступ 5px */
  left: 10px;         /* Отступ 10px от левой границы окна */
  max-width: 180px;   /* Задайте желаемый размер логотипа (подберите под себя) */
  height: auto;
  object-fit: contain;
  z-index: 25;        /* Выше поля (10), но ниже попапов (20) и экстра-окон (40) */
  pointer-events: none; /* Чтобы клики сквозь логотип уходили на игровое поле */
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4)); /* Легкая тень для читаемости */
}















/* ==========================================
   BOTTOM GROUP (BotPanel + Footer Container)
   ========================================== */
#bottomGroup {
  width: 100%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(6px);
  border-radius: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  margin-top: 30px; /* Отступ сверху, чтобы освободить место для выступающих кнопок */
  margin-bottom: 5px;
  overflow: visible; /* Ключевое: разрешает элементам выходить за рамки блока */
  pointer-events: auto;
}

/* Панель с иконками кнопок */
.botPanel {
  height: 65px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: -27px; /* Выталкиваем панель вверх на половину высоты кнопки (54px / 2) */
}

.botPanel button {
  /* Постоянная видимая подложка */
  background: #154f59; 
  border: 1px solid #154f59;
  padding: 2px;
  cursor: pointer;
  border-radius: 14px; /* Красивое скругление подложки */
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
  /* transition: background 0.2s ease, transform 0.1s ease; */

  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2);
}

/* Эффект при наведении (подложка становится ярче) */
.botPanel button:hover {
  background: #258a9c; /* Более светлый и яркий оттенок при наведении */
  border-color: #258a9c;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2);
  transform: scale(1.05);
}

.botPanel button img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 12px;
}

.botPanel button:active {
  transform: scale(0.92);
}

/* Футер внутри общего светлого блока */
.footer {
  height: 38px;
  background: rgba(0, 0, 0, 0.04);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #ffffff;
}

.footer a {
  color: #ffffff;
  text-decoration: underline;
  font-weight: 600;
}






/* ==========================================
   LAYER 2: CELL POPUPS (Новый стиль)
   ========================================== */
#layerPopups {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 20;
  pointer-events: none;
}

.popupCard,
.claimPopupWrapper {
  pointer-events: none;
}

.popupBtn,
.claimInputBox {
  pointer-events: auto !important;
}
 
/* .popupCard * {
  pointer-events: auto !important;
} */

.popupCard {
  position: absolute; /* Делаем карточку позиционируемой */
  /* background: #190f39b0; */
  background: #2b401fc7;

  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 24px 20px 20px 20px;
  border-radius: 20px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  width: 320px;
  box-sizing: border-box;
  font-family: inherit;
  color: #fffadc;
  /* Убираем центрирование через transform по умолчанию, вычисляем JS-ом */
}

/* Шапка попапа */
.popupHeader {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 16px;
  font-weight: bold;
  color: #fffadc;
  margin-bottom: 12px;
}

.popupHeader span {
  font-size: 13px;
  color: #b0b695;
  font-weight: normal;
}

/* Разделительные линии */
.popupDivider {
  height: 2px;
  background: rgba(255, 255, 255, 0.25);
  width: 100%;
  margin: 10px 0;
}

/* Блок имени владельца */
.popupOwnerSection {
  text-align: center;
  padding: 8px 0;
}

.popupOwnerName {
  font-size: 26px;
  font-weight: 800;
  color: #ffe135;
  text-shadow: 0 0 10px rgba(255, 225, 53, 0.6), 0 0 20px rgba(255, 225, 53, 0.3);
  word-break: break-word;
  line-height: 1.2;
}

.popupOwnerBadge {
  font-size: 12px;
  color: #2ed573;
  margin-top: 4px;
  font-weight: 600;
}

.popupOwnerBadge.readonly {
  color: #d1cfde;
}

/* Блок описания */
.popupDescSection {
  text-align: center;
  font-size: 14px;
  color: #fffadc;
  padding: 10px 0;
  line-height: 1.4;
  min-height: 40px;
  word-break: break-word;
}

/* Нижняя панель: статус и сетка кнопок */
.popupFooterGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.popupStatusText {
  font-size: 13px;
  color: #f1f0f5;
  font-weight: 500;
}




/* Стилизация кнопок под дизайн */
.popupBtn {
  width: 100%;
  padding: 10px 0;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s ease, filter 0.2s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.popupBtn:active {
  transform: scale(0.96);
}

.popupBtn-close {
  background: #6c677d;
  color: #e0e0e0;
}

.popupBtn-clean {
  background: #00cec9;
  color: #fff;
}

.popupBtn-share {
  background: #ffd32a;
  color: #ac5504;
}

.popupBtn-close:hover {
  background: #948dac;
}
.popupBtn-clean:hover {
  background: #0bfffb;
}
.popupBtn-share:hover {
  background: #fbff2a;
}

/* ==========================================
   CLAIM CELL POPUP EXTENSIONS
   ========================================== */

/* Заголовки полей ввода внутри формы */
.claimFieldLabel {
  font-size: 13px;
  font-weight: 600;
  color: #f1f0f5;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.claimFieldLabel span {
  font-size: 11px;
  color: #d1cfde;
  font-weight: normal;
}



/* Светлые контейнеры под текстовые поля и textarea */
.claimInputBox {
  background: #fcf8e8; /* Кремовый/светло-желтоватый фон как на макете */
  color: #190f39;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: bold;
  border: none;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  font-family: inherit;
  resize: none;
  text-align: center;
  scrollbar-width: none;
}

.claimInputBox::placeholder {
  color: #b2bec3;
  font-weight: normal;
}

/* Предупреждающий текст перед подтверждением (на втором скриншоте) */
.claimWarningBox {
  text-align: center;
  font-size: 12px;
  color: #f1f0f5;
  font-weight: 500;
  line-height: 1.3;
  padding: 8px 4px;
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 12px;
}
/* ==========================================
   CLAIM CELL CONFIRMATION ANIMATION
   ========================================== */

/* Затеняем только кнопки главного блока формы (первый футер) */
.popupCard.confirm-active > .popupFooterGrid {
  opacity: 0.2;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* Отдельный блок подтверждения, выезжающий снизу */
.confirmSubBlock {
  margin-top: 12px;
  background: #190f39b0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 16px;
  border-radius: 16px;
  box-sizing: border-box;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  
  /* Начальное состояние для анимации (невидим и смещен вниз) */
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

/* Конечное состояние анимации при активации */
.confirmSubBlock.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Гарантируем, что кнопки внутри блока подтверждения всегда на 100% видимы и активны */
.confirmSubBlock .popupFooterGrid {
  opacity: 1 !important;
  pointer-events: auto !important;
}


/* ==========================================
   LAYER 3: EXTRA WINDOWS
   ========================================== */
#layerExtraWindows {
  z-index: 40;

  background: #190f39f1;

  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;

  /* font-size: 18px; */
  /* color: #eff0ee; */
}

.popupWindow {
  /* background: #190f39; */
  /* border: 1px solid rgba(255, 255, 255, 0.25); */
  border-radius: 20px;
  padding: 24px;
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  box-sizing: border-box;
  color: #fffadc;
  /* box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6); */
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

.subPage {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: calc(80vh - 48px);
}

.subPage h1 {
  font-size: 20px;
  font-weight: bold;
  color: #ffe135;
  margin-bottom: 14px;
  text-align: center;
  flex-shrink: 0;
}

.subPage .content {
  flex-grow: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.scroll-text {
  overflow-y: auto;
  padding-right: 6px;
  font-size: 18px;
  line-height: 1.5;
  color: #f1f0f5;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.3) transparent;
}

.scroll-text::-webkit-scrollbar {
  width: 6px;
}

.scroll-text::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.3);
  border-radius: 3px;
}

.social-btn {
  display: inline-block;
  background: #2a2a3e;
  color: #ffe135;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 16px;
  border-radius: 18px;
  text-decoration: none;
  font-weight: bold;
  transition: background 0.2s, border-color 0.2s;
}

.social-btn:hover {
  background: #3a3a52;
  border-color: #ffe135;
}

.links-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tshortshop-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* border-radius: 12px; */
  transition: box-shadow 0.2s ease;
}

.tshortshop-img:hover {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.8); 
}


/* ==========================================
   BUTTONS & UI CONTROLS
   ========================================== */
button {
  background: #2a2a32;
  color: #fff;
  border: 1px solid #444;
  padding: 6px 14px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  transition: background 0.2s, transform 0.1s;
}

button:hover {
  background: #3a3a46;
}

button:active {
  transform: scale(0.96);
}

#layerField {
  z-index: 10;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* #canvasHolder {
  width: 100%;
  height: 100%;
  touch-action: none;
}

#canvasHolder canvas {
  display: block;
  width: 100%;
  height: 100%;

  touch-action: none;
} */

#canvasHolder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

#canvasHolder canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover; /* Сохраняет пропорции холста, обрезая лишнее по краям, либо используйте contain */
  touch-action: none;
}


/* ==========================================
   SEARCH SYSTEM POPUP & RESULTS
   ========================================== */

/* Попап поиска по центру экрана */
.popupCard.searchPopupCentered {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #190f39b0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 24px 20px 20px 20px;
  border-radius: 20px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  width: 320px;
  box-sizing: border-box;
  font-family: inherit;
  color: #fff;
  z-index: 1000;
}

/* claimInputBox */
#searchInput {
  pointer-events: auto !important;
}
/* Список результатов (теперь располагается НАД полем ввода) */
.searchResultsList {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 210px;
  overflow-y: auto;
  margin-bottom: 14px;
  padding-right: 4px;
  scrollbar-width: none;
}
.searchResultItem {
  pointer-events: auto !important;
}

/* Карточка отдельного результата поиска */
.searchResultItem {
  background: rgba(252, 248, 232, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 8px 12px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.searchResultItem:hover {
  background: rgba(252, 248, 232, 0.22);
  border-color: #ffe135;
}

.searchResultInfo {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.searchResultOwner {
  font-weight: bold;
  color: #ffe135;
  font-size: 13px;
}

.searchResultCoords {
  font-size: 11px;
  color: #d1cfde;
}

/* ==========================================
   MINIMAP
   ========================================== */

.minimap-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  box-sizing: border-box;
  padding: 15px; /* Отступы от краев экрана мобильных и ПК */
}

.minimap-popup {
  background: #16161e;
  border: 1px solid #2a2a3c;
  border-radius: 24px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 1046px;
  max-height: 90vh; /* Строго не выше видимой области экрана */
  box-sizing: border-box;
}

.minimap-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  align-items: baseline;
  margin-bottom: 12px;
  color: #fff;
  font-family: sans-serif;
  flex-shrink: 0;
}

.minimap-header h3 {
  margin: 0;
  font-size: 18px;
}

.minimap-info {
  font-size: 12px;
  color: #8b8ba7;
}

.minimap-canvas-container {
  width: 100%;
  height: 450px;
  max-height: calc(90vh - 130px); /* Автоматический подгон под оставшееся место */
  position: relative;
  cursor: grab; /* Курсор руки для перетаскивания */
  border: 2px solid #2a2a3c;
  border-radius: 20px;
  overflow: auto; /* Скролл для 1000х1000 холста */
  background: #0d0d12;
  box-sizing: border-box;
  user-select: none;
}

.minimap-canvas-container:active {
  cursor: grabbing; /* Курсор сжатой руки при зажатии */
}

#minimapCanvas1000 {
  width: 1000px;
  height: 1000px;
  display: block;
}

.minimap-footer {
  margin-top: 16px;
  width: 100%;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

.close-btn {
  background: #e4b10a;
  color: white;
  border: none;
  padding: 10px 32px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  transition: background 0.2s;
}

.close-btn:hover {
  background: #ffc814;
}

/* Скрываем полосы прокрутки для Chrome, Safari и Opera */
.minimap-canvas-container {
  background: #538724; /* Под цвет фона карты */
}

/* Скрываем полосы прокрутки для Firefox */
.minimap-canvas-container {
  scrollbar-width: none;
}

