/* A non-modal settings surface: the exhibition keeps running behind it. */
#stage.game-ui[data-settings-open="true"] .topbar { z-index: 40; }
#stage.game-ui .appearance-tools > .center-tools {
  position: fixed;
  top: var(--settings-top, 108px);
  left: var(--settings-left, auto);
  right: 12px;
  width: var(--settings-width, min(380px, calc(100vw - 24px)));
  max-width: calc(100vw - 24px);
  max-height: var(--settings-height, calc(100dvh - 120px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  /* Override the old flex toolbar's align-items:center: the body must shrink
     into its grid track, not paint through the fixed header when constrained. */
  align-items: stretch;
  gap: 0;
  padding: 0;
  min-width: 0;
  border: 1px solid #d7deef;
  border-radius: 22px;
  overflow: hidden;
  white-space: normal;
  color: #29345c;
  background: #fff;
  box-shadow: 0 16px 40px #29345c26, 0 3px 0 #e1e6f1;
  pointer-events: auto;
}
#stage.game-ui .settings-panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #e3e8f3;
  background: #f5f7ff;
}
#stage.game-ui .settings-panel-header h2 { margin: 0; font-size: 17px; line-height: 1.3; letter-spacing: 0; }
#stage.game-ui #settings-close { min-width: 64px; min-height: 44px; font-size: 13px; }
#stage.game-ui .settings-panel-body {
  display: grid; align-content: start; gap: 16px;
  min-width: 0; min-height: 0; padding: 18px;
  overflow-x: hidden; overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin; scrollbar-color: #a8b5d9 #f2f5fc;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}
#stage.game-ui .settings-panel-body > *,
#stage.game-ui .settings-panel-body .sound-action-row,
#stage.game-ui .settings-panel-body label { min-width: 0; }
#stage.game-ui .settings-panel-body label { font-size: 13px; line-height: 1.4; }
#stage.game-ui .settings-panel-body select { min-width: 0; max-width: 100%; font-size: 14px; min-height: 44px; }
#stage.game-ui .settings-panel-body .sound-action-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#stage.game-ui .settings-panel-body .soft-control {
  min-width: 0; min-height: 44px; height: auto;
  padding: 9px 8px; line-height: 1.45; font-size: 13px;
  white-space: normal; overflow-wrap: anywhere;
}
#stage.game-ui .settings-panel-body p { font-size: 12px; line-height: 1.65; white-space: normal; overflow-wrap: anywhere; }
#stage.game-ui .settings-panel-body [hidden] { display: none !important; }
@media (max-width: 520px) {
  #stage.game-ui .appearance-tools > .center-tools { border-radius: 18px; }
  #stage.game-ui .settings-panel-header { padding: 10px 12px; }
  #stage.game-ui .settings-panel-body { padding: 14px; gap: 14px; }
}
