:root {
  color-scheme: dark;
  --accent: #2ea6ff;
  --button-text: #ffffff;
  --error: #ff0000;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { min-height: 100%; background: #17212b; }
body {
  margin: 0;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { touch-action: manipulation; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
button:focus-visible { outline: 3px solid #ffffff; outline-offset: 4px; }

.background {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-color: #17212b;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}
.background-video {
  position: fixed;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.background-dim {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: rgba(9, 17, 26, var(--bg-dim, .32));
}
/* Контент скрыт, пока JS не подтвердит наличие ref — иначе мелькает при загрузке. */
html:not(.ta-ready) .stage { display: none; }

.sticker {
  width: 140px;
  height: 140px;
  margin-bottom: 2px;
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, .38));
}
.sticker svg { display: block; width: 100%; height: 100%; }
@media (max-height: 720px) { .sticker { width: 110px; height: 110px; } }
@media (max-height: 620px) { .sticker { width: 92px; height: 92px; } }
@media (max-height: 500px) { .sticker { display: none; } }

.stage {
  position: relative;
  min-height: 100vh;
  min-height: var(--app-height, 100dvh);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: calc(28px + var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px))
    calc(24px + var(--tg-safe-area-inset-right, env(safe-area-inset-right, 0px)) + var(--tg-content-safe-area-inset-right, 0px))
    calc(28px + var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) + var(--tg-content-safe-area-inset-bottom, 0px))
    calc(24px + var(--tg-safe-area-inset-left, env(safe-area-inset-left, 0px)) + var(--tg-content-safe-area-inset-left, 0px));
}
.screen {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  text-align: center;
}
.lead {
  margin: 0;
  font-size: 24px;
  line-height: 1.28;
  font-weight: 800;
  letter-spacing: -.3px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .45);
}
.button {
  width: 100%;
  max-width: 320px;
  min-height: 52px;
  padding: 15px 20px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--button-text);
  font-size: 16px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: .2px;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: opacity .15s, transform .1s, box-shadow .15s;
}
.button:disabled { opacity: .65; }
.button:active:not(:disabled) { opacity: .82; }
.message { margin: 0; font-size: 15px; line-height: 1.35; text-shadow: 0 1px 8px rgba(0, 0, 0, .5); transition: opacity .25s ease, transform .25s ease; }
.message:empty { display: none; }
.message.is-visible { animation: msg-in .28s ease both; }
.message.is-hiding { opacity: 0; transform: translateY(6px); }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Ошибки — крупнее, ярко-красные, на подложке, чтобы не терялись. */
.message.is-error,
.lead.is-error {
  color: var(--error);
  font-weight: 700;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .6);
}
.message.is-error {
  font-size: 17px;
  line-height: 1.35;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(255, 0, 0, .18);
  box-shadow: 0 0 0 1px rgba(255, 0, 0, .5) inset;
}
.lead.is-error {
  font-size: 25px;
  font-weight: 800;
}

.code-control { position: relative; width: 100%; direction: ltr; }
.code-slots { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.code-slot {
  position: relative;
  display: grid;
  place-items: center;
  height: 58px;
  border: 2px solid rgba(255, 255, 255, .55);
  border-radius: 13px;
  background: rgba(255, 255, 255, .17);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 25px;
  line-height: 1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.code-control:focus-within .code-slot.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
  background: rgba(255, 255, 255, .17);
}
.code-control:focus-within .code-slot.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}
.code-control:focus-within .code-slot.is-caret::after {
  content: "";
  position: absolute;
  width: 2px;
  height: 26px;
  background: #ffffff;
  animation: blink 1.1s step-end infinite;
}
.code-slot.is-filled.is-caret::after { right: 7px; }
@keyframes blink { 50% { opacity: 0; } }
.code-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  border-radius: 12px;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: transparent;
  font-size: 25px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  text-align: left;
}
.code-input::selection { background: transparent; }
.visually-hidden, .code-status:not(.is-error) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .22);
  border-top-color: #ffffff;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress {
  width: 100%;
  max-width: 320px;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .25);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #7cc7ff);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent);
  transition: width .18s linear;
}
.progress-label {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .5);
}

.password-input {
  width: 100%;
  max-width: 320px;
  min-height: 52px;
  padding: 14px 16px;
  border: 2px solid rgba(255, 255, 255, .5);
  border-radius: 14px;
  background: rgba(255, 255, 255, .17);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 17px;
  text-align: center;
  outline: none;
}
.password-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}

.done-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  border: 2px solid rgba(255, 255, 255, .35);
  font-size: 38px;
  line-height: 1;
}

noscript { padding: 24px; text-align: center; }
@media (max-width: 360px) {
  .code-slots { gap: 6px; }
  .code-slot { height: 52px; }
  .lead { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
