* {
  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: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 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;
  background: #000;
  overflow: hidden;
}

.video-container {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

#video::-webkit-media-controls {
  display: none !important;
}

#video::-webkit-media-controls-enclosure {
  display: none !important;
}

.buffering-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2;
  pointer-events: none;
}

.buffering-overlay.show {
  display: flex;
}

.buffering-indicator {
  padding: 12px 20px;
  border-radius: 8px;
  background: rgba(20, 20, 22, 0.9);
  border: 1px solid #333;
  font-weight: 600;
  color: #dfe7ff;
  font-size: 14px;
}

.offline-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  z-index: 3;
  pointer-events: none;
}

.offline-overlay.show {
  display: flex;
}

.offline-overlay img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-b) + 10px);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.controls-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.player.show-controls .controls {
  opacity: 1;
  pointer-events: auto;
}

.player.controls-hidden .controls {
  opacity: 0 !important;
  pointer-events: none !important;
}

.player.hide-cursor,
.player.hide-cursor #video {
  cursor: none !important;
}

.player.hide-cursor .controls {
  opacity: 0 !important;
  pointer-events: none !important;
}

@media (hover: hover) {
  .player:hover:not(.controls-hidden) .controls {
    opacity: 1;
    pointer-events: auto;
  }
}

.control-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.control-btn:hover {
  opacity: 0.8;
}

.control-btn:active {
  opacity: 0.6;
}

.control-btn img {
  width: 1.2rem;
  height: 1.2rem;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7));
}

#mute-icon {
  transform: translateY(-0.05rem);
}

#reload-icon {
  width: 1.5rem;
  height: 1.5rem;
  transition: transform 0.3s ease, opacity 0.2s ease;
}

#reload-icon.reloading {
  transform: rotate(180deg);
  opacity: 0.5;
}

#fullscreen-icon {
  width: 1.2rem;
  height: 1.2rem;
}

.volume-slider {
  appearance: none;
  width: 8rem;
  height: 4px;
  background: #444;
  border-radius: 2px;
  cursor: pointer;
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  margin-top: -4px;
}

.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
}

.quality-selector {
  margin-left: 0.2rem;
  margin-right: 0.2rem;
}

#quality {
  appearance: none;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid #3a3a3a;
  border-radius: 0.4rem;
  color: #eaeaea;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  min-width: 80px;
  outline: none;
  text-align: center;
  text-align-last: center;
}

#quality:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: #4a4a4a;
}

#quality:focus {
  border-color: #a0c2e9;
  box-shadow: 0 0 0 2px rgba(160, 194, 233, 0.2);
}

#quality option {
  background: #1a1a1a;
  color: #eaeaea;
}

.player::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(68px + var(--safe-b));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.86) 0%, rgba(0, 0, 0, 0.58) 45%, rgba(0, 0, 0, 0) 100%);
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.player.show-controls::after,
.player:hover:not(.controls-hidden)::after {
  opacity: 1;
}


.player.audio-only .video-container {
  display: none;
}

.player.audio-only {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.player.audio-only::before {
  content: "🎵 Audio Only";
  font-size: 24px;
  color: #a0c2e9;
  text-align: center;
  opacity: 0.8;
  animation: pulse 2s ease-in-out infinite alternate;
}

@keyframes pulse {
  from {
    opacity: 0.6;
  }
  to {
    opacity: 1;
  }
}

#chat-toggle {
  margin-left: 0.2rem;
}

#chat-toggle img {
  width: 1.5rem;
  height: 1.5rem;
}

.chat {
  width: 320px;
  border-left: 1px solid #333;
  background: #000;
  overflow: hidden;
  position: relative;
  z-index: 6;
  display: flex;
  flex-direction: column;
  transition: border-left 0.3s ease, border-right 0.3s ease;
}

.container.chat-left {
  flex-direction: row-reverse;
}

.container.chat-left .chat {
  border-left: none;
  border-right: 1px solid #333;
}

.container.chat-off .chat {
  display: none;
}

.container.chat-off .player {
  width: 100%;
}

.chat-header {
  background: #111;
  border-bottom: 1px solid #333;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  position: relative;
}

.chat-tabs-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
}

.chat-position-btn {
  appearance: none;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid #3a3a3a;
  border-radius: 0.4rem;
  color: #eaeaea;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  min-width: 32px;
  text-align: center;
  transition: all 0.2s ease;
  position: absolute;
  left: 12px;
}

.chat-position-btn:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: #4a4a4a;
}

.chat-position-btn:active {
  transform: translateY(1px);
}

.chat-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.chat-tab {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
}

.chat-tab-active {
  display: block;
}

.chat-tab iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100% + 40px);
  border: none;
  transform: translateY(-40px);
}

.chat-tab-btn {
  appearance: none;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid #3a3a3a;
  border-radius: 0.4rem;
  color: #eaeaea;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  min-width: 60px;
  text-align: center;
  transition: all 0.2s ease;
}

.chat-tab-btn:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: #4a4a4a;
}

.chat-tab-btn:active {
  transform: translateY(1px);
}

.chat-tab-btn.active {
  background: rgba(160, 194, 233, 0.2);
  border-color: #a0c2e9;
  color: #a0c2e9;
  box-shadow: 0 0 0 1px rgba(160, 194, 233, 0.3);
}

.chat-tab-btn.active:hover {
  background: rgba(160, 194, 233, 0.3);
  border-color: #a0c2e9;
}

@media screen and (max-width: 1024px) {
  .container {
    flex-direction: column;
  }
  
  .container.chat-left {
    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-right: none;
    border-top: 1px solid #333;
  }
  
  .container.chat-left .chat {
    border-top: 1px solid #333;
    border-bottom: none;
  }
  
  @supports (height: 100svh) {
    .chat {
      height: 50svh;
    }
  }
  
  @supports (height: 100dvh) {
    .chat {
      height: 50dvh;
    }
  }
  
  .chat-tab iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100% + 40px);
    transform: translateY(-40px);
  }
  
  .container.chat-off .player {
    height: 100vh;
  }
  
  @supports (height: 100svh) {
    .container.chat-off .player {
      height: 100svh;
    }
  }
  
  @supports (height: 100dvh) {
    .container.chat-off .player {
      height: 100dvh;
    }
  }
}

@media screen and (max-width: 1024px) and (orientation: landscape) and (hover: none) {
  .container {
    flex-direction: row;
    align-items: center;
  }
  
  .container.chat-left {
    flex-direction: row-reverse;
  }
  
  .player {
    flex: none;
    width: 60vw;
    position: relative;
    height: 100vh;
  }
  
  @supports (height: 100svh) {
    .player {
      height: 100svh;
    }
  }
  
  @supports (height: 100dvh) {
    .player {
      height: 100dvh;
    }
  }

  .chat {
    flex: none;
    width: 40vw;
    height: 100vh;
    border-left: 1px solid #333;
    border-top: none;
  }
  
  .container.chat-left .chat {
    border-left: none;
    border-right: 1px solid #333;
  }
  
  @supports (height: 100svh) {
    .chat {
      height: 100svh;
    }
  }
  
  @supports (height: 100dvh) {
    .chat {
      height: 100dvh;
    }
  }
  
  .chat-tab iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(100% + 40px) !important;
    transform: translateY(-40px) !important;
  }
}

@media (max-width: 768px) {
  .controls {
    gap: 0.4rem;
    padding: 0.45rem 0.5rem;
  }
  
  .volume-slider {
    width: 6rem;
  }
  
  #quality {
    min-width: 70px;
    font-size: 0.65rem;
    padding: 0.25rem 0.4rem;
  }
}

.chat-tab-btn{position:relative;}

.chat-tab-btn.has-unread::after{
  content:"";
  position:absolute;
  top:6px;
  right:6px;
  width:10px;
  height:10px;
  border-radius:9999px;
  background:#ef4444;
  box-shadow:0 0 0 2px rgba(17,24,39,.9);
}

.buffering-overlay,
.buffering-overlay.show{
  display:none !important;
  background:transparent !important;
}

.buffering-indicator{
  display:none !important;
}