* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --slider-fill: #a0c2e9;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

html,
body {
  height: 100%;
  width: 100%;
  background: #000;
  color: #fff;
  font-family: sans-serif;
  overflow: hidden;
}

.container {
  display: flex;
  height: 100vh;
  width: 100vw;
  padding-bottom: var(--safe-b);
}

@supports (height: 100svh) {
  .container {
    height: 100svh;
  }
}

@supports (height: 100dvh) {
  .container {
    height: 100dvh;
  }
}

.player {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
}

.video {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#owncast-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.custom-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-b) + 10px);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

@media (hover: hover) {
  .player:hover .custom-controls {
    opacity: 1;
    pointer-events: auto;
  }
}

.player.show-controls .custom-controls {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.custom-controls button {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin-right: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.custom-controls button img {
  width: 1.2rem;
  height: 1.2rem;
  object-fit: contain;
}

#mute-icon {
  transform: translateY(-0.05rem);
}

#volume-slider {
  appearance: none;
  width: 8rem;
  height: 4px;
  background: #444;
  cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  margin-top: -4px;
  cursor: pointer;
}

#volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
}

#reload-btn {
  margin-left: auto;
}

#reload-btn img {
  width: 1.5rem;
  height: 1.5rem;
}

#fullscreen-btn {
  appearance: none;
  font-size: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
}

#schedule-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  height: 28px;
  min-width: 86px;
  padding: 0.22rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid #3a3a3a;
  border-radius: 0.6rem;
  background: #111;
  color: #eaeaea;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: translateZ(0);
}

#schedule-btn img {
  width: 1rem;
  height: 1rem;
  display: inline-block;
}

#schedule-btn:active {
  transform: translateY(1px);
}

.player:fullscreen .custom-controls,
.player:-webkit-full-screen .custom-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-b) + 10px);
}

.chat {
  width: 320px;
  border-left: 1px solid #333;
  background: #000;
  overflow: hidden;
  position: relative;
}

.chat iframe {
  position: relative;
  top: -40px;
  width: 100%;
  height: calc(100% + 40px);
  border: none;
}

@media screen and (max-width: 1024px) {
  .container {
    flex-direction: column;
  }

  .player {
    width: 100%;
    flex: none;
    height: 50vh;
  }

  @supports (height: 100svh) {
    .player {
      height: 50svh;
    }
  }

  @supports (height: 100dvh) {
    .player {
      height: 50dvh;
    }
  }

  .chat {
    width: 100%;
    flex: none;
    height: 50vh;
    border-left: none;
    border-top: 1px solid #333;
  }

  @supports (height: 100svh) {
    .chat {
      height: 50svh;
    }
  }

  @supports (height: 100dvh) {
    .chat {
      height: 50dvh;
    }
  }

  .chat iframe {
    top: -40px;
    height: calc(100% + 40px);
  }
}

@media screen and (max-width: 1024px) and (orientation: landscape) and (hover: none) {
  .container {
    flex-direction: row;
    align-items: center;
  }

  .player {
    flex: none;
    width: 60vw;
    position: relative;
    height: 100vh;
  }

  @supports (height: 100svh) {
    .player {
      height: 100svh;
    }
  }

  @supports (height: 100dvh) {
    .player {
      height: 100dvh;
    }
  }

  .video {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
  }

  .video::before {
    content: "";
    display: block;
    aspect-ratio: 16 / 9;
    width: 100%;
    max-height: 100%;
    visibility: hidden;
  }

  #owncast-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .custom-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(var(--safe-b) + 10px);
  }

  .chat {
    flex: none;
    width: 40vw;
    height: 100vh;
    border-left: 1px solid #333;
    border-top: none;
  }

  @supports (height: 100svh) {
    .chat {
      height: 100svh;
    }
  }

  @supports (height: 100dvh) {
    .chat {
      height: 100dvh;
    }
  }

  .chat iframe {
    position: relative !important;
    top: -40px !important;
    width: 100% !important;
    height: calc(100% + 40px) !important;
  }
}

.buffering-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  z-index: 3;
  pointer-events: none;
}

.buffering-overlay.show {
  display: flex;
}

.buffering-overlay .buf-indicator {
  padding: 0.6rem 0.8rem;
  border-radius: 0.6rem;
  background: rgba(20, 20, 22, 0.7);
  border: 1px solid #333;
  font-weight: 600;
  color: #dfe7ff;
}

.offline-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  z-index: 4;
  pointer-events: none;
}

.offline-overlay.show {
  display: flex;
}

.offline-overlay img {
  display: block;
}

.schedule-overlay[hidden] {
  display: none;
}

.schedule-overlay {
  position: fixed;
  z-index: 9999;
  display: grid;
  place-items: center;
}

.schedule-overlay.player-scope {
  left: var(--sched-left, 0px);
  top: var(--sched-top, 0px);
  width: var(--sched-w, 100%);
  height: var(--sched-h, 100%);
}

.schedule-overlay.fs {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.schedule-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.schedule-panel {
  position: relative;
  width: min(1000px, calc(100% - 24px));
  height: auto;
  max-height: calc(100% - 24px);
  background: rgba(20, 20, 22, 0.92);
  border: 1px solid #2a2a2a;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sched-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid #2a2a2a;
}

.sched-title {
  font-weight: 600;
  letter-spacing: 0.2px;
}

.sched-actions {
  display: flex;
  gap: 8px;
}

.sched-btn {
  appearance: none;
  border: 1px solid #3a3a3a;
  background: #111;
  color: #eee;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.sched-btn:hover {
  background: #181818;
}

.sched-btn:active {
  transform: translateY(1px);
}

.sched-body {
  padding: 6px 12px;
  display: grid;
  gap: 6px;
}

.sched-axis {
  display: none !important;
}

.sched-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  align-items: start;
}

.sched-channel {
  font-weight: 600;
  color: #ddd;
  padding-top: 8px;
  text-align: right;
}

.sched-scroller {
  position: relative;
  height: 200px;
  overflow: auto;
  border: 1px solid #2a2a2a;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
}

.sched-track {
  position: relative;
  height: 100%;
  min-height: 100%;
}

.sched-block {
  position: absolute;
  top: 8px;
  height: 86px;
  background: rgba(82, 110, 181, 0.25);
  border: 1px solid rgba(160, 194, 233, 0.35);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sched-block .b-time {
  flex: 0 0 22px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 12px;
  color: #c6d6f3;
  background: rgba(20, 25, 40, 0.35);
  border-bottom: 1px solid rgba(160, 194, 233, 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sched-block .b-title {
  flex: 1 1 auto;
  padding: 10px 12px 14px;
  color: #e8efff;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
}

.sched-status {
  color: #bbb;
  font-size: 12px;
  padding: 2px 4px;
  min-height: 18px;
}

@media (max-width: 600px) {
  .sched-scroller {
    height: 190px;
  }
}

#sched-jump-now,
.sched-actions #sched-jump-now {
  display: none !important;
}

.player.hide-cursor {
  cursor: none;
}

.player.hide-cursor .custom-controls {
  opacity: 0 !important;
  pointer-events: none !important;
}

@media (max-width: 600px), (max-width: 1024px) and (orientation: portrait) {
  #schedule-btn {
    min-width: 36px;
    padding: 0.22rem;
    font-size: 0;
    letter-spacing: 0;
  }

  #schedule-btn img {
    width: 1.2rem;
    height: 1.2rem;
  }

  .custom-controls {
    gap: 0.4rem;
    padding: 0.45rem 0.5rem;
  }
}

.custom-controls {
  background: transparent !important;
  box-shadow: none !important;
}

.custom-controls button img,
#mute-icon {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7));
}

#schedule-btn {
  background: transparent !important;
  border-color: transparent !important;
}

#owncast-video::-webkit-media-controls {
  display: none !important;
}

#owncast-video::-webkit-media-controls-enclosure {
  display: none !important;
}

#owncast-video::-webkit-media-controls-panel {
  display: none !important;
}

#owncast-video::-webkit-media-controls-overlay-play-button {
  display: none !important;
}

#owncast-video::-webkit-media-controls-play-button {
  display: none !important;
}

.rc-menu {
  position:absolute;
  z-index:8;
  display:none;
  min-width:140px;
  background:rgba(0,0,0,.35);
  backdrop-filter:blur(4px);
  border:1px solid #2a2a2a;
  border-radius:10px;
  box-shadow:0 10px 30px rgba(0,0,0,.45);
  overflow:hidden
}

.rc-menu.show {
  display:block
}

.rc-item {
  padding:.5rem .8rem;
  cursor:pointer;
  font-weight:600;
  letter-spacing:.2px;
  color:#eaeaea;
  user-select:none;
  white-space:nowrap
}

.rc-item:hover {
  background:rgba(255,255,255,.06)
}