:root {
  --display-bg: #030813;
  --display-text: #f2fbff;
  --display-muted: #aeb9c8;
  --display-cyan: #00e5ff;
  --display-pink: #ff4fb8;
  --display-gold: #ffd13d;
  --display-panel: rgba(5, 12, 25, 0.78);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--display-bg);
  color: var(--display-text);
  font-family: "Montserrat", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  background:
    linear-gradient(120deg, rgba(0, 229, 255, 0.14), transparent 38%, rgba(255, 79, 184, 0.13)),
    linear-gradient(rgba(3, 8, 19, 0.62), rgba(3, 8, 19, 0.76)),
    url("../images/wallpaperv1.jpg") center / cover no-repeat;
}

#display-frame {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  border: 0;
  background: #020711;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

body.has-target #display-frame {
  opacity: 1;
  pointer-events: auto;
}

.display-standby {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 42px;
}

body.has-target .display-standby {
  opacity: 0;
  pointer-events: none;
}

.display-panel {
  width: min(880px, calc(100vw - 84px));
  min-height: min(420px, calc(100vh - 84px));
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  padding: 34px 42px;
  border: 2px solid rgba(0, 229, 255, 0.58);
  border-radius: 10px;
  background: var(--display-panel);
  box-shadow:
    0 0 34px rgba(0, 229, 255, 0.24),
    inset 0 0 32px rgba(255, 79, 184, 0.08);
  text-align: center;
}

.display-brand {
  font-family: "Orbitron", "Montserrat", sans-serif;
  max-width: 100%;
  font-size: clamp(38px, 5.4vw, 92px);
  font-weight: 900;
  line-height: 1.04;
  letter-spacing: 0;
  color: var(--display-text);
  text-shadow: 0 0 18px rgba(0, 229, 255, 0.42);
  overflow-wrap: anywhere;
}

.display-kicker {
  color: var(--display-cyan);
  font-size: clamp(18px, 2.2vw, 34px);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.display-code {
  width: min(700px, 100%);
  min-width: 0;
  padding: 14px 28px 16px;
  border: 1px solid rgba(255, 209, 61, 0.72);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.34);
  color: var(--display-gold);
  font-family: "Orbitron", "Montserrat", sans-serif;
  font-size: clamp(48px, 7vw, 108px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-shadow: 0 0 24px rgba(255, 209, 61, 0.32);
}

.display-join-url {
  color: var(--display-cyan);
  font-size: clamp(28px, 4vw, 66px);
  font-weight: 900;
  line-height: 1.08;
  text-shadow: 0 0 18px rgba(0, 229, 255, 0.34);
}

.display-join-url[hidden] {
  display: none;
}

body.is-join-screen .display-kicker {
  color: var(--display-gold);
}

body.is-join-screen .display-code {
  width: min(700px, 100%);
  min-width: 0;
  font-size: clamp(76px, 13vw, 180px);
}

.display-status {
  max-width: 680px;
  color: var(--display-muted);
  font-size: clamp(18px, 2vw, 30px);
  font-weight: 700;
  line-height: 1.35;
}

.display-corner {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 8px 12px;
  border: 1px solid rgba(0, 229, 255, 0.42);
  border-radius: 8px;
  background: rgba(2, 6, 14, 0.76);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.18);
  color: var(--display-text);
  font-size: 14px;
  line-height: 1;
}

.display-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--display-muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.display-dot::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #788394;
  box-shadow: 0 0 10px rgba(120, 131, 148, 0.55);
}

body.is-connected .display-dot::before {
  background: var(--display-cyan);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.85);
}

body.is-paired .display-dot::before {
  background: #36e879;
  box-shadow: 0 0 12px rgba(54, 232, 121, 0.85);
}

#display-corner-label {
  min-width: 0;
  color: var(--display-gold);
  font-family: "Orbitron", "Montserrat", sans-serif;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0;
}

#display-corner-label:empty {
  display: none;
}

/* Offline holding card — sits above everything (incl. a live frame) while the
   screen has no network, then display.js hides it once connectivity returns. */
.display-offline {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 42px;
  background:
    linear-gradient(120deg, rgba(0, 229, 255, 0.14), transparent 38%, rgba(255, 79, 184, 0.13)),
    linear-gradient(rgba(3, 8, 19, 0.82), rgba(3, 8, 19, 0.92)),
    var(--display-bg);
}

.display-offline[hidden] {
  display: none;
}

.display-offline-panel {
  border-color: rgba(255, 209, 61, 0.5);
  box-shadow:
    0 0 34px rgba(255, 209, 61, 0.18),
    inset 0 0 32px rgba(0, 229, 255, 0.06);
}

.display-offline-spinner {
  width: clamp(48px, 6vw, 84px);
  height: clamp(48px, 6vw, 84px);
  border-radius: 999px;
  border: 6px solid rgba(0, 229, 255, 0.22);
  border-top-color: var(--display-cyan);
  animation: display-spin 1s linear infinite;
}

@keyframes display-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .display-offline-spinner {
    animation-duration: 2.4s;
  }
}

.display-offline-label {
  color: var(--display-gold);
  font-family: "Orbitron", "Montserrat", sans-serif;
  font-size: clamp(16px, 1.8vw, 26px);
  font-weight: 900;
  letter-spacing: 0.04em;
}

.display-offline-label:empty {
  display: none;
}

body.display-low-power *,
body.display-low-power *::before,
body.display-low-power *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

.display-device-menu-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(28px, 4vw);
  background: rgba(1, 5, 12, 0.9);
}

.display-device-menu-backdrop[hidden] {
  display: none;
}

.display-device-menu {
  width: min(900px, 100%);
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  padding: clamp(24px, 4vw, 48px);
  border: 2px solid rgba(0, 229, 255, 0.48);
  border-radius: 14px;
  background: #08101c;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.72), 0 0 36px rgba(0, 229, 255, 0.16);
}

.display-device-menu-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.display-device-menu-kicker,
.display-device-details span {
  color: var(--display-cyan);
  font-size: clamp(13px, 1.4vw, 19px);
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.display-device-menu-head h1 {
  margin: 5px 0 0;
  font-family: "Orbitron", "Montserrat", sans-serif;
  font-size: clamp(28px, 4vw, 54px);
}

.display-device-menu-close {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: var(--display-text);
  font-size: 34px;
}

.display-device-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.display-device-details > div {
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(0, 229, 255, 0.16);
  border-radius: 10px;
  background: rgba(0,0,0,0.22);
}

.display-device-details strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 7px;
  font-size: clamp(17px, 2vw, 26px);
}

.display-device-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.display-device-actions button {
  min-height: 62px;
  padding: 12px 16px;
  border: 1px solid rgba(0, 229, 255, 0.46);
  border-radius: 10px;
  background: rgba(0, 229, 255, 0.08);
  color: var(--display-text);
  font: inherit;
  font-size: 16px;
  font-weight: 900;
}

.display-device-actions button:focus {
  outline: 4px solid var(--display-gold);
  outline-offset: 3px;
}

.display-device-actions button.is-danger {
  border-color: rgba(255, 79, 120, 0.5);
  color: #ff8bab;
}

.display-device-menu-help {
  margin: 22px 0 0;
  color: var(--display-muted);
  text-align: center;
}

@media (max-width: 720px) {
  .display-panel {
    width: calc(100vw - 28px);
    min-height: calc(100vh - 28px);
    padding: 24px;
  }

  .display-corner {
    right: 10px;
    bottom: 10px;
    font-size: 12px;
  }

  .display-device-details,
  .display-device-actions {
    grid-template-columns: 1fr;
  }
}
