/* Phone-only controls are injected as progressive enhancements. */
.trade-trust-toggle,
.mobile-filter-backdrop,
.mobile-filter-heading,
.mobile-filter-actions {
  display: none;
}

@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    height: 100%;
    min-height: 0 !important;
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh !important;
    min-height: 0;
  }

  .site-header {
    z-index: 40;
    flex: 0 0 56px;
    height: 56px;
    min-height: 56px;
    gap: 6px;
    padding: 0 10px;
    background: #fffdf9;
    backdrop-filter: none;
  }

  .site-header .brand-home:is(.has-image-logo, .has-custom-logo) .brand-mark {
    width: auto;
    max-width: clamp(92px, 25vw, 106px);
    height: 32px;
  }

  .site-header .account-status {
    min-width: 0;
    gap: 2px;
  }

  .site-header .account-status .user-account {
    min-width: 0;
    gap: 4px;
    padding-left: 0;
  }

  .site-header .account-status .user-account strong {
    max-width: 52px;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .site-header .header-avatar {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
  }

  .site-header .notification-link {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .site-header .logout-button {
    padding-left: 6px;
    font-size: 12px;
    white-space: nowrap;
  }

  .board-shell {
    display: flex;
    width: 100%;
    min-height: 0;
    flex: 1 1 0;
    margin: 0;
    overflow: hidden;
  }

  .board-switcher {
    display: flex;
    height: 44px;
    min-height: 44px;
    flex: 0 0 44px;
    justify-content: flex-start;
    gap: 18px;
    margin: 0;
    padding: 0 10px;
    overflow-x: auto;
    overflow-y: hidden;
    border-bottom: 1px solid #e9e2d8;
    background: #fffdf9;
    scrollbar-width: none;
    touch-action: pan-x;
  }

  .board-switcher::-webkit-scrollbar,
  .trade-page-tabs::-webkit-scrollbar {
    display: none;
  }

  .board-switcher a {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    flex: 0 0 auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    color: #6f6978;
    background: transparent;
    box-shadow: none;
    font-size: 13px;
    white-space: nowrap;
  }

  .board-switcher a:hover,
  .board-switcher a.active {
    border: 0;
    color: #5a429f;
    background: transparent;
    box-shadow: inset 0 -3px #6852ba;
  }

  html.initial-board-tavern [data-board-link="tavern"],
  html.initial-board-lezi [data-board-link="lezi"],
  html.initial-board-game4399 [data-board-link="game4399"],
  html.initial-board-tools [data-board-link="tools"] {
    border: 0;
    color: #5a429f;
    background: transparent;
    box-shadow: inset 0 -3px #6852ba;
  }

  .board-feedback {
    flex: 0 0 auto;
    margin: 5px 10px 0;
    font-size: 11px;
  }

  .board-pane {
    position: relative;
    display: flex;
    min-height: 0;
    flex: 1 1 0;
    padding: 0 10px;
    overflow: hidden;
    isolation: isolate;
  }

  .board-heading {
    order: 0;
    display: flex;
    min-height: 0;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    padding: 5px 0 3px;
    border-bottom: 0;
  }

  .board-heading > div:first-child,
  .trade-page-heading > div:first-child {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .board-heading-actions,
  .board-heading .board-heading-actions {
    display: flex;
    width: 100%;
    gap: 6px;
    justify-content: flex-end;
    margin: 0;
    flex-wrap: nowrap;
  }

  .my-posts-link,
  .board-heading .publish-button,
  .trade-page-heading .publish-button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0 11px;
    border-radius: 7px;
    box-shadow: none;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
  }

  .trade-board-heading {
    display: none;
  }

  .trade-trust-note {
    position: absolute;
    top: 48px;
    right: 0;
    left: 0;
    z-index: 30;
    display: flex;
    min-height: 0;
    margin: 0;
    padding: 11px;
    border: 1px solid #d9d0ed;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(48, 38, 77, .18);
    font-size: 11px;
    line-height: 1.65;
  }

  .trade-trust-toggle {
    display: inline-flex;
    min-width: 62px;
    min-height: 44px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-left: auto;
    padding: 0 2px;
    border: 0;
    border-radius: 0;
    color: #62569b;
    background: transparent;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
  }

  .trade-trust-toggle:focus-visible {
    outline: 2px solid #806bd0;
    outline-offset: 2px;
  }

  .trade-trust-note .note-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
    border-radius: 6px;
    font-size: 12px;
  }

  .trade-trust-arrow {
    width: 7px;
    height: 7px;
    border-right: 2px solid #756a8e;
    border-bottom: 2px solid #756a8e;
    transform: translateY(-2px) rotate(45deg);
    transition: transform .16s ease;
  }

  .trade-trust-toggle[aria-expanded="true"] .trade-trust-arrow {
    transform: translateY(2px) rotate(225deg);
  }

  .trade-trust-note > div:last-child {
    min-width: 0;
  }

  .trade-trust-note strong {
    margin: 0 0 3px;
    font-size: 12px;
  }

  .trade-page-tabs {
    display: flex;
    height: 44px;
    min-height: 44px;
    flex: 0 0 44px;
    gap: 14px;
    margin: 0 -10px;
    padding: 0 10px;
    overflow-x: auto;
    overflow-y: hidden;
    border-bottom: 1px solid #e9e2d8;
    scrollbar-width: none;
    touch-action: pan-x;
  }

  .trade-page-tabs a {
    display: inline-flex;
    min-width: 0;
    min-height: 44px;
    flex: 0 0 auto;
    align-items: center;
    padding: 0;
    border: 0;
    border-radius: 0;
    color: #6f6978;
    background: transparent;
    font-size: 13px;
  }

  .trade-page-tabs a:hover,
  .trade-page-tabs a.active {
    border: 0;
    color: #5a429f;
    background: transparent;
    box-shadow: inset 0 -3px #6852ba;
  }

  .mobile-filter-backdrop {
    position: absolute;
    inset: 0;
    z-index: 17;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(35, 29, 54, .22);
    cursor: default;
  }

  .trade-page {
    position: relative;
    display: flex;
    min-height: 0;
    flex: 1 1 0;
    overflow: hidden;
    isolation: isolate;
  }

  .trade-page-heading {
    order: 0;
    display: flex;
    min-height: 0;
    flex: 0 0 auto;
    justify-content: flex-end;
    padding: 5px 0 3px;
  }

  .content-search-panel {
    order: 1;
    display: grid;
    min-height: 44px;
    flex: 0 0 44px;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
    margin: 3px 0 6px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .content-search-panel input {
    min-width: 0;
    min-height: 44px;
    padding: 8px 10px;
    border-color: #dcd5e4;
    border-radius: 8px;
    font-size: 16px;
  }

  .search-submit,
  .search-clear {
    min-width: 50px;
    min-height: 44px;
    padding: 0 9px;
    border-radius: 8px;
    font-size: 12px;
  }

  .tag-filter-bar,
  .trade-page .tag-filter-bar {
    order: 2;
    display: grid;
    min-height: 44px;
    flex: 0 0 44px;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 7px;
    margin: 0 0 6px;
  }

  .board-sort-control {
    display: block;
    width: 100%;
    min-width: 0;
    font-size: 0;
  }

  .board-sort-control select {
    width: 100%;
    max-width: none;
    min-height: 44px;
    padding: 7px 30px 7px 10px;
    border-radius: 8px;
    font-size: 16px;
  }

  .tag-filter-toggle {
    display: inline-flex;
    min-width: 92px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 9px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
  }

  .tag-filter-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 18;
    order: 3;
    display: block;
    max-height: min(410px, 58dvh);
    margin: 0;
    padding: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 10px 10px 0 0;
    background: #fff;
    box-shadow: 0 -12px 30px rgba(43, 34, 68, .18);
    scrollbar-gutter: stable;
  }

  .mobile-filter-heading,
  .mobile-filter-actions {
    position: sticky;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #fff;
  }

  .mobile-filter-heading {
    top: -12px;
    margin: -12px -12px 10px;
    padding: 11px 12px 9px;
    border-bottom: 1px solid #ece7f0;
  }

  .mobile-filter-heading strong {
    color: #4d475d;
    font-size: 14px;
  }

  .mobile-filter-close {
    min-width: 44px;
    min-height: 44px;
    border: 0;
    color: #665a92;
    background: transparent;
    font-size: 13px;
    font-weight: 800;
  }

  .mobile-filter-actions {
    bottom: -12px;
    margin: 10px -12px -12px;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
    border-top: 1px solid #ece7f0;
  }

  .tag-filter-panel > .clear-tags {
    display: none;
  }

  .mobile-filter-reset {
    min-height: 44px;
    margin: 0;
    padding: 0 8px;
    border: 0;
    color: #6d628f;
    background: transparent;
    font-size: 12px;
    font-weight: 800;
  }

  .mobile-filter-done {
    min-height: 44px;
    flex: 1 1 auto;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: #6852ba;
    font-size: 13px;
    font-weight: 800;
  }

  .tag-category-heading {
    align-items: baseline;
  }

  .tag-category-group > strong,
  .tag-category-heading > strong {
    font-size: 14px;
  }

  .tag-option {
    min-height: 44px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .board-results,
  .board-results.is-empty {
    order: 4;
    display: block;
    min-height: 0;
    flex: 1 1 0;
    padding: 0 0 max(8px, env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: auto;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    contain: layout paint;
  }

  .board-results.is-empty {
    overflow-y: hidden;
  }

  .board-refresh-status {
    position: static;
  }

  .post-grid,
  .tool-grid {
    margin: 0 -10px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .post-card,
  .post-card.with-image {
    padding: 15px 13px;
  }

  .post-top {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 10px;
  }

  .post-top-actions {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: end;
    align-items: center;
    gap: 0 12px;
  }

  .post-top-actions time {
    grid-column: 1 / -1;
    justify-self: end;
    max-width: 100%;
    font-size: 11px;
    line-height: 1.45;
    text-align: right;
    white-space: normal;
  }

  .post-top-actions .card-edit-link,
  .post-top-actions .card-archive-link {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1.3;
  }

  #detail-dialog .detail-header {
    align-items: center;
    gap: 8px;
  }

  #detail-dialog .detail-actions {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
  }

  #detail-dialog .detail-actions time {
    min-width: 0;
    flex: 0 1 auto;
    flex-basis: auto;
    text-align: right;
    white-space: nowrap;
  }

  #detail-dialog .detail-actions .owner-edit-link,
  #detail-dialog .detail-actions .owner-archive-link,
  #detail-dialog .detail-actions .report-link {
    display: inline-flex;
    min-height: 44px;
    flex: 0 0 auto;
    align-items: center;
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
  }

  #detail-dialog .comments-heading .content-interactions .detail-like,
  #detail-dialog .comments-heading .content-interactions .detail-like-count,
  #detail-dialog .comments-heading .content-interactions .share-link {
    min-height: 44px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
  }

  .post-summary h2 {
    margin: 9px 0 5px;
    font-size: 17px;
    line-height: 1.5;
    letter-spacing: 0;
  }

  .post-summary > p {
    font-size: 14px;
    line-height: 1.7;
    -webkit-line-clamp: 4;
  }

  .post-card footer {
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-top: 13px;
    padding-top: 9px;
  }

  .post-card footer > span:first-child {
    min-width: 0;
    gap: 7px;
  }

  .post-card-actions {
    min-width: 0;
    margin-left: auto;
    gap: 4px;
  }

  .card-like,
  .card-like-count,
  .card-replies,
  .card-share-link {
    min-width: 44px;
    min-height: 44px;
    padding: 5px 6px;
    font-size: 12px;
  }

  .board-pagination {
    order: 5;
    min-height: 40px;
    flex: 0 0 auto;
    margin: 0;
    padding: 4px 0 2px;
  }

  .board-pagination button {
    min-width: 44px;
    min-height: 44px;
  }

  .site-footer {
    display: none !important;
    height: 28px;
    min-height: 28px;
    flex: 0 0 28px;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0 10px;
    overflow: hidden;
    font-size: 10px;
    line-height: 1;
  }

  .site-footer-title {
    display: none;
  }

  .site-footer-copy {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .site-footer-title,
  .site-footer-copy {
    display: none;
  }

  .site-footer-open {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    border: 0;
    color: #665a92;
    background: transparent;
    font: 800 11px inherit;
  }

  .site-footer-dialog-shell {
    max-height: min(70dvh, 560px);
    padding: 24px 20px max(24px, env(safe-area-inset-bottom));
  }

  .site-footer-dialog-shell h2 {
    margin-right: 38px;
    font-size: 20px;
  }
}

/* Four primary boards are always a complete choice set.  At 320px the
   normal 18px gap clipped part of the last tab while hiding the scrollbar,
   making "Tools" look unavailable instead of horizontally reachable.  Keep
   the 44px touch height and only tighten the non-interactive spacing. */
@media (max-width: 360px) {
  .board-switcher {
    gap: 10px;
  }
}

@media (max-width: 380px) {
  .site-header .account-status .user-account strong {
    max-width: 42px;
  }

}

@media (max-width: 760px) and (max-height: 560px) {
  .site-header { height:48px; min-height:48px; flex-basis:48px; }
  .board-switcher { height:36px; min-height:36px; flex-basis:36px; }
  .board-switcher a { min-height:36px; }
  .trade-page-tabs { height:38px; min-height:38px; flex-basis:38px; }
  .trade-page-tabs a,.trade-trust-toggle { min-height:38px; }
  .content-search-panel { min-height:40px; flex-basis:40px; margin:2px 0 4px; }
  .content-search-panel input,.search-submit,.search-clear { min-height:40px; }
  .tag-filter-bar,.trade-page .tag-filter-bar { min-height:40px; flex-basis:40px; margin-bottom:4px; padding-right:164px; }
  .board-sort-control select,.tag-filter-toggle { min-height:40px; }
  [data-board-pane="tavern"] > .board-heading,.trade-page-heading { position:absolute; top:46px; right:0; z-index:6; width:158px; padding:0; }
  [data-board-pane="tavern"] > .board-heading { right:10px; }
  .my-posts-link,.board-heading .publish-button,.trade-page-heading .publish-button { min-height:40px; padding-inline:7px; font-size:11px; }
  .site-footer { display:flex; height:30px; min-height:30px; flex-basis:30px; }
  .board-pagination { min-height:44px; }
}
