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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif;
  background: #0a0a0a;
  color: #ffffff;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
  margin: 0;
}

/* Screens */
.screen {
  position: absolute;
  top: 15px;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  -webkit-transition: opacity 0.5s ease;
  transition: opacity 0.5s ease;
}

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

/* ===== CODE SCREEN ===== */
.code-container {
  text-align: center;
  padding: 20px;
}

.logo {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 20px;
  background: -webkit-linear-gradient(45deg, #667eea, #764ba2);
  background: linear-gradient(45deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.instruction {
  font-size: 24px;
  color: #aaaaaa;
  margin-bottom: 40px;
}

.code-digits {
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 40px;
}

.digit {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  width: 80px;
  height: 100px;
  background: #1a1a2e;
  border: 2px solid #333366;
  border-radius: 12px;
  font-size: 48px;
  font-weight: 700;
  color: #ffffff;
  font-family: 'Courier New', monospace;
}

.digit.filled {
  border-color: #667eea;
  background: #1a1a3e;
  -webkit-animation: digitPulse 0.3s ease;
  animation: digitPulse 0.3s ease;
}

@-webkit-keyframes digitPulse {
  0% { -webkit-transform: scale(1); }
  50% { -webkit-transform: scale(1.1); }
  100% { -webkit-transform: scale(1); }
}

@keyframes digitPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.sub-instruction {
  font-size: 16px;
  color: #666666;
  margin-bottom: 20px;
}

.status {
  font-size: 14px;
  color: #888888;
  padding: 0;
  border-radius: 20px;
  background: #111122;
  display: inline-block;
}

.status.connected {
  color: #4caf50;
  background: #0a1f0a;
}

.status.error {
  color: #f44336;
  background: #1f0a0a;
}

/* ===== CONNECTED SCREEN ===== */
.connected-container {
  text-align: center;
  padding: 40px;
}

.connected-icon {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: #1b5e20;
  color: #4caf50;
  font-size: 60px;
  line-height: 120px;
  margin: 0 auto 30px;
}

.connected-container h1 {
  font-size: 36px;
  margin-bottom: 10px;
}

.connected-container p {
  font-size: 20px;
  color: #aaaaaa;
  margin-bottom: 8px;
}

.status-detail {
  color: #667eea !important;
  font-size: 16px !important;
}

/* ===== BROADCAST SCREEN ===== */
.broadcast-container {
  width: 100%;
  height: 100%;
  background: #000000;
  position: relative;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  overflow: hidden;
}

#broadcast-image {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  margin: auto;
  -o-object-fit: contain;
  object-fit: contain;
  /* Дополнительные свойства для старых ТВ */
  -webkit-background-size: contain;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background: #000;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Кнопка fullscreen — в правом нижнем углу, поверх контента */
#btn-fullscreen {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 100;
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-transition: background 0.2s;
  transition: background 0.2s;
  outline: none;
  /* Скрываем пока не в режиме трансляции — показывается через JS */
  opacity: 0.7;
}

#btn-fullscreen:hover,
#btn-fullscreen:focus {
  background: rgba(255,255,255,0.2);
  opacity: 1;
}

/* Видео — центрируется и подстраивается под любую ориентацию (portrait/landscape).
   object-fit: contain даёт letterbox (горизонтальные полосы) или pillarbox (вертикальные).
   position: absolute + inset 0 + margin: auto — надёжное центрирование для Tizen. */
#broadcast-video {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  margin: auto;
  -o-object-fit: contain;
  object-fit: contain;
  /* Дополнительные свойства для старых ТВ */
  -webkit-background-size: contain;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background: #000;
  width: 100% !important;
  height: 100% !important;
  display: none;
}

.broadcast-title {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(0,0,0,0.7);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  color: #ffffff;
  display: none;
}

.broadcast-title.visible {
  display: block;
}

/* ===== AUDIO PLAYER ===== */
#audio-player {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  width: 520px;
  max-width: 90vw;
  background: rgba(20, 20, 40, 0.95);
  border: 1px solid rgba(102, 126, 234, 0.4);
  border-radius: 20px;
  padding: 40px 36px 32px;
  text-align: center;
  z-index: 10;
}

.audio-art {
  font-size: 80px;
  margin-bottom: 20px;
  line-height: 1;
  color: #667eea;
}

.audio-title {
  font-size: 22px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 28px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-progress-wrap {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.audio-progress-wrap span {
  font-size: 13px;
  color: #aaa;
  min-width: 36px;
  font-family: 'Courier New', monospace;
}

.audio-progress-bg {
  -webkit-flex: 1;
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  overflow: hidden;
}

.audio-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 3px;
  -webkit-transition: width 0.5s linear;
  transition: width 0.5s linear;
}

.audio-controls {
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-align-items: center;
  align-items: center;
  gap: 16px;
}

.audio-controls button {
  background: rgba(102, 126, 234, 0.2);
  border: 1px solid rgba(102, 126, 234, 0.5);
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  padding: 10px 20px;
  cursor: pointer;
  -webkit-transition: background 0.2s;
  transition: background 0.2s;
  outline: none;
}

.audio-controls button:focus,
.audio-controls button:hover {
  background: rgba(102, 126, 234, 0.5);
}

#audio-btn-play {
  width: 64px;
  height: 64px;
  border-radius: 50% !important;
  font-size: 24px !important;
  padding: 0 !important;
  background: #667eea !important;
  border-color: #667eea !important;
}

#audio-btn-play:focus,
#audio-btn-play:hover {
  background: #764ba2 !important;
}

/* ===== DISCONNECTED SCREEN ===== */
.disconnected-container {
  text-align: center;
  padding: 40px;
}

.disconnected-icon {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: #4a1111;
  color: #f44336;
  font-size: 60px;
  line-height: 120px;
  margin: 0 auto 30px;
}

.disconnected-container h1 {
  font-size: 36px;
  margin-bottom: 10px;
}

.disconnected-container p {
  font-size: 20px;
  color: #aaaaaa;
  margin-bottom: 30px;
}

.btn-reconnect {
  padding: 16px 40px;
  font-size: 18px;
  background: #667eea;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.btn-reconnect:hover {
  background: #5a6fd6;
}

.btn-reconnect:focus {
  outline: 2px solid #ffffff;
}
