/* Size the overlay independently of the Spine canvas and its hit coordinates. */
:root { --desktop-ui: 1.15; }
@media (min-width: 800px) and (min-height: 540px) {
  :root { --desktop-ui: 1.3; }
}
@media (min-width: 1500px) and (min-height: 850px) {
  :root { --desktop-ui: 1.5; }
}
@media (min-width: 2400px) and (min-height: 1300px) {
  :root { --desktop-ui: 1.85; }
}

main #sceneHud {
  bottom: auto;
  height: calc(100% / var(--desktop-ui));
  transform: scale(var(--desktop-ui));
  transform-origin: top right;
}
#uiToggle { transform: scale(var(--desktop-ui)); transform-origin: top right; }
#hidePointsWithUi {
  position: absolute;
  z-index: 4;
  top: calc(3px + 6px * var(--desktop-ui));
  right: calc(5px + 50px * var(--desktop-ui));
  transform: scale(var(--desktop-ui));
  transform-origin: top right;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 2px 7px;
  font: 12px/1.3 var(--font);
  color: var(--ink);
  background: #211e29d9;
  border: 1px solid #ffffff38;
  border-radius: 6px;
  cursor: pointer;
}
#hidePointsWithUi::before {
  content: "";
  width: 26px;
  height: 20px;
  background: url("bt_off.png") center/contain no-repeat;
}
#hidePointsWithUi[aria-pressed=true]::before { background-image: url("bt_on.png"); }
#hidePointsWithUi:focus-visible { outline: 2px solid var(--gold); }

/* Fit the foreground sprite independently of its original round backplate. */
.hud nav > button:not(#tool)::before, .hud .sound-controls > button::before {
  box-sizing: border-box;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 3px;
  border-radius: 50%;
  background-color: #201d29e6;
  background-origin: content-box, padding-box;
  background-size: contain, contain;
}
.hud .sound-controls #mixOptions::before { background-size: contain, contain; }
#characterGallery .gallery-section button.wallpaper-choice {
  display: block;
  padding-inline: 8px 27px;
  background: #323239 url("arrow_dromdown.png") right 9px center/10px 8px no-repeat;
}
#characterGallery .gallery-tabs button::before, #galleryClose::before { flex: none; }
#nearPan {
  right: calc((var(--rail) + 8px) * var(--desktop-ui));
  transform: translateY(-50%) scale(var(--desktop-ui));
  transform-origin: right center;
}
#notice { transform: translateX(-50%) scale(var(--desktop-ui)); transform-origin: bottom center; }

/* Fixed popovers are positioned relative to the scaled rail. */
.hud #mixPanel {
  max-width: calc(100vw / var(--desktop-ui) - var(--rail) - 18px);
  max-height: calc(100dvh / var(--desktop-ui) - 24px);
}
.wallpaper-choice-panel {
  max-width: calc(94vw / var(--desktop-ui));
  max-height: calc(84dvh / var(--desktop-ui));
  transform: scale(var(--desktop-ui));
}
#characterGallery .gallery-controls :is(button, label, output), #characterGallery .gallery-head button {
  font-size: calc(13px * var(--desktop-ui));
}
#characterGallery .gallery-controls button, #characterGallery .gallery-head button {
  min-height: calc(30px * var(--desktop-ui));
}
#characterGallery .gallery-head h2 { font-size: calc(21px * var(--desktop-ui)); }
#characterGallery .gallery-tabs button::before {
  width: calc(29px * var(--desktop-ui));
  height: calc(22px * var(--desktop-ui));
}
@media (min-width: 761px) {
  #characterGallery .gallery-body {
    grid-template-columns: minmax(0, 1fr) calc(245px * var(--desktop-ui));
  }
}
@media (max-height: 760px) {
  main .hud { gap: 6px; }
  .hud .identity { gap: 4px; }
  .hud nav { gap: 1px; }
}
@media (min-width: 651px) and (min-height: 511px) and (max-height: 760px) {
  .hud .identity h1 { flex-direction: row; align-items: baseline; gap: 5px; }
  .hud nav > button, .hud .sound-controls > button {
    min-height: 32px;
    padding-block: 2px;
  }
}
@media (min-width: 500px) and (max-height: 510px) {
  :root { --rail: 94px; }
  .hud nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hud .sound-controls { display: contents; }
  #hintAppearance { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto; }
  #hint[aria-pressed=false] + #hintAppearance { display: none; }
  #hintOpacity { writing-mode: horizontal-tb; direction: ltr; width: 100%; height: 18px; }
}
@media (max-width: 650px), (max-height: 510px) {
  .hud .identity {
    left: calc(var(--rail) - 100vw / var(--desktop-ui) + 8px);
    max-width: calc(100vw / var(--desktop-ui) - var(--rail) - 20px);
  }
}
@media (max-width: 460px) {
  .hud .identity { top: 49px; }
  #characterGallery .gallery-tabs button { flex-direction: column; }
}
@media (max-height: 500px) and (min-width: 590px) {
  #characterGallery .gallery-tabs button { flex-direction: column; }
}
#characterGallery[open] {
  background: transparent;
  box-shadow: 0 0 0 110vmax #100e15b8;
}
#characterGallery::backdrop { background: transparent; }
#characterGallery .gallery-stage { background: #19162252; }
#characterGallery[data-loop] .gallery-stage { background: transparent; }
main:has(~ #characterGallery[open]) > :not(#scene) { visibility: hidden; }
.wallpaper-scroll-shell {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
#sceneHud > .wallpaper-scroll-shell {
  flex: 0 1 auto;
  grid-template-rows: minmax(0, 1fr);
}
#sceneControls.wallpaper-scroll-pane { scrollbar-width: none; }
#sceneHud .wallpaper-scroll-rail { width: 12px; pointer-events: auto; }
#characterGallery .wallpaper-scroll-shell { background: #25252c; }
.wallpaper-scroll-pane { min-height: 0; overflow-y: auto; scrollbar-width: none; overscroll-behavior: contain; }
.wallpaper-scroll-pane::-webkit-scrollbar { display: none; }
.wallpaper-scroll-rail {
  position: relative;
  align-self: stretch;
  width: 18px;
  margin-block: 4px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  background: url("zoom_gauge_back.png") center/5px 100% no-repeat;
}
.wallpaper-scroll-thumb { position:absolute; inset-inline: 3px; border-radius: 7px; background: #cdb98f; border: 1px solid #524638; cursor: grab; }
.wallpaper-scroll-rail:active .wallpaper-scroll-thumb { cursor: grabbing; }
.wallpaper-scroll-rail:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.wallpaper-choice-panel[open] { display: flex; flex-direction: column; overflow: hidden; }
.wallpaper-choice-panel > button, .wallpaper-choice-panel > h2 { flex: none; }
#galleryControls input[type=range], #mixPanel input[type=range] { touch-action:none; }
#points .point[data-compact] { width: 18px; height: 18px; }
