/* Each default HUD row stays in place even when its text is cleared or customized. */
#game .stage-overlay {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 46px 1.4rem;
  row-gap: 6px;
  align-content: center;
  align-items: start;
  justify-items: center;
}
#game.themed .stage-overlay {
  grid-template-rows: calc(clamp(28px, 5vw, 58px) * 1.04) 52px;
  row-gap: 8px;
  align-content: start;
}
#game .stage-overlay > #combo {
  grid-area: 1 / 1;
}
#game .stage-overlay > #judgment {
  grid-area: 2 / 1;
  margin-block-start: 0;
}
#game.themed .stage-overlay > #judgment:not(:empty) {
  margin-block-start: 0;
}
#game .stage-overlay > #countdown {
  inset-inline-start: 50%;
  transform: translateX(-50%);
}
/* A repositioned element stays anchored independently at its saved HUD point. */
#game .custom-hud-layer .hud-widget[data-hud-item="combo"] > #combo {
  inline-size: 5ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
#game:not(.themed) .custom-hud-layer .hud-widget[data-hud-item="judgment"] > #judgment {
  inline-size: min(11rem, calc(100vw - 18px));
  min-block-size: 1.4rem;
  line-height: 1.4rem;
  text-align: center;
}

/* Editor-only samples make the two independently movable elements discoverable. */
#game.hud-live-editing #combo:empty:not([data-hud-config-hidden])::after {
  content: "12";
  opacity: .8;
}
#game.hud-live-editing #judgment:empty:not([data-hud-config-hidden]) {
  display: grid;
  place-items: center;
  inline-size: min(230px, 70%);
  min-block-size: 1.4rem;
  margin-block-start: 0;
  color: #ffe2bd;
  line-height: 1.4rem;
  text-shadow: 0 2px 6px #000b;
}
#game.hud-live-editing.themed #judgment:empty:not([data-hud-config-hidden]) {
  aspect-ratio: 4.5;
}
#game.hud-live-editing .hud-widget > #judgment:empty:not([data-hud-config-hidden]) {
  inline-size: min(11rem, calc(100vw - 18px));
}
#game.hud-live-editing.themed .hud-widget > #judgment:empty:not([data-hud-config-hidden]) {
  inline-size: min(230px, calc(100vw - 18px));
}
#game.hud-live-editing #judgment:empty:not([data-hud-config-hidden])::after {
  content: "PERFECT";
  padding-inline: .5em;
  border: 1px dashed currentColor;
  border-radius: .25em;
  font-size: .75rem;
  line-height: 1.45;
  letter-spacing: .1em;
  opacity: .85;
}
#game.hud-live-editing .custom-hud-layer .hud-widget:has(>#combo:empty:not([data-hud-config-hidden]),>#judgment:empty:not([data-hud-config-hidden])) {
  display: block;
}
.hud-live-panel > header { cursor: grab; touch-action: none; user-select: none; }
.hud-live-panel > header:active { cursor: grabbing; }
.hud-live-panel [data-live-panel-move] { cursor: inherit; }
.hud-live-collapsed .hud-live-panel { grid-template-rows: auto; }
.hud-live-collapsed .hud-live-panel > header { border-bottom: 0; }
.hud-live-collapsed .hud-live-panel footer[hidden] { display: none; }
#game .hud-widget > #countdown { position: static; transform: none; }
#game.hud-live-editing #countdown:empty:not([data-hud-config-hidden])::after,
#game.hud-live-editing #holdStatus:empty:not([data-hud-config-hidden])::after {
  content: "3";
  font-size: .45em;
  opacity: .7;
}
#game.hud-live-editing #holdStatus:empty:not([data-hud-config-hidden])::after {
  content: "HOLD";
  font-size: .75rem;
}
#game.hud-live-editing .hud-widget:has(>#holdStatus:empty:not([data-hud-config-hidden])) { display: block; }
#game.hud-live-editing.hud-editor-preview-badge #judgment:empty:not([data-hud-config-hidden]) {
  background: var(--editor-judgment-preview) center/contain no-repeat;
}
#game.hud-live-editing.hud-editor-preview-badge #judgment:empty::after { opacity: 0; }
#game.hud-live-editing :is(#opponentStage,#mobilePerfReadout)[hidden]:not([data-hud-config-hidden]) {
  display: grid !important;
  min-inline-size: 4.5rem;
  min-block-size: 1.65rem;
  align-content: center;
}
#game.hud-live-editing #opponentStage[hidden] > * { display: none; }
#game.hud-live-editing #opponentStage[hidden]::after,
#game.hud-live-editing #mobilePerfReadout[hidden]::after {
  content: "Opponent panel";
  font-size: .75rem;
  text-align: center;
}
#game.hud-live-editing #mobilePerfReadout[hidden]::after { content: "FPS readout"; }
#game.hud-live-editing .hud-widget:has(>:is(#opponentStage,#mobilePerfReadout)[hidden]:not([data-hud-config-hidden])) {
  display: block;
}
#game .hud-widget > :is(#opponentStage,#mobilePerfReadout) {
  position: static;
  inset: auto;
  transform: none;
}

.hud-live-panel { max-height: min(67%, 570px); }
@media (max-width: 820px), (max-height: 670px) {
  .hud-live-panel { max-height: min(45%, 294px); }
}
#settingsModal dialog.settings-reset-confirm {
  position: fixed;
  inset: 0;
  width: min(420px, calc(100vw - 32px));
  margin: auto;
  padding: 18px;
  color: #edded1;
}
#settingsModal dialog.settings-reset-confirm:not([open]) { display: none; }
#settingsModal dialog.settings-reset-confirm::backdrop { background: rgb(0 0 0 / 55%); }
