/* A small test label and readable enemy traits. The existing integrated UI,
   camera, geometry and all 44px interaction targets remain in charge. */
body[data-td-v1] #build-version { color:#795534; font-weight:700; }
body[data-td-v1] .prototype-label { color:#835829; }
/* Dense V1 routes leave less unused terrain than the GB21 layouts. The dock
   caption and explicit touch Preview / Build instructions already teach this
   action; a second floating helper must not cover a road or the resource HUD. */
body[data-td-v1] #first-build-help { display:none!important; }
body[data-td-v1] .settings-card .v1-test-note {
  display:block; margin:0; padding:6px 0; color:#6a573e; font-size:11px; line-height:1.4;
  overflow-wrap:anywhere;
}
body[data-td-v1] .forecast-enemy { overflow-wrap:anywhere; }
body[data-td-v1] .forecast-enemy[data-enemy='bastion'] { border-left:3px solid #c4a55f; padding-left:7px; }
body[data-td-v1] .forecast-enemy[data-enemy='wing'] { border-left:3px solid #a983c4; padding-left:7px; }
body[data-td-v1] .forecast-enemy[data-enemy='boss'] { border-left:3px solid #d17559; padding-left:7px; }
body[data-td-v1] .enemy-card[data-enemy='boss'] .enemy-count { color:#a14732; font-weight:800; }
body[data-td-v1] .forecast-details { max-width:calc(100% - 12px); }
body[data-td-v1] .forecast-heading { align-items:flex-start; }
body[data-td-v1] .forecast-heading>strong { min-width:0; overflow-wrap:anywhere; }
body[data-td-v1] #close-forecast { flex:none; min-width:44px; min-height:44px; }
@media (prefers-reduced-motion:reduce) {
  body[data-td-v1] #start-wave[data-ready='true'] { animation:none; }
}

/* Camera controls are optional settings, never a permanent action slot. */
body[data-td-v1] #view-toggle { display:none!important; }

/* Tower controls retain a stable dock; scene information does not reserve
   a header strip or shrink the battlefield. */
body[data-td-v1] .game-shell[data-side-controls="false"] {
  --v1-dock-height:78px;
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] {
  --v1-dock-height:116px;
}
body[data-td-v1] .game-shell[data-side-controls="false"] .battle-region {
  top:var(--safe-top);
  bottom:calc(var(--safe-bottom) + var(--v1-dock-height));
  left:var(--safe-left); right:var(--safe-right);
}
body[data-td-v1] .v1-status-bar {
  pointer-events:auto; min-width:0; background:none;
}
body[data-td-v1] .game-shell[data-side-controls="false"] .v1-status-bar {
  display:none;
}
body[data-td-v1] .game-shell .map-heading strong {
  overflow:hidden; text-overflow:ellipsis;
}
body[data-td-v1] .game-shell[data-side-controls="false"] .game-dock {
  position:absolute; top:auto; left:calc(var(--safe-left) + 6px); right:calc(var(--safe-right) + 6px);
  bottom:var(--safe-bottom); width:auto; max-width:none;
  height:var(--v1-dock-height); min-height:var(--v1-dock-height);
  margin:0; padding:9px; transform:none; border-radius:11px;
}
body[data-td-v1] .game-shell[data-side-controls="false"][data-selected-tower="true"] .game-dock {
  height:calc(var(--v1-dock-height) + 48px);
  min-height:calc(var(--v1-dock-height) + 48px);
}
body[data-td-v1] .game-shell[data-side-controls="false"] .dock-row {
  height:100%; min-height:0; align-items:flex-end; justify-content:flex-start;
  flex-direction:row; gap:8px;
}
body[data-td-v1] .game-shell[data-side-controls="false"] #shop-inline {
  flex:1; width:auto; height:60px; min-width:0; margin:0;
}
body[data-td-v1] .game-shell[data-side-controls="false"][data-selected-tower="true"] #shop-inline {
  height:108px;
}
body[data-td-v1] .game-shell[data-side-controls="false"] #tower-shop {
  margin-top:0; height:60px;
}
body[data-td-v1] .game-shell #dock-help {
  display:none!important;
}
body[data-td-v1] .game-shell #tower-panel {
  position:static; inset:auto; width:100%; max-width:none; max-height:none;
  margin:0; padding:0; border:0; border-radius:0; background:none;
  box-shadow:none; transform:none;
}
body[data-td-v1] .game-shell .selected-info {
  position:relative; inset:auto; width:100%; max-width:none;
  min-height:44px; height:44px; margin:0 0 4px; padding:0 5px;
  border:0; border-radius:6px; box-shadow:none; transform:none;
  background:#f8f1d8;
}
body[data-td-v1] .game-shell .selected-info .panel-heading {
  min-height:44px; height:44px; margin:0; gap:5px;
}
body[data-td-v1] .game-shell .selected-info .panel-heading strong {
  font-size:12px; line-height:15px; overflow:hidden; text-overflow:ellipsis;
}
body[data-td-v1] .game-shell .selected-info .panel-heading canvas {
  display:block; width:28px; height:28px;
}
body[data-td-v1] .game-shell .selected-values {
  display:flex; flex-wrap:wrap; gap:0 7px; margin:0;
  font-size:11px; line-height:14px;
}
body[data-td-v1] .game-shell .selected-values b {
  font-size:12px; line-height:14px;
}
body[data-td-v1] .game-shell #close-tower-panel {
  width:64px; min-width:64px; height:44px; min-height:44px; margin:0;
  padding:0 4px; flex:0 0 64px; gap:3px; font-size:12px; line-height:16px; font-weight:700;
}
body[data-td-v1] .game-shell #close-tower-panel .cancel-symbol {
  flex:none; font-size:16px; line-height:18px;
}
body[data-td-v1] .game-shell #remove-tower #remove-icon {
  display:none;
}
body[data-td-v1] .game-shell #remove-tower .remove-label {
  display:inline-flex; align-items:center; justify-content:center; gap:3px;
  font-size:12px; line-height:16px; font-weight:700; white-space:nowrap;
}
body[data-td-v1] .game-shell #remove-tower .sell-coin {
  width:13px; height:13px; flex:none;
}
body[data-td-v1] .game-shell .branch-copy strong,
body[data-td-v1] .game-shell .tower-copy strong {
  max-width:100%; white-space:normal; overflow-wrap:normal;
}
body[data-td-v1] .game-shell #range-detail,
body[data-td-v1] .game-shell .branch-stats,
body[data-td-v1] .game-shell .branch-afford {
  max-width:100%; white-space:normal; overflow-wrap:normal;
}
body[data-td-v1] .game-shell #range-detail>span { display:block; }
/* Purchased already appears in the copy; avoid a second status squeezing it. */
body[data-td-v1] .game-shell #range-upgrade[data-purchased="true"] #range-price {
  display:none;
}
body[data-td-v1] .game-shell #range-afford {
  display:block; max-width:100%; font-size:10px; line-height:13px;
  color:#8d3c28; font-weight:700; white-space:normal;
}
body[data-td-v1] .game-shell[data-side-controls="false"] .play-controls {
  flex:none; width:auto; height:44px; margin:0; gap:4px;
}

/* Portrait keeps the direct tower and upgrade controls in the same slot. */
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] .game-dock {
  padding:2px 6px;
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"][data-selected-tower="true"] .game-dock {
  height:calc(var(--v1-dock-height) + 70px);
  min-height:calc(var(--v1-dock-height) + 70px);
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] .dock-row {
  flex-direction:column; align-items:stretch; gap:4px;
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] #shop-inline {
  flex:none; width:100%; height:64px;
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"][data-selected-tower="true"] #shop-inline {
  height:134px;
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] #tower-shop {
  margin-top:0; height:64px;
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] .tower-button {
  height:64px; min-height:64px;
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] #branches {
  height:86px; gap:4px;
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] .branch-button,
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] #range-upgrade {
  height:86px; min-height:86px;
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] .play-controls {
  width:100%;
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] .branch-copy strong .branch-full-name {
  white-space:normal;
}
@media(max-width:345px) {
  body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] .play-controls {
    gap:3px;
  }
  body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] #remove-tower {
    width:44px; min-width:44px;
  }
  body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"][data-selected-tower="true"] #start-wave,
  body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] .play-controls:has(#cancel-placement:not([hidden])) #start-wave {
    flex-direction:column; gap:0;
  }
  body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"][data-selected-tower="true"] .start-icon,
  body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] .play-controls:has(#cancel-placement:not([hidden])) .start-icon {
    font-size:14px; line-height:16px; height:16px;
  }
  body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"][data-selected-tower="true"] .wave-button-label,
  body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] .play-controls:has(#cancel-placement:not([hidden])) .wave-button-label {
    font-size:11px; line-height:14px;
  }
}
@media(max-width:300px) {
  body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] .branch-copy strong .branch-full-name {
    display:none;
  }
  body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] .branch-copy strong .branch-short-name {
    display:block; font-size:inherit; line-height:inherit; color:inherit;
  }
}

/* A cohesive landscape rail: tower actions above fixed game controls. */
body[data-td-v1] .control-icon,body[data-td-v1] .menu-label { display:none; }
/* Phone landscape: a single fixed rail; selection never changes its budget. */
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .battle-region {
  top:var(--safe-top); bottom:var(--safe-bottom); left:var(--safe-left); right:calc(192px + var(--safe-right));
}
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .control-rail {
  width:192px; padding:4px; gap:4px; overflow:visible; border:0;
  background:linear-gradient(#f7efd5,#e5ddb9); box-shadow:inset 1px 0 #acb587; pointer-events:auto;
}
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .v1-status-bar {
  position:relative; inset:auto; display:flex; flex-direction:column; flex:none;
  width:100%; height:auto; min-height:0; padding:0; gap:4px; background:none; pointer-events:auto;
}
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .hud[data-control-layout="rail"] {
  display:grid; position:relative; inset:auto; width:100%; height:46px; min-height:46px;
  grid-template-columns:.8fr 1fr 1.2fr; grid-template-rows:16px 22px; gap:2px;
  margin:0; padding:2px 3px; transform:none; pointer-events:none;
}
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .map-heading { display:block; grid-column:1/-1; grid-row:1; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .hud-item { grid-row:2; gap:2px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] :is(.resource-label,#phase) { display:none; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .resource-copy :is(#lives,#gold) { font-size:17px; line-height:22px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .resource-copy #wave { font-size:14px; line-height:22px; white-space:nowrap; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .wave-forecast {
  display:flex; position:relative; inset:auto; margin:0; height:44px; min-height:44px; padding:2px 3px;
}
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .wave-forecast #wave-preview { flex:1; gap:0 3px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .enemy-card { min-height:18px; height:18px; gap:2px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .enemy-icon { width:18px; height:18px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .enemy-count { font-size:11px; line-height:14px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .game-dock {
  flex:1; height:auto; min-height:0; padding:0; margin:0; border:0; outline:0;
  border-radius:0; background:none; box-shadow:none; pointer-events:auto;
}
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .dock-row {
  height:100%; min-height:0; justify-content:flex-end; flex-direction:column; align-items:stretch; gap:4px;
}
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #shop-inline { flex:1; display:flex; flex-direction:column; width:100%; height:auto; min-height:100px; margin:0; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #tower-shop {
  grid-template-columns:repeat(3,minmax(0,1fr)); grid-template-rows:repeat(2,minmax(48px,1fr)); height:100%; flex:1; gap:4px;
}
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .tower-button {
  display:flex; flex-direction:column; justify-content:center; align-items:center;
  grid-column:auto; min-height:48px; height:100%; padding:0; gap:0; text-align:center;
}
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .tower-icon { width:20px; height:20px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .tower-copy { text-align:center; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .tower-copy strong,
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .tower-price { font-size:11px; line-height:12px; white-space:nowrap; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #tower-panel { display:flex; flex:1; flex-direction:column; gap:4px; min-height:144px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .selected-info { height:28px; min-height:28px; margin:0; padding:0; background:none; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .selected-info .panel-heading { height:28px; min-height:28px; gap:4px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .selected-info .panel-heading canvas { display:block; width:24px; height:24px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .selected-info .panel-heading strong { font-size:11px; line-height:13px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .selected-values { flex-wrap:nowrap; font-size:9px; line-height:12px; gap:0 4px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .selected-values b { font-size:10px; line-height:12px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #branches { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); flex:1; height:auto; min-height:64px; gap:4px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .branch-button { display:grid; grid-template-columns:26px minmax(0,1fr); grid-template-rows:13px 13px 12px 12px; align-content:center; align-items:center; height:100%; min-height:64px; padding:3px; gap:0 3px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .upgrade-preview { display:block; grid-column:1; grid-row:1/span 2; width:26px; height:26px; margin:0; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] :is(.branch-copy,.branch-copy strong) { display:contents; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] :is(.branch-copy .branch-full-name,.branch-role,.branch-full-reason) { display:none; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .branch-copy .branch-short-name { display:block; grid-column:2; grid-row:1; font-size:11px; line-height:12px; color:#314334; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .branch-copy .branch-price { grid-column:2; grid-row:2; font-size:10px; line-height:12px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .branch-stats { grid-column:1/-1; grid-row:3; font-size:10px; line-height:12px; white-space:nowrap; text-align:center; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .branch-afford { grid-column:1/-1; grid-row:4; font-size:10px; line-height:12px; text-align:center; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] :is(.branch-afford[data-state="ready"],.branch-afford[data-state="chosen"]) { visibility:hidden; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .branch-short-reason { display:block; font:inherit; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #tower-utilities { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px; height:44px; min-height:44px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #tower-utilities :is(#range-upgrade,#remove-tower,#close-tower-panel) { position:relative; width:100%; min-width:44px; height:44px; min-height:44px; margin:0; padding:2px; flex:none; pointer-events:auto; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #tower-utilities #range-upgrade { display:grid; grid-template-columns:18px minmax(0,1fr); grid-template-rows:16px 12px 12px; align-content:center; padding:1px; gap:0; font-size:10px; line-height:12px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #range-icon { display:block; width:16px; height:16px; grid-row:1; grid-column:1; justify-self:end; margin-right:2px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .range-copy { display:contents; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #range-upgrade .range-copy strong { grid-row:1; grid-column:2; font-size:10px; line-height:12px; text-align:left; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .range-name-prefix { display:none; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #tower-utilities #range-detail { grid-row:2; grid-column:1; justify-self:start; font-size:10px; line-height:12px; white-space:nowrap; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #tower-utilities #range-price { grid-row:2; grid-column:2; justify-self:end; font-size:10px; line-height:12px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #range-afford { grid-row:3; grid-column:1/-1; font-size:10px; line-height:12px; white-space:nowrap; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #range-upgrade[data-purchased="true"] #range-detail { grid-column:1/-1; font-size:9px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #tower-utilities #close-tower-panel { flex-direction:column; gap:0; font-size:11px; line-height:13px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #tower-utilities #close-tower-panel .cancel-symbol { font-size:17px; line-height:17px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #tower-utilities #remove-tower { background:#f1dfbd; border-color:#b99c71; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .play-controls {
  display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); grid-template-rows:44px 44px;
  width:100%; height:92px; min-height:92px; margin:0; gap:4px; flex:none;
}
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .play-controls>button,
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .play-controls>.settings-menu,
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #tower-shop>#cancel-placement {
  position:relative; inset:auto; width:100%; min-width:44px; height:44px; min-height:44px;
  margin:0; padding:1px; font-size:11px; line-height:13px; white-space:normal;
}
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .settings-menu summary { width:100%; min-width:44px; height:44px; min-height:44px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .play-controls>.settings-menu { padding:0; grid-column:3; grid-row:2; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #start-wave { grid-column:1/span 2; grid-row:1; gap:3px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #pause { grid-column:3; grid-row:1; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #speed { grid-column:1; grid-row:2; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #maps { grid-column:2; grid-row:2; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #tower-shop>#cancel-placement { grid-column:3; grid-row:2; height:100%; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .start-icon { font-size:12px; line-height:16px; height:16px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .wave-button-label { font-size:11px; line-height:13px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #pause,body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #speed,body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #maps { width:100%; min-width:44px; flex-direction:column; gap:0; font-size:11px; line-height:13px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .control-icon { display:block; width:16px; height:16px; flex:none; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #pause .resume-symbol,body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #pause[data-paused="true"] .pause-symbol { display:none; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #pause[data-paused="true"] .resume-symbol { display:block; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .settings-menu summary { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:0; font-size:18px; line-height:18px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] .menu-label { display:block; font-size:10px; line-height:13px; }
/* Short landscape retains artwork and44px controls. The next-wave card
   folds only while selecting a tower when the usable height is below304px. */
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] :is(.control-rail,.v1-status-bar,.dock-row) { gap:2px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] .control-rail { padding:2px 4px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] .hud[data-control-layout="rail"] {
  height:24px; min-height:24px; grid-template-rows:20px; padding:1px 3px; gap:0 2px;
}
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] .map-heading { display:none; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] .hud-item { grid-row:1; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] .resource-copy :is(#lives,#gold) { font-size:16px; line-height:20px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] .resource-copy #wave { font-size:14px; line-height:20px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] #tower-shop { grid-template-rows:repeat(2,minmax(44px,1fr)); height:100%; min-height:90px; gap:2px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] .tower-button { height:100%; min-height:44px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] .tower-icon { width:18px; height:18px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] .selected-info { margin-bottom:0; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] :is(#branches,.branch-button) { height:auto; min-height:58px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] .play-controls { height:90px; min-height:90px; gap:2px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] #shop-inline { min-height:90px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] #tower-panel { min-height:134px; gap:2px; }
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-compact-rail="true"] :is(#branches,#tower-utilities) { gap:2px; }
/* The exceptionally short selected panel follows GB21: preview stays in
   Settings until selection closes; resource totals remain visible. */
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"][data-tiny-rail="true"][data-selected-tower="true"] .wave-forecast { display:none; }
/* No instruction strip floats over the battlefield. Landscape selection is
   announced accessibly; Build/Cancel and placement failures stay by the ghost. */
body[data-td-v1] .game-shell[data-layout-device="landscape"][data-side-controls="true"] #placement-panel {
  position:absolute; width:1px; height:1px; min-height:0; margin:-1px; padding:0;
  overflow:hidden; clip-path:inset(50%); border:0;
}
/* Portrait uses20px inside the existing64px shop row for the brief hint. */
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] #shop-inline { position:relative; }
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] #placement-panel {
  position:absolute; left:0; right:0; top:auto; bottom:0; width:100%; max-width:none;
  height:18px; min-height:18px; padding:0 3px; margin:0; border:0; border-radius:0;
  box-shadow:none; background:none; font-size:11px; line-height:18px; white-space:nowrap;
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"] #placement-title { display:none; }
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"][data-awaiting-ground="true"] #tower-shop { height:44px; grid-template-rows:44px; }
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"][data-awaiting-ground="true"] .tower-button { height:44px; min-height:44px; padding:0; gap:0; }
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"][data-awaiting-ground="true"] .tower-icon { width:16px; height:16px; }
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"][data-awaiting-ground="true"] :is(.tower-copy strong,.tower-price) { font-size:11px; line-height:12px; }

/* Fixed-size scene cards let the presentation planner find and retain a safe
   anchor. Their content cannot resize the card when gold or a wave changes. */
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"] {
  position:absolute; z-index:5; top:4px; left:4px; right:auto; bottom:auto;
  display:grid; grid-template-columns:repeat(2,minmax(0,1fr));
  grid-template-rows:16px 24px 22px; gap:2px 4px; align-content:center;
  width:164px; max-width:none; height:76px; min-height:76px;
  margin:0; padding:4px 6px; border:1px solid #96a977; border-radius:9px;
  background:linear-gradient(#426b51f5,#2f5141f5); color:#fff7db;
  box-shadow:0 2px 5px #263e2922; transform:none; pointer-events:none;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"] .map-heading {
  display:block; grid-column:1/-1; grid-row:1; align-self:center;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"] .map-heading strong {
  display:block; font-size:12px; line-height:16px; white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"] .hud-item {
  grid-row:2; grid-column:auto; flex:none; gap:3px; align-self:center;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"] .hud-item:nth-of-type(4) {
  grid-column:1/-1; grid-row:3;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"] .resource-icon {
  width:16px; height:16px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"] .resource-label {
  position:absolute; width:1px; height:1px; margin:-1px; padding:0; border:0;
  overflow:hidden; clip:rect(0,0,0,0); clip-path:inset(50%);
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"] .resource-copy #lives {
  font-size:20px; line-height:24px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"] .resource-copy #gold {
  font-size:18px; line-height:24px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"] .resource-copy #wave {
  font-size:16px; line-height:22px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"] {
  position:absolute; z-index:5; top:84px; left:4px; right:auto; bottom:auto;
  display:flex; align-items:center; gap:4px;
  width:196px; max-width:none; height:52px; min-height:52px;
  margin:0; padding:4px 6px; border:1px solid #96a977; border-radius:9px;
  background:#f8f1d8f2; box-shadow:0 2px 5px #263e2922;
  transform:none; pointer-events:auto;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"] #wave-label {
  flex:none; width:46px; max-width:none; font-size:10px; line-height:14px; white-space:nowrap;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"] #wave-preview {
  flex:1; display:flex; flex-wrap:wrap; gap:0 3px; min-width:0;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"] .enemy-card {
  flex:none; min-height:18px; height:18px; gap:2px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"] .enemy-icon {
  width:18px; height:18px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"] .enemy-name {
  display:none;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"] .enemy-count {
  font-size:12px; line-height:16px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"] .forecast-open-icon {
  flex:none; font-size:16px; line-height:20px;
}
/* Compact scene cards are selected once for a map/format, never by a changing
   balance. Unequal value columns leave room for a five-digit gold amount. */
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"]) {
  width:128px; height:44px; min-height:44px; padding:1px 4px;
  grid-template-columns:40px minmax(0,1fr); grid-template-rows:20px 20px;
  gap:0 4px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"])>.map-heading {
  display:none;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"])>.hud-item {
  grid-area:auto; position:static; gap:2px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"])>.hud-item:nth-child(2) {
  grid-column:1; grid-row:1;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"])>.hud-item:nth-child(3) {
  grid-column:2; grid-row:1;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"])>.hud-item:nth-child(4) {
  grid-column:1/-1; grid-row:2;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"]) .resource-icon {
  width:14px; height:14px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"]) .resource-copy #lives {
  font-size:18px; line-height:20px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"]) .resource-copy #gold {
  font-size:16px; line-height:20px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"]) .resource-copy #wave {
  font-size:16px; line-height:20px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"]) {
  display:grid; grid-template-columns:minmax(0,1fr) 14px;
  grid-template-rows:10px 28px; align-content:center; gap:2px 0;
  width:124px; height:44px; min-height:44px; padding:0 5px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"]) #wave-label {
  grid-column:1; grid-row:1; width:auto; max-width:none; font-size:10px; line-height:10px;
  white-space:nowrap;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"]) #wave-preview {
  grid-column:1/-1; grid-row:2; display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:14px 14px;
  height:28px; gap:0 2px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"]) .enemy-card {
  min-height:14px; height:14px; gap:0;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"]) .enemy-icon {
  width:14px; height:14px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"]) .enemy-count {
  font-size:10px; line-height:14px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"]) .enemy-count::before {
  font-size:10px; margin-right:0;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"]:is([data-scene-shape="compact"],[data-scene-shape="slim"],[data-scene-shape="narrow"]) .forecast-open-icon {
  grid-column:2; grid-row:1; font-size:12px; line-height:10px;
}
/* A narrow scene fallback keeps the same readable values and 44px target,
   using vertical cards before any full-width information budget is needed. */
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="slim"],[data-scene-shape="narrow"]) {
  width:96px; height:60px; min-height:60px; padding:0 4px; border:0;
  grid-template-columns:minmax(0,1fr); grid-template-rows:20px 20px 20px;
  gap:0; box-shadow:inset 0 0 0 1px #96a977,0 2px 5px #263e2922;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="slim"],[data-scene-shape="narrow"])>.hud-item:nth-child(3) {
  grid-column:1; grid-row:2;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="slim"],[data-scene-shape="narrow"])>.hud-item:nth-child(4) {
  grid-column:1; grid-row:3;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"]:is([data-scene-shape="slim"],[data-scene-shape="narrow"]) .resource-copy #lives {
  font-size:16px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"]:is([data-scene-shape="slim"],[data-scene-shape="narrow"]) {
  width:96px; height:60px; min-height:60px; padding:2px 5px;
  grid-template-rows:10px 28px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] :is(.hud,.wave-forecast)[data-control-layout="scene"][data-scene-shape="narrow"] {
  width:76px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .hud[data-control-layout="scene"][data-scene-shape="narrow"] {
  padding:0 1px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-control-layout="scene"][data-scene-shape="narrow"] {
  padding-right:1px; padding-left:1px;
}
body[data-td-v1] .v1-status-bar:empty { display:none; }
body[data-td-v1] .game-shell .scene-status-fallback {
  display:flex; flex-wrap:wrap; align-items:center; gap:2px 8px;
  width:100%; height:auto; min-height:0; margin:0 0 4px;
  padding:0; border-radius:6px; background:none;
  color:#344e39; font-size:12px; line-height:16px;
}
body[data-td-v1] .game-shell .scene-status-fallback strong {
  font-size:16px; line-height:20px; font-variant-numeric:tabular-nums;
}
body[data-td-v1] .game-shell[data-side-controls="false"][data-scene-fallback="true"] {
  --v1-dock-height:158px;
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"][data-scene-fallback="true"] {
  --v1-dock-height:196px;
}
/* If no readable card fits on a very small battlefield, the reserved rail
   must grow with upgrades instead of pulling its information over the road. */
body[data-td-v1] .game-shell[data-side-controls="false"][data-scene-fallback="true"][data-selected-tower="true"] .battle-region {
  bottom:calc(var(--safe-bottom) + var(--v1-dock-height) + 48px);
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"][data-scene-fallback="true"][data-selected-tower="true"] .battle-region {
  bottom:calc(var(--safe-bottom) + var(--v1-dock-height) + 70px);
}
body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"][data-scene-fallback="true"] .game-dock {
  padding-left:4px; padding-right:4px;
}
body[data-td-v1] .game-shell[data-side-controls="false"][data-scene-fallback="true"] .scene-status-fallback {
  flex-wrap:nowrap; gap:4px; height:76px; min-height:76px;
}
body[data-td-v1] .game-shell[data-side-controls="false"][data-scene-fallback="true"] .dock-row {
  height:calc(100% - 80px);
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .hud {
  position:relative; inset:auto; flex:1; min-width:132px; width:132px;
  max-width:none; height:76px; min-height:76px; margin:0; padding:4px 5px;
  display:grid; grid-template-columns:repeat(2,minmax(0,1fr));
  grid-template-rows:16px 24px 22px; gap:2px 4px; align-content:center;
  transform:none; box-shadow:none; pointer-events:none;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .hud>.map-heading {
  display:block; grid-column:1/-1; grid-row:1;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .map-heading strong {
  font-size:11px; line-height:16px; white-space:nowrap;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .hud>.hud-item {
  grid-area:auto; position:static; flex:none; gap:2px;
  align-self:center; min-width:0;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .hud>.hud-item:nth-child(2) {
  grid-column:1; grid-row:2;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .hud>.hud-item:nth-child(3) {
  grid-column:2; grid-row:2;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .hud>.hud-item:nth-child(4) {
  grid-column:1/-1; grid-row:3;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .resource-label {
  position:absolute; width:1px; height:1px; margin:-1px; padding:0; border:0;
  overflow:hidden; clip:rect(0,0,0,0); clip-path:inset(50%);
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .resource-icon {
  width:14px; height:14px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .resource-copy :is(#lives,#gold) {
  font-size:16px; line-height:24px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .resource-copy #wave {
  font-size:14px; line-height:22px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .wave-forecast {
  position:relative; inset:auto; flex:1; min-width:44px; width:auto;
  display:grid; grid-template-columns:minmax(0,1fr) 14px;
  grid-template-rows:10px 36px; align-content:center; gap:2px 0;
  max-width:none; height:52px; min-height:52px; margin:0; padding:1px 5px;
  transform:none; box-shadow:none;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .wave-forecast #wave-label {
  grid-column:1; grid-row:1; width:auto; max-width:none;
  font-size:10px; line-height:10px; white-space:nowrap;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .wave-forecast #wave-preview {
  grid-column:1/-1; grid-row:2; display:grid; min-width:0;
  grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:18px 18px;
  height:36px; gap:0 3px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .wave-forecast .forecast-open-icon {
  grid-column:2; grid-row:1; font-size:12px; line-height:10px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .enemy-card {
  min-height:18px; height:18px; gap:2px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .enemy-icon {
  width:18px; height:18px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .enemy-name {
  display:none;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .enemy-count {
  font-size:11px; line-height:16px;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] :is(.hud,.wave-forecast)[data-occluded="true"] {
  visibility:hidden; pointer-events:none;
}
body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .wave-forecast[data-pass-through="true"] {
  pointer-events:none;
}
@media(max-width:300px) {
  body[data-td-v1] .game-shell[data-layout-device="portrait"][data-side-controls="false"][data-scene-fallback="true"] .game-dock {
    padding-left:2px; padding-right:2px;
  }
  body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .hud {
    flex:none; width:96px; min-width:96px; padding:2px 5px;
    grid-template-columns:1fr; grid-template-rows:22px 22px 22px;
  }
  body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .hud>.map-heading {
    display:none;
  }
  body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .hud>.hud-item:nth-child(2) {
    grid-column:1; grid-row:1;
  }
  body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .hud>.hud-item:nth-child(3) {
    grid-column:1; grid-row:2;
  }
  body[data-td-v1] .game-shell[data-layout-device][data-side-controls] .scene-status-fallback .hud>.hud-item:nth-child(4) {
    grid-column:1; grid-row:3;
  }
}

/* V1.1: desktop status has its own readable scale and one stable scene anchor. */
body[data-td-v1] #desktop-status {
  position:absolute; z-index:5; width:320px; height:126px; border-radius:12px;
  overflow:hidden; box-shadow:0 3px 12px #20392b40; pointer-events:none;
}
body[data-td-v1] #desktop-status[hidden] { display:none; }
body[data-td-v1] #desktop-status .hud {
  position:static; inset:auto; display:grid; width:320px; max-width:none;
  height:74px; min-height:74px; margin:0; padding:6px 10px;
  grid-template-columns:70px 112px 1fr; grid-template-rows:18px 40px;
  gap:2px 6px; border:0; border-radius:0; transform:none; opacity:1;
  background:linear-gradient(#426b51fa,#2f5141fa); color:#fff7db; pointer-events:none;
}
body[data-td-v1] #desktop-status .hud>.map-heading {
  display:block; grid-column:1/-1; grid-row:1; margin:0;
}
body[data-td-v1] #desktop-status #map-name { font-size:13px; line-height:18px; }
body[data-td-v1] #desktop-status #phase,
body[data-td-v1] #desktop-status .resource-label { display:none; }
body[data-td-v1] #desktop-status .hud>.hud-item {
  position:static; grid-row:2; grid-column:auto; display:flex; gap:4px;
  align-items:center; min-width:0; margin:0;
}
body[data-td-v1] #desktop-status .resource-icon { width:22px; height:22px; flex:none; }
body[data-td-v1] #desktop-status .resource-copy { display:block; min-width:0; }
body[data-td-v1] #desktop-status .resource-copy :is(#lives,#gold) {
  font-size:28px; line-height:36px; white-space:nowrap;
}
body[data-td-v1] #desktop-status .resource-copy #wave { font-size:24px; line-height:36px; white-space:nowrap; }
body[data-td-v1] #desktop-status .wave-forecast {
  position:static; inset:auto; display:flex; align-items:center; gap:8px;
  width:320px; max-width:none; height:52px; min-height:52px;
  margin:0; padding:4px 10px; border:0; border-radius:0; transform:none;
  background:#f8f1d8fa; opacity:1; pointer-events:auto;
}
body[data-td-v1] #desktop-status .wave-forecast[data-pass-through="true"] { pointer-events:none; }
body[data-td-v1] #desktop-status #wave-label { width:50px; flex:none; font-size:12px; line-height:16px; white-space:nowrap; }
body[data-td-v1] #desktop-status #wave-preview { display:flex; flex-wrap:wrap; flex:1; gap:2px 8px; min-width:0; }
body[data-td-v1] #desktop-status .enemy-card { display:flex; flex:none; height:20px; min-height:20px; gap:3px; }
body[data-td-v1] #desktop-status .enemy-icon { width:20px; height:20px; }
body[data-td-v1] #desktop-status .enemy-count { font-size:14px; line-height:20px; }
body[data-td-v1] #desktop-status .enemy-name,
body[data-td-v1] #desktop-status .enemy-trait,
body[data-td-v1] #desktop-status #reward { display:none; }
body[data-td-v1] #desktop-status .forecast-open-icon { font-size:18px; flex:none; }
/* The two preview actions move as one group, including at screen edges. */
body[data-td-v1] #placement-actions { width:122px; max-width:calc(100% - 14px); gap:5px; }
body[data-td-v1] #placement-actions :is(#confirm-placement,#cancel-placement) {
  display:block; width:112px; min-width:112px; height:44px; min-height:44px;
  padding:6px 8px; margin:0; font-size:14px; line-height:20px; pointer-events:auto;
}
body[data-td-v1] #placement-actions #cancel-placement { background:#f6edcf; color:#455339; box-shadow:none; }
body[data-td-v1] #placement-actions #placement-reason { max-width:112px; font-size:11px; line-height:14px; overflow-wrap:anywhere; }
body[data-td-v1] .rotation-lab-link { display:flex; align-items:center; min-height:44px; padding:4px 8px; border:1px solid #a5af82; border-radius:8px; }

/* Desktop tower information belongs beside its upgrade choices. Keep one
   selection height per format so the world never jumps when opening a card. */
@container battlefield (max-width:1279px) {
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-touch-ui="false"] .range-name-prefix {
    display:none;
  }
}
@container battlefield (min-width:850px) {
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"] .game-dock {
    --v1-overview-dock-height:126px;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"][data-selected-tower="true"] .dock-row {
    display:grid; grid-template-columns:minmax(0,1fr); grid-template-rows:60px 44px;
    gap:4px; align-items:end;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"][data-selected-tower="true"] #shop-inline {
    height:60px; width:100%;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"][data-selected-tower="true"] .play-controls {
    justify-self:end;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"] #tower-panel {
    display:flex; align-items:stretch; gap:8px; height:60px;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"] .selected-info {
    flex:0 0 264px; width:264px; height:60px; min-height:60px; margin:0; padding:0 5px;
    border:1px solid #adb48a; border-radius:8px; background:#f8f1d8;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"] .selected-info .panel-heading {
    height:58px; min-height:58px; gap:5px;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"] .selected-values {
    gap:0 6px;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"] .selected-values>span {
    white-space:nowrap;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"] #branches {
    flex:1; min-width:0; width:auto;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"] .selected-info #remove-tower {
    flex:0 0 68px; width:68px; min-width:68px; height:44px; min-height:44px;
    flex-direction:column; justify-content:center; gap:0; margin:0; padding:3px;
    background:#ecdfbc; border-color:#b59b6d; color:#755a36;
    font-size:12px; line-height:16px; pointer-events:auto;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"] .selected-info #remove-icon {
    width:20px; height:20px;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"] #tower-panel>#close-tower-panel {
    align-self:center; width:80px; min-width:80px; height:52px; min-height:52px;
    flex:0 0 80px; font-size:14px;
  }
}
@container battlefield (min-width:1150px) {
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"] .game-dock {
    --v1-overview-dock-height:78px;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"][data-selected-tower="true"] .game-dock {
    height:78px; min-height:78px;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"][data-selected-tower="true"] .dock-row {
    display:flex; flex-direction:row; gap:8px; align-items:center;
  }
  body[data-td-v1] .game-shell[data-layout-device="desktop"][data-side-controls="false"][data-desktop-status="true"][data-selected-tower="true"] #shop-inline {
    width:auto;
  }
}

/* Dialogs escape the dock/rail stacking contexts without raising game controls. */
body[data-td-v1] #v1-ui-layer { position:absolute; inset:0; z-index:40; pointer-events:none; }
body[data-td-v1] #panel-backdrop {
  position:absolute; inset:0; z-index:0; width:100%; height:100%; min-width:0; min-height:0;
  margin:0; padding:0; border:0; border-radius:0; box-shadow:none; background:#2a422b33; pointer-events:auto;
}
body[data-td-v1] #v1-ui-layer>.settings-card,
body[data-td-v1] #v1-ui-layer>.forecast-details { z-index:2; pointer-events:auto; }
body[data-td-v1] #v1-ui-layer>.game-overlay { pointer-events:auto; }
/* Long menus scroll under their own opaque header; Close remains reachable. */
body[data-td-v1] #v1-ui-layer .settings-heading { position:sticky; top:-12px; z-index:1; background:#f5ebcc; padding-block:4px; }
body[data-td-v1] #v1-ui-layer .forecast-heading { position:sticky; top:-8px; z-index:1; background:#fff6db; padding-block:4px; }
