html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
}

html {
  color-scheme: dark;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.player {
  --pad: clamp(12px, 3vmin, 30px);
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #000;
  touch-action: manipulation;
}

.player__video {
  position: absolute;
  left: var(--pad);
  top: var(--pad);
  width: calc(100% - 2 * var(--pad));
  height: calc(100% - 2 * var(--pad));
  /* Safe-area enhancement where env() exists; the plain declarations above
     are the fallback kept by browsers without env support. */
  left: max(var(--pad), env(safe-area-inset-left));
  top: max(var(--pad), env(safe-area-inset-top));
  width: calc(100% - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 2 * var(--pad));
  height: calc(100% - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 2 * var(--pad));
  display: block;
  border: 0;
  object-fit: contain;
  object-position: center;
  background: #000;
  opacity: 0;
  z-index: 0;
  transition: opacity 180ms ease-out;
}

.player__video.is-visible {
  opacity: 1;
}

.player__logo {
  position: absolute;
  z-index: 5;
  top: var(--pad);
  top: max(var(--pad), env(safe-area-inset-top));
  right: var(--pad);
  right: max(var(--pad), env(safe-area-inset-right));
  display: block;
  width: clamp(88px, 11vw, 160px);
  height: auto;
  opacity: 0.68;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.player__fs {
  position: absolute;
  right: var(--pad);
  right: max(var(--pad), env(safe-area-inset-right));
  bottom: var(--pad);
  bottom: max(var(--pad), env(safe-area-inset-bottom));
  z-index: 6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  /* Controls hide with the cursor and surface only on activity: move, tap
     or press anything and they fade in; idle returns the frame to black. */
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-out;
}

.player__sound {
  position: absolute;
  right: calc(var(--pad) + 52px);
  right: calc(max(var(--pad), env(safe-area-inset-right)) + 52px);
  bottom: var(--pad);
  bottom: max(var(--pad), env(safe-area-inset-bottom));
  z-index: 6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-out;
}

.player__fs[hidden],
.player__sound[hidden] {
  display: none;
}

/* Any recent pointer or key activity reveals both controls; true hover
   sharpens them. The watermark is exempt: it shows regardless of hover. */
:root:not(.cursor-idle) .player__fs,
:root:not(.cursor-idle) .player__sound {
  opacity: 0.9;
  pointer-events: auto;
}

:root:not(.cursor-idle) .player__fs:hover,
:root:not(.cursor-idle) .player__sound:hover {
  opacity: 1;
}

.player__fs svg,
.player__sound svg {
  width: 20px;
  height: 20px;
  display: block;
  pointer-events: none;
}

.player__fs .fs-icon-compress {
  display: none;
}

.player__fs[aria-pressed="true"] .fs-icon-expand {
  display: none;
}

.player__fs[aria-pressed="true"] .fs-icon-compress {
  display: block;
}

.player__sound .snd-wave {
  display: none;
}

.player__sound[aria-pressed="true"] .snd-wave {
  display: block;
}

.player__sound[aria-pressed="true"] .snd-cross {
  display: none;
}

/* The controls hide with the cursor: the channel shows a black frame when
   nobody is interacting, and any pointer activity brings them back. */
:root.cursor-idle .player__fs,
:root.cursor-idle .player__sound {
  opacity: 0;
  pointer-events: none;
}

/* Fullscreen is the point of fullscreen: the framed-page margins are an
   on-page affordance and come off. Overlays keep only a small safe-area
   aware inset so they never sit under display cutouts. */
.player:fullscreen .player__video {
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  left: env(safe-area-inset-left, 0px);
  top: env(safe-area-inset-top, 0px);
  width: calc(100% - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  height: calc(100% - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}

.player:fullscreen .player__logo {
  top: 14px;
  right: 16px;
  top: max(14px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
}

.player:fullscreen .player__fs {
  right: 16px;
  bottom: 14px;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
}

.player:-webkit-full-screen .player__video {
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  left: env(safe-area-inset-left, 0px);
  top: env(safe-area-inset-top, 0px);
  width: calc(100% - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  height: calc(100% - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}

.player:-webkit-full-screen .player__logo {
  top: 14px;
  right: 16px;
  top: max(14px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
}

.player:-webkit-full-screen .player__fs {
  right: 16px;
  bottom: 14px;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
}

.player:-webkit-full-screen .player__sound {
  right: calc(max(16px, env(safe-area-inset-right)) + 52px);
  bottom: max(14px, env(safe-area-inset-bottom));
}

.player:fullscreen .player__sound {
  right: calc(max(16px, env(safe-area-inset-right)) + 52px);
  bottom: max(14px, env(safe-area-inset-bottom));
}

@media (prefers-reduced-motion: reduce) {
  .player__video,
  .player__fs {
    transition-duration: 1ms;
  }
}

/* Cursor idle hide: the dashboard of a TV channel never shows a parked
   pointer. Any pointer or key activity restores it. */
:root.cursor-idle,
:root.cursor-idle * {
  cursor: none;
}
