html { scroll-padding-top: env(safe-area-inset-top); }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain; }
button, .jump, .import-button { touch-action: manipulation; }
#battlefield { touch-action: none; }
#travel { touch-action: pan-x; }
#play { scroll-margin-top: env(safe-area-inset-top); }
#install-app { border: 1px solid var(--gold); color: var(--cream); background: var(--pine); }
#install-app[hidden], .install-note[hidden] { display: none !important; }
.install-note { margin: .5rem 0 0; padding: .75rem; color: var(--cream); background: var(--deep); border-left: 3px solid var(--gold); font-size: .85rem; line-height: 1.4; }

@media (pointer: coarse) {
  .match-actions button, .command-strip button, .world-controls button, .import-button { min-height: 44px; }
  .command-strip button:active, .match-actions button:active, .world-controls button:active { transform: scale(.98); }
}

@media (max-width: 700px) {
  body { padding-bottom: calc(153px + env(safe-area-inset-bottom)); background: var(--deep); }
  .site-header { padding: 8px 12px; }
  .site-header nav, .cover, .next-step { display: none; }
  .wordmark { font-size: 18px; }
  .wordmark small { font-size: 8px; }
  .sigil { width: 33px; height: 33px; font-size: 20px; }
  .match-section { padding: 0 0 24px; }
  .section-lead { display: block; margin: 0; padding: 9px 12px 10px; color: var(--cream); background: #1b3329; border-bottom: 1px solid #516750; }
  .section-lead .kicker { color: var(--gold); font-size: 8px; }
  .section-lead h2 { margin-top: 2px; font-size: 24px; line-height: 1; }
  .section-lead > p { display: none; }
  .match-layout { display: block; }
  .game-column, .command-desk { width: 100%; max-width: none; }
  .match-hud { border-inline: 0; }
  .match-hud > div { padding: 7px 9px 6px; }
  .match-hud small { font-size: 7px; letter-spacing: .08em; white-space: nowrap; }
  .match-hud strong { margin: 3px 0 5px; font-size: 21px; }
  .meter { height: 3px; }
  .match-actions { flex-wrap: nowrap; gap: 5px; min-height: 46px; padding: 5px 7px; background: #172d24; }
  .match-actions button { flex: 1 1 0; min-width: 0; min-height: 36px; padding: 5px; font-size: 10px; }
  .match-actions #start { flex: 1.4 1 0; min-width: 0; }
  .save-indicator { flex: 0 0 auto; max-width: 92px; margin-left: 1px; padding: 4px 5px; color: #e2dbb7; border-color: #586b50; font-size: 8px; letter-spacing: 0; overflow-wrap: anywhere; }
  .save-indicator::before { width: 5px; height: 5px; background: var(--gold); }
  .campaign-track { gap: 7px; min-height: 27px; padding: 4px 8px; border-inline: 0; }
  .campaign-track-label { font-size: 7px; letter-spacing: .07em; }
  .campaign-track-end { display: none; }
  .campaign-track ol { gap: 3px; }
  .campaign-track li { font-size: 8px; }
  .stage-frame { padding: 4px; border-inline: 0; }
  .stage-top, .stage-bottom { min-height: 24px; padding-inline: 6px; font-size: 8px; letter-spacing: .06em; }
  .stage-status, .stage-clock { gap: 5px; }
  .pan-hint { font-size: 7px; }
  .stage-clock-label { display: none; }
  #clock { font-size: 11px; }
  #battlefield { width: min(100%, 480px); }
  .stage-bottom { font-size: 7px; }
  .world-controls { padding: 8px 9px 9px; border-inline: 0; }
  .control-head { font-size: 9px; }
  .road-range { gap: 7px; margin: 5px 0 8px; }
  .road-range span { font-size: 7px; }
  .map-presets { gap: 5px; }
  .world-controls button { min-height: 38px; padding: 5px; font-size: 9px; }
  .command-strip { position: fixed; right: 0; bottom: 0; left: 0; z-index: 30; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-width: 1px 0 0; background: #d8d2bb; box-shadow: 0 -8px 24px #071910a6; }
  .command-strip button { min-height: 63px; padding: 6px 7px; }
  .command-num { font-size: 7px; letter-spacing: .04em; }
  .command-strip strong { margin: 3px 0 2px; font-size: clamp(13px, 3.6vw, 17px); }
  .command-strip small { font-size: 9px; }
  .command-desk { margin-top: 12px; border-inline: 0; }
  .desk-title { min-height: 145px; padding: 18px; }
  .desk-title h3 { font-size: 30px; }
  .battle-brief { padding: 12px 15px; }
  .readout, .feed { margin-inline: 15px; }
  .desk-footer { padding-inline: 15px; }
}

@media (max-width: 380px) {
  .save-indicator { max-width: 65px; }
  .pan-hint { display: none; }
  .stage-bottom { letter-spacing: 0; }
}

@media (max-height: 600px) and (orientation: landscape) and (max-width: 1100px) {
  body { padding-bottom: 0; background: var(--deep); }
  .site-header, .cover, .next-step, .section-lead { display: none; }
  .match-section { max-width: none; padding: 0 0 16px; }
  .match-layout { display: block; }
  .game-column { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(250px, .75fr); grid-template-areas: "stage hud" "stage actions" "stage campaign" "stage controls" "stage commands"; align-items: start; gap: 4px 7px; width: 100%; max-width: none; padding: 4px; }
  .stage-frame { grid-area: stage; align-self: stretch; margin: 0; padding: 4px; }
  .match-hud { grid-area: hud; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid #50624d; }
  .match-hud > div { padding: 5px; }
  .match-hud small { font-size: 7px; letter-spacing: 0; }
  .match-hud strong { margin: 2px 0 3px; font-size: 18px; }
  .match-actions { grid-area: actions; flex-wrap: nowrap; min-height: 38px; padding: 0; background: transparent; }
  .match-actions button { flex: 1 1 0; min-width: 0; min-height: 36px; padding: 3px; font-size: 9px; }
  .match-actions #start { flex: 1.3 1 0; min-width: 0; }
  .save-indicator { display: none; }
  .campaign-track { grid-area: campaign; gap: 6px; min-height: 24px; padding: 3px 6px; border: 1px solid #617356; }
  .campaign-track-label { font-size: 7px; }
  .campaign-track-end { display: none; }
  .campaign-track ol { gap: 2px; }
  .campaign-track li { padding: 2px 0; font-size: 7px; }
  .stage-top, .stage-bottom { min-height: 21px; padding: 3px 5px; font-size: 7px; }
  .stage-clock-label { display: none; }
  #battlefield { width: min(100%, calc((100svh - 58px) * .6)); }
  .world-controls { grid-area: controls; padding: 5px 7px 6px; border: 1px solid #526950; }
  .control-head { font-size: 8px; }
  .road-range { margin: 3px 0 5px; }
  .road-range span { font-size: 7px; }
  .world-controls button { min-height: 28px; padding: 2px 3px; font-size: 8px; }
  .command-strip { position: static; grid-area: commands; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; margin: 0; padding: 4px; border: 1px solid #9da78d; box-shadow: none; }
  .command-strip button { min-height: 37px; padding: 3px 6px; }
  .command-strip strong { margin: 1px 0; font-size: 12px; }
  .command-strip small { font-size: 8px; }
  .command-num { font-size: 7px; }
  .command-desk { width: 100%; max-width: none; margin: 6px 0 0; }
}

@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); }
  .cover { display: none; }
  #play { scroll-margin-top: 0; }
}
