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

body {
  background: #0f0f0f;
  color: #ffffff;
  font-family: sans-serif;
  height: 100vh;
  overflow: hidden;
}

/* Екрани */
.screen {
  display: none;
  width: 100vw;
  height: 100vh;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* QR екран */
.logo {
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 2rem;
  color: #e50914;
}

.qr-box {
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

#qr-canvas {
  border-radius: 8px;
}

.qr-hint {
  color: #aaa;
  font-size: 1rem;
  text-align: center;
}

.qr-hint.small {
  font-size: 0.8rem;
  color: #666;
}

.qr-status {
  margin-top: 1.5rem;
  font-size: 1rem;
  color: #888;
}

/* Плеєр */
.player-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: #1a1a1a;
}

#player-title {
  font-size: 1.2rem;
  font-weight: bold;
}

#btn-back {
  background: #333;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}

.player-wrap {
  flex: 1;
  width: 100%;
}

#player-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* TV фокус */
[data-focusable]:focus,
.tv-focused {
  outline: none;
  box-shadow: 0 0 0 3px #e50914;
  transform: scale(1.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* ─── Бейдж стану з'єднання ─── */
.conn-badge {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
  z-index: 50;
  transition: all 0.3s ease;
}
.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.conn-badge.online   .conn-dot { background: #4caf50; box-shadow: 0 0 8px #4caf50; }
.conn-badge.connecting .conn-dot { background: #ffa726; animation: pulse 1.2s infinite; }
.conn-badge.offline  .conn-dot { background: #ef5350; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ─── Таймер життя сесії ─── */
.qr-timer {
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 1rem;
}
.qr-timer-bar {
  height: 100%;
  width: 100%;
  background: #4caf50;
  transform-origin: left;
  transition: transform 1s linear, background-color 0.6s ease;
}
.qr-timer-bar.warn   { background: #ffa726; }
.qr-timer-bar.danger { background: #ef5350; }

/* ─── Overlay для критичних повідомлень ─── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.overlay.visible { display: flex; }
.overlay-card {
  background: #1a1a1a;
  border-radius: 16px;
  padding: 2.5rem 3rem;
  max-width: 500px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.overlay-icon { font-size: 3rem; margin-bottom: 1rem; }
.overlay-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.overlay-text {
  color: #aaa;
  margin-bottom: 1.5rem;
  font-size: 1rem;
}
.overlay-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #e50914;
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 0.8s linear infinite;
}
.overlay-spinner.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
