/* Phone layouts override desktop positioning while preserving the desktop UI. */
#mobile-menu-tabs{display:none}
@media(max-width:700px),(max-width:950px) and (max-height:500px){
  html,body{width:100%;min-height:100%;overscroll-behavior:none}
  #world{touch-action:none}
  header{height:64px;padding:8px max(12px,env(safe-area-inset-left));gap:8px}
  .brand{font-size:16px;letter-spacing:1px;gap:6px}.brand>span{font-size:28px}.brand small{font-size:8px;letter-spacing:1px}
  .player-profile{min-width:0;padding:6px 8px;gap:0}.player-profile b{font-size:11px}.player-profile small{font-size:8px;display:block;margin-top:2px}
  .player-profile small span{display:block}.player-sigil{display:none}
  #mobile-menu-tabs{position:fixed;top:68px;left:12px;right:12px;display:grid;grid-template-columns:1fr 1fr;gap:8px;z-index:4}
  #mobile-menu-tabs button{min-height:40px;border:1px solid #9ab28c;border-radius:9px;background:#f6f8e9ef;color:#40634f;font-size:13px}
  #mobile-menu-tabs button[aria-pressed=true]{background:#3e6551;color:#fff9df}
  body.game #mobile-menu-tabs{display:none}
  body:not(.game) #menu{position:fixed;left:12px;right:12px;top:118px;bottom:max(10px,env(safe-area-inset-bottom));width:auto;transform:none;margin:0;padding:0 2px 16px;overflow-y:auto;overflow-x:hidden;scrollbar-width:none;-webkit-overflow-scrolling:touch}
  #menu h1{font-size:21px;line-height:1.3;margin:0 0 12px}#menu h1 br{display:none}
  #menu .intro,#menu .eyebrow,#menu .hint{display:none}
  #menu .select-label{font-size:12px;max-width:none}#menu .select-label span{font-size:8px}
  #maps{max-width:none;gap:6px}.map-option{min-height:52px}.map-option b{font-size:12px;white-space:nowrap}.map-option small{font-size:9px}
  #map-description{font-size:10px;margin:7px 0 12px;line-height:1.6}
  .job-category-tabs button{min-height:40px;font-size:11px;white-space:normal}
  #menu #jobs{height:204px;width:100%;max-width:none;overflow:visible}
  #menu .job-category-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}
  #menu .job{min-height:96px;padding:6px 2px}#menu .job.active{padding:5px 1px}
  #menu .job canvas{width:46px;height:46px}#menu .job strong{font-size:11px}#menu .job small{font-size:8px}
  #menu .primary{min-height:46px;margin-top:12px;max-width:none}#menu .camp-actions button,#menu .save-entry button{min-height:42px}
  body:not(.game) #character-stats{display:none}
  body:not(.game)[data-mobile-panel=camp] #menu{display:none}
  body:not(.game)[data-mobile-panel=camp] #character-stats{display:block;position:fixed;top:118px;left:12px;right:12px;width:auto;padding:10px 14px}
  #character-stats .sheet-label{font-size:10px}#character-stats .sheet-label span,#character-stats #character-mode,#character-stats .stat-footnote{display:none}
  #character-stats #character-values{grid-template-columns:repeat(4,minmax(0,1fr));margin:6px 0;gap:4px}
  #character-stats #character-values>div:nth-child(n+5){display:none}
  #character-stats #character-values dt{font-size:9px}#character-stats #character-values dd{font-size:12px}
  #character-stats #character-start{display:block;font-size:9px;line-height:1.5}
  body:not(.game) #scene-label{display:none}body:not(.game) .vignette,body:not(.game)[data-map] .vignette{background:#f2f7e533}
  .game header{height:48px}.game .brand{font-size:13px}.game .brand>span{font-size:24px}.game .brand small{font-size:7px}.game #pause{margin-left:auto;width:40px;height:40px}
  #hud{padding:58px 10px 0}.xp{top:48px}
  #hud .status{width:calc(100% - 124px);max-width:280px;min-height:85px;padding:8px;gap:6px;border-radius:10px}
  #hud-portrait{width:36px;height:36px;flex-basis:36px}.status-heading{display:block}.status-heading b{font-size:12px}.status-heading span{display:block;font-size:9px}.status-info small{white-space:normal;overflow-wrap:anywhere;font-size:9px}
  .timer{top:159px;left:12px;right:auto;transform:none;text-align:left;max-width:calc(100% - 130px)}.timer b{font-size:23px}.timer small{max-width:100%;font-size:10px;line-height:1.5}.map-chip{font-size:10px}
  .stats{top:224px;right:10px;padding:6px 10px;font-size:11px}.stats small{font-size:9px}
  #bossbar{top:248px;width:min(300px,88vw);font-size:10px;max-height:90px;overflow-y:auto}
  #combat-controls{bottom:max(10px,env(safe-area-inset-bottom));width:calc(100% - 16px)}
  #limit-panel{width:min(330px,92%);margin-bottom:7px}.limit-heading{font-size:9px;letter-spacing:1px}.limit-heading b{font-size:11px}.limit-segment{height:9px}#limit-hint{font-size:9px}
  #combat-health{width:min(320px,90vw);margin-bottom:7px}#combat-health .bar{height:12px;margin-top:4px}#combat-health small{font-size:10px}#combat-health .mp-track{height:8px}#combat-health .shield-track{height:5px}
  .combat-hotbar{grid-template-columns:repeat(12,minmax(0,1fr));gap:4px;padding:5px}
  #hud .hotkey-slot{grid-column:span 3;min-height:54px;font-size:10px;padding:16px 3px 4px;line-height:1.35;overflow-wrap:anywhere}
  #hud .hotkey-slot:nth-child(n+5){grid-column:span 2}#hud .hotkey-slot:before{font-size:11px;left:4px}
  #buff-panel{left:10px;bottom:290px;width:145px;padding:8px 10px}#buff-panel h3{font-size:10px;letter-spacing:1px}#buff-panel #item-buffs{font-size:10px;line-height:1.7}
  #hud .bottom{display:none}
  #camp-overlay,#bestiary-overlay,#save-overlay{padding:max(8px,env(safe-area-inset-top)) 8px max(8px,env(safe-area-inset-bottom));overflow:auto;overscroll-behavior:contain}
  .camp-panel,.save-panel,.bestiary-panel{min-width:0;width:100%;max-height:calc(100dvh - 20px);overflow:auto;padding:16px 12px}
  .camp-top{gap:8px}.camp-top h2{font-size:21px}.camp-top button{min-width:40px;min-height:40px}.camp-tabs{flex-wrap:wrap}.camp-tabs button{min-height:40px}
  .role-choices{grid-template-columns:repeat(2,minmax(0,1fr))}.role-choice small{font-size:10px}.role-choice{min-height:0}
  .growth-panel,.talent-tree{grid-template-columns:1fr}.tree-scope{flex-wrap:wrap;gap:6px}.role-talent-tree>article{grid-template-columns:minmax(0,1fr)}
  .equipment-stage{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.equipment-character{grid-column:1/-1;grid-row:1;min-height:260px;max-height:310px}.equipment-column button{min-height:76px}
  .equipment-layout .item-closet{grid-template-columns:1fr}.equipment-layout .item-closet>*{grid-column:1}.carry-slots{grid-template-columns:repeat(2,minmax(0,1fr))}.carry-slots select{font-size:16px;padding:8px 3px}
  .merchant-grid,.save-actions{grid-template-columns:1fr}.blank-card-row{gap:6px}.blank-card{min-width:0;overflow-wrap:anywhere}.blank-card p{font-size:10px}
  #modal{padding:10px;overflow:auto}.modal-inner{width:100%;max-height:calc(100dvh - 24px);overflow:auto;padding:16px 8px}.modal-inner h2{font-size:25px}.choices{display:grid;grid-template-columns:1fr;gap:8px;margin-top:16px}.choice{width:100%;padding:12px;min-height:74px;text-align:left}.choice em{display:inline-block;font-size:24px;margin:0 10px 0 0}.choice p{min-height:0;margin:7px 0}.modal-inner .primary{max-width:100%;min-height:44px}
}
@media(max-width:950px) and (max-height:500px){
  body:not(.game)[data-mobile-panel=camp] #character-stats{display:none}
  #mobile-menu-tabs{top:55px}header{height:52px}body:not(.game) #menu{top:105px}
  #menu h1{font-size:18px}#menu #jobs{height:186px}
  #hud{padding-top:48px}#hud .status{min-height:64px;width:220px;padding:6px}#hud-portrait{width:32px;height:32px;flex-basis:32px}.status-info small{font-size:8px}.status-heading span{display:inline;font-size:8px}
  .timer{top:49px;left:245px;max-width:260px}.timer b{font-size:21px}.stats{top:47px;right:115px}
  #combat-controls{width:min(65vw,650px);left:auto;right:10px;transform:none;bottom:8px}
  .combat-hotbar{grid-template-columns:repeat(10,minmax(0,1fr));gap:3px;padding:4px}#hud .hotkey-slot,#hud .hotkey-slot:nth-child(n+5){grid-column:auto;min-height:50px;font-size:9px}
  #limit-panel{width:280px;margin-bottom:4px}#limit-hint{font-size:8px}#combat-health{width:240px;margin-bottom:5px}#combat-health small{font-size:9px}#combat-health .bar{height:9px;margin:2px 0}
  #buff-panel{bottom:12px;width:min(170px,28vw);padding:7px}#buff-panel #item-buffs{font-size:9px;line-height:1.5}
  #bossbar{top:132px;width:270px;left:43%;max-height:60px}
}

@media(min-width:600px) and (max-width:950px) and (max-height:500px){.choices{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.choice{min-width:0;padding:12px 10px;min-height:125px}.choice b{font-size:13px}.choice p{font-size:10px;line-height:1.5}.modal-inner h2{font-size:23px}.modal-inner>p{font-size:11px}.modal-inner .eyebrow{font-size:8px}}

.upgrade-choices { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.upgrade-choices .choice { position: relative; width: 100%; min-width: 0; padding: 24px 14px; }
.upgrade-choices .choice>small:first-child { display: block; font-size: 10px; margin-bottom: 16px; }
.upgrade-choices .choice:disabled { opacity: .5; cursor: default; background: #e1e7d9; }
.upgrade-choices .choice:disabled:hover { transform: none; box-shadow: none; border-color: #e2eacb; }
.choice-key { display: block; margin-top: 14px; font-size: 11px; color: #9a8955; }
@media(max-width:700px), (max-width:950px) and (max-height:500px) {
  .upgrade-choices { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .upgrade-choices .choice { padding: 12px; min-height: 140px; }
  .upgrade-choices .choice>small:first-child { margin-bottom: 8px; }
  .upgrade-choices .choice em { margin-bottom: 8px; }
  .upgrade-choices .choice p { min-height: 0; }
  .choice-key { margin-top: 7px; }
}
