:root {
  color-scheme: dark;
  --orion-safe-x: max(env(safe-area-inset-left, 0px), 3vw);
  --orion-safe-y: max(env(safe-area-inset-bottom, 0px), 3vh);
  --orion-scale: clamp(.78, calc(100vw / 1920), 4);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: #050711;
  color: #f7f8ff;
}

:root.playback-visible,
body.playback-visible {
  background: transparent;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { width: 100%; min-height: 100%; margin: 0; }

body {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(1, 2, 10, .05), rgba(1, 2, 10, .20)),
    url("./orion-cast-logo.png") center center / cover no-repeat,
    url("./orion-cast-background.jpg") center center / cover no-repeat,
    #050711;
}

button, input { font: inherit; }

button {
  border: 0;
  border-radius: 12px;
  padding: 14px 24px;
  color: white;
  background: #5267ff;
  font-weight: 700;
  cursor: pointer;
}

button:focus-visible, input:focus-visible { outline: max(3px, calc(3px * var(--orion-scale))) solid #70deff; outline-offset: 4px; box-shadow: 0 0 0 7px rgba(82, 103, 255, .35); }
button:disabled { opacity: .4; cursor: default; }
button.secondary { background: rgba(255,255,255,.12); }

.shell { min-height: 100vh; display: grid; place-items: center; padding: 6vw; }

.panel {
  width: 90vw;
  max-width: 760px;
  padding: 64px;
  text-align: center;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 28px;
  background: rgba(10, 14, 30, .82);
  box-shadow: 0 32px 100px rgba(0,0,0,.45);
}

.panel.receiver-linked {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  width: 100vw;
  max-width: none;
  min-height: 100vh;
  padding: 0;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(1, 2, 10, .03), rgba(1, 2, 10, .18)),
    url("./orion-cast-logo.png") center center / cover no-repeat,
    url("./orion-cast-background.jpg") center center / cover no-repeat #02030a;
  box-shadow: none;
}

.receiver-linked .welcome-content {
  position: absolute;
  left: 50%;
  bottom: 7vh;
  width: 82vw;
  max-width: 760px;
  padding: 22px 32px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 22px;
  background: rgba(2, 3, 10, .78);
  box-shadow: 0 16px 50px rgba(0,0,0,.42);
  transform: translateX(-50%);
}

.receiver-linked .brand-mark,
.receiver-linked .eyebrow,
.receiver-linked .pairing {
  display: none;
}

.receiver-linked h1 {
  margin: 0 0 6px;
  font-size: 30px;
}

.receiver-linked .subtitle {
  margin: 0;
  font-size: 18px;
}

.receiver-linked .connection-status {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 14px 0 0;
  color: #f7f8ff;
}

.receiver-linked .connection-status::before {
  width: 18px;
  height: 18px;
  content: "";
  border: 3px solid rgba(255,255,255,.28);
  border-top-color: #70deff;
  border-radius: 50%;
  animation: loading-spin .9s linear infinite;
  margin-right: 12px;
}

.receiver-linked.receiver-online .connection-status::before {
  width: 12px;
  height: 12px;
  border: 0;
  background: #39e6a4;
  box-shadow: 0 0 18px rgba(57,230,164,.8);
  animation: none;
}

.brand-mark {
  width: 88px;
  height: 88px;
  margin: 0 auto 24px;
  display: block;
  object-fit: contain;
  border-radius: 28px;
  box-shadow: 0 15px 45px rgba(82, 103, 255, .36);
}

.receiver-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border: 1px solid rgba(112, 222, 255, .24);
  border-radius: 999px;
  color: #dfe8ff;
  background: rgba(15, 23, 48, .72);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.receiver-badge > span:first-child { width: 9px; height: 9px; border-radius: 50%; background: #39e6a4; box-shadow: 0 0 13px rgba(57,230,164,.85); }

.eyebrow { color: #8fa0ff; letter-spacing: .2em; font-size: 14px; font-weight: 800; }
h1 { margin: 12px 0; font-size: 56px; line-height: 1.05; }
h2 { margin: 8px 0 28px; font-size: 42px; }
.subtitle { color: #aeb5cc; font-size: 22px; }

.pairing {
  margin: 38px auto 28px;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 16px;
  background: rgba(255,255,255,.07);
  color: #aeb5cc;
}

.pairing strong { color: white; font-size: 34px; letter-spacing: .16em; }
.connection-status { color: #70deff; font-size: 18px; }
.startup-retry {
  margin-top: 18px;
  min-width: 190px;
}
.startup-retry[hidden] { display: none; }
.receiver-actions {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}
.receiver-actions > * + * { margin-left: 12px; }

.receiver-linked .receiver-actions button {
  min-width: 210px;
  padding: 12px 18px;
}
.dev-tools { margin-top: 18px; }

.player-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  background: #000;
}
.player-panel.playback-visible { background: transparent; }
.player-panel video,
.player-panel .native-player {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.player-panel .native-player {
  z-index: 0;
  display: block;
  background: transparent;
}

.player-panel video { z-index: 1; }

.playback-diagnostic {
  position: absolute;
  top: 2vh;
  left: 2vw;
  z-index: 20;
  margin: 0;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .72);
  color: #70deff;
  font: 700 18px/1.2 monospace;
}

.playback-diagnostic[hidden] { display: none; }

.loading-splash {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(1, 2, 10, .03), rgba(1, 2, 10, .18)),
    url("./orion-cast-logo.png") center center / cover no-repeat,
    url("./orion-cast-background.jpg") center center / cover no-repeat #02030a;
}

.loading-splash[hidden] { display: none; }

.loading-message {
  position: absolute;
  left: 50%;
  bottom: 7vh;
  display: flex;
  align-items: center;
  padding: 14px 24px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: rgba(2, 3, 10, .78);
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.loading-message p { margin: 0; color: #f7f8ff; font-size: 20px; font-weight: 700; }

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255,255,255,.28);
  border-top-color: #70deff;
  border-radius: 50%;
  animation: loading-spin .9s linear infinite;
  margin-right: 16px;
}

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

.player-overlay {
  position: absolute;
  left: var(--orion-safe-x);
  right: var(--orion-safe-x);
  bottom: var(--orion-safe-y);
  z-index: 25;
  padding: clamp(20px, 2vw, 40px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 22px;
  background: linear-gradient(100deg, rgba(3,5,14,.97), rgba(7,12,29,.84));
  box-shadow: 0 22px 80px rgba(0,0,0,.56);
  opacity: 1;
  transform: translateY(0);
  transition: opacity .22s ease, transform .22s ease;
}

.player-panel.hud-hidden .player-overlay {
  pointer-events: none;
  opacity: 0;
  transform: translateY(18px);
}

.diagnostics-enabled .player-panel.hud-hidden .player-overlay {
  pointer-events: auto;
  opacity: 1;
  transform: none;
}

.player-overlay h2 { margin-bottom: 10px; font-size: clamp(30px, 3.2vw, 64px); }
.player-overlay .eyebrow { margin-top: 0; }
.player-overlay-content, .player-overlay::after { clear: both; }
.player-overlay::after { display: table; content: ""; }

.player-overlay > .player-overlay-content,
.player-overlay > .player-overlay-content + * { position: relative; }
.player-overlay .media-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.player-heading-row { display: flex; justify-content: space-between; gap: 20px; }
.media-badge { padding: 6px 10px; border: 1px solid rgba(143,160,255,.35); border-radius: 999px; color: #dce3ff; background: rgba(33,45,89,.72); font-size: clamp(12px, 1vw, 16px); font-weight: 800; letter-spacing: .06em; }
.media-badge-live { border-color: rgba(255,83,119,.58); color: #fff; background: #d62953; }
.player-overlay .player-overlay-content { display: block; }
.player-overlay > .player-overlay-content { min-height: 1px; }
.player-overlay .player-heading-row + h2 { margin-top: 8px; }

.player-overlay .player-overlay-content { overflow: hidden; }
.player-overlay .player-heading-row { align-items: flex-start; }
.player-overlay .player-heading-row .eyebrow { flex: 1; }

.playback-timeline { margin: 22px 0 0; }
.progress-track { width: 100%; height: clamp(7px, .65vw, 13px); overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.18); }
.progress-track > span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5267ff, #70deff); box-shadow: 0 0 18px rgba(112,222,255,.58); }
.timeline-labels { display: flex; justify-content: space-between; margin-top: 8px; color: #d8ddef; font-variant-numeric: tabular-nums; font-size: clamp(13px, 1.1vw, 18px); }
.media-technical { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 16px 0 0; color: #c7cee4; }
.media-technical > div { display: flex; gap: 7px; }
.media-technical dt { color: #8f9ab8; }
.media-technical dd { margin: 0; font-weight: 700; }

.media-artwork {
  float: right;
  width: 28vw;
  max-width: 360px;
  max-height: 203px;
  margin-left: 28px;
  border-radius: 14px;
  object-fit: cover;
}

.media-subtitle { margin: 0; color: #c6ccdf; font-size: clamp(16px, 1.35vw, 23px); }

.player-overlay label { display: block; margin-bottom: 10px; color: #c5cade; }
.url-row { display: flex; }
.url-row > * + * { margin-left: 12px; }
.url-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  padding: 14px 18px;
  color: white;
  background: rgba(255,255,255,.08);
}
.controls { display: flex; margin-top: 18px; }
.controls > * + * { margin-left: 12px; }
.diagnostic-tests { display: flex; justify-content: center; margin-top: 18px; }
.diagnostic-tests > * + * { margin-left: 12px; }
.diagnostic-tests[hidden] { display: none; }
#status { margin-bottom: 0; color: #aeb5cc; }

.transfer-state { position: fixed; top: var(--orion-safe-y); left: 50%; z-index: 45; display: flex; align-items: center; gap: 12px; padding: 13px 20px; border: 1px solid rgba(112,222,255,.4); border-radius: 999px; background: rgba(5,7,17,.94); transform: translateX(-50%); }
.transfer-icon { color: #70deff; font-size: 24px; }

.fullscreen-prompt {
  position: fixed;
  left: 50%;
  bottom: 6vh;
  z-index: 40;
  width: min(760px, 88vw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px;
  border: 1px solid rgba(112, 222, 255, .4);
  border-radius: 20px;
  background: rgba(5, 7, 17, .94);
  box-shadow: 0 20px 70px rgba(0, 0, 0, .6), 0 0 40px rgba(82, 103, 255, .18);
  transform: translateX(-50%);
}

.fullscreen-prompt div { display: grid; gap: 6px; }
.fullscreen-prompt > button { margin-left: 12px; }
.fullscreen-prompt strong { font-size: 22px; }
.fullscreen-prompt span { color: #aeb5cc; }
.fullscreen-prompt button { min-width: 190px; }

.setup-guide {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 5vw;
  background: rgba(1, 2, 10, .88);
}

.setup-guide-card {
  width: min(760px, 92vw);
  max-height: 88vh;
  overflow: auto;
  padding: 38px;
  border: 1px solid rgba(112, 222, 255, .28);
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(15, 21, 45, .98), rgba(6, 9, 22, .98));
  box-shadow: 0 28px 100px rgba(0, 0, 0, .65), 0 0 55px rgba(82, 103, 255, .16);
}

.setup-guide-card h2 { margin-bottom: 14px; }
.setup-guide-card > p:not(.eyebrow) { color: #c5cade; font-size: 19px; line-height: 1.55; }
.setup-guide-card ol { margin: 24px 0; padding-left: 26px; color: #e7eaff; font-size: 18px; line-height: 1.7; }
.setup-guide-status { min-height: 26px; color: #70deff !important; font-weight: 700; }
.setup-guide-actions { display: flex; flex-wrap: wrap; margin-top: 24px; }
.setup-guide-actions > * + * { margin-left: 12px; }

@media (max-width: 700px) {
  .panel { padding: 32px 20px; }
  .pairing, .url-row { flex-direction: column; }
  .receiver-actions, .fullscreen-prompt { flex-direction: column; }
  .receiver-actions button, .fullscreen-prompt button { width: 100%; }
  .receiver-actions > * + *, .fullscreen-prompt > button, .setup-guide-actions > * + * { margin-left: 0; margin-top: 12px; }
  .url-row > * + * { margin-left: 0; margin-top: 12px; }
  .url-row button { width: 100%; }
  .setup-guide-card { padding: 26px 20px; }
  .setup-guide-actions button { width: 100%; }
}

@media (max-height: 600px), (max-width: 900px) {
  .player-overlay { padding: 18px; }
  .media-artwork { width: 24vw; max-height: 28vh; }
  .media-technical { display: none; }
  .controls { margin-top: 12px; }
  #status { font-size: 14px; }
}

@media (min-width: 2560px) {
  button { border-radius: 18px; padding: 20px 34px; font-size: 1.15rem; }
  .player-overlay { border-radius: 32px; }
}

@media (min-width: 5000px) {
  body { font-size: 1.45rem; }
  .panel { max-width: 1500px; border-radius: 48px; }
  .brand-mark { width: 170px; height: 170px; }
}

[dir="rtl"] .media-artwork { float: left; margin-left: 0; margin-right: 28px; }
[dir="rtl"] .receiver-linked .connection-status::before,
[dir="rtl"] .loading-spinner { margin-right: 0; margin-left: 12px; }
[dir="rtl"] .controls > * + *,
[dir="rtl"] .receiver-actions > * + *,
[dir="rtl"] .setup-guide-actions > * + * { margin-left: 0; margin-right: 12px; }

@media (max-width: 1280px) {
  .panel { padding: 42px; }
  .brand-mark { width: 72px; height: 72px; }
  h1 { font-size: 44px; }
  h2 { font-size: 34px; }
  .subtitle { font-size: 19px; }
}

@media (max-width: 700px) {
  .panel { padding: 32px 20px; }
}

/* O perfil adaptativo afeta somente a interface; nunca a resolução do vídeo. */
html[data-orion-performance="ultra-low"] .panel,
html[data-orion-performance="low"] .panel,
html.adaptive-reduced-motion .fullscreen-prompt,
html.adaptive-reduced-motion .setup-guide-card {
  box-shadow: none;
  backdrop-filter: none;
}

html[data-orion-performance="ultra-low"] body::before,
html[data-orion-performance="low"] body::before {
  opacity: .28;
}

html.adaptive-reduced-motion *,
html.adaptive-reduced-motion *::before,
html.adaptive-reduced-motion *::after {
  transition-duration: 0s !important;
  animation-duration: 1.5s !important;
  animation-iteration-count: 1 !important;
}

html.adaptive-reduced-motion .loading-spinner {
  animation-iteration-count: infinite !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; animation-duration: 0s !important; }
}

@media (prefers-contrast: more) {
  .panel, .player-overlay, .fullscreen-prompt, .setup-guide-card { border-color: #fff; background: #02040b; }
  .subtitle, .media-subtitle, #status { color: #fff; }
}
