:root {
  --red: #e3121b;
  --red-hi: #ff2b2b;
  --red-lo: #b0060c;
  --bg: #0e0e10;
  --panel: #18181c;
  --line: #2a2a30;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100dvh; display: flex; flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 24px; height: 24px; fill: currentColor; flex: none; }

/* Header */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  max-width: 1100px; width: 100%; margin: 0 auto;
}
.logo { height: 40px; width: auto; }
.onair {
  display: inline-flex; align-items: center; gap: 7px;
  font-weight: 800; font-size: 13px; letter-spacing: .08em;
  background: var(--red); color: #fff; padding: 5px 10px; border-radius: 999px;
}
.onair i, .golive i {
  width: 8px; height: 8px; border-radius: 50%; background: #fff;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; } }

main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; }

/* Player */
.player {
  position: relative; background: #000; aspect-ratio: 16 / 9; width: 100%;
  overflow: hidden; user-select: none;
}
@media (min-width: 700px) { .player { border-radius: 14px; } main { padding: 0 16px; } }
.player video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.player:fullscreen { border-radius: 0; aspect-ratio: auto; }
.player:-webkit-full-screen { border-radius: 0; }

.state {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(0,0,0,.55); text-align: center; padding: 20px; pointer-events: none;
}
.state p { margin: 0; color: #ddd; font-size: 15px; max-width: 320px; }
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.2); border-top-color: var(--red);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.bigplay {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 84px; height: 84px; border-radius: 50%; border: 0;
  background: var(--red); color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 30px rgba(227,18,27,.5);
}
.bigplay svg { width: 44px; height: 44px; margin-left: 4px; }

.unmute {
  position: absolute; top: 12px; left: 12px; z-index: 3;
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; color: #111; border: 0; border-radius: 999px;
  padding: 8px 14px 8px 10px; font-weight: 700; font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.unmute svg { width: 20px; height: 20px; }

/* Control bar */
.bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; align-items: center; gap: 4px;
  padding: 26px 8px calc(8px + var(--fs-safe, 0px));
  background: linear-gradient(transparent, rgba(0,0,0,.8));
  transition: opacity .25s;
}
.player.idle .bar { opacity: 0; pointer-events: none; }
.player.idle { cursor: none; }
.bar button {
  background: none; border: 0; padding: 8px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px;
}
.bar button:hover, .bar button:focus-visible { background: rgba(255,255,255,.12); outline: none; }
.grow { flex: 1; }
.golive { font-weight: 800; font-size: 12px; letter-spacing: .08em; color: #bbb !important; }
.golive i { background: #888; animation: none; }
.golive.at-live { color: #fff !important; }
.golive.at-live i { background: var(--red-hi); animation: pulse 1.4s ease-in-out infinite; }
#btnPlay .i-play, #btnPlay.paused .i-pause { display: none; }
#btnPlay.paused .i-play { display: inline; }
#btnMute .i-muted, #btnMute.muted .i-vol { display: none; }
#btnMute.muted .i-muted { display: inline; }

.qwrap { position: relative; }
#btnQuality { font-weight: 700; font-size: 13px; border: 1px solid rgba(255,255,255,.35) !important; padding: 5px 10px !important; min-height: 32px !important; }
.qmenu {
  position: absolute; right: 0; bottom: calc(100% + 8px); margin: 0; padding: 6px;
  list-style: none; background: rgba(20,20,24,.97); border: 1px solid var(--line);
  border-radius: 12px; min-width: 170px; max-height: 60vh; overflow: auto;
}
.qmenu li button {
  width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px;
  display: flex; justify-content: space-between; gap: 12px;
}
.qmenu li button small { color: var(--muted); }
.qmenu li button[aria-checked="true"] { color: var(--red-hi); font-weight: 700; }

/* Actions */
.actions { display: flex; gap: 12px; padding: 18px 16px; flex-wrap: wrap; justify-content: center; }
@media (min-width: 700px) { .actions { padding: 22px 0; } }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 0 22px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); font-weight: 700; font-size: 16px;
  flex: 1 1 200px; max-width: 320px;
}
.btn.primary { background: linear-gradient(var(--red-hi), var(--red-lo)); border-color: transparent; color: #fff; }
.btn:active { transform: scale(.98); }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 18px 16px calc(18px + var(--safe-b)); }

/* Sheets */
.sheet {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 480px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 22px 20px calc(20px + var(--safe-b));
  animation: up .2s ease-out;
}
@media (min-width: 560px) { .sheet { align-items: center; } .sheet-card { border-radius: 20px; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet h2 { margin: 0 0 16px; font-size: 19px; }
.share-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.share-grid a, .share-grid button {
  display: grid; place-items: center; min-height: 54px; border-radius: 12px;
  background: #222228; border: 1px solid var(--line); color: var(--text);
  text-decoration: none; font-weight: 600; font-size: 14px;
}
.steps { margin: 0 0 18px; padding-left: 22px; line-height: 1.9; }
.inline { width: 18px; height: 18px; vertical-align: -3px; color: #3b82f6; }
.btn.close { width: 100%; max-width: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%);
  background: #fff; color: #111; padding: 10px 18px; border-radius: 999px;
  font-weight: 600; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

/* Landscape phone: fill the screen with the player */
@media (orientation: landscape) and (max-height: 500px) {
  .top, .actions, .foot { display: none; }
  main { max-width: none; padding: 0; }
  .player { height: 100dvh; aspect-ratio: auto; border-radius: 0; }
}
