/*
 GOLD EMPIRE UI 1.0 · Stage 3
 Compact Telegram Mini App polish on top of UI foundation and panels.
 No gameplay element is hidden or disabled; no map coordinates are modified.
*/
:root{
  --ge-safe-bottom:max(env(safe-area-inset-bottom,0px),var(--tg-content-safe-area-inset-bottom,0px));
}
.ge-ui{min-width:0}
.ge-ui .app-shell{min-width:0}
.ge-ui .topbar,.ge-ui .brand,.ge-ui .brand-copy,.ge-ui .top-actions{min-width:0}
.ge-ui .bottom-nav .nav{touch-action:manipulation}
.ge-ui :is(button,[role="switch"]):focus-visible{
  outline:2px solid var(--ge-focus);
  outline-offset:3px;
}
.ge-ui #more-menu[hidden]{display:none!important}
.ge-ui #more-menu{
  overscroll-behavior:contain;
  scrollbar-width:thin;
  scrollbar-color:rgba(229,188,103,.38) transparent;
  border:1px solid rgba(229,188,103,.37);
  background:#222733;
  box-shadow:0 16px 44px #0009;
}
.ge-ui #more-menu button{
  min-width:0;
  min-height:48px;
  color:var(--ge-text);
  border-color:var(--ge-border);
  border-radius:12px;
  background:#2c303d;
  overflow-wrap:anywhere;
}
.ge-ui #more-menu button:focus-visible{outline-offset:-3px}
.ge-ui .nav.active{
  border-color:rgba(229,188,103,.35);
  background:rgba(229,188,103,.12);
}
.ge-ui #notice{
  max-height:30dvh;
  overflow-y:auto;
  width:min(calc(100% - 24px),600px);
  overflow-wrap:anywhere;
}
#gold-city-rebirth .rb-app{
  height:var(--ge-viewport-height,100dvh);
  max-height:100dvh;
  min-height:0;
}
#gold-city-rebirth .rb-content{
  min-width:0;
  overflow-x:hidden;
  overscroll-behavior-y:contain;
  -webkit-overflow-scrolling:touch;
}
#gold-city-rebirth .rb-header{
  min-width:0;
}
#gold-city-rebirth .rb-wallet{
  min-width:0;
  max-width:40%;
  white-space:normal;
  overflow-wrap:anywhere;
}
#gold-city-rebirth .rb-wallet strong{font-variant-numeric:tabular-nums}
#gold-city-rebirth .rb-brand{min-width:0}
#gold-city-rebirth .rb-brand strong{white-space:normal;line-height:1.1}
#gold-city-rebirth .rb-x{
  flex:none;
  min-height:44px;
  min-width:44px;
}
#gold-city-rebirth .rb-nav{
  min-width:0;
}
#gold-city-rebirth .rb-nav button{
  touch-action:manipulation;
  min-width:0;
  min-height:48px;
}
#gold-city-rebirth .rb-nav span{
  max-width:100%;
  overflow-wrap:anywhere;
}
#gold-city-rebirth .rb-my-businesses,
#gold-city-rebirth .rb-industry-management,
#gold-city-rebirth .rb-panel-page,
#gold-city-rebirth .rb-income-details{
  min-width:0;
  overflow-wrap:break-word;
}
#gold-city-rebirth .rb-my-business-value,
#gold-city-rebirth .rb-industry-stat b,
#gold-city-rebirth .rb-budget-stat strong,
#gold-city-rebirth .rb-income-enterprise-head>strong{
  white-space:normal;
  overflow-wrap:anywhere;
}
#finance-modal .finance-panel,
#enterprise-modal .enterprise-dialog{
  min-width:0;
}
#finance-modal .finance-panel input,
#finance-modal .finance-panel select,
#enterprise-modal input{font-size:16px}
#finance-modal .finance-actions button,
#finance-modal .finance-more button{
  min-width:0;
  min-height:44px;
  white-space:normal;
}
#finance-modal #finance-content{
  min-width:0;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
}
#finance-modal .finance-history{
  min-width:0;
  flex-wrap:wrap;
}
#finance-modal .finance-history>div{min-width:0;flex:1 1 140px}
#finance-modal .finance-history span{
  white-space:normal;
  font-variant-numeric:tabular-nums;
  overflow-wrap:anywhere;
}
#enterprise-modal .enterprise-content{
  overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
}
#page-invest .ge9{
  min-width:0;
  overflow-x:hidden;
}

@media(max-width:530px){
  .ge-ui .app-shell{
    padding-left:10px;
    padding-right:10px;
    padding-bottom:calc(109px + var(--ge-safe-bottom));
  }
  .ge-ui .topbar{
    gap:7px;
    padding:10px 1px;
  }
  .ge-ui .brand{gap:7px;flex:1 1 auto;min-width:0}
  .ge-ui .brand-mark{
    width:37px;
    height:37px;
    flex:none;
    font-size:18px;
    border-radius:11px;
  }
  .ge-ui .brand-copy b{
    font-size:clamp(15px,4.5vw,20px);
    letter-spacing:-.02em;
  }
  .ge-ui .brand-copy small{font-size:8px;letter-spacing:.065em}
  .ge-ui .top-actions{gap:5px;flex:0 1 auto}
  .ge-ui .balance{
    min-height:42px;
    padding:4px 5px 4px 9px;
    font-size:clamp(11px,2.95vw,14px);
    max-width:42vw;
  }
  .ge-ui .balance b{
    min-width:0;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  .ge-ui .balance i{width:30px;height:30px;flex:none}
  .ge-ui .avatar{min-width:40px;min-height:40px;width:40px;height:40px}
  .ge-ui .bottom-nav{
    bottom:calc(6px + var(--ge-safe-bottom));
    width:calc(100% - 12px);
    padding:6px 4px;
    gap:2px;
    grid-template-columns:repeat(5,minmax(0,1fr));
    border-radius:19px;
  }
  .ge-ui .nav{
    min-height:62px;
    padding:7px 1px;
    border-radius:13px;
    min-width:0;
  }
  .ge-ui .nav .glyph{font-size:22px}
  .ge-ui .nav span:last-child{
    font-size:clamp(9px,2.55vw,11px);
    white-space:normal;
    line-height:1.2;
    overflow-wrap:anywhere;
    text-align:center;
  }
  .ge-ui #more-menu{
    position:fixed;
    left:50%;
    top:auto;
    bottom:calc(88px + var(--ge-safe-bottom));
    transform:translateX(-50%);
    width:calc(100% - 20px);
    max-width:440px;
    max-height:min(58dvh,calc(var(--ge-viewport-height,100dvh) - 168px));
    overflow-y:auto;
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    padding:10px;
    gap:8px;
    z-index:45;
  }
  #gold-city-rebirth .rb-app{
    height:var(--ge-viewport-height,100dvh);
    max-height:100dvh;
  }
  #gold-city-rebirth .rb-header{
    min-height:65px;
    padding:10px 9px 8px;
    padding-top:max(9px,env(safe-area-inset-top,0px));
    gap:7px;
  }
  #gold-city-rebirth .rb-mark{
    width:35px;
    height:35px;
    font-size:23px;
    flex:none;
  }
  #gold-city-rebirth .rb-brand small{font-size:7px;line-height:1.15}
  #gold-city-rebirth .rb-brand strong{font-size:clamp(14px,4.1vw,18px)}
  #gold-city-rebirth .rb-wallet{
    max-width:38%;
    padding:6px 9px;
    border-radius:10px;
  }
  #gold-city-rebirth .rb-wallet strong{
    font-size:clamp(12px,3.75vw,17px);
    line-height:1.15;
  }
  #gold-city-rebirth .rb-x{width:44px;height:44px}
  #gold-city-rebirth .rb-content{padding:10px 10px 15px}
  #gold-city-rebirth .rb-footer-caption{
    padding-bottom:max(5px,var(--ge-safe-bottom));
  }
  #gold-city-rebirth .rb-nav{
    gap:2px;
    padding:5px 4px;
  }
  #gold-city-rebirth .rb-nav button{
    min-height:51px;
    font-size:10px;
    padding:5px 2px;
  }
  #gold-city-rebirth .rb-nav svg{width:19px;height:19px}
  #gold-city-rebirth .rb-scene-wrap{
    height:clamp(260px,46svh,410px);
    min-height:260px;
  }
  #gold-city-rebirth .rb-plot-inspector{
    max-height:min(50%,315px);
    bottom:71px;
  }
  #finance-modal.modal-backdrop{
    padding:0;
  }
  #finance-modal .finance-panel{
    height:var(--ge-viewport-height,100dvh);
    max-height:100dvh;
    width:100%;
    border-radius:0;
  }
  #finance-modal .finance-header{
    padding:12px 13px;
    padding-top:max(12px,env(safe-area-inset-top,0px));
  }
  #finance-modal #finance-content{
    padding:13px 12px calc(22px + var(--ge-safe-bottom));
  }
  #finance-modal #finance-nav{gap:3px;padding:7px}
  #finance-modal #finance-nav button{
    font-size:11px;
    min-height:46px;
    padding:8px 3px;
  }
  #enterprise-modal.enterprise-overlay{
    padding:0;
  }
  #enterprise-modal .enterprise-dialog{
    max-height:var(--ge-viewport-height,100dvh);
    width:100%;
    border-radius:0;
  }
  #enterprise-modal .enterprise-content{
    padding:13px 12px calc(18px + var(--ge-safe-bottom));
  }
}
@media(max-width:350px){
  .ge-ui .brand-copy small{font-size:7px}
  .ge-ui .brand-mark{width:32px;height:32px;font-size:16px}
  .ge-ui .balance{max-width:40vw;padding-left:6px}
  .ge-ui .balance i{width:26px;height:26px;font-size:17px}
  .ge-ui .avatar{min-width:36px;width:36px;height:36px}
  .ge-ui .bottom-nav{padding:5px 2px;gap:1px}
  .ge-ui .nav .glyph{font-size:20px}
  .ge-ui #more-menu{grid-template-columns:1fr 1fr;padding:7px;gap:6px}
  #gold-city-rebirth .rb-header{gap:5px;padding-inline:6px}
  #gold-city-rebirth .rb-wallet{padding:5px 6px}
  #gold-city-rebirth .rb-industry-stat{padding:8px}
  #gold-city-rebirth .rb-industry-stat b{font-size:11px}
  #gold-city-rebirth .rb-industry-material .rb-btn{max-width:100%}
  #gold-city-rebirth .rb-my-business-value{max-width:100%}
  #finance-modal #finance-nav button{font-size:10px}
}
@media(max-height:500px) and (orientation:landscape){
  .ge-ui .bottom-nav{padding:3px;bottom:3px}
  .ge-ui .nav{min-height:49px;gap:1px}
  .ge-ui .app-shell{padding-bottom:calc(69px + var(--ge-safe-bottom))}
  .ge-ui #more-menu{bottom:calc(64px + var(--ge-safe-bottom));max-height:45dvh}
  #gold-city-rebirth .rb-header{min-height:54px;padding-block:5px}
  #gold-city-rebirth .rb-nav button{min-height:43px}
  #gold-city-rebirth .rb-scene-wrap{min-height:230px;height:230px}
}
@media(prefers-reduced-motion:reduce){
  .ge-ui .screen{animation:none}
  .ge-ui .nav,.ge-ui #more-menu button{transition:none!important;animation:none!important}
}


/* GOLD EMPIRE Mobile 1.2 — narrow-screen finish.
   Target existing production DOM selectors (not hypothetical .grid-2 classes).
   Preserve all financial actions, menus and real server-sourced values. */
@media (max-width: 767px){
  .ge-ui :is(.screen,.card,.stack,.grid2,.bank-overview,.bank-links,.business-row){
    min-width:0;
    max-width:100%;
  }
  .ge-ui :is(.screen .card,.bank-overview>div,.bank-link){
    overflow-wrap:anywhere;
  }
  .ge-ui :is(.screen .button,.screen .pill,.business-row,.bank-link){
    min-height:44px;
    touch-action:manipulation;
  }
  #page-invest .ge9 :is(.ge9-primary-tabs button,.ge9-tools-grid button,.ge9-actions button,
    .ge9-chart-buttons button,.ge9-periods button,.ge9-close,.ge9-company-back,.ge9-refresh){
    min-height:44px;
    touch-action:manipulation;
  }
  #page-invest .ge9-close{min-width:44px;width:44px;height:44px}
  #page-invest .ge9 :is(.ge9-asset,.ge9-chart-card,.ge9-company-section,.ge9-hero){
    min-width:0;
    max-width:100%;
    overflow-wrap:anywhere;
  }
  #page-invest .ge9 :is(.ge9-asset-main,.ge9-company-row,.ge9-asset-price){
    min-width:0;
  }
  #page-invest .ge9-chart-svg svg{max-width:100%;height:auto}
  #finance-modal #finance-nav{
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
  }
  #finance-modal .finance-panel :is(button,input,select,textarea){
    max-width:100%;
  }
  #finance-modal .finance-panel :is(input,select,textarea),
  #enterprise-modal .enterprise-content :is(input,select,textarea),
  #gold-city-rebirth .rb-content :is(input,select,textarea){
    font-size:16px;
  }
  #finance-modal .finance-panel :is(.finance-actions,.finance-more,.finance-card){
    min-width:0;
  }
  #enterprise-modal .enterprise-content :is(.enterprise-actions,.enterprise-row,.enterprise-metrics){
    min-width:0;
  }
  #enterprise-modal .enterprise-content .enterprise-row{
    gap:10px;
    overflow-wrap:anywhere;
  }
  #gold-city-rebirth .rb-budget-history-row{min-width:0}
  #gold-city-rebirth .rb-budget-history-row :is(span,strong){
    min-width:0;
    overflow-wrap:anywhere;
  }
}
@media(max-width:530px){
  /* The real home screen uses .ge-home: small metrics remain legible. */
  #page-world .ge-home{
    width:100%;
    min-width:0;
    gap:12px;
  }
  #page-world .ge-home-sectionhead{
    flex-wrap:wrap;
    align-items:flex-start;
  }
  #page-world .ge-home-sectionhead h2{font-size:17px}
  #page-world .ge-home-balance strong{
    font-size:clamp(24px,7.5vw,34px);
    overflow-wrap:anywhere;
  }
  /* Keep original bank overview, earned-items and profile cards fully readable. */
  .ge-ui .grid2,
  .ge-ui .bank-links{grid-template-columns:minmax(0,1fr)}
  .ge-ui .business-row{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    align-items:center;
    overflow-wrap:anywhere;
  }
  .ge-ui .business-row>span:nth-of-type(1){
    min-width:0;
    flex:1 1 130px;
  }
  .ge-ui .business-row>b{
    min-width:0;
    max-width:100%;
    font-variant-numeric:tabular-nums;
    overflow-wrap:anywhere;
  }
  #gold-city-rebirth .rb-my-business-row{
    display:grid;
    grid-template-columns:40px minmax(0,1fr) minmax(64px,auto);
    grid-template-areas:"icon name arrow" "icon status value";
    align-items:center;
    gap:7px 8px;
  }
  #gold-city-rebirth .rb-my-business-icon{grid-area:icon}
  #gold-city-rebirth .rb-my-business-copy{grid-area:name}
  #gold-city-rebirth .ge-business-status{
    grid-area:status;
    justify-self:start;
  }
  #gold-city-rebirth .rb-my-business-value{
    grid-area:value;
    max-width:100%;
    text-align:right;
    margin:0;
  }
  #gold-city-rebirth .rb-my-business-row>span:last-child{
    grid-area:arrow;
    justify-self:end;
  }
  #gold-city-rebirth .rb-my-staff-row,
  #gold-city-rebirth .rb-my-upgrade,
  #gold-city-rebirth .rb-municipal-project{
    min-width:0;
    flex-wrap:wrap;
    align-items:flex-start;
  }
  #gold-city-rebirth :is(.rb-my-staff-row,.rb-my-upgrade)>.rb-btn{
    width:100%;
    min-width:0;
  }
  #gold-city-rebirth .rb-municipal-project .rb-btn{
    min-height:44px;
    width:100%;
  }
  #gold-city-rebirth .rb-industry-offer{min-width:0}
  #gold-city-rebirth .rb-industry-offer .rb-btn{
    max-width:100%;
    overflow-wrap:anywhere;
  }
  #gold-city-rebirth .rb-budget-actions{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  #gold-city-rebirth .rb-budget-actions .rb-btn{
    min-width:0;
    overflow-wrap:anywhere;
  }
  /* Four actual bank tabs, not five placeholder columns. */
  #finance-modal #finance-nav button{
    min-width:0;
    font-size:clamp(10px,2.75vw,12px);
    overflow-wrap:anywhere;
  }
  #finance-modal .finance-actions,
  #finance-modal .finance-more{
    display:grid;
    grid-template-columns:minmax(0,1fr);
  }
  #finance-modal .finance-actions>button,
  #finance-modal .finance-more>button{width:100%;min-width:0}
  #enterprise-modal .enterprise-metrics{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  #enterprise-modal .enterprise-row{
    display:flex;
    flex-wrap:wrap;
  }
  #enterprise-modal .enterprise-row>div{flex:1 1 140px;min-width:0}
  #enterprise-modal .enterprise-row .button{
    flex:1 1 auto;
    min-width:105px;
    white-space:normal;
  }
  #enterprise-modal .enterprise-actions{display:grid;grid-template-columns:1fr}
  #enterprise-modal .enterprise-actions .button{width:100%}
  #page-invest .ge9-asset-main{
    grid-template-columns:40px minmax(0,1fr) minmax(0,.85fr);
    gap:8px;
  }
  #page-invest .ge9-token{width:40px;height:40px}
  #page-invest .ge9-mainvalue{font-size:clamp(24px,6.5vw,34px)}
}
@media(max-width:380px){
  /* No tiny two-column quick action cards on 320/360/375px phones. */
  #page-world .ge-home-grid,
  #page-world .ge-home-stats{
    grid-template-columns:minmax(0,1fr);
    gap:8px;
  }
  #page-world .ge-home-link{
    min-height:86px;
    display:grid;
    grid-template-columns:42px minmax(0,1fr);
    grid-template-rows:1fr;
    align-items:center;
    justify-content:start;
    gap:12px;
    padding:12px 16px;
  }
  #page-world .ge-home-link-icon{grid-column:1}
  #page-world .ge-home-link-content{grid-column:2}
  #page-world .ge-home-link-chevron{top:calc(50% - 14px);right:12px}
  #page-world .ge-home-stat{padding:13px 15px;gap:5px}
  #page-world .ge-home-stat strong{font-size:19px}
  #gold-city-rebirth .rb-business-summary,
  #gold-city-rebirth .rb-my-metrics,
  #gold-city-rebirth .rb-industry-stats,
  #gold-city-rebirth .rb-budget-stats{
    grid-template-columns:minmax(0,1fr);
  }
  #gold-city-rebirth .rb-budget-actions{grid-template-columns:minmax(0,1fr)}
  #gold-city-rebirth .rb-my-business-row{
    grid-template-columns:36px minmax(0,1fr) minmax(50px,auto);
    gap:6px;
    padding:11px 9px;
  }
  #gold-city-rebirth .rb-my-business-copy strong{font-size:12px}
  #gold-city-rebirth .ge-business-status{font-size:9px;padding:4px 7px}
  #gold-city-rebirth .rb-my-business-value{font-size:11px}
  #finance-modal .finance-metrics,
  #enterprise-modal .enterprise-metrics{
    grid-template-columns:minmax(0,1fr);
  }
  #page-invest .ge9-metrics,
  #page-invest .ge9-company-stats,
  #page-invest .ge9-company-financial-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  #page-invest .ge9-asset-price strong{font-size:11px}
}

/* Single-column phone reading mode: touch targets do not share narrow rows. */
@media(max-width:530px){
  #page-world .ge-home-grid,
  #page-world .ge-home-stats,
  #gold-city-rebirth .rb-my-metrics,
  #gold-city-rebirth .rb-industry-stats,
  #gold-city-rebirth .rb-budget-stats,
  #gold-city-rebirth .rb-budget-actions{
    grid-template-columns:minmax(0,1fr);
    gap:9px;
  }
  #page-world .ge-home-link{
    min-height:86px;
    display:grid;
    grid-template-columns:42px minmax(0,1fr);
    align-items:center;
    gap:12px;
    padding:12px 16px;
  }
  #page-world .ge-home-link-icon{grid-column:1}
  #page-world .ge-home-link-content{grid-column:2}
  #page-world .ge-home-link-chevron{top:calc(50% - 14px);right:12px}
  #page-world .ge-home-stat{padding:13px 15px}
  #gold-city-rebirth .rb-my-metrics>div,
  #gold-city-rebirth .rb-industry-stat,
  #gold-city-rebirth .rb-budget-stat{
    min-width:0;
    padding:13px;
  }
}

@media(min-width:1050px){
  /* Original desktop sidebar is 222px wide; leave room for it. */
  .ge-ui .app-shell{
    max-width:1600px;
    margin-inline:auto;
    padding-left:275px;
    padding-right:32px;
    padding-bottom:55px;
  }
}
