:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --bg-elev: #14171c;
  --bg-elev-2: #1a1e25;
  --border: rgba(255, 255, 255, .06);
  --border-strong: rgba(255, 255, 255, .1);
  --text: #e6e8eb;
  --text-dim: #8a9099;
  --text-faint: #5a6068;
  --accent: #ff3b3b;
  --accent-glow: rgba(255, 59, 59, .5);
  --success: #4ade80;
  --warn: #fbbf24;
  --error: #f87171;
  --info: #60a5fa;
  --trouble-fg: var(--warn);
  --trouble-bg: var(--bg-elev);
  --trouble-border: rgba(251, 191, 36, .22);
  --trouble-hover-bg: var(--bg-elev-2);
  --trouble-hover-border: rgba(251, 191, 36, .4);
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, .6), 0 8px 24px -12px rgba(0, 0, 0, .4);
  --transition: 200ms cubic-bezier(.4, 0, .2, 1);
  --aspect-w: 704;
  --aspect-h: 636;
  --chrome-space: 150px;
  --banner-space: 0px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --player-bg: #000;
  --player-rail-bg: rgba(0, 0, 0, .92);
  --player-overlay-fg: rgba(255, 255, 255, .94);
  --control-rail-height: 60px;
  --control-rail-padding: 8px;
  --video-aspect-w: 704;
  --video-aspect-h: 576;
}

/* Light theme */
[data-theme="light"] {
  color-scheme: only light;
  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --bg-elev-2: #e8e8ed;
  --border: rgba(0, 0, 0, .08);
  --border-strong: rgba(0, 0, 0, .12);
  --text: #1c1c1e;
  --text-dim: #636366;
  --text-faint: #aeaeb2;
  --trouble-fg: #8a5a00;
  --trouble-bg: #fffdf8;
  --trouble-border: rgba(138, 90, 0, .18);
  --trouble-hover-bg: #fff7e8;
  --trouble-hover-border: rgba(138, 90, 0, .28);
  --player-bg: #e8e8ed;
}
[data-theme="light"] body {
  background: var(--bg);
}
[data-theme="light"] .brand { color: var(--text-faint); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(60, 70, 90, .08), transparent 60%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(40, 50, 70, .06), transparent 50%),
    var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.shell {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 2.5vw, 18px);
}

.header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.brand:focus-visible { outline: 2px solid var(--info); outline-offset: 3px; border-radius: 6px; }

.brand-icon {
  width: 18px;
  height: 18px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-dim);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  transition: all var(--transition);
}
.theme-toggle:hover,
.theme-toggle:focus-visible { background: var(--bg-elev-2); color: var(--text); }
.theme-toggle:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: block; }
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* Announcement editor */
.announce-editor {
  padding: 0 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.announce-textarea {
  width: 100%;
  min-height: 100px;
  max-height: 200px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
}
.announce-textarea:focus { border-color: var(--info); }
.announce-textarea::placeholder { color: var(--text-faint); }
.announce-actions {
  display: flex;
  gap: 10px;
}
.announce-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity var(--transition);
}
.announce-btn:active { opacity: .7; }
.announce-publish {
  background: var(--accent);
  color: #fff;
}
.announce-delete {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--border-strong);
}
.announce-status {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  min-height: 1.4em;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--text-dim);
  transition: all var(--transition);
  flex-shrink: 0;
}

.live-badge[data-state=live] {
  color: #fff;
  border-color: rgba(255, 59, 59, .25);
  background: linear-gradient(180deg, rgba(255, 59, 59, .08), rgba(255, 59, 59, .02));
}

.live-badge[data-state=buffering] {
  color: var(--warn);
  border-color: rgba(251, 191, 36, .2);
}

.live-badge[data-state=error] {
  color: var(--error);
  border-color: rgba(248, 113, 113, .2);
}

.header-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.temp-pill .tcond {
  font-weight: 400;
  opacity: .6;
  font-size: .9em;
}
.temp-pill .tcond::before {
  content: "·";
  margin: 0 4px;
}
.viewers,
.temp-pill,
.net-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px 6px 9px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text-dim);
  transition: opacity var(--transition), color var(--transition);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.viewers[hidden],
.temp-pill[hidden],
.net-pill[hidden] { display: none; }

.viewers.is-disconnected,
.temp-pill.is-stale,
.net-pill.is-stale { opacity: .45; }

.net-pill.is-ok { color: #22c55e; }
.net-pill.is-warn { color: var(--warn); }
.net-pill.is-error { color: var(--error); }

.viewers svg,
.temp-pill svg,
.net-pill svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: .8;
}

.viewers .vcount,
.temp-pill .tvalue,
.temp-pill .tcond,
.net-pill .netvalue {
  min-width: 1ch;
  text-align: right;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
  transition: background var(--transition);
  position: relative;
}

.live-badge[data-state=live] .live-dot {
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow);
  animation: pulse 1.8s ease-out infinite;
}

.live-badge[data-state=buffering] .live-dot {
  background: var(--warn);
  animation: blink 1s ease-in-out infinite;
}

.live-badge[data-state=error] .live-dot { background: var(--error); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  70%  { box-shadow: 0 0 0 10px rgba(255, 59, 59, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 59, 0); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes snap-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(.88); }
  100% { transform: scale(1); }
}

@keyframes flash-fade {
  0%   { opacity: 0; }
  10%  { opacity: .85; }
  100% { opacity: 0; }
}

/* Trouble-report button */
.trouble-btn {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  background: var(--trouble-bg);
  border: 1px solid var(--trouble-border);
  border-radius: var(--radius-sm);
  color: var(--trouble-fg);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: all var(--transition);
}
.trouble-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.trouble-btn span {
  min-width: 0;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.trouble-btn:hover { background: var(--trouble-hover-bg); border-color: var(--trouble-hover-border); }
.trouble-btn:active { transform: scale(.99); }
.trouble-btn:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.trouble-btn:disabled { opacity: .5; cursor: default; color: var(--text-dim); border-color: var(--border); }
.trouble-btn.is-sent { color: var(--success); border-color: rgba(74, 222, 128, .3); }
.trouble-btn.is-error { color: var(--error); border-color: rgba(248, 113, 113, .35); }

/* Open-gate button */
.gate-open-btn {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 14px;
  background: linear-gradient(180deg, rgba(255, 59, 59, .10), rgba(255, 59, 59, .03));
  border: 1px solid rgba(255, 59, 59, .3);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .03em;
  cursor: pointer;
  transition: all var(--transition);
}
.gate-open-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.gate-open-btn span {
  min-width: 0;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.gate-open-btn:hover { background: rgba(255, 59, 59, .15); border-color: rgba(255, 59, 59, .5); }
.gate-open-btn:active { transform: scale(.99); }
.gate-open-btn:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.gate-open-btn.is-fallback {
  color: var(--text-dim);
  border-color: var(--border-strong);
  background: var(--bg-elev);
  font-weight: 600;
  font-size: 13px;
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* Close-app button (PWA standalone only) */
.close-app-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: all var(--transition);
}
.close-app-btn[hidden] { display: none !important; }
.close-app-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.close-app-btn:hover { background: var(--bg-elev-2); color: var(--text); border-color: var(--border-strong); }
.close-app-btn:active { transform: scale(.99); }
.close-app-btn:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

/* Install-app bar */
.install-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 14px;
  background: linear-gradient(180deg, rgba(255, 59, 59, .10), rgba(255, 59, 59, .03)), var(--bg-elev);
  border: 1px solid rgba(255, 59, 59, .22);
  border-radius: var(--radius-sm);
}
.install-bar[hidden] { display: none !important; }
.install-bar-icon { width: 20px; height: 20px; color: var(--accent); flex-shrink: 0; }
.install-bar-main {
  flex: 1;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  padding: 4px 0;
  min-width: 0;
}
.install-bar-main:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; border-radius: 4px; }
.install-bar-close {
  width: 30px; height: 30px;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; border-radius: 8px;
  color: var(--text-dim); cursor: pointer; padding: 0;
  transition: color var(--transition), background var(--transition);
}
.install-bar-close:hover { color: var(--text); background: rgba(255,255,255,.06); }
.install-bar-close svg { width: 16px; height: 16px; }
.install-bar-close:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

/* Install instruction sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop[hidden] { display: none !important; }
.sheet {
  width: 100%;
  max-width: 520px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 10px 20px max(20px, env(safe-area-inset-bottom)) 20px;
  box-shadow: 0 -10px 40px -10px rgba(0,0,0,.6);
  animation: sheet-up 260ms cubic-bezier(.4, 0, .2, 1);
}
.sheet-grip {
  width: 38px; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,.18);
  margin: 0 auto 14px;
}
.sheet-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.sheet-body { font-size: 14px; color: var(--text-dim); line-height: 1.6; margin-bottom: 18px; }
.sheet-body b { color: var(--text); }
.sheet-body .ios-share {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; vertical-align: -5px;
  color: var(--info);
}
.sheet-close {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--transition);
}
.sheet-close:hover { filter: brightness(1.08); }
.sheet-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
}

/* Gate-open PIN sheet (numpad) */
.gate-pin-display {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 6px 0 20px;
}
.gate-pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--text-faint);
  background: transparent;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.gate-pin-dot.filled {
  background: var(--text);
  border-color: var(--text);
}
.gate-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.gate-key {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 16px 0;
  font-family: var(--font);
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform 80ms ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.gate-key:hover { background: var(--bg-elev-2); }
.gate-key:active { transform: scale(.95); background: var(--bg-elev-2); }
.gate-key:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.gate-key.gate-action { font-size: 18px; color: var(--text-dim); }
.gate-key.gate-ok { color: #fff; background: var(--accent); border-color: var(--accent); }
.gate-key.gate-ok:hover { filter: brightness(1.08); background: var(--accent); }
.gate-key.gate-ok:disabled { opacity: .5; cursor: default; filter: none; }
.gate-key svg { width: 22px; height: 22px; display: block; margin: 0 auto; }
.gate-status {
  min-height: 20px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 14px;
  transition: color var(--transition);
}
.gate-status.is-ok { color: var(--success); }
.gate-status.is-error { color: var(--error); }
.gate-status.is-warn { color: var(--warn); }
.gate-pin-display.shake { animation: gate-shake 360ms cubic-bezier(.36,.07,.19,.97); }
@keyframes gate-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
@media (prefers-reduced-motion: reduce) {
  .gate-pin-display.shake { animation: none; }
}

/* Gate action sheet — Palgate / call / cancel */
.gate-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.gate-action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  text-align: left;
}
.gate-action-btn:hover { background: var(--bg-elev-2); border-color: var(--border); }
.gate-action-btn:active { transform: scale(.98); }
.gate-action-btn:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.gate-action-btn svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.gate-action-btn .gate-action-label {
  flex: 1;
  min-width: 0;
}
.gate-action-btn .gate-action-hint {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-faint);
  margin-top: 2px;
  line-height: 1.3;
}
.gate-action-btn.gate-palgate { color: var(--accent); border-color: rgba(255, 59, 59, .22); }
.gate-action-btn.gate-palgate svg { color: var(--accent); }
.gate-action-btn.gate-palgate:hover { background: rgba(255, 59, 59, .08); }
.gate-action-btn.gate-call { color: #4ade80; border-color: rgba(74, 222, 128, .18); }
.gate-action-btn.gate-call svg { color: #4ade80; }
.gate-action-btn.gate-call:hover { background: rgba(74, 222, 128, .07); }

/* Announcements banner */
.announce {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.55;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-height: 30vh;
  overflow-y: auto;
  transition: opacity var(--transition), border-color var(--transition);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.12) transparent;
}

.announce[hidden] { display: none !important; }

.announce::-webkit-scrollbar { width: 6px; }
.announce::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }
.announce::-webkit-scrollbar-track { background: transparent; }

.announce-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--accent);
  opacity: .85;
  margin-top: 2px;
}

.announce-body {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.announce-body > *:first-child { margin-top: 0; }
.announce-body > *:last-child  { margin-bottom: 0; }
.announce-body p {
  margin: 0 0 6px 0;
  color: var(--text);
}
.announce-body p:last-child { margin-bottom: 0; }
.announce-body .ann-h1 {
  font-size: 14.5px;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: var(--text);
  letter-spacing: .01em;
}
.announce-body .ann-h2 {
  font-size: 13.5px;
  font-weight: 600;
  margin: 0 0 6px 0;
  color: var(--text);
}
.announce-body strong { color: var(--text); font-weight: 700; }
.announce-body em { color: var(--text-dim); font-style: italic; }
.announce-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed rgba(255, 59, 59, .35);
  transition: border-color var(--transition), color var(--transition);
}
.announce-body a:hover { border-bottom-color: var(--accent); }
.announce-body a:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
  border-radius: 2px;
}

.player {
  position: relative;
  background: var(--player-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  width: min(100%, 900px, calc((100dvh - var(--chrome-space) - var(--banner-space)) * var(--aspect-w) / var(--aspect-h)));
  isolation: isolate;
}

.player::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
  z-index: 2;
}

#video {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: var(--video-aspect-w) / var(--video-aspect-h);
  object-fit: contain;
  object-position: center;
  background: var(--player-bg);
  display: block;
}

.player-error {
  position: absolute;
  top: 0;
  right: 0;
  bottom: var(--control-rail-height);
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(18px, 4vw, 32px);
  background:
    radial-gradient(circle at top, rgba(248, 113, 113, .16), transparent 48%),
    linear-gradient(180deg, rgba(10, 12, 15, .18), rgba(10, 12, 15, .72));
  pointer-events: none;
}

.player-error[hidden] {
  display: none;
}

.player-error-card {
  max-width: min(540px, 100%);
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid rgba(248, 113, 113, .22);
  background: rgba(10, 12, 15, .78);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .28);
  color: var(--player-overlay-fg);
  text-align: center;
  text-wrap: balance;
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.5;
}

.snap-flash {
  position: absolute;
  top: 0;
  right: 0;
  bottom: var(--control-rail-height);
  left: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  border-radius: inherit;
}

.snap-flash.is-flashing {
  animation: flash-fade 200ms ease-out forwards;
}

.player-overlay {
  position: relative;
  pointer-events: none;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0;
}

.overlay-bottom {
  width: 100%;
  min-height: var(--control-rail-height);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: var(--control-rail-padding) clamp(10px, 2vw, 14px);
  background: var(--player-rail-bg);
  border-top: 1px solid rgba(255, 255, 255, .08);
  max-width: 100%;
}

.fs-btn {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 15, 18, .7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 11px;
  color: var(--player-overlay-fg);
  cursor: pointer;
  padding: 0;
  transition: all var(--transition);
  opacity: 1;
  transform: translateY(0);
  flex-shrink: 0;
}

.fs-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}

.fs-btn:hover {
  background: rgba(26, 30, 37, .85);
  border-color: rgba(255, 255, 255, .14);
  transform: translateY(0);
}

.fs-btn:active { transform: translateY(0) scale(.95); }

.fs-btn:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

.fs-btn.is-pulse {
  animation: snap-pulse 280ms ease-out;
}

.fs-btn .icon-exit { display: none; }

.player:fullscreen .fs-btn .icon-enter,
.player:-webkit-full-screen .fs-btn .icon-enter { display: none; }

.player:fullscreen .fs-btn .icon-exit,
.player:-webkit-full-screen .fs-btn .icon-exit { display: block; }

.player:fullscreen,
.player:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  border: none;
  max-width: none;
  aspect-ratio: auto;
  display: flex;
  flex-direction: column;
}

.player:fullscreen #video,
.player:-webkit-full-screen #video {
  flex: 1;
  min-height: 0;
  height: auto;
  object-fit: contain;
}

.player:fullscreen .fs-btn,
.player:-webkit-full-screen .fs-btn {
  opacity: 1;
  transform: translateY(0);
}

.fs-btn[hidden] { display: none !important; }

.fs-btn.is-spinning svg {
  animation: spin 1s linear infinite;
}

/* Status bar — ambient tech info by default; transient messages with tone */
.status-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-dim);
  min-height: 42px;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  font-variant-numeric: tabular-nums;
}

.status-bar[data-tone=tech] {
  color: var(--text-faint);
  border-color: var(--border);
}

.status-bar[data-tone=success] {
  color: var(--text);
  border-color: rgba(74, 222, 128, .15);
}

.status-bar[data-tone=warn] {
  color: var(--warn);
  border-color: rgba(251, 191, 36, .18);
}

.status-bar[data-tone=error] {
  color: var(--error);
  border-color: rgba(248, 113, 113, .2);
  background: linear-gradient(180deg, rgba(248, 113, 113, .04), transparent);
}

.status-bar[data-tone=info] { color: var(--text-dim); }

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  opacity: .85;
}

.status-bar[data-tone=tech] .status-indicator { animation: none; opacity: .35; }
.status-bar[data-tone=info] .status-indicator { animation: blink 1.4s ease-in-out infinite; }
.status-bar[data-tone=warn] .status-indicator { animation: blink .9s ease-in-out infinite; }

.status-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: .02em;
}

@media (max-width: 640px) {
  :root { --chrome-space: 140px; }
  body {
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }
  .shell { gap: 10px; }
  .header { padding: 0 2px; gap: 8px; }
  .player {
    --control-rail-height: 56px;
    border-radius: 12px;
  }
  .status-bar { padding: 9px 12px; font-size: 12px; }
  .brand { font-size: 11.5px; letter-spacing: .08em; }
  .live-badge { font-size: 10.5px; padding: 5px 10px 5px 9px; }
  .viewers, .temp-pill, .net-pill { font-size: 10.5px; padding: 5px 10px 5px 8px; }
  .header-right { gap: 6px; }
  .announce { padding: 10px 12px; font-size: 12.5px; max-height: 28vh; }
  .announce-body .ann-h1 { font-size: 13.5px; }
  .announce-body .ann-h2 { font-size: 12.5px; }
}

@media (max-width: 420px) {
  .brand span { display: none; }
}

@media (max-width: 360px) {
  .fs-btn { width: 38px; height: 38px; border-radius: 10px; }
  .fs-btn svg { width: 18px; height: 18px; }
  .overlay-bottom { gap: 6px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  :root { --chrome-space: 70px; }
  body { padding: 8px; }
  .header { display: none; }
  .status-bar { display: none; }
  .announce { display: none !important; } /* keep landscape video unobstructed */
  .shell { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .live-badge[data-state=live] .live-dot { box-shadow: 0 0 0 3px var(--accent-glow); }
  .fs-btn.is-spinning svg { animation: none; }
  .fs-btn.is-pulse { animation: none; }
  .snap-flash.is-flashing { animation: none; opacity: 0; }
}
