:root {
  color-scheme: dark;
  font-family: 'Segoe UI', Inter, Roboto, Arial, sans-serif;
  background: #05060f;
  color: #ffffff;
  --accent: #7df4c6;
  --card-bg: rgba(15, 18, 40, 0.62);
  --card-border: rgba(140, 130, 255, 0.28);
  --panel-bg: rgba(9, 17, 31, 0.92);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
}

/* Shared background: uses the branded artwork on every screen. A soft dark
   veil keeps text readable over the brighter parts of the image. */
.shell {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  /* Anchor top-left so the branded logo in the artwork is never cropped,
     regardless of the browser window's aspect ratio. */
  background:
    linear-gradient(180deg, rgba(5, 6, 15, 0.55), rgba(5, 6, 15, 0.78)),
    url('./background.png') left top / cover no-repeat;
  background-color: #05060f;
}

/* ---- Full-screen views (only one visible at a time) --------------------- */

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3vh, 34px);
  padding: clamp(20px, 5vh, 60px) clamp(20px, 5vw, 72px);
  text-align: center;
  z-index: 2;
}

.center-view {
  gap: clamp(14px, 2.4vh, 22px);
}

.setup-view {
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

/* ---- Section eyebrow with decorative rules ------------------------------ */

.section-eyebrow {
  align-items: center;
  color: var(--accent);
  display: flex;
  font-size: clamp(15px, 2vw, 24px);
  font-weight: 800;
  gap: clamp(12px, 2vw, 24px);
  letter-spacing: 4px;
  margin: 0;
  text-transform: uppercase;
}

.section-eyebrow .rule {
  background: linear-gradient(90deg, transparent, rgba(125, 244, 198, 0.7));
  display: inline-block;
  height: 2px;
  width: clamp(48px, 9vw, 150px);
}

.section-eyebrow .rule:last-child {
  background: linear-gradient(90deg, rgba(125, 244, 198, 0.7), transparent);
}

/* ---- Setup: two responsive columns -------------------------------------- */

.setup-grid {
  align-items: stretch;
  display: flex;
  flex-wrap: wrap;
  gap: clamp(18px, 3vw, 40px);
  justify-content: center;
  max-width: 1240px;
  width: 100%;
}

.setup-left,
.setup-right {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2vh, 22px);
  min-width: 280px;
}

.setup-left {
  flex: 1 1 380px;
  justify-content: center;
  min-width: 0;
}

.setup-right {
  flex: 1 1 420px;
  justify-content: center;
  text-align: left;
}

/* Big glowing code card */
.code-card {
  background: var(--card-bg);
  border: 1px solid rgba(125, 244, 198, 0.35);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 0 60px rgba(125, 244, 198, 0.12) inset;
  min-width: 0;
  overflow: hidden;
  padding: clamp(22px, 4vh, 40px) clamp(20px, 4vw, 48px) clamp(26px, 4vh, 44px);
  text-align: center;
}

.code-caption {
  align-items: center;
  color: #c3c9ee;
  display: flex;
  font-size: clamp(14px, 1.6vw, 20px);
  font-weight: 600;
  gap: 8px;
  justify-content: center;
  margin: 0 0 clamp(10px, 2vh, 18px);
}

.mini-ico {
  font-size: 1.15em;
  line-height: 1;
}

.code {
  color: #ffffff;
  font-family: 'Segoe UI', Consolas, monospace;
  font-size: clamp(40px, 6.4vw, 84px);
  font-weight: 800;
  letter-spacing: clamp(3px, 0.7vw, 9px);
  line-height: 1;
  margin: 0;
  max-width: 100%;
  /* letter-spacing adds trailing space after the last glyph; the negative
     margin re-centers the code so it never appears to spill past the box. */
  margin-right: calc(clamp(3px, 0.7vw, 9px) * -1);
  overflow: hidden;
  text-overflow: clip;
  text-shadow: 0 0 34px rgba(125, 244, 198, 0.5);
  white-space: nowrap;
}

/* Numbered step cards */
.step-cards {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.6vh, 16px);
  list-style: none;
  margin: 0;
  padding: 0;
}

.step-card {
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  color: #dfe3ff;
  display: flex;
  font-size: clamp(15px, 1.7vw, 21px);
  gap: clamp(12px, 1.6vw, 18px);
  padding: clamp(12px, 1.8vh, 18px) clamp(14px, 2vw, 22px);
}

.step-card b {
  color: #ffffff;
}

.step-badge {
  align-items: center;
  background: linear-gradient(135deg, #8b5cf6, #ff8a4c);
  border-radius: 12px;
  color: #ffffff;
  display: inline-flex;
  flex: none;
  font-size: clamp(15px, 1.6vw, 20px);
  font-weight: 800;
  height: clamp(34px, 4vw, 46px);
  justify-content: center;
  width: clamp(34px, 4vw, 46px);
}

.step-text {
  line-height: 1.35;
}

/* Highlighted status / notice card */
.notice-card {
  align-items: center;
  background: rgba(125, 244, 198, 0.12);
  border: 1px solid rgba(125, 244, 198, 0.55);
  border-radius: 16px;
  box-shadow: 0 0 26px rgba(125, 244, 198, 0.18);
  color: #d6ffef;
  display: flex;
  font-size: clamp(15px, 1.7vw, 21px);
  font-weight: 700;
  gap: 10px;
  padding: clamp(12px, 1.8vh, 18px) clamp(14px, 2vw, 22px);
}

.notice-card::before {
  content: '\2714';
  color: var(--accent);
  font-size: 1.1em;
}

.notice-card.is-plain {
  background: var(--card-bg);
  border-color: var(--card-border);
  box-shadow: none;
  color: #c3c9ee;
  font-weight: 600;
}

.notice-card.is-plain::before {
  content: '\2026';
  color: #8f97c9;
}

/* Server URL card */
.url-card {
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  color: #ffffff;
  display: flex;
  font-family: Consolas, Monaco, monospace;
  font-size: clamp(14px, 1.5vw, 20px);
  gap: 12px;
  overflow-wrap: anywhere;
  padding: clamp(12px, 1.8vh, 18px) clamp(14px, 2vw, 22px);
}

.url-value {
  overflow-wrap: anywhere;
}

/* ---- Buttons ------------------------------------------------------------- */

.cta-button {
  align-items: center;
  background: linear-gradient(135deg, #8b5cf6, #ff8a4c);
  border: 0;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(139, 92, 246, 0.35);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  gap: 10px;
  font-size: clamp(16px, 1.9vw, 22px);
  font-weight: 800;
  justify-content: center;
  min-height: 60px;
  padding: 0 clamp(24px, 3vw, 40px);
  text-decoration: none;
}

.cta-ico {
  font-size: 1.1em;
  line-height: 1;
}

.pill-primary {
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  color: #09111f;
  cursor: pointer;
  font-size: clamp(15px, 1.7vw, 19px);
  font-weight: 800;
  min-height: 48px;
  padding: 0 24px;
}

.pill-ghost {
  background: transparent;
  border: 1px solid #4a5488;
  border-radius: 999px;
  color: #c6d4ee;
  cursor: pointer;
  font-size: clamp(14px, 1.5vw, 17px);
  font-weight: 700;
  min-height: 44px;
  padding: 0 20px;
}

/* ---- Mirror view: video is the hero, always centered ------------------- */

.stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  overflow: hidden;
  z-index: 4;
}

video {
  background: #000000;
  display: block;
  height: auto;
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  transform-origin: center center;
  width: auto;
}

/* Rotation is applied only on demand so TV browsers keep the hardware
   video overlay (a permanent transform can make some TVs render black). */
.stage video.rotated {
  transform: rotate(var(--screeno-rotation, 0deg));
}

.stage.fit-fill video {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.stage.fit-compact video {
  height: auto;
  max-height: 82%;
  max-width: 78%;
  width: auto;
}

.stage.fit-contain video {
  height: auto;
  max-height: 100%;
  max-width: 100%;
  width: auto;
}

/* ---- Top status pill (mirror view) -------------------------------------- */

.topbar {
  position: absolute;
  right: clamp(12px, 2.4vw, 28px);
  top: clamp(12px, 2.4vh, 26px);
  z-index: 6;
}

.conn-pill {
  align-items: center;
  background: rgba(9, 17, 31, 0.82);
  border: 1px solid rgba(125, 244, 198, 0.5);
  border-radius: 999px;
  color: #d6ffef;
  display: inline-flex;
  font-size: clamp(13px, 1.4vw, 17px);
  font-weight: 700;
  gap: 8px;
  padding: 8px 16px;
}

.conn-dot {
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
  height: 10px;
  width: 10px;
}

/* ---- Connecting ---------------------------------------------------------- */

.spinner {
  animation: spin 0.9s linear infinite;
  border: 6px solid rgba(125, 244, 198, 0.2);
  border-radius: 50%;
  border-top-color: var(--accent);
  height: 72px;
  width: 72px;
}

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

.connecting-title {
  color: #ffffff;
  font-size: clamp(22px, 3vw, 36px);
  font-weight: 800;
  margin: 0;
}

.connecting-detail {
  color: #9fb2d4;
  font-size: clamp(14px, 1.7vw, 20px);
  margin: 0;
}

/* ---- Expired / lost ------------------------------------------------------ */

.expired-title {
  color: #ffd479;
  font-size: clamp(24px, 3.2vw, 40px);
  font-weight: 800;
  margin: 0;
}

.expired-detail {
  color: #c6d4ee;
  font-size: clamp(15px, 1.8vw, 22px);
  margin: 0;
}

/* ---- Fatal --------------------------------------------------------------- */

.fatal-panel {
  background: var(--panel-bg);
  border: 2px solid rgba(224, 79, 95, 0.6);
  border-radius: 20px;
  z-index: 8;
}

.fatal-title {
  color: #ffb4a8;
  font-size: clamp(24px, 3vw, 40px);
  font-weight: 800;
  margin: 0;
}

.fatal-text {
  color: #dbe7ff;
  font-size: clamp(15px, 1.8vw, 22px);
  margin: 0;
}

/* ---- Exit fullscreen button (only shown while in fullscreen) ------------ */

.exit-fs {
  align-items: center;
  background: rgba(9, 17, 31, 0.92);
  border: 1px solid #33507d;
  border-radius: 999px;
  color: #dbe7ff;
  cursor: pointer;
  display: flex;
  font-size: clamp(14px, 1.6vw, 18px);
  font-weight: 800;
  gap: 8px;
  padding: 10px 18px;
  position: absolute;
  right: clamp(10px, 2vw, 22px);
  top: clamp(10px, 2vh, 22px);
  z-index: 12;
}

.exit-fs-icon {
  font-size: 18px;
  line-height: 1;
}

/* ---- Buttons ------------------------------------------------------------- */

.primary-button {
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  color: #09111f;
  cursor: pointer;
  font-size: clamp(16px, 2vw, 24px);
  font-weight: 800;
  min-height: 60px;
  padding: 0 36px;
}

.ghost-button {
  background: transparent;
  border: 1px solid #33507d;
  border-radius: 12px;
  color: #c6d4ee;
  cursor: pointer;
  font-size: clamp(14px, 1.6vw, 18px);
  font-weight: 700;
  min-height: 48px;
  padding: 0 24px;
}

/* ---- Network banner ------------------------------------------------------ */

.network-banner {
  align-items: center;
  background: rgba(224, 79, 95, 0.95);
  border-radius: 999px;
  color: #ffffff;
  display: flex;
  font-size: clamp(13px, 1.5vw, 18px);
  font-weight: 700;
  gap: 10px;
  left: 50%;
  padding: 10px 22px;
  position: absolute;
  top: 20px;
  transform: translateX(-50%);
  z-index: 10;
}

.network-banner.reconnecting {
  background: rgba(255, 179, 71, 0.95);
  color: #221a00;
}

.banner-dot {
  animation: pulse 1.2s ease-in-out infinite;
  background: #ffffff;
  border-radius: 50%;
  height: 12px;
  width: 12px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ---- Left control rail (only after connect) ----------------------------- */

.rail {
  align-items: stretch;
  backdrop-filter: blur(6px);
  background: rgba(9, 17, 31, 0.86);
  border: 1px solid #21324f;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  left: clamp(8px, 2vw, 24px);
  max-height: 92vh;
  overflow-y: auto;
  padding: 12px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
}

.tool {
  align-items: center;
  background: #16263d;
  border: 1px solid #24395c;
  border-radius: 12px;
  color: #dbe7ff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  justify-content: center;
  min-height: 62px;
  min-width: 96px;
  padding: 8px 14px;
}

.tool.primary,
.tool.attention {
  background: var(--accent);
  border-color: var(--accent);
  color: #09111f;
}

.tool.attention {
  animation: pulse 1.3s ease-in-out infinite;
}

/* Fullscreen: hide chrome, show only the video on black. */
body.is-fullscreen .rail,
body.is-fullscreen .topbar,
body.is-fullscreen .view {
  display: none !important;
}

body.is-fullscreen .stage {
  background: #000000;
  z-index: 20;
}

.tool-icon {
  font-size: 20px;
  line-height: 1;
}

.tool-label {
  font-size: 13px;
  font-weight: 800;
}

#audioButton[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #09111f;
}

/* Focus ring so a TV remote's D-pad shows which control is selected. */
button:focus,
button:focus-visible,
a:focus,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

@media (max-height: 560px) {
  .setup-view {
    justify-content: flex-start;
    padding-bottom: 16px;
    padding-top: 16px;
  }
}

/* ---- Diagnostics --------------------------------------------------------- */

.diagnostic-panel {
  background: rgba(5, 11, 20, 0.82);
  border: 1px solid rgba(125, 244, 198, 0.25);
  border-radius: 8px;
  color: #dbe7ff;
  font-family: Consolas, Monaco, monospace;
  font-size: clamp(12px, 1.2vw, 15px);
  left: clamp(120px, 13vw, 200px);
  max-width: min(680px, calc(100vw - 220px));
  overflow-wrap: anywhere;
  padding: 10px 12px;
  position: absolute;
  bottom: 16px;
  z-index: 3;
}
