/* Mobile-first. Colors come from the Telegram theme (CSS vars set by telegram-web-app.js). */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8a8a);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --card: var(--tg-theme-secondary-bg-color, #f2f2f5);
  --vh: var(--tg-viewport-stable-height, 100vh);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app { min-height: var(--vh); }

.view {
  min-height: var(--vh);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.view[hidden] { display: none; }
.view.center { justify-content: center; align-items: center; text-align: center; }

h1 { font-size: 1.4rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0; }
p { margin: 0; }
.hint { color: var(--hint); }

.poster {
  width: 100%;
  max-height: 45vh;
  object-fit: cover;
  border-radius: 12px;
  background: var(--card);
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.show-desc { white-space: pre-line; }
.badge { font-weight: 600; }

.bottom { margin-top: auto; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 14px 18px;
  width: 100%;
  font: inherit;
  font-weight: 600;
  background: var(--btn);
  color: var(--btn-text);
  cursor: pointer;
}
.btn:disabled { opacity: .6; }

.countdown {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 8px 0;
}

/* Live: full-screen player */
.view.live {
  padding: 0;
  background: #000;
  justify-content: center;
  position: relative;
}
#player {
  width: 100%;
  height: var(--vh);
  background: #000;
  object-fit: contain;
}
.tap-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: auto;
}
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
}
.overlay[hidden] { display: none; }

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--hint);
  border-top-color: var(--btn);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 640px) {
  .view:not(.live) { max-width: 560px; margin: 0 auto; }
}

/* Channel buttons */
.channels {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 16px;
  background: var(--bg);
  scrollbar-width: none;
}
.channels[hidden] { display: none; }
.channels::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--hint);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: .9rem;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.chip.active {
  background: var(--btn);
  color: var(--btn-text);
  border-color: var(--btn);
}
/* Over the player the bar floats on the video. */
body.is-live .channels {
  position: fixed;
  left: 0;
  right: 0;
  background: linear-gradient(rgba(0, 0, 0, .6), transparent);
}
body.is-live .chip:not(.active) {
  background: rgba(0, 0, 0, .5);
  color: #fff;
  border-color: rgba(255, 255, 255, .4);
}
