/* =========================================================
   ПОЛНАЯ МОБИЛЬНАЯ АДАПТАЦИЯ PRIfantasy (ТЕЛЕФОНЫ И ПЛАНШЕТЫ)
========================================================= */
html,
body {
  height: 100dvh;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

#site {
  height: 100dvh;
  max-width: 100vw;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Защита от выхода любого текста и картинок за пределы экрана */
img,
svg,
canvas {
  max-width: 100%;
}

p,
h1,
h2,
h3,
h4,
span,
div,
a,
button {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* =========================================================
   МОБИЛЬНЫЕ ЭКРАНЫ (ДО 768px)
========================================================= */
@media (max-width: 768px) {
  /* 1. Экран приветствия и логотипа */
  #introThemeSlot {
    top: calc(14px + env(safe-area-inset-top, 0px));
    right: 14px;
  }

  #helloWord {
    font-size: clamp(2.5rem, 12vw, 4.4rem);
    padding: 0 12px;
    text-align: center;
  }

  #skipBtn {
    right: 18px;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    min-height: 42px;
    padding: 0 20px;
  }

  #enterSiteBtn {
    bottom: calc(50% - 7.8rem);
    min-height: 46px;
    padding: 0 28px;
  }

  /* 2. Верхний баннер: чистая шапка без наложения кнопок на логотип */
  #banner {
    height: auto;
    min-height: 132px;
    max-height: none;
    padding: calc(56px + env(safe-area-inset-top, 0px)) 14px 16px;
  }

  #logo {
    font-size: clamp(1.85rem, 8.2vw, 2.5rem);
  }

  #logoSub {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }

  #fantasyWord {
    font-size: 0.66rem;
    letter-spacing: 0.2em;
  }

  /* 3. Карусель главных новостей */
  #featuredCarouselWrap {
    padding: 10px 8px 4px;
  }

  .carousel-stage {
    height: 148px;
  }

  .feat-card {
    width: min(340px, 86vw);
    height: 136px;
    padding: 13px 15px;
    border-radius: 18px;
  }

  .feat-title {
    font-size: 0.96rem;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
  }

  .feat-excerpt {
    font-size: 0.78rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  /* 4. Прилипающее горизонтальное меню разделов (свайп пальцем) */
  #mainDockWrap {
    top: 0;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px;
  }

  .main-dock {
    width: 100%;
    max-width: 100%;
    height: 44px;
    padding: 3px;
  }

  .main-dock-thumb {
    top: 3px;
    left: 3px;
    width: calc((100% - 6px) / 4);
    height: calc(100% - 6px);
  }

  .dock-btn {
    padding: 0 4px;
    font-size: 0.76rem;
    font-weight: 600;
  }

  .dock-btn svg {
    display: none;
  }

  /* 5. Нижняя рабочая область контента */
  #workspace {
    padding: 2px 10px calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .window-box {
    border-radius: 20px;
  }

  .dock-page {
    padding: 16px 14px;
    min-height: 360px;
  }

  .sec-title {
    font-size: 1.32rem;
    margin-bottom: 12px;
  }
}
/* =========================================================
   МОБИЛЬНЫЕ КАРТОЧКИ, МОДАЛКИ, ИГРА И ПРОФИЛЬ (ДО 768px)
========================================================= */
@media (max-width: 768px) {
  /* Единая верхняя панель в баннере: День/Ночь слева, Профиль справа — никогда не наезжают друг на друга */
  #bannerTopBar {
    position: absolute;
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: 12px;
    right: 12px;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  #bannerTopBar #bannerThemeSlot,
  #bannerTopBar #bannerAuthSlot {
    position: static !important;
    inset: auto !important;
    margin: 0 !important;
  }

  .user-profile-pill {
    max-width: 58vw;
    height: 34px !important;
    padding: 0 10px 0 4px !important;
    font-size: 0.74rem !important;
  }

  .user-profile-pill span:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* 6. Новости и посты сообщества: текст без обрезаний и выхода за рамки */
  .news-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .news-widget {
    min-height: auto;
    padding: 15px 16px;
  }

  .news-title {
    font-size: 1rem;
    -webkit-line-clamp: unset;
    line-clamp: unset;
  }

  .news-excerpt {
    font-size: 0.84rem;
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }

  /* 7. Проекты (PRI&SF / PRI / St.Fantastica) */
  .proj-top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .proj-switcher {
    width: 100%;
    height: 42px;
  }

  .proj-tab-btn {
    font-size: 0.74rem;
  }

  .proj-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .proj-widget {
    min-height: auto;
    padding: 16px;
  }

  /* 8. Разворачивание карточек (Новости и Проекты) на телефоне */
  .proj-overlay-layer {
    padding: 12px;
    align-items: center;
  }

  .proj-modal-card {
    max-width: 100%;
    max-height: 86dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 18px;
    border-radius: 20px;
  }

  .exp-title {
    font-size: 1.15rem !important;
    line-height: 1.3;
  }

  .exp-full-text {
    font-size: 0.9rem !important;
    line-height: 1.6;
  }

  /* 9. Вкладка «Работа» */
  .jobs-inline-stage {
    min-height: 360px;
    padding: 20px 14px;
    border-radius: 18px;
  }

  .jobs-main-title {
    font-size: 1.08rem;
    line-height: 1.35;
  }

  .jobs-switcher {
    width: 100%;
    max-width: 320px;
  }

  .jobs-info-box {
    padding: 20px 16px;
  }

  /* 10. Вкладка «Игра» (Крестики-нолики) */
  .game-arena {
    padding: 14px 10px 20px;
  }

  .game-menu-card,
  .ttt-card {
    padding: 18px 14px;
    border-radius: 20px;
    gap: 12px;
  }

  .ttt-board {
    width: min(276px, 76vw);
  }

  .ttt-glyph {
    font-size: 2.2rem;
  }

  .room-code-row,
  .room-join-row {
    flex-wrap: wrap;
  }

  .room-code-pill,
  .room-copy-btn,
  .room-join-input {
    width: 100%;
  }

  /* 11. Полноэкранный Профиль */
  #profileScreen {
    padding: calc(12px + env(safe-area-inset-top, 0px)) 10px calc(48px + env(safe-area-inset-bottom, 0px));
  }

  .prof-top-nav {
    margin-bottom: 12px;
    gap: 8px;
  }

  .prof-back-btn {
    height: 36px;
    padding: 0 13px;
    font-size: 0.78rem;
  }

  .prof-mode-pill {
    font-size: 0.66rem;
    padding: 4px 10px;
  }

  .prof-gear-btn {
    width: 36px;
    height: 36px;
  }

  .prof-master-frame {
    border-radius: 22px;
  }

  .prof-banner-cover {
    height: 138px;
  }

  .prof-master-body {
    padding: 16px 16px 24px;
    gap: 16px;
  }

  .prof-header-grid {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-top: -48px;
  }

  .prof-avatar-wrap {
    width: 82px;
    height: 82px;
    border-radius: 20px;
  }

  .prof-title-box {
    padding-top: 0;
  }

  .prof-nickname {
    font-size: 1.24rem;
  }

  .prof-posts-grid {
    grid-template-columns: 1fr;
  }

  .crop-modal-card {
    padding: 16px;
    border-radius: 20px;
  }

  .crop-stage-frame.mode-avatar {
    width: 210px;
    height: 210px;
  }
}
/* =========================================================
   ВЕРХНЯЯ ПАНЕЛЬ БАННЕРА В ПОТОКЕ (НИКОГДА НЕ ЗАГОРАЖИВАЕТ ЛОГОТИП)
========================================================= */
#banner {
  height: auto !important;
  min-height: 138px !important;
  max-height: none !important;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 20px 18px !important;
  justify-content: flex-start !important;
}

#bannerTopBar {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  width: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
  margin-bottom: 10px !important;
  z-index: 25 !important;
}

@media (max-width: 768px) {
  #banner {
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 16px !important;
  }

  #bannerTopBar {
    justify-content: space-between !important;
    margin-bottom: 12px !important;
  }
}
