.rp-stage-filter-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.rp-stage-filter-bg {
  z-index: 1;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.rp-stage-filter-bg video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#rp-companion-stage > #rp-companion-sprite-wrap {
  z-index: 2;
}

.rp-stage-filter-tint {
  z-index: 3;
  background: var(--rp-stage-filter-tint, transparent);
  opacity: var(--rp-stage-filter-tint-opacity, 0);
  mix-blend-mode: soft-light;
}

.rp-stage-filter-foreground {
  z-index: 4;
}

.rp-stage-filter-foreground img {
  position: absolute;
  left: var(--rp-fg-x, 50%);
  top: var(--rp-fg-y, 50%);
  width: var(--rp-fg-size, 100%);
  height: auto;
  max-width: none;
  opacity: var(--rp-fg-opacity, 1);
  transform: translate(-50%, -50%);
  object-fit: contain;
}

.rp-stage-filter-weather {
  z-index: 4;
}

.rp-stage-filter-particle {
  position: absolute;
  top: -12%;
  left: var(--rp-particle-x, 50%);
  width: var(--rp-particle-size, 5px);
  height: var(--rp-particle-size, 5px);
  opacity: var(--rp-particle-opacity, .7);
  animation-delay: var(--rp-particle-delay, 0s);
  animation-duration: var(--rp-particle-duration, 8s);
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}

.rp-stage-filter-weather[data-weather="snow"] .rp-stage-filter-particle {
  border-radius: 50%;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 0 5px rgba(255, 255, 255, .55);
  animation-name: rp-stage-filter-snow;
}

.rp-stage-filter-weather[data-weather="rain"] .rp-stage-filter-particle {
  width: 1px;
  height: calc(var(--rp-particle-size, 5px) * 5);
  background: rgba(218, 237, 255, .72);
  transform: rotate(9deg);
  animation-name: rp-stage-filter-rain;
}

.rp-stage-filter-vignette {
  z-index: 4;
  background: radial-gradient(circle at center, transparent 42%, rgba(8, 10, 18, var(--rp-stage-filter-vignette, 0)) 100%);
}

@keyframes rp-stage-filter-snow {
  from { transform: translate3d(0, -8vh, 0) rotate(0deg); }
  to { transform: translate3d(var(--rp-particle-drift, 30px), 120vh, 0) rotate(360deg); }
}

@keyframes rp-stage-filter-rain {
  from { transform: translate3d(0, -8vh, 0) rotate(9deg); }
  to { transform: translate3d(-35px, 120vh, 0) rotate(9deg); }
}

.rp-stage-filter-overlay {
  position: fixed;
  inset: 0;
  z-index: 100090;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 22, 29, .52);
  backdrop-filter: blur(6px);
}

.rp-stage-filter-overlay.show {
  display: flex;
}

.rp-stage-filter-panel {
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: min(88vh, 820px);
  overflow: hidden;
  color: #26303d;
  background: #f8fafc;
  border: 1px solid rgba(80, 90, 110, .18);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(16, 20, 30, .3);
}

.rp-stage-filter-head,
.rp-stage-filter-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: 12px 14px;
  background: #fff;
}

.rp-stage-filter-head {
  border-bottom: 1px solid rgba(80, 90, 110, .12);
}

.rp-stage-filter-foot {
  justify-content: flex-end;
  border-top: 1px solid rgba(80, 90, 110, .12);
}

.rp-stage-filter-title {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  font-weight: 700;
}

.rp-stage-filter-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #435064;
  background: #eef2f6;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.rp-stage-filter-body {
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.rp-stage-filter-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  margin-bottom: 12px;
}

.rp-stage-filter-section {
  padding: 13px 0;
  border-top: 1px solid rgba(80, 90, 110, .12);
}

.rp-stage-filter-section:first-of-type {
  border-top: 0;
}

.rp-stage-filter-section h3 {
  margin: 0 0 10px;
  color: #26303d;
  font-size: .86rem;
  letter-spacing: 0;
}

.rp-stage-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 14px;
}

.rp-stage-filter-field {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: #566273;
  font-size: .78rem;
}

.rp-stage-filter-field input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: #496b86;
}

.rp-stage-filter-field output {
  text-align: right;
  color: #26303d;
  font-variant-numeric: tabular-nums;
}

.rp-stage-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rp-stage-filter-row + .rp-stage-filter-row {
  margin-top: 9px;
}

.rp-stage-filter-panel button,
.rp-stage-filter-panel select,
.rp-stage-filter-panel input[type="text"] {
  min-height: 34px;
  box-sizing: border-box;
  border: 1px solid rgba(73, 91, 111, .2);
  border-radius: 6px;
  color: #324052;
  background: #fff;
  font: inherit;
}

.rp-stage-filter-panel button {
  padding: 7px 12px;
  cursor: pointer;
}

.rp-stage-filter-panel button.primary {
  border-color: #496b86;
  color: #fff;
  background: #496b86;
}

.rp-stage-filter-panel button.danger {
  color: #9d3344;
  background: #fff5f6;
}

.rp-stage-filter-panel select,
.rp-stage-filter-panel input[type="text"] {
  min-width: 0;
  padding: 6px 9px;
}

.rp-stage-filter-toolbar select {
  width: 100%;
}

.rp-stage-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  color: #4e5c6d;
  font-size: .8rem;
}

.rp-stage-filter-toggle input {
  accent-color: #496b86;
}

.rp-stage-filter-asset-name {
  flex: 1 1 160px;
  min-width: 0;
  overflow: hidden;
  color: #677487;
  font-size: .76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rp-stage-filter-foreground-list {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}

.rp-stage-filter-foreground-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(73, 91, 111, .12);
  border-radius: 6px;
  background: #fff;
}

.rp-stage-filter-empty {
  padding: 10px;
  color: #7a8594;
  font-size: .78rem;
  text-align: center;
  border: 1px dashed rgba(73, 91, 111, .2);
  border-radius: 6px;
}

.rp-stage-filter-color {
  width: 36px;
  height: 30px;
  padding: 2px;
  border: 1px solid rgba(73, 91, 111, .2);
  border-radius: 5px;
  background: #fff;
}

@media (max-width: 640px) {
  .rp-stage-filter-overlay { padding: 0; }
  .rp-stage-filter-panel { width: 100%; max-height: 100%; height: 100%; border: 0; border-radius: 0; }
  .rp-stage-filter-grid { grid-template-columns: 1fr; }
  .rp-stage-filter-toolbar { grid-template-columns: minmax(0, 1fr) auto; }
  .rp-stage-filter-toolbar button:last-child { grid-column: 1 / -1; }
  .rp-stage-filter-foreground-item { grid-template-columns: minmax(0, 1fr) auto; }
  .rp-stage-filter-foreground-item input[type="range"] { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .rp-stage-filter-particle { animation-play-state: paused; }
}
