:root {
  --responsive-content-width: 1200px;
  --responsive-admin-width: 1440px;
}

html,
body {
  width: 100%;
  min-width: 320px;
  overflow-x: hidden;
}

html.admin-document,
html.admin-document body {
  max-width: none;
  margin: 0;
}

body.h5-shell {
  margin-inline: auto;
}

body.admin-shell {
  max-width: none;
  width: 100%;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-attachment: scroll;
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

button,
input,
select,
textarea {
  max-width: 100%;
}

@media (max-width: 767px) {
  body.h5-shell {
    max-width: 480px;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .h5-shell .page {
    width: 100%;
    padding-bottom: calc(104px + env(safe-area-inset-bottom));
  }

  .h5-shell .staff-list {
    padding-bottom: 24px;
  }

  .h5-shell .staff-list > .staff-loading,
  .h5-shell .staff-list > .empty {
    grid-column: 1 / -1;
  }

  .h5-shell .product-list > .empty-game {
    grid-column: 1 / -1;
  }

  .h5-shell .staff-search {
    scroll-margin-top: env(safe-area-inset-top);
  }

  .h5-shell .btn,
  .h5-shell .hero-btn,
  .h5-shell .kf-btn,
  .h5-shell .sbtn,
  .h5-shell .order-btn,
  .h5-shell .coupon-use,
  .admin-shell .btn,
  .admin-shell .adm-tab {
    min-height: 44px;
  }

  .h5-shell input,
  .h5-shell select,
  .h5-shell textarea,
  .admin-shell input,
  .admin-shell select,
  .admin-shell textarea {
    font-size: 16px;
  }

  .h5-shell .mask,
  .h5-shell .modal-mask,
  .h5-shell .dialog-mask,
  .admin-shell .mask,
  .admin-shell .chat-drawer-mask {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .h5-shell .sheet,
  .h5-shell .modal-card,
  .h5-shell .dialog-card,
  .admin-shell .sheet {
    max-height: min(90vh, calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .h5-shell .tabbar,
  .admin-shell .adm-tabbar {
    width: 100%;
    max-width: 480px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .admin-shell .wrap {
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: 40px;
  }

  .admin-shell.has-tabbar {
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }

  .admin-shell .login {
    width: auto;
    margin: 20px 16px;
  }

  .admin-shell .chat-drawer {
    height: 100vh;
    height: 100dvh;
  }

  .admin-shell .chat-drawer .ch-input-bar {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
}

@media (min-width: 768px) {
  body.h5-shell {
    width: 100%;
    max-width: none;
    margin: 0;
    padding-top: env(safe-area-inset-top);
    box-shadow: none;
  }

  .h5-shell .page {
    width: 100%;
    max-width: 960px;
    margin-inline: auto;
    padding: 24px 28px 132px;
  }

  .h5-shell .games {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    padding-inline: 0;
  }

  .h5-shell .game-item {
    min-width: 0;
  }

  .h5-shell .product-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    padding-inline: 0;
  }

  .h5-shell .staff-search,
  .h5-shell .staff-tags,
  .h5-shell .staff-list {
    padding-inline: 0;
  }

  .h5-shell .staff-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .h5-shell .staff-card,
  .h5-shell .product-item {
    min-width: 0;
  }

  .h5-shell .tabbar {
    left: 50%;
    bottom: 16px;
    width: calc(100% - 48px);
    max-width: 960px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    transform: translateX(-50%);
  }

  .h5-shell .mine-user-card,
  .h5-shell .orders-wrap,
  .h5-shell .mine-menu-card {
    max-width: 880px;
    margin-inline: auto;
  }

  .admin-shell .wrap {
    width: 100%;
    max-width: var(--responsive-admin-width);
    margin-inline: auto;
    padding: 0 24px 40px;
  }

  .admin-shell .login {
    width: min(560px, calc(100% - 48px));
    margin: 36px auto;
  }

  .admin-shell .admin-menu-card {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 20px;
    padding-inline: 20px;
  }

  .admin-shell .list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 12px;
    padding-inline: 0;
  }

  .admin-shell .list > * {
    min-width: 0;
  }

  .admin-shell .list > .empty,
  .admin-shell .list > .loading {
    grid-column: 1 / -1;
  }

  .admin-shell .adm-tabbar {
    left: 50%;
    width: calc(100% - 48px);
    max-width: var(--responsive-admin-width);
    border: 1px solid var(--line);
    border-radius: 14px;
    transform: translateX(-50%);
  }

  .admin-shell .chat-drawer {
    max-width: 600px;
    height: 100vh;
    height: 100dvh;
  }
}

@media (min-width: 1024px) {
  body.h5-shell {
    padding-top: calc(68px + env(safe-area-inset-top));
  }

  .h5-shell .page {
    max-width: var(--responsive-content-width);
    padding: 32px 40px 80px;
  }

  .h5-shell .tabbar {
    top: env(safe-area-inset-top);
    bottom: auto;
    left: 0;
    width: 100%;
    max-width: none;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    transform: none;
    padding: 0;
  }

  .h5-shell .tabbar-tabs {
    width: 100%;
    max-width: var(--responsive-content-width);
    margin-inline: auto;
    justify-content: flex-start;
    gap: 12px;
    padding: 8px 40px;
  }

  .h5-shell .tab {
    flex: 0 0 auto;
    min-width: 116px;
    min-height: 50px;
    flex-direction: row;
    gap: 9px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
  }

  .h5-shell .tab.active {
    background: rgba(59, 108, 255, .14);
  }

  .h5-shell .games {
    gap: 16px;
  }

  .h5-shell .product-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }

  .h5-shell .staff-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }

  .h5-shell .staff-search {
    top: calc(68px + env(safe-area-inset-top));
  }

  .h5-shell .mask .sheet {
    max-width: min(760px, calc(100vw - 64px));
    border-radius: 20px;
  }

  .h5-shell .modal-card {
    max-width: min(760px, calc(100vw - 64px));
    max-height: calc(100dvh - 48px);
  }

  .h5-shell .staff-register-page {
    max-width: 820px;
    min-height: calc(100dvh - 68px);
  }

  .admin-shell.has-tabbar {
    padding-top: 64px;
    padding-bottom: 0;
  }

  .admin-shell .wrap {
    padding-inline: 32px;
  }

  .admin-shell .admin-menu-card {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-shell .adm-tabbar {
    top: env(safe-area-inset-top);
    bottom: auto;
    left: 50%;
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    transform: translateX(-50%);
    padding: 6px 20px;
  }

  .admin-shell .adm-tab {
    flex: 0 1 180px;
    flex-direction: row;
    gap: 9px;
    min-height: 48px;
    padding: 6px 12px;
    font-size: 13px;
  }

  .admin-shell .sheet {
    max-width: min(760px, calc(100vw - 64px)) !important;
    max-height: calc(100dvh - 48px);
  }

  .admin-shell .coupon-fab {
    right: max(24px, calc((100vw - var(--responsive-admin-width)) / 2 + 32px));
  }

  .admin-shell {
    background-attachment: fixed;
  }
}

@media (min-width: 1360px) {
  .h5-shell .staff-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .admin-shell .list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-height: 480px) and (orientation: landscape) {
  .h5-shell .page {
    padding-top: 12px;
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .h5-shell .hero {
    min-height: 0;
  }

  .h5-shell .tabbar-tabs {
    padding-top: 5px;
    padding-bottom: 5px;
  }

  .admin-shell .chat-drawer .ch-input-bar {
    padding-top: 6px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .h5-shell .tab:hover,
  .h5-shell .game-item:hover,
  .admin-shell .adm-tab:hover {
    filter: brightness(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
