/* Shared game UI scale. Keep the map's world-space labels and artwork independent. */
:root {
  --ui-font:12px;
  --ui-caption:11px;
  --ui-title:14px;
  --ui-control:28px;
  --companion-font:var(--ui-font);
  --companion-small:var(--ui-caption);
  --companion-control:var(--ui-control);
}

/* Explicit typography wins over older component-specific and inline sizes. */
:is(#mobilePanelDrawer,.modal-panel,.modal-box,.game-dialog,.cmd-menu,.obj-action-popup,.tutorial-card,.auth-panel,#adminPanel,.social-peek,.hud-disclosure,.map-toolbar,.mobile-map-hud,.map-control-bar,.sync-status),
:is(#mobilePanelDrawer,.modal-panel,.modal-box,.game-dialog,.cmd-menu,.obj-action-popup,.tutorial-card,.auth-panel,#adminPanel,.social-peek,.hud-disclosure,.map-toolbar,.mobile-map-hud,.map-control-bar,.sync-status) :is(p,span,small,b,strong,label,dt,dd,li,summary,button,input,textarea,select,td,th,output) {
  font-size:var(--ui-font)!important;
  line-height:1.45;
}
:is(#mobilePanelDrawer,.modal-panel,.modal-box,.game-dialog,.cmd-menu,.obj-action-popup,.tutorial-card,.auth-panel,#adminPanel) :is(h1,h2,h3,h4),
.target-detail-title,.item-detail-identity h3 {
  font-size:var(--ui-title)!important;
  line-height:1.4;
}
:is(.modal-panel,.modal-box,.game-dialog,.cmd-menu,.obj-action-popup,.tutorial-card,.auth-panel,#adminPanel) button {
  min-height:var(--ui-control);padding:4px 8px;border-radius:6px;
}
:is(#mobilePanelDrawer,.modal-panel,.modal-box,.game-dialog,.cmd-menu,.auth-panel,#adminPanel) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]),select,textarea) {
  box-sizing:border-box;min-height:var(--ui-control);padding:4px 8px;border-radius:6px;
}
:is(#mobilePanelDrawer,.modal-panel,.modal-box,.game-dialog,.auth-panel,#adminPanel) textarea {min-height:64px;max-height:240px;}
.game-dialog {padding:16px;border-radius:12px;}
.game-dialog-actions,.item-detail-actions {gap:6px;margin-top:12px;}
.item-detail-identity {gap:10px;}
.item-detail-art {width:44px;height:44px;}
.item-detail-actions button {min-height:var(--ui-control);}
.target-action-menu .target-action-mode {min-height:var(--ui-control);padding:4px 7px;}
.target-action-menu .target-action-row {padding:4px;gap:4px;}

/* Only the slim roster stays above the two independently scrolling columns. */
#mobilePanelDrawer.bottom-grid {width:420px;}
#mobilePanelDrawer .companion-panel-head {height:36px;padding:0 48px 0 12px;gap:8px;}
#mobilePanelDrawer .companion-panel-head h2 {margin-right:auto;}
#mobilePanelDrawer .companion-panel-head button {min-height:24px;padding:2px 6px;background:none;border:0;white-space:nowrap;}
#mobilePanelDrawer:not([data-mobile-active-panel=pet]) #openCreatePetBtn {display:none;}
#mobilePanelDrawer .mobile-panel-close {top:4px;right:8px;width:28px;height:28px;min-height:28px;padding:6px;}
#mobilePanelDrawer .companion-fixed {padding:6px 12px 8px;}
#mobilePanelDrawer #petList {margin:0 0 5px;}
#mobilePanelDrawer #petList .pet-group[data-group=alive] .pet-group-body {gap:6px;padding:1px 0 3px;scrollbar-width:thin;}
#mobilePanelDrawer #petList .pet-chip-wrap {flex-basis:50px;width:50px;}
#mobilePanelDrawer #petList .pet-chip {width:50px;min-height:50px;padding:2px;gap:0;border-radius:7px;}
#mobilePanelDrawer #petList .pet-chip .pixel-pet.tiny {width:26px;height:26px;}
#mobilePanelDrawer #petList .pet-group[data-group=alive] .pet-chip-wrap {flex-basis:40px;width:40px;}
#mobilePanelDrawer #petList .pet-group[data-group=alive] .pet-chip {width:40px;height:36px;min-height:36px;align-items:center;justify-content:center;}
#mobilePanelDrawer #petList .pet-group[data-group=alive] .pet-chip .pixel-pet.tiny {width:30px;height:30px;}
#mobilePanelDrawer #petList .pet-manage-btn {width:18px;height:20px;min-height:20px;padding:0;right:-1px;top:0;}
#mobilePanelDrawer #petList .pet-group[data-group=dead] .pet-group-body {max-height:54px;}
#mobilePanelDrawer .selected-companion {display:block;}
#mobilePanelDrawer .selected-companion .pet-title {display:flex;gap:4px;align-items:stretch;}
#mobilePanelDrawer .pet-title > div {min-width:0;}
#mobilePanelDrawer .pet-title h3 {line-height:24px;margin:0;gap:4px;}
#mobilePanelDrawer .pet-name-icon-btn {width:24px;height:24px;min-height:24px;padding:4px;}
#mobilePanelDrawer .pet-name-actions {gap:4px;}
#mobilePanelDrawer #petSummaryMeta {line-height:17px;margin:0;}
#mobilePanelDrawer .companion-title-meta {flex-direction:row;justify-content:space-between;gap:4px;line-height:17px;}
#mobilePanelDrawer #petPortrait:not(.hidden) {display:grid;place-items:center;min-height:0!important;}
#mobilePanelDrawer #petPortrait .pet-overview-art,#mobilePanelDrawer #petPortrait .pixel-pet.large {width:112px!important;height:112px!important;}
#mobilePanelDrawer .companion-columns {display:grid;grid-template-columns:164px minmax(0,1fr);flex:1;min-height:0;overflow:hidden;}
#mobilePanelDrawer .companion-primary,#mobilePanelDrawer .companion-secondary {min-width:0;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-gutter:auto;display:flex;flex-direction:column;gap:10px;padding:10px;}
#mobilePanelDrawer .companion-primary {border-right:1px solid var(--panel-line);}
#mobilePanelDrawer .companion-primary > * {flex-shrink:0;}
#mobilePanelDrawer .companion-primary .pet-care-actions {grid-template-columns:repeat(2,minmax(0,1fr));gap:4px;}
#mobilePanelDrawer #petCareActions .care-btn {padding:4px;gap:2px;white-space:nowrap;}
#mobilePanelDrawer .companion-primary .pet-care-actions button:last-child {grid-column:1/-1;}
#mobilePanelDrawer #companionEquipment:empty {display:none;}

/* Spend the recovered space on scrollable content rather than empty control padding. */
#mobilePanelDrawer .companion-scroll {padding:10px 12px;gap:10px;}
#mobilePanelDrawer > .social-panel,#mobilePanelDrawer > .log-panel {padding:10px 12px;gap:8px;}
#mobilePanelDrawer .pet-panel button:not(.pet-name-icon-btn):not(.inv-slot):not(.pet-chip):not(.pet-manage-btn):not(.pet-group-avatar-btn) {min-height:var(--ui-control);padding:4px 8px;border-radius:6px;}
#mobilePanelDrawer #petStatusOverview {gap:4px;}
#mobilePanelDrawer .companion-meter {gap:8px;}
#mobilePanelDrawer .pet-care-actions,#mobilePanelDrawer .companion-play-actions {gap:6px;}
#mobilePanelDrawer #survivalStats {padding-top:10px;gap:10px;}
#mobilePanelDrawer .inventory-row,#mobilePanelDrawer .equipment-row {gap:5px;}
#mobilePanelDrawer .inv-slots,#mobilePanelDrawer .equip-slots {gap:6px;}
#mobilePanelDrawer .inv-slot {height:42px;min-height:42px;padding:3px;border-radius:7px;}
#mobilePanelDrawer .equip-slot {height:54px;min-height:54px;padding:3px;gap:1px;border-radius:7px;}
#mobilePanelDrawer .inv-slot .inventory-art,#mobilePanelDrawer .inv-slot .equipment-asset,#mobilePanelDrawer .equip-slot .equipment-asset,#mobilePanelDrawer .equip-slot .equipment-icon {width:28px;height:28px;}
#mobilePanelDrawer .inv-qty {bottom:2px;right:2px;line-height:14px;}
#mobilePanelDrawer #commandActions {padding-top:10px;}
#mobilePanelDrawer .command-cost {margin:0 0 6px;}
#mobilePanelDrawer .command-grid {gap:6px;}
#mobilePanelDrawer #commandActions > .command-grid {grid-template-columns:repeat(4,minmax(0,1fr));}
#mobilePanelDrawer .command-status {margin-top:6px;text-align:left;}
#mobilePanelDrawer .command-status .cmd-row {margin:5px 0;justify-content:flex-start;}
#mobilePanelDrawer .command-status .command-hint {margin:6px 0 0;}
#mobilePanelDrawer .more-actions {margin-top:8px;padding-top:8px;}
#mobilePanelDrawer .companion-details {padding-top:8px;}
#mobilePanelDrawer .companion-details > summary {padding:2px 0;}
#mobilePanelDrawer .ability {padding:6px 0;}
#mobilePanelDrawer .panel-actions button {height:var(--ui-control);min-height:var(--ui-control);}

/* Remove the decorative stripe that overlapped skill text. */
.ability::before {content:none;display:none;}
#mobilePanelDrawer .ability-top {flex-wrap:wrap;gap:4px;}
#mobilePanelDrawer .ability-tag {padding:0 4px;white-space:normal;}
#mobilePanelDrawer .ability-chips {gap:4px;}
#mobilePanelDrawer .ability-chip {padding:1px 4px;border-radius:4px;}
#mobilePanelDrawer .ability-desc {overflow-wrap:anywhere;}
#mobilePanelDrawer .pet-quick-actions {grid-template-columns:minmax(0,1fr) auto auto;gap:4px;align-items:center;}
#mobilePanelDrawer .pet-quick-actions .career-badge {display:flex;flex-wrap:wrap;align-items:center;gap:3px;min-width:0;min-height:0;padding:0;border:0;background:none!important;}
#mobilePanelDrawer .pet-quick-actions .career-badge :is(small,b) {margin:0;}
#mobilePanelDrawer #petDescription .pet-quick-actions .ghost {min-width:0;min-height:24px;padding:2px 5px;font-weight:500;}
#mobilePanelDrawer .stat-quick-row {display:flex;justify-content:space-between;gap:4px;}
#mobilePanelDrawer .stat-quick-row .stat.stat-compact {display:flex;gap:3px;min-height:20px;min-width:0;margin:0;padding:0;border:0;border-radius:0;background:none!important;}
#mobilePanelDrawer .stat.stat-compact b {min-width:0;padding:0;border:0;border-radius:0;background:none;}
#mobilePanelDrawer #stats {gap:6px;}
#mobilePanelDrawer #survivalStats {border-top:0;padding-top:0;}
#mobilePanelDrawer #commandActions > .command-grid {grid-template-columns:repeat(2,minmax(0,1fr));}
#mobilePanelDrawer .command-head {flex-wrap:wrap;gap:2px;}
#mobilePanelDrawer .companion-secondary .inv-slots {gap:4px;}
#mobilePanelDrawer .companion-secondary .inv-slot {height:36px;min-height:36px;padding:2px;}
#mobilePanelDrawer .companion-secondary .inv-slot .inventory-art,#mobilePanelDrawer .companion-secondary .inv-slot .equipment-asset {width:24px;height:24px;}

/* Pet profiles use the same left/right information arrangement. */
#petProfileModal .pet-profile-panel {width:min(580px,calc(100vw - 24px));max-width:none;}
#petProfileBody {display:grid;grid-template-columns:180px minmax(0,1fr);gap:12px;align-items:start;}
#petProfileBody .profile-primary,#petProfileBody .profile-secondary {display:flex;flex-direction:column;gap:10px;min-width:0;}
#petProfileBody .profile-primary {padding-right:12px;border-right:1px solid #d7dccf;}
#petProfileBody .profile-death-layout {grid-column:1/-1;}
#petProfileBody .profile-portrait,#petProfileBody .profile-portrait .pixel-pet.pet-sprite-avatar.large {width:132px;height:132px;}
#petProfileBody .companion-hero {gap:6px;}
#petProfileBody .companion-identity {gap:4px;}
#petProfileBody .companion-vitals {padding:0;border:0;background:none;gap:6px;}
#petProfileBody .companion-facts {grid-template-columns:repeat(2,minmax(0,1fr));padding:6px;gap:6px;}
#petProfileBody .profile-career-rarity {grid-template-columns:1fr;gap:4px;}
#petProfileBody #petProfileActions {margin:0;padding:0;border:0;grid-template-columns:repeat(2,minmax(0,1fr));}
#petProfileBody #petProfileActions button {min-width:0;white-space:normal;min-height:var(--ui-control);padding:4px 6px;}
#petProfileBody .equipment-row {display:flex;flex-direction:column;align-items:stretch;gap:5px;padding:0;margin:0;border:0;}
#petProfileBody .equip-slots {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;}
#petProfileBody .equip-slot {display:flex;flex-direction:column;justify-content:center;align-items:center;gap:2px;min-width:0;width:auto;height:54px;padding:3px;border:1px solid #d7dccf;border-radius:7px;background:#e9ecdf;box-shadow:none;cursor:pointer;}
#petProfileBody .equip-slot.empty {background:none;border-style:dashed;color:#728276;cursor:default;}
#petProfileBody .equip-slot :is(.equipment-asset,.equipment-icon) {width:26px;height:26px;}
#petProfileBody .equip-slot small {color:#607368;}
#petProfileBody .equip-slot::after {display:none;}
:is(#mobilePanelDrawer .companion-primary,#petProfileBody .profile-primary) .companion-meter {grid-template-columns:1fr auto;gap:2px 4px;}
:is(#mobilePanelDrawer .companion-primary,#petProfileBody .profile-primary) .companion-track {grid-column:1/-1;grid-row:2;height:4px;}
:is(#mobilePanelDrawer .companion-primary,#petProfileBody .profile-primary) .companion-meter small {grid-column:2;grid-row:1;}

/* The same control/text scale applies to the map chrome, without scaling the map. */
.topbar :is(button,summary),.topbar .account-menu-items .circ-btn,.mobile-map-menu-btn b,.map-controls output {font-size:var(--ui-font)!important;}
.topbar .hud-disclosure > summary {padding:5px 8px;border-radius:8px;}
.topbar .account-menu-items .circ-btn {height:var(--ui-control);min-height:var(--ui-control);padding:4px 8px;}
.map-controls button {width:28px;height:28px;min-height:28px;}
.mobile-map-menu-btn {height:36px;min-height:36px;gap:2px;}
.mobile-map-hud {padding:3px;}

@media (max-width:900px) {
  #mobilePanelDrawer.bottom-grid {width:auto;height:min(60dvh,480px);}
  #mobilePanelDrawer.bottom-grid.expanded {height:min(80dvh,760px);}
  #mobilePanelDrawer .companion-columns {grid-template-columns:38% minmax(0,1fr);}
  #mobilePanelDrawer .companion-primary,#mobilePanelDrawer .companion-secondary {padding:8px;gap:8px;}
  #mobilePanelDrawer #petPortrait .pet-overview-art,#mobilePanelDrawer #petPortrait .pixel-pet.large {width:96px!important;height:96px!important;}
  #mobilePanelDrawer .companion-primary .equip-slots {gap:2px;}
  #mobilePanelDrawer .companion-primary .equip-slot,#petProfileBody .equip-slot {padding:2px 0;}
  #mobilePanelDrawer .companion-primary .equip-slot small,#petProfileBody .equip-slot small {white-space:nowrap;}
  #mobilePanelDrawer .companion-primary .equip-slot :is(.equipment-asset,.equipment-icon) {width:24px;height:24px;}
  #petProfileBody {grid-template-columns:38% minmax(0,1fr);gap:8px;}
  #petProfileBody .profile-primary {padding-right:8px;}
  #petProfileBody .profile-portrait,#petProfileBody .profile-portrait .pixel-pet.pet-sprite-avatar.large {width:96px;height:96px;}
  #petProfileBody .companion-facts {grid-template-columns:1fr;}
  #panelExpandBtn {margin-left:0;}
}
@media (max-width:380px) {
  #mobilePanelDrawer .companion-primary .pet-care-actions {grid-template-columns:1fr;}
  #mobilePanelDrawer .companion-secondary .inv-slots {grid-template-columns:repeat(3,minmax(0,1fr));}
  #mobilePanelDrawer .pet-quick-actions .career-badge {grid-column:1/-1;}
  #mobilePanelDrawer .pet-quick-actions {grid-template-columns:repeat(2,minmax(0,1fr));}
  #mobilePanelDrawer .pet-name-line {flex-wrap:wrap;}
  #mobilePanelDrawer .pet-name-actions {margin-left:0;}
  #petProfileBody .equip-slot :is(.equipment-asset,.equipment-icon) {width:22px;height:22px;}
}
@media (pointer:coarse) {
  :root {--ui-control:32px;}
  #mobilePanelDrawer .companion-panel-head {height:40px;}
  #mobilePanelDrawer .companion-panel-head button,#mobilePanelDrawer .mobile-panel-close {min-height:32px;}
  #mobilePanelDrawer .mobile-panel-close {top:4px;width:32px;height:32px;}
  #mobilePanelDrawer .pet-name-icon-btn {width:28px;height:28px;min-height:28px;}
  .mobile-map-menu-btn {height:40px;min-height:40px;}
}

/* Descriptions have their own reading scale. Keep names, prices, controls and
   resource values on the normal scale, even inside a compact panel. */
:is(#mobilePanelDrawer, #adminPanel, .modal-panel, .cmd-menu, .auth-panel, .obj-action-popup, .tutorial-card)
  :is(.command-hint, .command-cost, .create-desc, .target-detail-desc, .ability-desc, .bestiary-lore,
      .equipment-detail-note, .modal-hint, .editor-asset-note, .apc-edit-hint,
      .help-body p, .help-body li, .auth-footnote, .game-logo p, .tutorial-card > p, .terrain-skin-head small, .admin-tab-panel label small) {
  font-size:var(--ui-caption)!important;
  line-height:1.55;
}
:is(#mobilePanelDrawer, #adminPanel, .modal-panel, .cmd-menu)
  :is(.target-detail-desc, .command-hint, .create-desc, .help-body li, .help-body p) :is(span,b,strong) {
  font-size:inherit!important;
}
#authForm .game-logo h2 {font:700 30px/1.2 var(--sb-serif)!important;letter-spacing:.12em;}
#authForm .game-logo {gap:6px;margin-bottom:18px;}
#authView #authForm input {min-height:38px;border-radius:9px;}
@media (max-width:900px) {
  #authForm input {font-size:16px!important;}
  #authForm .game-logo-emoji {display:none;}
  #authForm .game-logo {margin-bottom:10px;}
  #authForm .tabs {margin-bottom:14px;}
}
