/* P10.25.27 — mobile first screen and settings icon sizing. */
@media (max-width:700px) and (orientation:portrait){
  #startScreen.titleScreen{background-position:center center!important;}
  #startScreen .titleBrand{
    top:calc(12px + env(safe-area-inset-top,0px));
    left:calc(12px + env(safe-area-inset-left,0px));
    max-width:calc(100vw - 24px);
  }
  #startScreen .titleUiCompact{
    position:fixed!important;
    inset:0!important;
    display:flex!important;
    flex-direction:column!important;
    align-items:center!important;
    justify-content:flex-end!important;
    width:100vw!important;
    max-width:none!important;
    height:100vh!important;
    height:100dvh!important;
    min-height:0!important;
    box-sizing:border-box!important;
    padding:max(12px,env(safe-area-inset-top,0px)) max(12px,env(safe-area-inset-right,0px)) max(12px,env(safe-area-inset-bottom,0px)) max(12px,env(safe-area-inset-left,0px))!important;
    gap:8px!important;
  }
  #startScreen .titleMenuCompact,
  #startScreen .titleSaveInfoCompact{
    width:min(420px,100%)!important;
    max-width:420px!important;
    margin:0!important;
    box-sizing:border-box!important;
  }
  #startScreen .titleMenuCompact{
    top:auto!important;
    right:12px!important;
    bottom:calc(12px + env(safe-area-inset-bottom,0px))!important;
    left:12px!important;
    width:auto!important;
    max-width:none!important;
    transform:none!important;
  }
  #startScreen .titleMenuCompact{padding:10px!important;}
  #startScreen .titleBtn{
    width:100%!important;
    min-width:0!important;
    min-height:48px!important;
    height:auto!important;
    margin:4px 0!important;
    padding:8px 12px!important;
    gap:10px!important;
    font-size:clamp(13px,4vw,16px)!important;
    line-height:1.2!important;
    box-sizing:border-box!important;
  }
  #startScreen .titleBtn .btnIcon:empty{display:none!important;}
  #startScreen .titleBtn .uiSpriteIcon{width:24px!important;height:24px!important;flex:0 0 24px!important;}
  #startScreen .titleSaveInfoCompact{padding:8px 10px!important;overflow-wrap:anywhere!important;}
}

#settingsScreen .settingsBigIconSprite{display:block;width:24px;height:24px;object-fit:contain;}
#settingsScreen .settingsPreferenceIcon{display:block;width:20px;height:20px;flex:0 0 20px;object-fit:contain;}
#settingsScreen .settingsQualityLead{display:inline-flex;align-items:center;gap:7px;min-width:0;}
#settingsScreen .settingsSectionIcon{display:inline-block;width:20px;height:20px;margin-right:7px;vertical-align:-4px;object-fit:contain;}
@media(max-width:700px){
  #settingsScreen .settingsBigIcon{width:24px!important;flex:0 0 24px!important;}
  #settingsScreen .settingsBigIconSprite{width:22px;height:22px;}
  #settingsScreen .settingsPreferenceIcon,#settingsScreen .settingsSectionIcon{width:18px;height:18px;flex-basis:18px;}
  #settingsScreen .settingsQualityLead{gap:5px;}
  #settingsScreen .settingsThemeHeading{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    align-items:stretch!important;
    gap:7px!important;
  }
  #settingsScreen .settingsResetBtn{
    display:flex!important;
    align-items:center!important;
    justify-content:space-between!important;
    gap:7px!important;
    text-align:right!important;
    width:100%!important;
    min-width:0!important;
    min-height:44px!important;
    padding:8px 10px!important;
    font-size:12px!important;
    line-height:1.2!important;
    white-space:nowrap!important;
  }
  #settingsScreen .settingsResetBtn .uiSpriteIcon{width:18px!important;height:18px!important;flex:0 0 18px!important;}
}

/* P10.25.27-popup-visual-standard — diplomatic panel tokens shared by every popup. */
body.rrmModernUiP485 .rrmModalShellP102467{
  border:1px solid var(--bd-border)!important;
  border-radius:22px!important;
  background:linear-gradient(145deg,var(--bd-panel-alt),var(--bd-panel))!important;
  box-shadow:0 24px 72px var(--bd-shadow-color),inset 0 1px 0 color-mix(in srgb,var(--bd-border-soft) 22%,transparent)!important;
  color:var(--bd-text)!important;
}

body.rrmModernUiP485 .rrmModalShellP102467 .rrmModalHeaderP102467{
  box-sizing:border-box!important;
  min-height:50px!important;
  padding:12px 60px 10px 16px!important;
  display:flex!important;
  align-items:center!important;
  gap:8px!important;
  font-family:Georgia,"Times New Roman",serif!important;
  font-size:clamp(20px,2.6vw,31px)!important;
  font-weight:800!important;
  line-height:1.05!important;
  letter-spacing:.06em!important;
  text-align:left!important;
  text-transform:uppercase!important;
  color:var(--bd-title)!important;
  background:linear-gradient(180deg,var(--bd-panel-alt),var(--bd-panel))!important;
  border-bottom:1px solid color-mix(in srgb,var(--bd-border) 35%,transparent)!important;
}

body.rrmModernUiP485 .rrmModalShellP102467 :is(.panelSection,.objectPopupSection,.visitorCard){
  border:1px solid var(--bd-border-soft)!important;
  border-radius:15px!important;
  background:linear-gradient(145deg,var(--bd-panel-alt),var(--bd-panel))!important;
  box-shadow:inset 0 1px 0 color-mix(in srgb,var(--bd-border-soft) 16%,transparent),0 8px 20px color-mix(in srgb,var(--bd-shadow-color) 45%,transparent)!important;
}

/* An injected sprite and the older button background used to paint the same
   artwork twice. Keep the DOM sprite as the one canonical icon. */
body.rrmModernUiP485 .rrmModalShellP102467 :is(.iconOnly[data-ui-sprite]:not(#speedBtn),.panelTabs button[data-ui-sprite]).hasUiSpriteIcon{
  background-image:none!important;
}
body.rrmModernUiP485 .rrmModalShellP102467 button.hasUiSpriteIcon::before,
body.rrmModernUiP485 .rrmModalShellP102467 button.hasUiSpriteIcon::after{
  content:none!important;
  display:none!important;
}
body.rrmModernUiP485 .rrmModalShellP102467 button.hasUiSpriteIcon .uiSpriteIcon~.uiSpriteIcon,
body.rrmModernUiP485 .rrmModalShellP102467 button.hasUiSpriteIcon > :is(.btnIcon,.buttonIcon,.actionIcon,.emojiIcon,[aria-hidden="true"]):not(.uiSpriteIcon),
body.rrmModernUiP485 .rrmModalShellP102467 button.hasUiSpriteIcon > span:empty:not(.uiSpriteIcon){
  display:none!important;
}
body.rrmModernUiP485 .rrmModalShellP102467 :is(.objectActionRow,.compactButtonsP25,.rrmPopupActions,.rrmFactionActionsP6430,.diplomacyActions) button.hasUiSpriteIcon{
  display:inline-flex!important;
  align-items:center!important;
  justify-content:space-between!important;
  gap:8px!important;
  text-align:right!important;
}
body.rrmModernUiP485 .rrmModalShellP102467 :is(.objectActionRow,.compactButtonsP25,.rrmPopupActions,.rrmFactionActionsP6430,.diplomacyActions) button:not(.iconOnly):not(.confirm):not(.primary):not(.danger){
  border:1px solid color-mix(in srgb,var(--bd-border) 58%,transparent)!important;
  border-radius:10px!important;
  background:color-mix(in srgb,var(--bd-surface) 45%,transparent)!important;
  color:var(--bd-text)!important;
  font-weight:800!important;
}
body.rrmModernUiP485 .rrmModalShellP102467 .rrmFactionActionsP6430 button>span:empty{
  display:none!important;
}
body.rrmModernUiP485 .rrmModalShellP102467 :is(.objectActionRow,.compactButtonsP25,.rrmPopupActions,.rrmFactionActionsP6430,.diplomacyActions) button.hasUiSpriteIcon>.uiSpriteIcon{
  width:20px!important;
  height:20px!important;
  flex:0 0 20px!important;
}

/* Close controls have a transparent 44px touch target; only the close sprite is visible. */
body.rrmModernUiP485 .rrmModalShellP102467 :is(.rrmPanelClose,#sideCloseBtn,#objectPopupClose,#wpClose,#stockPanelClose,#scheduleCloseBtn,.settingsCloseBtn,.popupCloseX){
  display:grid!important;
  place-items:center!important;
  width:44px!important;
  min-width:44px!important;
  height:44px!important;
  min-height:44px!important;
  padding:0!important;
  border:0!important;
  border-radius:0!important;
  background:transparent!important;
  background-image:none!important;
  box-shadow:none!important;
  color:transparent!important;
  font-size:0!important;
  line-height:0!important;
  text-shadow:none!important;
}
body.rrmModernUiP485 .rrmModalShellP102467 :is(.rrmPanelClose,#sideCloseBtn,#objectPopupClose,#wpClose,#stockPanelClose,#scheduleCloseBtn,.settingsCloseBtn,.popupCloseX)>.uiSpriteIcon{
  display:block!important;
  width:24px!important;
  height:24px!important;
  flex:0 0 24px!important;
}
body.rrmModernUiP485 .rrmModalShellP102467 :is(.rrmPanelClose,#sideCloseBtn,#objectPopupClose,#wpClose,#stockPanelClose,#scheduleCloseBtn,.settingsCloseBtn,.popupCloseX).hasUiSpriteIcon>:not(.uiSpriteIcon){
  display:none!important;
}
body.rrmModernUiP485 .rrmModalShellP102467 :is(.rrmPanelClose,#sideCloseBtn,#objectPopupClose,#wpClose,#stockPanelClose,#scheduleCloseBtn,.settingsCloseBtn,.popupCloseX):focus-visible{
  outline:2px solid var(--bd-focus)!important;
  outline-offset:1px!important;
}

@media(max-width:900px),(pointer:coarse){
  body.rrmModernUiP485 .rrmModalShellP102467{border-radius:15px!important;}
  body.rrmModernUiP485 .rrmModalShellP102467 .rrmModalHeaderP102467{
    min-height:38px!important;
    padding:8px 52px 6px 14px!important;
    font-size:16px!important;
    letter-spacing:.045em!important;
  }
}

/* P10.25.27 — stock filters were being laid out as three flex columns because
   the modal owns its own scrolling. Keep the stock popup as one readable
   vertical surface at every profile; only the item grid changes density. */
body.rrmModernUiP485 #stockPanel.rrmModalShellP102467{
  /* PopupManager owns visibility; this rule only defines the open layout. */
  display:flex;
  flex-direction:column!important;
  align-items:stretch!important;
  gap:8px!important;
  min-width:0!important;
  box-sizing:border-box!important;
}
body.rrmModernUiP485 #stockPanel.rrmModalShellP102467>.rrmModalHeaderP102467{
  position:sticky!important;
  top:0!important;
  z-index:4!important;
  display:flex!important;
  align-items:center!important;
  align-self:stretch!important;
  flex:0 0 auto!important;
  width:auto!important;
  min-width:0!important;
  min-height:44px!important;
  margin:-12px -12px 0!important;
  padding:9px 54px 8px 14px!important;
  text-align:left!important;
}
body.rrmModernUiP485 #stockPanel.rrmModalShellP102467>.panelSection:first-of-type{
  display:flex!important;
  align-items:center!important;
  justify-content:space-between!important;
  align-self:stretch!important;
  flex:0 0 auto!important;
  gap:12px!important;
  width:auto!important;
  min-width:0!important;
  margin:0!important;
  padding:8px 10px!important;
}
body.rrmModernUiP485 #stockPanel.rrmModalShellP102467>.panelSection:first-of-type>.statRow{
  display:flex!important;
  align-items:center!important;
  justify-content:flex-end!important;
  flex:0 1 auto!important;
  gap:8px!important;
  width:auto!important;
  min-width:0!important;
  margin:0!important;
}
body.rrmModernUiP485 #stockPanel.rrmModalShellP102467>.panelSection:first-of-type>.statRow>span:last-child{
  display:flex!important;
  align-items:center!important;
  gap:4px!important;
  white-space:nowrap!important;
}
body.rrmModernUiP485 #stockPanel.rrmModalShellP102467>.stockFilterShellP10242{
  display:grid!important;
  align-self:stretch!important;
  flex:0 1 auto!important;
  grid-template-columns:minmax(0,1fr)!important;
  gap:8px!important;
  width:auto!important;
  min-width:0!important;
  max-width:none!important;
  min-height:0!important;
  margin:0!important;
  padding:9px!important;
  box-sizing:border-box!important;
}
body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterTopP10242,
body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterContentP10242{
  width:100%!important;
  min-width:0!important;
  max-width:100%!important;
  box-sizing:border-box!important;
}
body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterContentP10242{
  min-height:0!important;
  max-height:min(46dvh,420px)!important;
  overflow-x:hidden!important;
  overflow-y:auto!important;
  overscroll-behavior:contain!important;
  -webkit-overflow-scrolling:touch!important;
}
body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterCategoryP10242,
body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterGridP10242{
  width:100%!important;
  min-width:0!important;
  max-width:100%!important;
  box-sizing:border-box!important;
}
@media(max-width:900px),(pointer:coarse){
  body.rrmModernUiP485 #stockPanel.rrmModalShellP102467{gap:6px!important;padding:8px!important;}
  body.rrmModernUiP485 #stockPanel.rrmModalShellP102467>.rrmModalHeaderP102467{margin:-8px -8px 0!important;}
  body.rrmModernUiP485 #stockPanel.rrmModalShellP102467>.stockFilterShellP10242{gap:6px!important;padding:7px!important;}
}
@media(max-width:520px){
  body.rrmModernUiP485 #stockPanel.rrmModalShellP102467>.panelSection:first-of-type{align-items:flex-start!important;}
  body.rrmModernUiP485 #stockPanel.rrmModalShellP102467>.panelSection:first-of-type>.statRow{flex-wrap:wrap!important;justify-content:flex-end!important;}
  body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterTopP10242{display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:8px!important;}
  body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterToolbarP10242{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterGridP10242{grid-template-columns:1fr!important;}
  body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterCategoryHeadP10242{grid-template-columns:minmax(0,1fr) auto!important;}
  body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterCategoryHeadP10242>div{grid-column:1/-1!important;}
}

/* P10.25.29 — the stock filter sheet must fit its modal at desktop, tablet,
   and mobile sizes. The theme's earlier #stockPanel rules are more specific,
   so these scoped overrides deliberately include the theme root and shell. */
html[data-bd-theme] body.rrmModernUiP485 #stockPanel.rrmModalShellP102467>.stockFilterShellP10242{
  display:grid!important;
  align-self:stretch!important;
  flex:0 1 auto!important;
  grid-template-columns:minmax(0,1fr)!important;
  width:100%!important;
  min-width:0!important;
  max-width:100%!important;
  min-height:0!important;
  box-sizing:border-box!important;
}
html[data-bd-theme] body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterTopP10242,
html[data-bd-theme] body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterContentP10242,
html[data-bd-theme] body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterCategoryP10242,
html[data-bd-theme] body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterGridP10242{
  width:100%!important;
  min-width:0!important;
  max-width:100%!important;
  box-sizing:border-box!important;
}
html[data-bd-theme] body.rrmModernUiP485 #stockPanel.rrmModalShellP102467 .stockFilterContentP10242{
  min-height:0!important;
  max-height:min(46dvh,420px)!important;
  overflow-x:hidden!important;
  overflow-y:auto!important;
  overscroll-behavior:contain!important;
  -webkit-overflow-scrolling:touch!important;
}

/* P10.25.29 — Settings and save history sit outside the managed modal shell.
   Keep their close targets accessible, but let the single sprite stand alone. */
html[data-bd-theme] body.rrmModernUiP485 #settingsScreen .settingsCloseBtn,
html[data-bd-theme] body.rrmModernUiP485 #saveHistoryCloseBtn{
  display:grid!important;
  place-items:center!important;
  width:44px!important;
  min-width:44px!important;
  height:44px!important;
  min-height:44px!important;
  padding:0!important;
  border:0!important;
  border-radius:0!important;
  background:transparent!important;
  background-image:none!important;
  box-shadow:none!important;
  color:transparent!important;
  font-size:0!important;
  line-height:0!important;
  text-shadow:none!important;
}
html[data-bd-theme] body.rrmModernUiP485 #settingsScreen .settingsCloseBtn.hasUiSpriteIcon::before,
html[data-bd-theme] body.rrmModernUiP485 #settingsScreen .settingsCloseBtn.hasUiSpriteIcon::after,
html[data-bd-theme] body.rrmModernUiP485 #settingsScreen .settingsCloseBtn.hasUiSpriteIcon>:not(.uiSpriteIcon),
html[data-bd-theme] body.rrmModernUiP485 #saveHistoryCloseBtn.hasUiSpriteIcon::before,
html[data-bd-theme] body.rrmModernUiP485 #saveHistoryCloseBtn.hasUiSpriteIcon::after,
html[data-bd-theme] body.rrmModernUiP485 #saveHistoryCloseBtn.hasUiSpriteIcon>:not(.uiSpriteIcon){
  content:none!important;
  display:none!important;
}
html[data-bd-theme] body.rrmModernUiP485 #settingsScreen .settingsCloseBtn>.uiSpriteIcon,
html[data-bd-theme] body.rrmModernUiP485 #saveHistoryCloseBtn>.uiSpriteIcon{
  display:block!important;
  width:24px!important;
  height:24px!important;
  flex:0 0 24px!important;
}
