:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #252b2b;
  background: #f5f1e9;
}

* { box-sizing: border-box; }

html, body, #receiverApp {
  width: 100%;
  height: 100%;
  margin: 0;
}

body { overflow: hidden; }

button {
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid rgba(43, 115, 120, .25);
  border-radius: 999px;
  color: #205d60;
  background: #fffdf8;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.pairing-panel {
  position: fixed;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
  background:
    radial-gradient(circle at 20% 0%, rgba(144, 209, 211, .28), transparent 32%),
    radial-gradient(circle at 90% 20%, rgba(255, 107, 81, .13), transparent 30%),
    #f8f4ec;
}

.brand-mark {
  display: grid;
  width: 70px;
  height: 70px;
  place-items: center;
  border-radius: 22px;
  color: white;
  background: linear-gradient(145deg, #2b7378, #ff624e);
  box-shadow: 0 16px 38px rgba(36, 78, 77, .18);
  font-size: 22px;
  font-weight: 900;
}

.eyebrow {
  margin: 6px 0 -6px;
  color: #487072;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .16em;
}

h1 { margin: 0; font-size: clamp(26px, 3vw, 48px); }

.pairing-code {
  min-width: min(620px, 88vw);
  padding: 20px 36px 24px;
  border: 1px solid rgba(37, 43, 43, .09);
  border-radius: 28px;
  color: #e8503f;
  background: rgba(255, 253, 248, .9);
  box-shadow: 0 18px 50px rgba(39, 61, 58, .11);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(52px, 9vw, 110px);
  font-weight: 850;
  letter-spacing: .18em;
  line-height: 1;
  text-indent: .18em;
}

.pairing-status { margin: 2px 0 0; color: #5f6e6e; font-size: 18px; }
.pairing-help { margin: 0; color: #788484; font-size: 14px; }

.display-stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #fffdf8;
}

.display-stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fffdf8;
}

.display-header {
  position: fixed;
  z-index: 5;
  top: 14px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 7px 8px 7px 14px;
  border: 1px solid rgba(43, 115, 120, .18);
  border-radius: 18px;
  background: rgba(255, 253, 248, .9);
  box-shadow: 0 8px 22px rgba(30, 57, 55, .1);
  backdrop-filter: blur(14px);
}

.display-header > div:first-child { display: grid; gap: 2px; }
.display-header strong { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.display-header span { color: #2b7378; font-size: 11px; }
.display-header button { min-height: 36px; padding: 0 14px; font-size: 12px; }
.display-actions { display: flex; align-items: center; gap: 8px; }
#audioEnableButton.is-enabled { color: #fff; border-color: #2b7378; background: #2b7378; }
#audioEnableButton.is-error { color: #a43f33; border-color: rgba(164, 63, 51, .35); }
#audioEnableButton:disabled { cursor: wait; opacity: .62; }

.display-stage.is-loading .display-header { visibility: hidden; }
.loading-panel {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 32px 20px;
  text-align: center;
  background:
    radial-gradient(circle at 20% 0%, rgba(144, 209, 211, .22), transparent 45%),
    radial-gradient(circle at 90% 90%, rgba(255, 107, 81, .08), transparent 38%),
    #f8f4ec;
}
.loading-card {
  width: min(520px, 100%);
  padding: 36px 40px;
  border: 1px solid rgba(43, 115, 120, .12);
  border-radius: 28px;
  background: rgba(255, 253, 248, .94);
  box-shadow: 0 20px 60px rgba(39, 61, 58, .08);
}
.loading-card h1 { font-size: clamp(24px, 3vw, 32px); line-height: 1.35; }
.loading-visual { position: relative; width: 104px; height: 104px; margin: 30px auto 24px; }
.loading-orbit {
  position: absolute;
  inset: 0;
  border: 3px solid #e1edeb;
  border-top-color: #2b7378;
  border-right-color: #88c8c8;
  border-radius: 50%;
  animation: loading-orbit 2s linear infinite;
}
.loading-bars { display: flex; align-items: center; justify-content: center; gap: 5px; height: 100%; }
.loading-bars i {
  width: 5px;
  height: 30px;
  border-radius: 4px;
  background: #2b7378;
  animation: loading-wave 1.2s ease-in-out infinite;
}
.loading-bars i:nth-child(2), .loading-bars i:nth-child(4) { height: 42px; animation-delay: -.3s; }
.loading-bars i:nth-child(3) { height: 52px; animation-delay: -.6s; }
.loading-bars i:nth-child(5) { animation-delay: -.9s; }
.loading-song { margin: 10px 0 28px; color: #487072; font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.loading-status p { margin: 0; }
#loadingMessage { color: #526767; font-size: 15px; }
#loadingCount { margin-top: 8px; color: #2b7378; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.loading-progress {
  display: block;
  width: 100%;
  height: 8px;
  margin: 18px 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  appearance: none;
  background: #e2eeeb;
  accent-color: #2b7378;
}
.loading-progress::-webkit-progress-bar { background: #e2eeeb; border-radius: 8px; }
.loading-progress::-webkit-progress-value { background: #2b7378; border-radius: 8px; transition: width .3s ease; }
.loading-progress::-moz-progress-bar { background: #2b7378; border-radius: 8px; }
.loading-hint { margin: 0; color: #7b8987; font-size: 13px; line-height: 1.8; }
#loadingRetry { margin-top: 20px; background: #2b7378; color: white; }
.loading-panel.is-error .loading-orbit, .loading-panel.is-error .loading-bars i { animation: none; }
.loading-panel.is-error .loading-orbit { border-color: #e5cdc5; }
.loading-panel.is-error .loading-bars i { background: #a76b54; }
@keyframes loading-orbit { to { transform: rotate(360deg); } }
@keyframes loading-wave { 0%, 100% { transform: scaleY(.55); } 50% { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) {
  .loading-orbit, .loading-bars i { animation: none; }
  .loading-progress::-webkit-progress-value { transition: none; }
}
@media (max-width: 540px) {
  .loading-card { padding: 28px 22px; }
}
@media (max-height: 540px) {
  .loading-panel { padding: 16px; }
  .loading-card { padding: 20px 28px; }
  .loading-visual { width: 64px; height: 64px; margin: 16px auto 12px; }
  .loading-bars i { height: 20px; }
  .loading-bars i:nth-child(2), .loading-bars i:nth-child(4) { height: 28px; }
  .loading-bars i:nth-child(3) { height: 36px; }
  .loading-song { margin: 6px 0 14px; }
  .loading-card .eyebrow { font-size: 11px; }
  .loading-progress { margin: 12px 0; }
}

.ended-panel {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 22px;
  background: rgba(248, 244, 236, .92);
  backdrop-filter: blur(16px);
  font-size: clamp(24px, 3vw, 48px);
}

[hidden] { display: none !important; }

@media (max-height: 540px) {
  .pairing-panel { gap: 10px; }
  .brand-mark { width: 52px; height: 52px; border-radius: 16px; }
  .pairing-code { padding-block: 14px 18px; }
}
