/* Mobile-first layout for every player/admin panel surface. */
@media (max-width: 900px) {
  html:not([data-layout="desktop"]),
  html:not([data-layout="desktop"]) body { max-width:100%; overflow-x:clip; }
  html:not([data-layout="desktop"]) .player-hub,
  html:not([data-layout="desktop"]) #accountContent,
  html:not([data-layout="desktop"]) #accountContent .account-section,
  html:not([data-layout="desktop"]) #accountContent :is(.account-panel,.ucp-panel,.ucp-view,.shop-view,.admin-shop-workspace,.admin-shop-list-pane) { min-width:0; max-width:100%; box-sizing:border-box; }
  html:not([data-layout="desktop"]) #accountContent .account-section { width:100%; padding:0 10px 14px; }
  html:not([data-layout="desktop"]) #accountContent :is(.account-panel,.ucp-panel) { width:100%; padding:20px 14px; border-radius:10px; overflow:hidden; }

  /* Login and registration */
  html:not([data-layout="desktop"]) .account-panel { display:block; }
  html:not([data-layout="desktop"]) .account-heading { margin-bottom:22px; text-align:left; }
  html:not([data-layout="desktop"]) .account-heading h2 { font-size:clamp(25px,8vw,31px); overflow-wrap:anywhere; }
  html:not([data-layout="desktop"]) .auth-area,
  html:not([data-layout="desktop"]) .account-form,
  html:not([data-layout="desktop"]) .account-identity,
  html:not([data-layout="desktop"]) .account-passwords,
  html:not([data-layout="desktop"]) .login-form { display:grid; grid-template-columns:minmax(0,1fr); width:100%; min-width:0; }
  html:not([data-layout="desktop"]) .account-identity label:last-child,
  html:not([data-layout="desktop"]) .login-form :is(.account-submit,.account-status) { grid-column:1; }
  html:not([data-layout="desktop"]) :is(.account-form input,.account-form select,.account-submit) { box-sizing:border-box; width:100%; max-width:100%; min-height:48px; font-size:16px; }
  html:not([data-layout="desktop"]) .account-consent { display:grid!important; grid-template-columns:20px minmax(0,1fr); }
  html:not([data-layout="desktop"]) .captcha-slot { max-width:100%; overflow:hidden; }

  /* Account header and section tabs */
  html:not([data-layout="desktop"]) .ucp-header { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:14px; align-items:center; padding-bottom:17px; }
  html:not([data-layout="desktop"]) .ucp-header h2 { font-size:23px; overflow-wrap:anywhere; }
  html:not([data-layout="desktop"]) .ucp-logout { width:auto; min-width:72px; min-height:44px; padding:10px 14px; }
  html:not([data-layout="desktop"]) .ucp-tabs { display:flex; width:calc(100% + 28px); margin:14px -14px 20px; padding:0 14px 7px; gap:7px; overflow-x:auto; overflow-y:hidden; overscroll-behavior-inline:contain; scroll-snap-type:x proximity; scrollbar-width:thin; }
  html:not([data-layout="desktop"]) .ucp-tabs button { flex:0 0 auto; min-height:42px; padding:10px 12px; border:1px solid var(--xp-border); border-bottom-width:2px; border-radius:7px; white-space:nowrap; scroll-snap-align:start; }
  html:not([data-layout="desktop"]) .ucp-tabs button.active { background:hsl(var(--accent-h) 55% 45% / .15); }
  html:not([data-layout="desktop"]) .ucp-intro h3,
  html:not([data-layout="desktop"]) .shop-view h3 { font-size:clamp(21px,7vw,27px); overflow-wrap:anywhere; }
  html:not([data-layout="desktop"]) .ucp-intro p,
  html:not([data-layout="desktop"]) .shop-view p { font-size:13px; line-height:1.6; }
  html:not([data-layout="desktop"]) .character-intro,
  html:not([data-layout="desktop"]) .shop-heading,
  html:not([data-layout="desktop"]) .admin-shop-toolbar { display:grid; grid-template-columns:minmax(0,1fr); gap:14px; align-items:start; }
  html:not([data-layout="desktop"]) :is(.character-create-open,.admin-shop-toolbar button) { width:100%; min-height:46px; }

  /* Character cards */
  html:not([data-layout="desktop"]) .character-list { grid-template-columns:minmax(0,1fr); gap:12px; width:100%; }
  html:not([data-layout="desktop"]) .character-card { grid-template-columns:76px minmax(0,1fr) 32px; gap:11px; width:100%; min-height:0; padding:12px; overflow:visible; border-radius:8px; }
  html:not([data-layout="desktop"]) .character-portrait { width:76px; height:104px; object-fit:cover; object-position:top; }
  html:not([data-layout="desktop"]) .character-heading h4 { font-size:18px; white-space:normal; overflow-wrap:anywhere; }
  html:not([data-layout="desktop"]) .character-title { white-space:normal; }
  html:not([data-layout="desktop"]) .character-vital { grid-template-columns:minmax(58px,76px) minmax(0,1fr); }
  html:not([data-layout="desktop"]) .character-vital span { overflow:hidden; text-overflow:ellipsis; }
  html:not([data-layout="desktop"]) .character-counters { flex-wrap:wrap; }
  html:not([data-layout="desktop"]) .character-actions summary { width:32px; height:32px; }
  html:not([data-layout="desktop"]) .character-actions button { position:absolute; inset:38px 0 auto auto; width:min(180px,calc(100vw - 64px)); min-height:44px; padding:11px 12px; text-align:left; z-index:8; }

  /* Character creator */
  html:not([data-layout="desktop"]) .character-creator { width:100%; margin:18px 0; padding:12px; box-sizing:border-box; border-radius:8px; }
  html:not([data-layout="desktop"]) .character-creator>header { gap:10px; }
  html:not([data-layout="desktop"]) .creator-layout { grid-template-columns:minmax(0,1fr); gap:18px; }
  html:not([data-layout="desktop"]) .creator-preview { width:100%; min-height:340px; padding:12px; box-sizing:border-box; }
  html:not([data-layout="desktop"]) .creator-stage { height:250px; margin:0; }
  html:not([data-layout="desktop"]) .creator-character-portrait { width:min(230px,78vw); height:270px; }
  html:not([data-layout="desktop"]) .creator-armor-overlay { width:min(190px,65vw); }
  html:not([data-layout="desktop"]) .creator-controls,
  html:not([data-layout="desktop"]) .creator-controls fieldset { min-width:0; }
  html:not([data-layout="desktop"]) .creator-pair { grid-template-columns:minmax(0,1fr); gap:4px; }
  html:not([data-layout="desktop"]) :is(.creator-options,.creator-hairs,.creator-colors) { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  html:not([data-layout="desktop"]) .creator-races { grid-template-columns:repeat(2,minmax(0,1fr)); }
  html:not([data-layout="desktop"]) .creator-hairs { grid-template-columns:repeat(4,minmax(42px,1fr)); }
  html:not([data-layout="desktop"]) .creator-colors { display:flex; }
  html:not([data-layout="desktop"]) :is(.creator-options button,.creator-hairs button) { width:100%; min-width:0; min-height:44px; }
  html:not([data-layout="desktop"]) .creator-name input { min-height:48px; font-size:16px; }

  /* Store, coins and common search/pagination */
  html:not([data-layout="desktop"]) .shop-view { padding:8px 0 18px; }
  html:not([data-layout="desktop"]) :is(.shop-products,.item-shop-grid,.admin-shop-items,.admin-catalog-grid) { grid-template-columns:minmax(0,1fr); width:100%; min-width:0; }
  html:not([data-layout="desktop"]) .shop-product { grid-template-columns:38px minmax(0,1fr); width:100%; min-height:0; padding:15px; box-sizing:border-box; }
  html:not([data-layout="desktop"]) .shop-product button { width:100%; min-height:44px; }
  html:not([data-layout="desktop"]) .admin-catalog-search { display:grid; grid-template-columns:minmax(0,1fr); gap:8px; width:100%; }
  html:not([data-layout="desktop"]) .admin-catalog-search :is(input,button) { box-sizing:border-box; width:100%; min-width:0; min-height:46px; font-size:16px; }
  html:not([data-layout="desktop"]) .shop-category-nav { display:flex; gap:7px; max-width:100%; overflow-x:auto; padding-bottom:8px; }
  html:not([data-layout="desktop"]) .shop-category-nav button { flex:0 0 auto; min-height:42px; }
  html:not([data-layout="desktop"]) .item-shop-card { grid-template-columns:44px minmax(0,1fr); gap:10px; width:100%; padding:12px; box-sizing:border-box; }
  html:not([data-layout="desktop"]) .item-shop-card>:last-child { grid-column:1/-1; width:100%; }
  html:not([data-layout="desktop"]) .admin-item-actions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; }
  html:not([data-layout="desktop"]) .admin-item-actions button { width:100%; min-width:0; padding:9px 4px; overflow-wrap:anywhere; }
  html:not([data-layout="desktop"]) .shop-pagination { display:grid; grid-template-columns:minmax(0,1fr); gap:10px; align-items:center; width:100%; }
  html:not([data-layout="desktop"]) .shop-page-controls { display:flex; justify-content:center; flex-wrap:wrap; }
  html:not([data-layout="desktop"]) .shop-page-controls button { width:40px; min-width:40px; min-height:40px; }

  /* Admin categories and editors */
  html:not([data-layout="desktop"]) .admin-category-manager { max-width:100%; }
  html:not([data-layout="desktop"]) .admin-category-manager summary { line-height:1.5; }
  html:not([data-layout="desktop"]) .admin-category-manager summary small { display:block; margin-top:4px; }
  html:not([data-layout="desktop"]) .admin-category-manager form { grid-template-columns:minmax(0,1fr); padding:12px; }
  html:not([data-layout="desktop"]) .admin-category-manager form>* { grid-column:1; width:100%; }
  html:not([data-layout="desktop"]) :is(.admin-category-manager input,.admin-shop-form input,.admin-shop-form select,.admin-shop-form button) { box-sizing:border-box; width:100%; min-width:0; min-height:46px; font-size:16px; }
  html:not([data-layout="desktop"]) .admin-category-list { display:grid; grid-template-columns:minmax(0,1fr); }
  html:not([data-layout="desktop"]) .admin-category-chip { justify-content:space-between; max-width:100%; }
  html:not([data-layout="desktop"]) .admin-shop-editor:not([hidden]),
  html:not([data-layout="desktop"]) #adminPassEditor:not([hidden]) { position:fixed; z-index:3100; inset:0; width:100%; max-width:none; height:100dvh; max-height:none; padding:0; transform:none; border:0; border-radius:0; overflow:hidden; }
  html:not([data-layout="desktop"]) .admin-editor-header { padding:12px 14px; padding-top:max(12px,env(safe-area-inset-top)); }
  html:not([data-layout="desktop"]) .admin-editor-header button { flex:none; width:44px; height:44px; }
  html:not([data-layout="desktop"]) .admin-shop-editor>.admin-catalog-search { margin:10px 12px 0; width:auto; }
  html:not([data-layout="desktop"]) .admin-shop-editor>.admin-catalog-grid { margin:8px 12px 0; max-height:110px; }
  html:not([data-layout="desktop"]) .admin-shop-editor .admin-shop-form,
  html:not([data-layout="desktop"]) #adminPassEditor .admin-shop-form { display:grid; grid-template-columns:minmax(0,1fr); gap:11px; margin:10px 12px 12px; padding:12px; overflow-y:auto; overscroll-behavior:contain; }
  html:not([data-layout="desktop"]) .admin-shop-editor .admin-shop-form>* { grid-column:1!important; }
  html:not([data-layout="desktop"]) .admin-shop-editor .admin-existing-icon { display:grid; grid-template-columns:minmax(0,1fr); gap:7px; }
  html:not([data-layout="desktop"]) .admin-shop-editor .admin-enchant { display:flex; align-items:center; gap:10px; }
  html:not([data-layout="desktop"]) .admin-shop-editor .admin-enchant input { flex:none; width:20px; min-height:20px; }
  html:not([data-layout="desktop"]) .admin-shop-editor .admin-shop-form>button[type="submit"] { position:sticky; bottom:0; z-index:3; }
  html:not([data-layout="desktop"]) .admin-icon-picker { max-width:100%; overflow:auto; }
  html:not([data-layout="desktop"]) .admin-icon-grid { grid-template-columns:repeat(4,minmax(0,1fr)); }

  /* Reports */
  html:not([data-layout="desktop"]) .admin-report-toolbar { grid-template-columns:minmax(0,1fr); }
  html:not([data-layout="desktop"]) .admin-report-filters { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  html:not([data-layout="desktop"]) .admin-report-filters button { width:100%; min-width:0; min-height:44px; }
  html:not([data-layout="desktop"]) .admin-report-card { width:100%; padding:12px; box-sizing:border-box; }
  html:not([data-layout="desktop"]) .admin-report-card>div { align-items:flex-start; flex-wrap:wrap; }
  html:not([data-layout="desktop"]) .admin-report-detail:not([hidden]) { position:fixed; z-index:3200; inset:0; display:flex; flex-direction:column; width:100%; height:100dvh; max-height:none; padding:0 0 max(12px,env(safe-area-inset-bottom)); transform:none; border:0; overflow-y:auto; }
  html:not([data-layout="desktop"]) .admin-report-detail dl { grid-template-columns:minmax(0,1fr); margin:0 12px; }
  html:not([data-layout="desktop"]) .admin-report-detail dl div { grid-template-columns:78px minmax(0,1fr); }
  html:not([data-layout="desktop"]) .admin-report-description,
  html:not([data-layout="desktop"]) .admin-report-detail>label,
  html:not([data-layout="desktop"]) .admin-report-actions { margin-inline:12px; }
  html:not([data-layout="desktop"]) .admin-report-actions { display:grid; grid-template-columns:minmax(0,1fr); }
  html:not([data-layout="desktop"]) .admin-report-actions button { width:100%; min-height:46px; }

  /* Purchase dialogs */
  html:not([data-layout="desktop"]) .donation-modal { align-items:end; padding:0; }
  html:not([data-layout="desktop"]) .donation-dialog { width:100%; max-width:none; max-height:92dvh; padding:22px 16px max(18px,env(safe-area-inset-bottom)); border-width:1px 0 0; border-radius:16px 16px 0 0; box-sizing:border-box; }
  html:not([data-layout="desktop"]) .donation-summary { max-width:100%; box-sizing:border-box; }
  html:not([data-layout="desktop"]) .payment-method { width:100%; box-sizing:border-box; }
}

@media (max-width: 390px) {
  html:not([data-layout="desktop"]) #accountContent :is(.account-panel,.ucp-panel) { padding-inline:11px; }
  html:not([data-layout="desktop"]) .ucp-tabs { width:calc(100% + 22px); margin-inline:-11px; padding-inline:11px; }
  html:not([data-layout="desktop"]) .character-card { grid-template-columns:62px minmax(0,1fr) 30px; gap:8px; padding:10px; }
  html:not([data-layout="desktop"]) .character-portrait { width:62px; height:92px; }
  html:not([data-layout="desktop"]) .character-vital { grid-template-columns:58px minmax(0,1fr); gap:5px; }
  html:not([data-layout="desktop"]) .creator-hairs,
  html:not([data-layout="desktop"]) .admin-icon-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
  html:not([data-layout="desktop"]) .admin-item-actions { grid-template-columns:minmax(0,1fr); }
}
