/* Shirokami BGM Player v6. Isolated styles; does not modify the original music box. */
.shiro-bgm {
  --bgm-surface: rgba(255, 255, 255, .91);
  --bgm-ink: #384155;
  --bgm-subtle: #737b91;
  --bgm-accent: #8b79c8;
  --bgm-edge: rgba(172, 158, 210, .35);
  position: fixed;
  z-index: 9990;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: min(344px, calc(100vw - 24px));
  color: var(--bgm-ink);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", sans-serif;
  border: 1px solid var(--bgm-edge);
  border-radius: 18px;
  background: var(--bgm-surface);
  box-shadow: 0 14px 42px rgba(64, 54, 110, .17);
  -webkit-backdrop-filter: blur(19px);
  backdrop-filter: blur(19px);
  overflow: hidden;
}
.shiro-bgm, .shiro-bgm * { box-sizing: border-box; }
.shiro-bgm button, .shiro-bgm input { font: inherit; }
.shiro-bgm button {
  cursor: pointer;
  border: 0;
  color: inherit;
  background: transparent;
  touch-action: manipulation;
}
.shiro-bgm button:focus-visible, .shiro-bgm input:focus-visible {
  outline: 2px solid var(--bgm-accent);
  outline-offset: 2px;
}
.shiro-bgm .shiro-bgm-mini {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  min-height: 66px;
}
.shiro-bgm .shiro-bgm-art {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font: 26px Georgia, serif;
  color: white;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 12px;
  background: linear-gradient(140deg, #c5b9e6, #979bc9 55%, #c7d9eb);
  box-shadow: 0 3px 10px rgba(125, 111, 183, .17);
}
.shiro-bgm.is-playing .shiro-bgm-art { animation: shiro-bgm-float 3s ease-in-out infinite; }
@keyframes shiro-bgm-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
.shiro-bgm .shiro-bgm-summary { flex: 1; min-width: 0; }
.shiro-bgm .shiro-bgm-summary strong,
.shiro-bgm .shiro-bgm-summary span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.shiro-bgm .shiro-bgm-summary strong { font-size: 13px; font-weight: 700; }
.shiro-bgm .shiro-bgm-summary span { font-size: 11px; color: var(--bgm-subtle); }
.shiro-bgm .shiro-bgm-icon {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 18px;
  transition: background .18s, transform .18s;
}
.shiro-bgm .shiro-bgm-icon:hover { background: rgba(150, 136, 198, .14); }
.shiro-bgm .shiro-bgm-icon:active { transform: scale(.95); }
.shiro-bgm .shiro-bgm-primary { background: var(--bgm-accent); color: #fff; }
.shiro-bgm .shiro-bgm-primary:hover { background: #7661bb; }
.shiro-bgm .shiro-bgm-panel {
  padding: 13px 15px 15px;
  border-top: 1px solid var(--bgm-edge);
  max-height: min(66dvh, 490px);
  overflow-y: auto;
}
.shiro-bgm .shiro-bgm-panel[hidden] { display: none !important; }
.shiro-bgm .shiro-bgm-heading {
  font: 600 15px Georgia, "Microsoft YaHei", serif;
  letter-spacing: .05em;
  color: var(--bgm-accent);
  margin-bottom: 12px;
}
.shiro-bgm .shiro-bgm-heading small { font-family: inherit; font-size: 10px; line-height: 1.5; letter-spacing: .16em; }
.shiro-bgm .shiro-bgm-timeline,
.shiro-bgm .shiro-bgm-volume {
  display: flex;
  align-items: center;
  gap: 9px;
}
.shiro-bgm .shiro-bgm-timeline span,
.shiro-bgm .shiro-bgm-volume span { font-variant-numeric: tabular-nums; font-size: 11px; color: var(--bgm-subtle); }
.shiro-bgm input[type="range"] { flex: 1; min-width: 0; accent-color: var(--bgm-accent); cursor: pointer; }
.shiro-bgm .shiro-bgm-controls { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin: 10px 0; }
.shiro-bgm .shiro-bgm-controls button {
  border-radius: 10px;
  padding: 7px 11px;
  background: rgba(147, 132, 194, .10);
  font-size: 13px;
}
.shiro-bgm .shiro-bgm-controls button:hover,
.shiro-bgm .shiro-bgm-track:hover { background: rgba(147, 132, 194, .21); }
.shiro-bgm .shiro-bgm-volume button { font-size: 16px; padding: 2px; }
.shiro-bgm .shiro-bgm-tracks {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  max-height: 140px;
  overflow: auto;
}
.shiro-bgm .shiro-bgm-track {
  text-align: left;
  width: 100%;
  padding: 7px 9px;
  border-radius: 9px;
  background: rgba(147, 132, 194, .07);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shiro-bgm .shiro-bgm-track.selected { color: var(--bgm-accent); font-weight: 700; background: rgba(147, 132, 194, .18); }
.shiro-bgm .shiro-bgm-status { margin: 11px 0 0; font-size: 11px; color: var(--bgm-subtle); }
:root[data-theme="dark"] .shiro-bgm,
body[data-theme="dark"] .shiro-bgm {
  --bgm-surface: rgba(30, 32, 49, .94);
  --bgm-ink: #f3eefb;
  --bgm-subtle: #b7b4c6;
  --bgm-accent: #c0aafa;
  --bgm-edge: rgba(194, 177, 232, .27);
}
:root[data-theme="dark"] .shiro-bgm .shiro-bgm-primary,
body[data-theme="dark"] .shiro-bgm .shiro-bgm-primary { color: #241832; }
@media (max-width: 540px) {
  .shiro-bgm {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: min(312px, calc(100vw - 24px));
    border-radius: 15px;
  }
  .shiro-bgm .shiro-bgm-mini { min-height: 58px; padding: 7px 9px; }
  .shiro-bgm .shiro-bgm-art { width: 38px; height: 38px; flex-basis: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  .shiro-bgm .shiro-bgm-art { animation: none !important; }
  .shiro-bgm button { transition: none; }
}

/* ===== Galgame entry screen, shown only when browser blocks audible autoplay ===== */
.shiro-bgm-welcome,
.shiro-bgm-welcome * { box-sizing: border-box; }
.shiro-bgm-welcome[hidden] { display: none !important; }
.shiro-bgm-welcome {
  --entry-ink: #554d72;
  --entry-muted: #807895;
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(130deg, rgba(247,247,255,.90), rgba(231,226,247,.88) 56%, rgba(222,238,251,.86));
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  color: var(--entry-ink);
  font: 14px/1.65 -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", sans-serif;
  animation: shiro-entry-in .5s ease both;
}
.shiro-bgm-welcome.is-leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .42s ease, visibility .42s;
}
.shiro-bgm-welcome-card {
  position: relative;
  width: min(520px, 100%);
  padding: clamp(30px, 5vw, 56px) clamp(18px, 5vw, 55px);
  text-align: center;
  background: rgba(255,255,255,.73);
  border: 1px solid rgba(255,255,255,.88);
  border-radius: 28px;
  box-shadow: 0 25px 80px rgba(89,79,151,.14), 0 4px 25px rgba(111,101,161,.06);
}
.shiro-bgm-welcome-overline {
  margin: 0;
  color: #9c90bb;
  font: 600 11px/1.6 Georgia, serif;
  letter-spacing: .22em;
}
.shiro-bgm-welcome-emblem {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  margin: 28px auto 16px;
  color: #fff;
  font: 54px Georgia, serif;
  border-radius: 24px;
  background: linear-gradient(135deg, #c6b6e6, #a6b8e7);
  box-shadow: 0 8px 25px rgba(153,137,202,.22);
}
.shiro-bgm-welcome h2 {
  margin: 0;
  font: 600 clamp(23px, 4vw, 31px)/1.4 Georgia, "Microsoft YaHei", serif;
  letter-spacing: .055em;
}
.shiro-bgm-welcome-copy { color: var(--entry-muted); margin: 14px 0 33px; }
.shiro-bgm-welcome button {
  display: block;
  width: min(290px, 100%);
  min-height: 48px;
  margin-inline: auto;
  padding: 10px 15px;
  cursor: pointer;
  border-radius: 24px;
  font: 600 14px/1.5 -apple-system, BlinkMacSystemFont, "Microsoft YaHei", sans-serif;
}
.shiro-bgm-welcome .shiro-bgm-welcome-enter {
  border: 1px solid #a08cc9;
  background: linear-gradient(100deg, #afa0dc, #8c90ce);
  color: white;
  box-shadow: 0 8px 26px rgba(142,133,205,.2);
  transition: transform .2s ease, box-shadow .2s ease;
}
.shiro-bgm-welcome .shiro-bgm-welcome-enter:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(142,133,205,.28);
}
.shiro-bgm-welcome .shiro-bgm-welcome-enter:disabled { opacity: .65; cursor: wait; }
.shiro-bgm-welcome .shiro-bgm-welcome-skip {
  min-height: 38px;
  margin-top: 12px;
  background: none;
  border: none;
  font-size: 12px;
  color: var(--entry-muted);
}
.shiro-bgm-welcome .shiro-bgm-welcome-skip:hover { color: var(--entry-ink); }
.shiro-bgm-welcome button:focus-visible { outline: 3px solid #8b79c8; outline-offset: 3px; }
.shiro-bgm-welcome-hint { margin: 12px 0 0; font-size: 11px; color: #9992a7; }
.shiro-bgm-welcome-stars { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.shiro-bgm-welcome-stars i { position: absolute; color: rgba(147,132,196,.36); font: normal 30px Georgia, serif; animation: shiro-star-drift 6s ease-in-out infinite alternate; }
.shiro-bgm-welcome-stars i:nth-child(1) { top: 18%; left: 16%; }
.shiro-bgm-welcome-stars i:nth-child(2) { top: 26%; right: 12%; animation-delay: -2s; }
.shiro-bgm-welcome-stars i:nth-child(3) { bottom: 19%; right: 19%; animation-delay: -4s; }
.shiro-bgm-welcome-stars i:nth-child(4) { bottom: 27%; left: 10%; animation-delay: -1s; }
@keyframes shiro-entry-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes shiro-star-drift { to { transform: translateY(-16px) rotate(12deg); } }
@media (max-width: 540px) {
  .shiro-bgm-welcome { padding: 15px; }
  .shiro-bgm-welcome-card { border-radius: 22px; }
  .shiro-bgm-welcome-emblem { width: 60px; height: 60px; font-size: 43px; margin-top: 20px; }
  .shiro-bgm-welcome-copy { margin-bottom: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  .shiro-bgm-welcome, .shiro-bgm-welcome-stars i { animation: none !important; }
  .shiro-bgm-welcome.is-leaving, .shiro-bgm-welcome button { transition: none !important; }
}

/* ===== v4: next-visit autoplay preference ===== */
.shiro-bgm .shiro-bgm-settings {
  margin-top: 13px;
  padding: 12px 0 0;
  border-top: 1px solid var(--bgm-edge);
}
.shiro-bgm .shiro-bgm-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
}
.shiro-bgm .shiro-bgm-setting-text { flex: 1; min-width: 0; }
.shiro-bgm .shiro-bgm-setting-text strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--bgm-ink);
}
.shiro-bgm .shiro-bgm-setting-text small {
  display: block;
  margin-top: 3px;
  color: var(--bgm-subtle);
  font-size: 10px;
  line-height: 1.6;
}
.shiro-bgm .shiro-bgm-setting-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 23px;
  margin: 0;
  border: 1px solid var(--bgm-edge);
  border-radius: 99px;
  background: #bdbcc7;
  cursor: pointer;
  transition: background .2s ease;
}
.shiro-bgm .shiro-bgm-setting-row input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  transition: transform .2s ease;
}
.shiro-bgm .shiro-bgm-setting-row input[type="checkbox"]:checked {
  background: var(--bgm-accent);
}
.shiro-bgm .shiro-bgm-setting-row input[type="checkbox"]:checked::before {
  transform: translateX(17px);
}
@media (prefers-reduced-motion: reduce) {
  .shiro-bgm .shiro-bgm-setting-row input[type="checkbox"],
  .shiro-bgm .shiro-bgm-setting-row input[type="checkbox"]::before {
    transition: none;
  }
}

/* ===== v6: collapsible song list ===== */
.shiro-bgm .shiro-bgm-tracks-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 13px;
  padding: 10px 11px;
  border-radius: 11px;
  background: rgba(147, 132, 194, .10);
  color: var(--bgm-ink);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}
.shiro-bgm .shiro-bgm-tracks-toggle:hover { background: rgba(147, 132, 194, .20); }
.shiro-bgm .shiro-bgm-tracks-toggle small {
  margin-left: 5px;
  color: var(--bgm-subtle);
  font-size: 11px;
  font-weight: 400;
}
.shiro-bgm .shiro-bgm-tracks-chevron {
  flex: 0 0 auto;
  color: var(--bgm-accent);
  font-size: 16px;
  line-height: 1;
}
.shiro-bgm .shiro-bgm-tracks[hidden] { display: none !important; }
.shiro-bgm [data-bgm="track-search-row"]:not([hidden]) { display: grid; gap: 4px; margin-top: 8px; }
.shiro-bgm [data-bgm="track-search"] { min-width: 0; min-height: 44px; font: inherit; border: 1px solid currentColor; border-radius: 6px; padding: 4px 8px; }
.shiro-bgm .shiro-bgm-track[hidden] { display: none !important; }
.shiro-bgm .shiro-bgm-tracks:not([hidden]) { margin-top: 7px; }
.shiro-bgm[hidden] { display: none !important; }
.shiro-bgm .shiro-bgm-room-link {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 4px 11px;
  border-radius: 8px;
  color: var(--bgm-ink);
  font-weight: 600;
  text-decoration: none;
}
.shiro-bgm .shiro-bgm-room-link:hover { background: rgba(147, 132, 194, .12); }
.shiro-bgm .shiro-bgm-room-link:focus-visible { outline: 2px solid var(--bgm-accent); }
