/* HUD compositions scale once, including their lettering and original artwork.
   The village world/canvas is never transformed. Existing hover animation and
   hide/show rules keep working on descendants of these independent groups. */
#game-container[data-approved-ui] .village-hud.classic-topbar {
  inset:0;
}
#game-container .classic-topbar>.topbar-meter {
  transform:scale(var(--game-ui-scale,.8));
  transform-origin:left top;
}
#game-container .classic-topbar>.topbar-exp {left:.8cqw;top:1.2cqh}
#game-container .classic-topbar>.topbar-chakra {left:11.6cqw;top:1.75cqh}
#game-container .classic-topbar>.topbar-ryo {
  right:13.5cqw;top:1.2cqh;transform-origin:right top;
}
#game-container .classic-topbar>.topbar-gold {
  right:.8cqw;top:1.2cqh;transform-origin:right top;
}

/* Central navigation stays centred; shrinking it does not pull either wallet
   away from the right edge or change the map's own logical hit coordinates. */
#game-container .village-shell>:is(.topbar-map,.topbar-shortcuts) {
  left:50%;transform:translateX(-50%) scale(var(--game-ui-scale,.8));
  transform-origin:center top;
}
#game-container .village-shell>.topbar-map {top:7.36cqh}
#game-container .village-shell>.topbar-shortcuts {top:10.44cqh}
#game-container .village-shell>.topbar-quest {
  left:.4cqw;top:11cqh;transform:scale(var(--game-ui-scale,.8));
  transform-origin:left top;
}

/* The first left-rail button is Daily Wishes. Its mission children inherit this
   one scale; Quest and Daily Wishes remain visible when priorities are hidden. */
#game-container .village-shell>:is(.lower-leftbar,.left-missions-toggle,.lower-guide-callout) {
  transform:scale(var(--game-ui-scale,.8));transform-origin:left top;
}
#game-container .village-shell>.lower-leftbar {left:.25cqw;top:22cqh}
#game-container .village-shell>.left-missions-toggle {left:1.2cqw;top:60.4cqh}
#game-container[data-missions="hidden"] .village-shell>.left-missions-toggle {top:30cqh}
#game-container .village-shell>.lower-guide-callout {left:6.2cqw;top:29.2cqh}
#game-container .village-shell>:is(.lower-rightbar,.lower-rightbar-toggle) {
  transform:scale(var(--game-ui-scale,.8));transform-origin:right top;
}
#game-container .village-shell>.lower-rightbar {right:.4cqw;top:22cqh}
#game-container .village-shell>.lower-rightbar-toggle {right:1.2cqw;top:49.1cqh}

/* Keep the three shortcuts adjacent to All and the book at the opposite corner. */
#game-container .village-shell>:is(.formation-power-panel,.lower-shortcuts) {
  transform:scale(var(--game-ui-scale,.8));transform-origin:left bottom;
}
#game-container .village-shell>.formation-power-panel {left:1cqw;bottom:0;width:21.9765cqw;height:auto;aspect-ratio:var(--profile-panel-aspect)}
#game-container .village-shell>.lower-shortcuts {left:24cqw;right:auto;width:18cqw}
#game-container .village-shell>.classic-book-dock {
  transform:scale(var(--game-ui-scale,.8));transform-origin:right bottom;
}
#game-container .village-shell>.classic-book-dock {right:.6cqw;bottom:.6cqh}
#game-container .village-shell>.village-land-controls {
  left:69.2%;bottom:1cqh;
  transform:translateX(-50%) scale(var(--game-ui-scale,.8));
  transform-origin:center bottom;
}
#game-container[data-hud="hidden"] .village-shell>.village-land-controls {
  left:50%;bottom:.8cqh;
}
#game-container .village-shell>.kage-hud-toggle {
  transform:scale(var(--game-ui-scale,.8));transform-origin:left bottom;
}
#game-container[data-hud="hidden"] .village-shell>.kage-hud-toggle {
  left:.8cqw;bottom:.8cqh;
}

/* Short-lived status and placement messages use the same factor as menus. */
#game-container .app-shell.village-shell.has-resume>.resume-banner {
  left:50%;top:1.25cqh;
  transform:translateX(-50%) scale(var(--game-ui-scale,.8));
  transform-origin:center top;
}
/* The saved battle stays in the clear centre between the actual resource counters. */
#game-container .app-shell.village-shell.has-resume>.resume-banner.saved-battle-banner {
  position:absolute;grid-row:auto;z-index:14;left:50%;right:auto;top:1.25cqh;
  display:grid;grid-template-columns:clamp(18px,2.1cqw,28px) minmax(0,1fr) auto;
  align-items:center;column-gap:clamp(4px,.55cqw,8px);flex-wrap:nowrap;
  box-sizing:border-box;width:40cqw;max-width:560px;min-width:0;
  height:auto;min-height:0;max-height:none;margin:0;padding:.65cqh .7cqw;
  border:1px solid #b79e6a;border-radius:clamp(5px,.55cqw,8px);
  background:#f8f0d9f2;color:#263736;box-shadow:0 2px 5px #14242d30;
  transform:translateX(-50%);transform-origin:center top;
  font-family:Arial,sans-serif;font-size:clamp(9px,.95cqw,13px);line-height:1.15;
  overflow:hidden;
}
#game-container .saved-battle-banner>.saved-battle-art {
  display:grid;place-items:center;width:100%;min-width:0;height:100%;
}
#game-container .saved-battle-art>.icon {display:block;width:100%;height:auto;aspect-ratio:1;}
#game-container .saved-battle-banner>.saved-battle-copy {
  display:flex;flex-direction:column;align-items:flex-start;gap:.35cqh;min-width:0;line-height:1.15;
}
#game-container .saved-battle-copy>:is(strong,small) {
  display:block;box-sizing:border-box;width:100%;min-width:0;margin:0;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
#game-container .saved-battle-copy>strong {color:#263736;font-size:clamp(10px,1cqw,14px);font-weight:700;}
#game-container .saved-battle-copy>.saved-battle-status {color:#746446;font-size:clamp(8px,.76cqw,11px);font-weight:400;}
#game-container .saved-battle-banner>.saved-battle-resume {
  appearance:none;display:flex;align-items:center;justify-content:center;box-sizing:border-box;
  width:auto;min-width:0;height:clamp(26px,4.3cqh,34px);min-height:0;margin:0;padding:0 .85cqw;
  border:1px solid #92c5e2;border-image:none;border-radius:clamp(4px,.35cqw,6px);
  background:linear-gradient(#59b8ec,#277ebc);box-shadow:inset 0 1px #b8e9ff;
  color:#fffef0;font:700 clamp(9px,.95cqw,13px)/1.1 Arial,sans-serif;
  text-shadow:0 1px #24577b;white-space:nowrap;cursor:pointer;touch-action:manipulation;
}
#game-container .saved-battle-resume:hover {filter:brightness(1.06);}
#game-container .saved-battle-resume:focus-visible {outline:2px solid #268fc3;outline-offset:2px;}
#game-container .saved-battle-resume::before,#game-container .saved-battle-resume::after {content:none;display:none;}
/* Short landscape screens keep the minimap and shortcuts below the banner. */
#game-container .app-shell.village-shell.has-resume {
  --saved-battle-hud-shift:max(0px,calc(4px + clamp(26px,4.3cqh,34px) - 6.65cqh));
}
#game-container .app-shell.village-shell.has-resume>.topbar-map {top:calc(9.2cqh + var(--saved-battle-hud-shift));}
#game-container .app-shell.village-shell.has-resume>.topbar-shortcuts {top:calc(13.05cqh + var(--saved-battle-hud-shift));}
#game-container .village-world>.placement-bar {
  left:auto;right:11.5cqw;top:23cqh;bottom:auto;
  transform:scale(var(--game-ui-scale,.8));
  transform-origin:right top;
}
#game-container>#toast {
  bottom:12cqh;
  transform:translate(-50%,15px) scale(var(--game-ui-scale,.8));
  transform-origin:center bottom;
}
#game-container>#toast.show {
  transform:translate(-50%,0) scale(var(--game-ui-scale,.8));
}

/* Legacy HUD variants, if displayed by a saved/online view, remain compact.
   Restrict these to direct HUD roots so their children cannot scale twice. */
#game-container .village-shell>:is(.village-hud:not(.classic-topbar),.village-tools) {
  transform:scale(var(--game-ui-scale,.8));transform-origin:left top;
}
#game-container .village-shell>.village-sign {
  transform:scale(var(--game-ui-scale,.8));transform-origin:left bottom;
}
#game-container .village-shell>:is(.village-settings,.village-dock) {
  transform:scale(var(--game-ui-scale,.8));transform-origin:right bottom;
}
#game-container .village-shell>.kage-gold {
  transform:scale(var(--game-ui-scale,.8));transform-origin:right top;
}
#game-container .village-shell>:is(.kage-quickhub,.kage-resume) {
  left:50%;transform:translateX(-50%) scale(var(--game-ui-scale,.8));
  transform-origin:center top;
}
#game-container .village-world>.village-hint {
  transform:translateX(-50%) scale(var(--game-ui-scale,.8));
  transform-origin:center bottom;
}
