/*
 * Phone fixes for every page (owner, 2026-11-28: "проверить весь сайт на работу в мобильной версии ...
 * чтобы все страницы были читаемые, информация не залазила и не вылазила за рамки").
 * Loaded last on every page and unlayered, so an equal selector here beats app.css (legacy layer),
 * frame.css and pages.css. Every rule sits inside a phone media query: the desktop look is untouched.
 * Found by a 360 px audit of all sitemap pages (tools\pw\mobaudit2.js).
 */

@media (max-width: 760px) {
  /* A grid track sized by its widest child (a wide table, a nowrap row) pushed whole articles and the
     VIP card past the screen edge: the column may shrink, wide content scrolls inside its own box. */
  .is-legacy .page-shell .news-layout,
  .is-legacy .page-shell .wiki-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .is-legacy .page-shell .news-layout > *,
  .is-legacy .page-shell .wiki-layout > *,
  .is-legacy .page-shell .rsp > *,
  .is-legacy .page-shell .rsp__main > *,
  .is-legacy .page-shell .vipx-hero > *,
  .is-legacy .page-shell :is(.epic-shop-page, .chaos-page, .referral-page, .ref-x, .ref-x-kit, .ref-x-card, .chaos-panel) > * {
    min-width: 0;
  }
  /* Epic Shop, Chaos Machine, Referral: the page grid took the width of its widest child (390, 384,
     673 px on a 360 px phone). */
  .is-legacy .page-shell :is(.epic-shop-page, .chaos-page, .referral-page, .ref-x, .ref-x-kit, .ref-x-card, .chaos-panel) {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Table cells broke words in the middle ("Cas/tle/Gat/e", "Experien/ce"): words stay whole, and a
     table that is then wider than the phone scrolls sideways inside its box. */
  /* (!important: pages.css sets overflow-wrap: anywhere on several tables with long selectors, on purpose
     for the desktop column; on a phone it cut every word into syllables) */
  .is-legacy .page-shell td,
  .is-legacy .page-shell th,
  .is-legacy .page-shell .wiki-copy__cell {
    overflow-wrap: normal !important;
    word-break: normal !important;
  }
  /* The wiki tables were made to fold into the column; on a phone they scroll inside their box instead. */
  .is-legacy .page-shell .rsp--article .wiki-copy__table-scroll {
    overflow-x: auto;
  }
  .is-legacy .page-shell .wiki-copy__table th,
  .is-legacy .page-shell .wiki-copy__table td {
    min-width: 64px;
  }

  /* Referral "where they come from": the site's 620 px table floor (made for scroll boxes) stretched the
     card off the screen; this two-column table fits, and a long link breaks anywhere. */
  .is-legacy .page-shell .ref-x-card .ref-x-table {
    width: 100%;
    min-width: 0;
  }
  .is-legacy .page-shell .ref-x-card .ref-x-table td:first-child {
    overflow-wrap: anywhere !important;
  }

  /* A table box that scrolls sideways fades out at its right edge until it is scrolled to the end,
     so the hidden columns are seen to be there (scroll-driven: only when the box really scrolls). */
  @supports (animation-timeline: scroll()) {
    .is-legacy .page-shell .table-wrap,
    .is-legacy .page-shell .wiki-copy__table-scroll,
    .is-legacy .page-shell .reset-table__scroll,
    .is-legacy .page-shell .rsp-table {
      animation: epm-scroll-hint linear both;
      animation-timeline: scroll(self inline);
    }
  }
}

@keyframes epm-scroll-hint {
  0%, 92% {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), rgba(0, 0, 0, .15));
    mask-image: linear-gradient(to right, #000 calc(100% - 36px), rgba(0, 0, 0, .15));
  }
  100% {
    -webkit-mask-image: none;
    mask-image: none;
  }
}

@media (max-width: 640px) {
  /* Alice's "I'm Alice. How can I help?" line lay over the page text on every page; her portrait and
     the support button stay. The page ends above the fixed buttons, so they never cover a form button. */
  .alice-widget__bubble {
    display: none !important;
  }
  body {
    padding-bottom: 76px;
  }

  /* Rankings: the section tabs' titles were cut ("ПЕРСОНА", "ABYSSAL S"). */
  .is-legacy .page-shell .ranking-tab--art strong {
    inset: auto 2px 8px;
    font-size: 12px;
    letter-spacing: 0;
    white-space: normal;
    line-height: 1.1;
    overflow-wrap: normal;
  }
  .is-legacy .page-shell .rank-range-button,
  .is-legacy .page-shell .class-button {
    font-size: 11px;
  }

  /* Terms / refund policy: "ПОЛИТИКА КОНФИДЕНЦИАЛЬНОСТИ" did not fit its tab. */
  .is-legacy .page-shell .legal-tabs {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Market and account menus: the tabs sit in an even grid instead of a cut row ("Мои предм...") or a
     ragged stack (the account menu). */
  .is-legacy .page-shell .market-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    overflow: visible;
  }
  .is-legacy .page-shell .market-tabs .market-tab {
    justify-content: center;
    min-width: 0;
    text-align: center;
  }
  .is-legacy .page-shell .market-opt {
    font-size: 11px;
  }

  /* VIP: the period switch (30 / 15 / 7 days) wraps instead of cutting "7 дней". */
  .is-legacy .page-shell .vipx-hero {
    grid-template-columns: minmax(0, 1fr);
  }
  .is-legacy .page-shell .vipx-periods {
    grid-auto-flow: row;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-radius: 14px;
  }
  .is-legacy .page-shell .vipx-period {
    flex-wrap: wrap;
    padding: 6px 2px;
    white-space: normal;
  }
  .is-legacy .page-shell .vipx-period em {
    font-size: 11px;
  }
  .is-legacy .page-shell .vipx-hero__kicker {
    white-space: normal;
  }

  /* Quests, guilds: the number tiles ran out of their frames ("ЭЛИТНЫХ МОНСТРОВ", "11 / 517 / 570 / 000"):
     one tile per row. */
  .is-legacy .page-shell .quests-totals {
    grid-template-columns: minmax(0, 1fr);
  }

  /* The intro with an NPC picture beside it squeezed the text into a 120 px column
     (Chaos Mixes, Jewel of Harmony): picture above, text full width. */
  /* (the class repeated: pages.css styles the Chaos Mixes intro with a longer selector) */
  .is-legacy .page-shell .daily-lead.has-npc.has-npc.has-npc.has-npc {
    grid-template-columns: minmax(0, 1fr);
  }
  .is-legacy .page-shell .daily-lead.has-npc > * {
    min-width: 0;
  }

  /* Guilds: the NPC cards side by side broke the coordinates ("Lorencia (146, / 111)"). */
  .is-legacy .page-shell .guild-npcs.guild-npcs.guild-npcs.guild-npcs {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Castle siege: the tax tiles broke "10,000,000 Zen", the step names ran into each other,
     the three-line button overran its plate. */
  .is-legacy .page-shell .siege-stats {
    grid-template-columns: minmax(0, 1fr);
  }
  .is-legacy .page-shell .siege-steps .siege-step strong {
    font-size: 10px;
    letter-spacing: -.01em;
  }
  .is-legacy .page-shell .siege-steps {
    column-gap: 6px;
  }
  .is-legacy .page-shell .siege-cta {
    height: auto;
    padding: 12px 34px;
    line-height: 1.25;
    text-align: center;
  }

  /* Forum: section titles broke mid-word ("Обновлени/я"): the title takes the whole row, the counters
     go under it. */
  .is-legacy .page-shell .forum-section,
  .is-legacy .page-shell .forum-topic:not(.has-thumb) {
    grid-template-columns: auto auto minmax(0, 1fr);
  }
  .is-legacy .page-shell .forum-section__main,
  .is-legacy .page-shell .forum-topic:not(.has-thumb) .forum-topic__main {
    grid-column: 1 / -1;
  }
  .is-legacy .page-shell .forum-section__main strong,
  .is-legacy .page-shell .forum-topic__main > a {
    overflow-wrap: normal;
  }
  .is-legacy .page-shell .forum-section__count {
    display: flex;
    gap: 4px;
    align-items: baseline;
  }

  /* Class pages: combo skill names broke mid-word ("Strike of Destructio/n"): three per row. */
  .is-legacy .page-shell .combo-step__skills {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .is-legacy .page-shell .combo-skill__name {
    overflow-wrap: normal;
  }

  /* The plate buttons: a label that wraps to two or three lines grows the plate instead of running over it
     ("Войдите, чтобы получить набор", the siege registration button). */
  .is-legacy .page-shell :is(.bank-transfer__button, .donate-card__go, .donate-pack__buy, .epic-wallet__topup,
      .pin-session__button, .siege-cta, .streamers-join__cta, .first-steps__button, .first-steps__get, .invite-cta,
      .referral-share button, .referral-take, .starter__button, .vipx-price__buy, .armory__button--gold, .bp-btn--gold,
      .epic-service__buy) {
    height: auto;
    padding-top: 9px;
    padding-bottom: 9px;
    line-height: 1.2;
    text-align: center;
  }

  /* Article pictures beside the text (Jewel of Harmony: Chaos Goblin, Jerridon) left the text a 180 px
     column: picture above, text full width. */
  .is-legacy .page-shell .rsp-howto {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }
  .is-legacy .page-shell .rsp-howto > * {
    justify-self: stretch;
  }
  .is-legacy .page-shell .rsp-howto > figure {
    justify-self: center;
  }

  /* VIP list: a long description beside its value was squeezed to 100 px; the value moves under it. */
  .is-legacy .page-shell .vipx-row {
    flex-wrap: wrap;
  }
  .is-legacy .page-shell .vipx-row__name {
    flex: 1 1 170px;
    min-width: 0;
  }
  .is-legacy .page-shell .vipx-row small {
    font-size: 11.5px;
  }

  /* Downloads: the Android button's two-line label stays centred. */
  .is-legacy .page-shell .download-button span {
    text-align: center;
  }

  /* Castle treasury jewel names were 10 px. */
  .is-legacy .page-shell .siege-vault__jewels .siege-vault__jewel span {
    font-size: 11px;
  }

  /* Chaos Machine: the site bank (12 cells wide, 28 px minimum) was wider than the phone; the cell
     shrinks with the screen (items are placed in percent, so they follow). */
  .is-legacy .page-shell .chaos-bank {
    --bank-cell: clamp(20px, calc((100vw - 76px) / 12), 34px);
  }

  /* Character market: class filter names were cut to "Dark Wi...". */
  .is-legacy .page-shell .cm-class-tabs button span {
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
    line-height: 1.15;
  }
  .is-legacy .page-shell .cm-class-tabs button {
    white-space: normal;
  }

  /* Battle Pass: the head and its two buttons were wider than the card, the tier tabs broke "26- / 50". */
  .is-legacy .page-shell .bp,
  .is-legacy .page-shell .bp-top,
  .is-legacy .page-shell .bp-top__actions {
    grid-template-columns: minmax(0, 1fr);
  }
  .is-legacy .page-shell :is(.bp, .bp-top, .bp-top__actions) > * {
    min-width: 0;
  }
  .is-legacy .page-shell .bp-top__actions {
    grid-auto-flow: row;
  }
  .is-legacy .page-shell .bp-top .bp-btn {
    width: 100%;
    white-space: normal;
  }
  .is-legacy .page-shell .bp-tab__copy small {
    white-space: nowrap;
  }

  /* Partner program: the progress pips and "9 / 10" ran out of the player card. */
  .is-legacy .page-shell .partner-card__main {
    min-width: 0;
  }
  .is-legacy .page-shell .partner-pips {
    flex-wrap: wrap;
  }

  /* Class pages: the skill formulas stood in a 100 px column of the stacked table. */
  .is-legacy .page-shell .class-reference__skills .ranking-table--plain td,
  .is-legacy .page-shell .class-reference__skills .ranking-table--plain td:first-child {
    width: auto !important;
  }

  /* First steps: "Download for Android / Google Play" did not fit a half-width button. */
  .is-legacy .page-shell .first-steps__platforms {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Invite page: the hero text kept its desktop 46 % width and stood in a 150 px column. */
  .is-legacy .page-shell .invite .invite-hero--art .invite-hero__body {
    max-width: none;
  }

  /* Labels too small to read on a phone (9-10 px). */
  .is-legacy .page-shell .event-tag,
  .is-legacy .page-shell .wings-class,
  .is-legacy .page-shell .quests-table__badge,
  .is-legacy .page-shell .ancient-set h4,
  .is-legacy .page-shell .character-profile__stat span,
  .is-legacy .page-shell .siege-vault__jewel span,
  .is-legacy .page-shell .soulw-tab,
  .is-legacy .page-shell .soulw-name {
    font-size: 11px;
  }

  /* Home and register: the top guild / character lists cut the role with "...". */
  .nn-lead__text small {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
}
