.house-sound-toggle {
  position: fixed;
  top: max(0.55rem, env(safe-area-inset-top));
  right: max(0.65rem, env(safe-area-inset-right));
  z-index: 40;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: rgba(212, 175, 122, 0.55);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.25s ease, color 0.25s ease;
}

.house-sound-toggle__icon {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
}

.house-sound-toggle:hover,
.house-sound-toggle:focus-visible {
  opacity: 1;
  color: rgba(232, 204, 154, 0.9);
  outline: none;
}

.house-sound-toggle.is-silent {
  color: rgba(180, 160, 130, 0.45);
}

.house-sound-toggle[aria-expanded="true"] {
  opacity: 1;
  color: rgba(232, 204, 154, 0.95);
}

/* —— Volume popover —— */
.house-sound-panel {
  position: fixed;
  z-index: 41;
  display: grid;
  gap: 0.6rem;
  width: min(15rem, calc(100vw - 1.5rem));
  padding: 0.85rem 1rem 0.9rem;
  border: 1px solid rgba(232, 201, 138, 0.35);
  border-radius: 0.75rem;
  background: rgba(24, 9, 16, 0.94);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  color: #f1dcb0;
  font-family: "Cinzel", "Palatino Linotype", Palatino, serif;
  animation: sound-panel-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.house-sound-panel[hidden] {
  display: none;
}

.house-sound-panel__label {
  font-size: 0.66rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(232, 201, 138, 0.8);
}

.house-sound-panel__slider {
  --fill: 80%;
  width: 100%;
  height: 1.6rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.house-sound-panel__slider::-webkit-slider-runnable-track {
  height: 0.3rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #d4af6a var(--fill), rgba(232, 201, 138, 0.2) var(--fill));
}

.house-sound-panel__slider::-moz-range-track {
  height: 0.3rem;
  border-radius: 999px;
  background: rgba(232, 201, 138, 0.2);
}

.house-sound-panel__slider::-moz-range-progress {
  height: 0.3rem;
  border-radius: 999px;
  background: #d4af6a;
}

.house-sound-panel__slider::-webkit-slider-thumb {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: -0.4rem;
  border: 2px solid #2a1018;
  border-radius: 50%;
  background: #f1dcb0;
  box-shadow: 0 0 0 2px rgba(212, 175, 106, 0.6);
  appearance: none;
  -webkit-appearance: none;
}

.house-sound-panel__slider::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  border: 2px solid #2a1018;
  border-radius: 50%;
  background: #f1dcb0;
  box-shadow: 0 0 0 2px rgba(212, 175, 106, 0.6);
}

.house-sound-panel__slider:focus-visible {
  outline: 2px solid rgba(232, 201, 138, 0.7);
  outline-offset: 3px;
  border-radius: 0.3rem;
}

.house-sound-panel__mute {
  justify-self: start;
  padding: 0.4rem 0.8rem;
  border: 1px solid rgba(232, 201, 138, 0.4);
  border-radius: 999px;
  background: transparent;
  color: #f1dcb0;
  font-family: "Cormorant Garamond", "Palatino Linotype", Palatino, serif;
  font-size: 0.98rem;
  font-style: italic;
  cursor: pointer;
}

.house-sound-panel__mute:hover,
.house-sound-panel__mute:focus-visible {
  border-color: rgba(232, 201, 138, 0.8);
  outline: none;
}

.house-sound-panel__mute[aria-pressed="true"] {
  background: rgba(212, 175, 106, 0.18);
}

@keyframes sound-panel-in {
  from {
    opacity: 0;
    transform: translateY(-0.4rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .house-sound-toggle {
    transition: none;
  }

  .house-sound-panel {
    animation: none;
  }
}

/* Mobile: leave a small corner for the icon (castle gate has no .court-nav) */
@media (max-width: 960px) {
  body:has(.court-nav) .dedication > nav,
  body:has(.court-nav) .room-nav {
    padding-right: max(2.75rem, calc(env(safe-area-inset-right) + 2.35rem));
  }
}
