@media (max-width: 800px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .app-shell,
  .main-column,
  .content-area {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .content-area {
    padding: 0 14px calc(92px + env(safe-area-inset-bottom));
  }

  .mobile-header {
    height: 56px;
    padding: 0 14px;
  }

  .mobile-header .brand {
    font-size: 15px;
  }

  .update-banner {
    min-height: 58px;
    gap: 9px;
    margin: 0 -14px;
    padding: 7px 14px;
  }

  .update-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
  }

  .update-copy strong {
    max-width: min(52vw, 220px);
    font-size: 11px;
  }

  .update-copy span {
    font-size: 10px;
  }

  .banner-action {
    padding: 6px 8px;
    font-size: 10px;
  }

  .featured-hero {
    min-height: 315px;
    margin: 12px 0 14px;
    border-radius: 13px;
    background-position: center;
  }

  .hero-shade {
    background: linear-gradient(90deg, rgba(12, 20, 49, .88), rgba(22, 26, 65, .48) 70%, rgba(19, 25, 53, .14)), linear-gradient(0deg, rgba(12, 20, 49, .55), transparent 70%);
  }

  .hero-content {
    max-width: 100%;
    padding: 27px 19px 44px;
  }

  .hero-kicker {
    font-size: 9px;
  }

  .hero-content h1 {
    margin: 9px 0 7px;
    font-size: 27px;
    line-height: 1.25;
  }

  .hero-content p {
    display: -webkit-box;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.65;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  .hero-stats {
    flex-wrap: wrap;
    gap: 7px 12px;
    margin: 12px 0 15px;
    font-size: 10px;
  }

  .hero-button {
    min-height: 40px;
    padding: 9px 13px;
    font-size: 11px;
  }

  .hero-dots {
    right: 15px;
    bottom: 17px;
  }

  .promo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 21px;
  }

  .promo-card {
    min-width: 0;
    min-height: 64px;
    gap: 7px;
    padding: 9px;
    border-radius: 9px;
  }

  .promo-icon {
    width: 29px;
    height: 29px;
    flex: 0 0 29px;
    font-size: 16px;
  }

  .promo-card strong {
    font-size: 10px;
  }

  .promo-card small,
  .promo-card > svg {
    display: none;
  }

  .section-heading {
    margin-bottom: 11px;
  }

  .section-heading h2,
  .page-header h1 {
    font-size: 23px;
  }

  .section-heading p,
  .page-header p {
    font-size: 11px;
    line-height: 1.55;
  }

  .search-box {
    min-height: 42px;
    margin-top: 10px;
  }

  .rank-tabs {
    gap: 17px;
    margin-right: -14px;
    padding-right: 14px;
    scrollbar-width: none;
  }

  .rank-tabs::-webkit-scrollbar,
  .creator-type-tabs::-webkit-scrollbar,
  .saas-sidebar-v2 nav::-webkit-scrollbar {
    display: none;
  }

  .rank-tab,
  .sub-tab {
    min-height: 42px;
    font-size: 12px;
  }

  .sub-tabs {
    gap: 14px;
    margin-bottom: 9px;
  }

  .sub-tabs span {
    font-size: 10px;
  }

  .work-grid,
  .shelf-panel .work-grid,
  .editor-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
  }

  .work-card {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    min-height: 132px;
    border-radius: 10px;
  }

  .cover-art,
  .work-card.compact .cover-art {
    grid-row: 1;
    grid-column: 1;
    width: 96px;
    height: 100%;
    min-height: 132px;
    padding: 8px;
  }

  .cover-label {
    max-width: 80px;
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .work-card-body {
    grid-row: 1;
    grid-column: 2;
    min-width: 0;
    padding: 10px 11px;
  }

  .work-meta {
    flex-wrap: wrap;
    gap: 2px 8px;
    font-size: 9px;
  }

  .work-card h3 {
    display: -webkit-box;
    overflow: hidden;
    margin: 5px 0 3px;
    font-size: 13px;
    line-height: 1.4;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .work-card p {
    min-height: 0;
    font-size: 10px;
    line-height: 1.5;
    -webkit-line-clamp: 2;
  }

  .text-action {
    margin-top: auto;
    padding-top: 5px;
    font-size: 10px;
  }

  .page-header {
    padding: 22px 0 15px;
  }

  .page-header .primary-button,
  .page-header .secondary-button {
    min-height: 40px;
    margin-top: 11px;
  }

  .feed-card,
  .social-post,
  .post-composer,
  .form-section,
  .settings-card,
  .model-panel,
  .coin-panel,
  .side-panel,
  .shelf-panel,
  .saas-panel {
    border-radius: 10px;
  }

  .feed-card,
  .settings-card,
  .model-panel,
  .coin-panel,
  .side-panel,
  .shelf-panel {
    padding: 14px;
  }

  .community-v2-layout,
  .creator-center-v2,
  .profile-v2-grid,
  .recharge-v2,
  .community-layout,
  .creator-layout,
  .settings-layout,
  .recharge-layout,
  .game-layout {
    display: block;
    min-width: 0;
  }

  .social-post-body {
    overflow-wrap: anywhere;
  }

  .post-image {
    max-height: 62vh;
    border-radius: 8px;
  }

  .social-post-actions {
    gap: 13px;
  }

  .creator-type-tabs {
    gap: 4px;
    margin: 0 -2px 12px;
    padding: 4px;
  }

  .creator-type-tabs button {
    min-width: 0;
    min-height: 42px;
    padding: 8px 5px;
    font-size: 11px;
  }

  .creator-form,
  .saas-form {
    min-width: 0;
  }

  .creator-form input,
  .creator-form textarea,
  .creator-form select,
  .auth-form-wrap input,
  .auth-standalone-card input,
  .saas-form input,
  .saas-form textarea,
  .saas-select,
  .search-box input,
  .custom-recharge-input input,
  .turn-form textarea {
    font-size: 16px;
  }

  .creator-form input,
  .creator-form select,
  .auth-form-wrap input,
  .auth-standalone-card input {
    min-height: 44px;
  }

  .creator-form textarea,
  .turn-form textarea {
    min-height: 100px;
  }

  .creator-form-actions,
  .payment-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .creator-form-actions button,
  .payment-actions button {
    width: 100%;
    min-height: 46px;
    min-width: 0;
    padding: 9px 7px;
  }

  .profile-hero,
  .creator-public-hero {
    min-height: 190px;
    border-radius: 11px;
  }

  .profile-hero-content,
  .creator-public-info {
    gap: 11px;
    padding: 26px 16px;
  }

  .profile-main-avatar,
  .creator-public-info img {
    width: 58px;
    height: 58px;
    flex: 0 0 58px;
  }

  .profile-hero-content h2,
  .creator-public-info h1 {
    overflow-wrap: anywhere;
    font-size: 19px;
  }

  .recharge-v2 .model-panel,
  .profile-balance-card,
  .recharge-v2 > .recharge-entitlements {
    margin: 0 0 12px;
  }

  .coin-packages {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .coin-package {
    min-width: 0;
    min-height: 112px;
    padding: 12px 7px;
  }

  .payment-actions {
    position: sticky;
    bottom: calc(70px + env(safe-area-inset-bottom));
    z-index: 9;
    padding: 8px 0;
    background: linear-gradient(transparent, var(--bg) 25%);
  }

  .custom-recharge-input button {
    min-height: 42px;
    font-size: 13px;
  }

  .game-page {
    padding: 14px 0;
  }

  .game-top {
    gap: 8px;
    margin-bottom: 12px;
  }

  .game-intro {
    padding: 14px 0;
  }

  .game-intro h1 {
    font-size: 27px;
    line-height: 1.25;
  }

  .story-panel {
    min-height: 180px;
    padding: 14px;
    border-radius: 10px;
  }

  .turn-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .turn-form button {
    width: 100%;
    min-height: 46px;
    margin: 0;
  }

  .choices {
    gap: 7px;
  }

  .choice {
    min-height: 40px;
    border-radius: 8px;
  }

  .saas-sidebar-v2 nav {
    gap: 5px;
    margin: 0 -14px;
    padding: 0 14px 5px;
    scrollbar-width: none;
  }

  .saas-sidebar-v2 nav button {
    min-height: 40px;
    padding: 9px 11px;
  }

  .saas-main-v2 {
    padding: 18px 12px calc(90px + env(safe-area-inset-bottom));
  }

  .saas-topbar h1 {
    font-size: 24px;
  }

  .saas-top-actions {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .saas-panel {
    padding: 14px;
  }

  .saas-metrics,
  .finance-grid-v2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .saas-metrics article,
  .finance-grid-v2 article {
    min-width: 0;
    padding: 12px;
  }

  .saas-metrics strong {
    overflow-wrap: anywhere;
    font-size: 21px;
  }

  .finance-grid-v2 article div {
    align-items: flex-start;
    gap: 8px;
    font-size: 10px;
  }

  .finance-grid-v2 article b {
    text-align: right;
  }

  .saas-table-wrap {
    width: 100%;
    max-width: 100%;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .saas-table {
    min-width: 680px;
  }

  .saas-form-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .saas-top-actions .saas-secondary,
  .saas-secondary,
  .saas-primary,
  .primary-button,
  .secondary-button {
    min-height: 40px;
  }

  .mobile-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    height: calc(62px + env(safe-area-inset-bottom));
    padding: 4px 5px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid #e6e8ef;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 -5px 18px rgba(34, 43, 70, .08);
    backdrop-filter: blur(16px);
  }

  .mobile-bottom-nav a {
    min-width: 0;
    min-height: 48px;
    gap: 2px;
    font-size: 10px;
  }

  .mobile-bottom-nav a.active {
    color: #6254df;
  }

  .mobile-bottom-nav a.mobile-create-primary {
    position: relative;
    z-index: 1;
    color: #777f92;
  }

  .mobile-bottom-nav a.mobile-create-primary svg {
    box-sizing: content-box;
    width: 22px;
    height: 22px;
    margin-top: -23px;
    padding: 11px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #6f55ee;
    color: #fff;
    filter: drop-shadow(0 4px 7px rgba(87, 67, 208, .27));
  }

  .mobile-bottom-nav a.mobile-create-primary span {
    margin-top: -1px;
  }
}

@media (max-width: 380px) {
  .content-area {
    padding-right: 11px;
    padding-left: 11px;
  }

  .update-banner {
    margin-right: -11px;
    margin-left: -11px;
    padding-right: 11px;
    padding-left: 11px;
  }

  .work-card {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .cover-art,
  .work-card.compact .cover-art {
    width: 84px;
  }

  .mobile-create-primary svg {
    padding: 9px !important;
  }
}

/* Touch friendly controls: keep selection states rounded and remove the
   browser's square tap/focus treatment on compact screens. */
@media (max-width: 800px) {
  button,
  a,
  select,
  input[type="button"],
  input[type="submit"] {
    -webkit-tap-highlight-color: transparent;
  }

  button,
  input[type="button"],
  input[type="submit"] {
    transition: background-color .16s ease, border-color .16s ease,
      box-shadow .16s ease, color .16s ease, transform .12s ease;
  }

  button:not(:disabled):active,
  input[type="button"]:not(:disabled):active,
  input[type="submit"]:not(:disabled):active {
    transform: translateY(1px) scale(.985);
  }

  /* The bottom bar is a navigation control, not a filled rectangular tab. */
  .mobile-bottom-nav a,
  .mobile-bottom-nav a.active {
    margin: 4px 2px;
    border-radius: 16px;
    background: transparent !important;
    box-shadow: none !important;
  }

  .mobile-bottom-nav a.active {
    color: #5862d7;
    font-weight: 750;
  }

  .mobile-bottom-nav a:not(.mobile-create-primary):active {
    background: #f0f1ff !important;
  }

  .mobile-bottom-nav a.mobile-create-primary:active svg {
    transform: scale(.94);
  }

  /* Model and tab selections use a soft pill/card treatment instead of
     native square focus backgrounds. */
  .k1-engine-grid button,
  .model-row,
  .coin-package,
  .k1-shelf-tabs button,
  .rank-tab,
  .sub-tab,
  .creator-type-tabs button,
  .choice,
  .k1-dressup-tabs button,
  .k1-dressup-card-foot button {
    border-radius: 13px;
  }

  .k1-engine-grid button:focus,
  .model-row:focus,
  .coin-package:focus,
  .k1-shelf-tabs button:focus,
  .rank-tab:focus,
  .sub-tab:focus,
  .creator-type-tabs button:focus,
  .choice:focus,
  .k1-dressup-tabs button:focus {
    outline: none;
  }

  .k1-engine-grid button:focus-visible,
  .model-row:focus-visible,
  .coin-package:focus-visible,
  .k1-shelf-tabs button:focus-visible,
  .rank-tab:focus-visible,
  .sub-tab:focus-visible,
  .creator-type-tabs button:focus-visible,
  .choice:focus-visible,
  .k1-dressup-tabs button:focus-visible {
    outline: 2px solid rgba(98, 108, 219, .72);
    outline-offset: 2px;
  }

  .k1-engine-grid button.selected,
  .model-row.selected,
  .coin-package.selected,
  .k1-shelf-tabs button.selected {
    border-radius: 13px;
    box-shadow: 0 3px 12px rgba(98, 108, 219, .12);
  }

  /* Reset the native rectangular focus flash across every mobile control.
     Keyboard users still get a soft, rounded focus-visible cue. */
  button:focus,
  a:focus,
  select:focus,
  input:focus,
  textarea:focus {
    outline: none;
  }

  button:focus-visible,
  a:focus-visible,
  select:focus-visible,
  input:focus-visible,
  textarea:focus-visible {
    outline: 2px solid rgba(98, 108, 219, .55);
    outline-offset: 2px;
    border-radius: 12px;
  }
}
