.phoneOnly { display: none }
.phone { font-size: 15px; -webkit-text-size-adjust: 100% }
.phone body { overscroll-behavior: none }
.phone :is(button,select,summary) { touch-action: manipulation }
.phone main, .phone main.managing {
  display: flex; flex-direction: column; position: relative; isolation: isolate;
  height: 100vh; height: 100dvh; overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #152633
}
.phone main > header { min-height: 46px; flex: none; flex-wrap: nowrap; padding: 0 6px; gap: 5px; white-space: nowrap }
.phone main > header > :not(#phoneCrest,#gold,#researchButton,#clock,#pause,#phoneMenu) { display: none }
.phone main > header :is(#phoneCrest,#gold,#researchButton,#clock,#pause,#phoneMenu) { display: block }
.phone #phoneCrest { width: 23px; height: 27px; flex: none }
.phone #gold,.phone #researchButton { font-size: .86rem }
.phone #researchButton { font-weight: 600; color: #9ddbd6; padding: 0 2px; background: none; border: 0 }
.phone #clock { margin-left: auto; font-size: .8rem }
.phone main > header button { min-height: 44px; padding: 0 8px }
.phone #stage { flex: 1 1 0; width: 100%; min-height: 0; display: block; overflow: hidden }
.phone #frame { width: 100%; height: 100%; aspect-ratio: auto; box-shadow: none }
.phone #overlay { -webkit-touch-callout: none; user-select: none }
.phone main > footer, .phone #tools > :not(#fights), .phone #orderDetail { display: none }
.phone #tools { top: 7px; right: 7px; left: auto; bottom: auto; z-index: 2 }
.phone #tools:has(#fights[hidden]) { display: none }
.phone #tools #fights { min-height:44px; padding: 0 12px; font-size: .9rem }
.phone #phoneDock { flex: none; display: grid; grid-template-columns: repeat(4,1fr); gap: 1px; border-top: 1px solid #8a774e; background: #263c46 }
.phone #phoneDock button { min-height: 47px; padding: 0 3px; border: 0; border-radius: 0; font-size: .88rem; background: #172936 }
.phone #phoneDock button:active { background: #334753 }
.phone #phoneCard { position: absolute; inset: auto 7px 7px; padding: 7px 9px 9px; display: grid; gap: 7px; border: 1px solid #9e8757;
  border-top: 2px solid #e5c178; border-radius: 5px; background: linear-gradient(115deg,#253a46fa,#142632fa 74%); box-shadow: 0 3px 12px #07141ba3 }
.phone .phoneSelection { display: flex; align-items: center; gap: 8px; min-width: 0 }
.phone .phoneSelection > div { flex: 1; min-width: 0 }
.phone .phoneSelection strong,.phone .phoneSelection small { display: block; line-height: 1.2 }
.phone .phoneSelection strong { font: bold 1.18rem/1.12 Georgia,serif; color: #ffe5a8 }
.phone .phoneSelection small { margin-top: 3px; color: #d0d9d7; font-size: .84rem }
.phone .phoneMark { color: var(--tint); font: 1.45rem Georgia }
.phone .phoneSelection button { min-width: 44px; min-height: 44px; padding: 0; background: none; border: 0; color: #e7cea0 }
.phone .phoneActions { display: flex; gap: 5px }
.phone .phoneActions > button { flex: 1; min-width: 0; min-height: 44px; padding: .2rem; font-size: .89rem; white-space: normal }
.phone .phoneActions > .primary { font: bold 1rem Georgia,serif }
.phone main aside { display: none; position: absolute; z-index: 4; inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); border: 0; }
.phone main[data-phone-sheet]:not([data-phone-sheet=""]) aside { display: flex }
.phone #phonePaneBar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none; padding: 3px 10px; border-bottom: 1px solid #9e8757; background: #263947 }
.phone #phonePaneBar b { font: bold 1.15rem Georgia; color: var(--gold) }
.phone #phonePaneBar button,.phone #panel button,.phone #companyList button,.phone dialog button { min-height: 44px }
.phone #panelScroll,.phone .cityScroll,.phone #companyList,.phone dialog { overscroll-behavior: contain }
.phone main:not([data-phone-sheet="armies"]) #armyDock,.phone main[data-phone-sheet="armies"] #panelScroll { display: none }
.phone main[data-phone-sheet="armies"] #armyDock { max-height: none; flex: 1 }
.phone #armyToggle { display: none }
.phone .marchSelection .orderUnit { grid-template-columns: 44px minmax(0,1fr) 44px auto 44px }
.phone #panel .orderUnit .marchToggle { width: 44px }
.phone #panel .orderUnit .marchStep { width: 44px }
.phone .marchUnit .compactStats { flex-wrap: wrap }
.phone .marchHint { display: none }
.phone #commandAim { top: 5px; left: 5px; right: 5px; bottom: auto; max-width: none }
.phone #phoneHeroAim { position:absolute; inset:5px 5px auto; display:flex; align-items:center; justify-content:space-between; gap:8px; background:#192d3a; padding:4px 8px; border:1px solid #9e8757 }
.phone #phoneHeroAim button { min-height:44px }
.phone #phoneLandscape { position:absolute; z-index:1; top:8px; left:8px; display:flex; align-items:center; gap:8px; min-height:44px; padding:0 12px; font-size:.86rem; background:#172936f2; color:#fff0cc; border:1px solid #8b7956; border-radius:4px }
.phone #phoneLandscape span { width:18px; height:12px; border:2px solid #dbc391; border-right-width:4px; border-radius:3px }
.phone #rotationGuide { display:grid; gap:.9rem }
.phone #rotationGuide p { margin:0 }
.phone #rotationGuide b { display:block; color:var(--gold); margin-bottom:.2rem }
@media (orientation: landscape) { .phone #phoneLandscape { display:none } }
.phone #theater { z-index: 2; padding: 5px }
.phone #theater button { min-height: 44px }
.phone #theater #scene { width: min(100cqw,calc((100cqh - 6.8rem)*1.777)); height: auto }
.phone #phoneAtlas { width: 100%; height: auto; cursor: crosshair; touch-action: manipulation; border: 1px solid #9a865c }
.phone dialog { width: min(100vw,58rem); max-width: 100%; max-height: 100dvh; padding: max(.65rem,env(safe-area-inset-top)) max(.65rem,env(safe-area-inset-right)) max(.65rem,env(safe-area-inset-bottom)) max(.65rem,env(safe-area-inset-left)); margin: auto; overflow: auto }
.phone #sheet { min-width: 0; overflow-wrap: anywhere }
.phone #sheet > .row:first-child { top: -.65rem }
.phone .phoneMenu { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem }
.phone #titleScreen { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left) }
.phone #titleBox { width: min(95%,55rem) }
.phone #titleBox button,.phone #titleBox select { min-height: 44px }
.phone #choices { gap: 3px }
.phone .house strong { white-space: normal; overflow-wrap: anywhere }
.phone #lessonCoach { padding: .35rem .5rem; flex-wrap: wrap; gap: .35rem; flex: none }
.phone #lessonCoach .lessonPortrait { display: none }
.phone #lessonCoach .lessonCopy { flex: 1 1 220px }
.phone #lessonCoach .lessonCopy p { font-size: .8rem }
.phone #chapterHud,.phone #challengeHud { flex: none }
@media (orientation: landscape) {
  .phone main, .phone main.managing {
    --hud-edge: clamp(20px,6dvh,26px);
    --hud-top: max(var(--hud-edge),env(safe-area-inset-top));
    --hud-bottom: max(var(--hud-edge),env(safe-area-inset-bottom));
    position: fixed; inset: var(--phone-visible-top,0px) 0 auto;
    height: var(--phone-visible-height,100dvh); padding-block: 0;
  }
  .phone main > header { padding-top: var(--hud-top) }
  .phone #phoneCard { inset: auto 8px var(--hud-bottom) auto; width: clamp(250px,36%,364px); gap: 3px; padding: 3px 7px 5px }
  .phone #phoneDock { position: absolute; bottom: var(--hud-bottom); left: max(8px,env(safe-area-inset-left)); grid-template-columns: repeat(4,auto); border: 1px solid #8a774e; border-radius: 4px; overflow: hidden }
  .phone #phoneDock button { padding: 0 clamp(4px,1vw,8px); min-height: 44px }
  .phone main aside { top: var(--hud-top); bottom: var(--hud-bottom) }
  .phone #theater { padding-bottom: var(--hud-bottom) }
  .phone #titleBox { padding-block: 4px }
}
@media (orientation: portrait) {
  .phone .modeChoices:has(#challenges) { grid-template-columns: 1fr 1fr; gap: 7px }
  .phone .modeChoices .modeCard { display: flex; align-items: stretch; flex-direction: column; }
  .phone .modeCard canvas { width: 100%; height: auto; aspect-ratio: 2; border: 0; border-bottom: 1px solid #89764e }
  .phone .modeCard strong { font-size: 1.13rem; padding: .48rem .5rem .18rem }
  .phone .modeCard small { padding: 0 .5rem .5rem; font-size: .8rem }
  .phone #challengePicker { grid-template-columns: 1fr }
  .phone #trial { height: 100dvh; overflow: auto; display: flex; flex-direction: column }
  .phone #trial header { order: -2 }
  .phone #trial #arena { order: -1; container-type: inline-size; padding: 8px; flex: none }
  .phone #trial #duel { width: 96%; height: auto }
  .phone #trial .wing { overflow: visible; flex: none }
  .phone #trial button { min-height: 44px }
}
