* {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.hidden {
  display: none !important;
}

.screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Білі кнопки ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: none;
  outline: none;
  background: #fff;
  color: #000;
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  border-radius: 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.25s ease;
}

.btn:active {
  transform: scale(0.94);
  background-color: #d9d9d9;
  transition: transform 0.07s ease-out, background-color 0.07s ease-out;
}

/* ---------- Пароль ---------- */

#lock {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: #000;
  align-items: center;
  justify-content: center;
  padding-bottom: 18vh;
  box-sizing: border-box;
  touch-action: none;
}

body.locked #lock {
  display: flex;
}

/* Поки заблоковано, решта інтерфейсу не показується */
body.locked .screen,
body.locked .btn.back,
body.locked .btn.zoom,
body.locked #toast {
  display: none !important;
}

.lock-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(80vw, 320px);
}

#lockInput {
  -webkit-user-select: text;
  user-select: text;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  box-sizing: border-box;
  height: 56px;
  margin: 0;
  padding: 0 18px;
  border: 2px solid #fff;
  border-radius: 16px;
  outline: none;
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 18px; /* не менше 16px, інакше iPhone збільшує екран */
  letter-spacing: 2px;
  text-align: center;
  caret-color: #fff;
}

#lockInput::placeholder {
  color: #777;
  letter-spacing: 0;
}

#lockInput:focus {
  border-color: #fff;
}

/* Ховаємо кнопки автозаповнення та "око" в полі пароля */
#lockInput::-ms-reveal,
#lockInput::-ms-clear {
  display: none;
}

#lockInput::-webkit-credentials-auto-fill-button,
#lockInput::-webkit-contacts-auto-fill-button {
  visibility: hidden;
  display: none !important;
  pointer-events: none;
  position: absolute;
  right: 0;
}

.btn.lock-btn {
  width: 100%;
  height: 56px;
  font-size: 18px;
}

#lockError {
  margin: 0;
  height: 20px;
  line-height: 20px;
  font-size: 14px;
  color: #ef4444;
  text-align: center;
}

/* ---------- Екран вибору ---------- */

.buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.slot {
  width: min(80vw, 320px);
  height: 64px;
  margin: 8px 0;
  transition: height 0.55s cubic-bezier(0.4, 0, 0.2, 1),
              margin 0.55s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.4s ease,
              translate 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.slot.gone-up {
  height: 0;
  margin: 0;
  opacity: 0;
  translate: 0 -32px;
  overflow: hidden;
  pointer-events: none;
}

.slot.gone-down {
  height: 0;
  margin: 0;
  opacity: 0;
  translate: 0 32px;
  overflow: hidden;
  pointer-events: none;
}

.btn.big {
  width: 100%;
  height: 100%;
}

/* ---------- Кнопка "Повернутися" ---------- */

.btn.back {
  position: fixed;
  left: 0;
  right: 0;
  margin: 0 auto;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
  width: min(60vw, 240px);
  height: 52px;
  font-size: 16px;
  z-index: 10;
  animation: fadeIn 0.3s ease;
}

/* ---------- Відправник ---------- */

.wait {
  margin: 0;
  padding: 0 30px;
  text-align: center;
  font-size: 18px;
  color: #aaa;
  animation: breathe 2.4s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

video {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  animation: fadeIn 0.4s ease;
}

/* ---------- Отримувач: повзунок зв'язку ---------- */

.track {
  position: relative;
  width: 220px;
  height: 6px;
  border-radius: 3px;
  background: #1c1c1c;
}

.knob {
  position: absolute;
  top: 0;
  left: 0;
  width: 16px;
  height: 6px;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 12px 1px rgba(255, 255, 255, 0.6);
  animation: run 0.8s linear infinite alternate;
}

@keyframes run {
  0% {
    left: 0;
    width: 16px;
    animation-timing-function: ease-in;
  }
  50% {
    left: 73px;
    width: 73px;
    animation-timing-function: ease-out;
  }
  100% {
    left: 204px;
    width: 16px;
  }
}

/* ---------- Рамка по контуру екрана ---------- */

#frame {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 5;
}

.frame-green {
  animation: glowGreen 1.1s ease-out;
}

.frame-red {
  animation: glowRed 1.1s ease-out;
}

@keyframes glowGreen {
  0%, 35% {
    box-shadow: inset 0 0 0 8px #22c55e, inset 0 0 60px 10px rgba(34, 197, 94, 0.6);
  }
  100% {
    box-shadow: inset 0 0 0 0 rgba(34, 197, 94, 0), inset 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

@keyframes glowRed {
  0%, 35% {
    box-shadow: inset 0 0 0 8px #ef4444, inset 0 0 60px 10px rgba(239, 68, 68, 0.6);
  }
  100% {
    box-shadow: inset 0 0 0 0 rgba(239, 68, 68, 0), inset 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* ---------- Сповіщення зверху ---------- */

#toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  left: 50%;
  max-width: 86vw;
  padding: 14px 22px;
  border-radius: 16px;
  background: #fff;
  color: #000;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  z-index: 10;
  opacity: 0;
  transform: translate(-50%, -200px);
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.45s ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Текст над повзунком ---------- */

.receiver-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.receiver-text {
  margin: 0;
  font-size: 18px;
  color: #bbb;
}

/* ---------- Кнопка зуму ---------- */

.btn.zoom {
  position: fixed;
  left: 0;
  right: 0;
  margin: 0 auto;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 94px);
  width: 64px;
  height: 44px;
  font-size: 16px;
  z-index: 10;
  animation: fadeIn 0.3s ease;
}
