/* Приветственный экран */

#welcome-screen {
  --welcome-font-display: 'Unbounded', 'Inter', system-ui, sans-serif;
  align-items: center;
  justify-content: safe center;
  padding: calc(env(safe-area-inset-top) + 1.5rem)
    clamp(1.25rem, 4vw, 2.5rem)
    calc(env(safe-area-inset-bottom) + 1.5rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#welcome-screen::-webkit-scrollbar {
  display: none;
}

#welcome-screen::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 80% 70% at 50% 42%, rgba(14, 14, 16, 0.42) 0%, rgba(10, 10, 12, 0.72) 100%);
}

.welcome-layout {
  position: relative;
  z-index: 1;
  width: min(100%, 980px);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.welcome-stage {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.75rem;
}

.welcome-intro {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2.4rem;
  width: 100%;
  max-width: 36rem;
}

.welcome-mark-frame {
  width: 100%;
  padding: 2px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.26) 0%, rgba(255, 255, 255, 0.06) 46%, rgba(255, 255, 255, 0.14) 100%);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(255, 255, 255, 0.1),
    0 10px 28px rgba(0, 0, 0, 0.28);
}

.welcome-mark-crop {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 4.55;
  overflow: hidden;
  border-radius: 14px;
}

.welcome-mark {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center 38%;
  display: block;
}

.welcome-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  margin: 0;
  padding: 0 0 0 0.8rem;
  border-left: 2px solid rgba(232, 98, 10, 0.8);
}

#welcome-screen .welcome-title {
  margin: 0;
  font-family: var(--welcome-font-display);
  font-size: clamp(2.15rem, 5.5vw, 3.35rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1;
  width: max-content;
  max-width: 100%;
  align-self: start;
  text-transform: none;
  text-align: left;
  white-space: normal;
  color: transparent;
  background: linear-gradient(102deg, #fffaf4 0%, #f4ebe1 46%, #f0c7a2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: none;
  text-shadow: none;
}

.welcome-lead {
  margin: 0;
  max-width: 28rem;
  font-size: clamp(1.05rem, 2.2vw, 1.16rem);
  font-weight: 500;
  line-height: 1.35;
  color: #f7f3ec;
  text-wrap: pretty;
}

.welcome-lead strong {
  color: #f6f1ea;
  font-weight: 600;
}

.welcome-enter {
  width: min(100%, 18rem);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
}

.welcome-kb-lift {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: inherit;
  gap: 0.7rem;
}

/* Клавиатура: лого + заголовок + поле едут вверх одним блоком, без смены размера */
html.keyboard-open #welcome-screen {
  overflow: hidden;
  justify-content: safe center;
}

html.keyboard-open .welcome-stage {
  /* transform задаётся inline в platform.js — надёжнее на мобильных VV */
  transition: transform 0.18s ease-out;
  will-change: transform;
}

html.keyboard-open .welcome-mark-frame {
  width: var(--kb-logo-w, 100%);
  max-width: var(--kb-logo-w, 100%);
  flex-shrink: 0;
}

html.keyboard-open #welcome-screen .welcome-title {
  font-size: var(--kb-title-size, inherit);
}

html.keyboard-open .welcome-more {
  display: none;
}

#welcome-screen #mic-status:empty {
  display: none;
}

.welcome-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#welcome-screen .nickname-block {
  width: 100%;
  max-width: none;
  gap: 0.4rem;
}

#welcome-screen .nickname-label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  text-align: left;
  color: rgba(246, 241, 234, 0.48);
}

#welcome-screen .nickname-input {
  width: 100%;
  min-height: 3.05rem;
  padding: 0.75rem 0.95rem;
  text-align: left;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 8, 10, 0.55);
  box-shadow: none;
}

#welcome-screen .nickname-input:focus {
  border-color: rgba(232, 98, 10, 0.75);
  background: rgba(8, 8, 10, 0.72);
  box-shadow: 0 0 0 3px rgba(232, 98, 10, 0.16);
}

#welcome-screen .welcome-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  width: 100%;
  max-width: none;
  align-items: stretch;
}

#welcome-screen .btn-play,
#welcome-screen .btn-mic {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

#welcome-screen .btn-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3.05rem;
  padding: 0.7rem 1.15rem;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  border-radius: 12px;
  background: #e8620a;
  border: none;
  box-shadow: none;
}

#welcome-screen .btn-play:not(:disabled):hover {
  filter: brightness(1.08);
  background: #f06c12;
  box-shadow: none;
}

#welcome-screen .btn-play:not(:disabled):active {
  transform: scale(0.985);
}

#welcome-screen .btn-mic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  gap: 0.4rem;
  min-height: 3.05rem;
  padding: 0.7rem 0.95rem;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 500;
  color: rgba(246, 241, 234, 0.78);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

#welcome-screen .btn-mic:hover {
  color: #f6f1ea;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.04);
}

#welcome-screen .btn-mic.mic-active {
  color: #f6f1ea;
  border-color: rgba(232, 98, 10, 0.6);
  background: rgba(232, 98, 10, 0.14);
}

#welcome-screen .welcome-actions .hint,
#welcome-screen #mic-status {
  margin: 0;
  text-align: left;
  font-size: 0.78rem;
  line-height: 1.4;
  color: rgba(246, 241, 234, 0.4);
}

/* Одна строка, тот же градиент/шрифт что у номера комнаты (.room-code) */
#welcome-screen .welcome-stats {
  margin: 0.15rem 0 0;
  width: max-content;
  max-width: 100%;
  align-self: center;
  white-space: nowrap;
  font-family: 'Unbounded', 'Inter', system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.35rem;
  color: transparent;
  background: linear-gradient(102deg, #fffaf4 0%, #f4ebe1 46%, #f0c7a2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  pointer-events: none;
  user-select: none;
}

.welcome-more {
  width: 100%;
  margin-top: 0;
}

.welcome-more summary {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  width: fit-content;
  padding: 0.48rem 0.5rem 0.48rem 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  cursor: pointer;
  list-style: none;
  font-size: 1rem;
  font-weight: 600;
  color: #f6f1ea;
  transition: background 0.25s, border-color 0.25s;
}

.welcome-more summary:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.32);
}

.welcome-more summary::-webkit-details-marker {
  display: none;
}

.welcome-more-chevron {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  transition: transform 0.45s cubic-bezier(0.22, 0.8, 0.24, 1);
}

.welcome-more-chevron::before {
  content: '';
  width: 0.38rem;
  height: 0.38rem;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: translateY(-1px) rotate(45deg);
}

.welcome-more[open] .welcome-more-chevron {
  transform: rotate(180deg);
}

.welcome-more::details-content {
  block-size: 0;
  overflow: hidden;
  opacity: 0;
  interpolate-size: allow-keywords;
  transition: block-size 0.48s cubic-bezier(0.22, 0.8, 0.24, 1),
    opacity 0.35s ease;
}

.welcome-more[open]::details-content {
  block-size: auto;
  opacity: 1;
}

.welcome-more-body {
  display: grid;
  gap: 1.15rem;
  margin-top: 0.75rem;
  padding: 1.15rem 1.2rem 1.2rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 10, 12, 0.92);
  backdrop-filter: blur(18px) saturate(110%);
  -webkit-backdrop-filter: blur(18px) saturate(110%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 16px 40px rgba(0, 0, 0, 0.28);
  font-size: 1.08rem;
  line-height: 1.55;
  color: #f3eee6;
}

.welcome-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.7rem;
  counter-reset: welcome-step;
}

.welcome-steps li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: start;
}

.welcome-steps li::before {
  counter-increment: welcome-step;
  content: counter(welcome-step);
  width: 1.55rem;
  height: 1.55rem;
  margin-top: 0.1rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  background: rgba(232, 98, 10, 0.85);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.welcome-faq {
  display: grid;
  gap: 0.75rem;
  padding-top: 0.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.welcome-faq p {
  margin: 0;
}

.welcome-more-body strong {
  color: #fff;
  font-weight: 600;
}

.welcome-more[open] .welcome-steps li,
.welcome-more[open] .welcome-faq p {
  animation: welcomeItemIn 0.45s cubic-bezier(0.22, 0.8, 0.24, 1) both;
}

.welcome-more[open] .welcome-steps li:nth-child(2) {
  animation-delay: 0.05s;
}

.welcome-more[open] .welcome-steps li:nth-child(3) {
  animation-delay: 0.1s;
}

.welcome-more[open] .welcome-faq p:nth-child(1) {
  animation-delay: 0.14s;
}

.welcome-more[open] .welcome-faq p:nth-child(2) {
  animation-delay: 0.18s;
}

.welcome-more[open] .welcome-faq p:nth-child(3) {
  animation-delay: 0.22s;
}

.welcome-more[open] .welcome-faq p:nth-child(4) {
  animation-delay: 0.26s;
}

.welcome-more[open] .welcome-faq p:nth-child(5) {
  animation-delay: 0.3s;
}

.welcome-more[open] .welcome-faq p:nth-child(6) {
  animation-delay: 0.34s;
}

@keyframes welcomeItemIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (min-width: 880px) {
  .welcome-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18rem;
    align-items: start;
    justify-content: space-between;
    column-gap: 3.5rem;
    width: 100%;
  }

  .welcome-intro {
    max-width: 34rem;
    margin-top: -1.65rem;
  }

  .welcome-enter {
    width: 18rem;
  }

  .welcome-mark-frame {
    margin-top: -1.65rem;
  }

  .welcome-mark-crop {
    aspect-ratio: 5 / 5.37;
  }

  #welcome-screen .welcome-title {
    font-size: clamp(2.7rem, 4vw, 3.5rem);
  }
}

@media (max-width: 879px) {
  .welcome-layout {
    width: min(100%, 28rem);
  }

  .welcome-stage {
    align-items: center;
    width: 100%;
    gap: clamp(1.05rem, 3.6vh, 1.75rem);
  }

  .welcome-intro {
    display: contents;
    text-align: center;
  }

  #welcome-screen .welcome-title {
    order: 1;
    align-self: center;
    width: 100%;
    text-align: center;
    font-size: clamp(1.7rem, 8.6vw, 2.7rem);
  }

  .welcome-copy {
    display: none;
  }

  #welcome-screen::before {
    content: none;
  }

  .welcome-enter {
    order: 3;
  }

  .welcome-more {
    order: 4;
    width: min(100%, clamp(15.5rem, 78vw, 22rem));
    text-align: left;
  }

  .welcome-more summary {
    display: flex;
    width: 100%;
    justify-content: center;
    margin-inline: 0;
  }

  .welcome-more-body,
  .welcome-steps,
  .welcome-faq,
  .welcome-faq p {
    text-align: left;
  }

  .welcome-more-body {
    font-size: clamp(0.92rem, 3.3vw, 1.05rem);
    padding: clamp(0.9rem, 3vw, 1.15rem);
  }

  .welcome-enter {
    width: min(100%, clamp(15.5rem, 78vw, 22rem));
    align-items: stretch;
  }

  #welcome-screen .nickname-input,
  #welcome-screen .btn-play,
  #welcome-screen .btn-mic {
    min-height: clamp(2.7rem, 8vw, 3.05rem);
    font-size: clamp(0.92rem, 3.4vw, 1rem);
  }

  #welcome-screen .nickname-input,
  #welcome-screen #mic-status {
    text-align: center;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  #welcome-screen {
    justify-content: flex-start;
    padding-top: calc(env(safe-area-inset-top) + 0.55rem);
    padding-bottom: 0.6rem;
  }

  .welcome-layout {
    width: min(100%, 52rem);
    gap: 0.85rem;
  }

  .welcome-stage {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: clamp(1rem, 4vw, 2rem);
  }

  .welcome-intro {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    min-width: 0;
    margin-top: 0;
  }

  .welcome-mark-frame {
    width: 52px;
    min-width: 52px;
    border-radius: 12px;
    flex-shrink: 0;
    margin-top: 0;
  }

  .welcome-mark-crop {
    aspect-ratio: 5 / 4.55;
  }

  .welcome-enter {
    width: min(42vw, 16rem);
    gap: 0.4rem;
  }

  #welcome-screen .welcome-title {
    text-align: center;
    font-size: 1.55rem;
  }

  .welcome-lead,
  .welcome-copy {
    display: none;
  }

  .welcome-more {
    display: none;
  }

  #welcome-screen .nickname-input,
  #welcome-screen .btn-play,
  #welcome-screen .btn-mic {
    min-height: 2.45rem;
  }
}

@media (min-width: 769px) {
  #welcome-screen {
    align-items: center;
  }

  .welcome-actions {
    align-items: stretch;
    max-width: none;
  }

  .welcome-actions .btn {
    width: 100%;
    max-width: none;
  }
}

@supports (-webkit-touch-callout: none) {
  #welcome-screen #nickname-input {
    font-size: max(16px, 1rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  #welcome-screen .btn-play,
  #welcome-screen .btn-mic,
  .welcome-more summary,
  .welcome-more-chevron,
  .welcome-more::details-content {
    transition: none;
  }

  .welcome-more[open] .welcome-steps li,
  .welcome-more[open] .welcome-faq p {
    animation: none;
  }
}
