:root {
  --bg: #0b3d4c; --bg2: #0e4c5e; --accent: #21c0a8; --accent2: #14a58f;
  --ink: #eaf6f8; --muted: #9fc4cd; --card: #10485a; --danger: #e2604a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(160deg, var(--bg), var(--bg2));
  color: var(--ink); overflow: hidden;
}
.screen {
  display: none; flex-direction: column; gap: 14px;
  padding: 24px 22px; max-width: 520px; margin: 0 auto;
  height: 100dvh; overflow-y: auto; justify-content: safe center;
}
.screen.active { display: flex; }
#screen-room.active { justify-content: flex-start; }
.brand { font-weight: 700; letter-spacing: .3px; color: var(--accent); }
h1 { font-size: 30px; margin: 6px 0 0; }
h2 { font-size: 24px; margin: 0; }
.sub { color: var(--muted); margin: 0; line-height: 1.4; }
.or { text-align: center; color: var(--muted); font-size: 14px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,.15); }
.fineprint { text-align: center; color: var(--muted); font-size: 12px; margin: 2px 0 0; }

/* панель языков на старте */
.lang-bar { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.lang-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  border-radius: 20px; cursor: pointer; font-size: 14px; font-weight: 600;
  border: 1px solid rgba(255,255,255,.16); background: var(--card); color: var(--muted);
}
.lang-pill .lf { font-size: 18px; }
.lang-pill.sel { border-color: var(--accent); background: rgba(33,192,168,.16); color: var(--ink); }

/* сетка языков */
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lang-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 8px; border-radius: 14px; cursor: pointer;
  border: 2px solid rgba(255,255,255,.14); background: var(--card); color: var(--ink);
  transition: transform .06s, border-color .15s, background .15s;
}
.lang-btn:active { transform: scale(.97); }
.lang-btn .lf { font-size: 26px; }
.lang-btn .ln { font-size: 15px; font-weight: 600; }
.lang-btn.sel { border-color: var(--accent); background: rgba(33,192,168,.16); }
.chip-toggle {
  margin-top: 4px; align-self: start; padding: 8px 14px; border-radius: 20px;
  font-size: 14px; cursor: pointer; color: var(--muted);
  border: 1px solid rgba(255,255,255,.16); background: transparent;
}
.chip-toggle.on { color: #04262e; background: var(--accent); border-color: transparent; font-weight: 600; }

/* сегментированный переключатель режима */
.seg { display: flex; background: rgba(0,0,0,.18); border-radius: 12px; padding: 4px; gap: 4px; }
.seg-btn {
  flex: 1; padding: 10px; border: none; border-radius: 9px; background: transparent;
  color: var(--muted); font-size: 15px; font-weight: 600; cursor: pointer;
}
.seg-btn.sel { background: var(--accent); color: #04262e; }
.seg.small { max-width: 280px; margin: 0 auto 2px; }
.seg.small .seg-btn { padding: 7px; font-size: 13px; }
.talk.listen { animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 12px rgba(33,192,168,.12); } }

/* карточки ролей */
.hidden { display: none !important; }
.role-cards { display: flex; flex-direction: column; gap: 12px; }
.role-card {
  display: flex; align-items: center; gap: 14px; text-align: start;
  padding: 18px; border-radius: 16px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.16); background: var(--card); color: var(--ink);
  transition: transform .06s, border-color .15s;
}
.role-card:active { transform: scale(.98); }
.role-card:first-child { border-color: var(--accent); background: rgba(33,192,168,.12); }
.role-ic { font-size: 34px; line-height: 1; }
.role-title { font-size: 19px; font-weight: 700; }
.role-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.role-card > div:not(.role-ic) { flex: 1; }

/* экран входа гостя */
.join-ic { font-size: 60px; text-align: center; }
.joining-lang {
  align-self: center; display: inline-flex; align-items: center; gap: 8px;
  background: rgba(33,192,168,.16); border: 1px solid var(--accent);
  padding: 10px 18px; border-radius: 30px; font-size: 18px; font-weight: 600;
}
.joining-lang .lf { font-size: 24px; }
.qr-caption { font-size: 15px; font-weight: 600; color: var(--accent); }
[dir="rtl"] .bubble .from { text-align: right; }

.btn {
  border: 1px solid rgba(255,255,255,.18); background: var(--card); color: var(--ink);
  padding: 14px 18px; border-radius: 14px; font-size: 16px; font-weight: 600;
  cursor: pointer; transition: transform .06s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #04262e; border-color: transparent; }
.btn.big { padding: 18px; font-size: 18px; }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 12px; font-size: 14px; }

.join-inline { display: flex; gap: 10px; }
.join-inline input { flex: 1; }
input, select {
  width: 100%; padding: 14px; border-radius: 14px; font-size: 17px;
  border: 1px solid rgba(255,255,255,.18); background: rgba(0,0,0,.15); color: var(--ink);
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field span { font-size: 14px; color: var(--muted); }

/* room */
.room-head { display: flex; align-items: center; gap: 12px; width: 100%; padding-bottom: 6px; }
.room-head-main { display: flex; flex-direction: column; }
.room-label { font-size: 12px; color: var(--muted); }
.room-code { font-size: 24px; font-weight: 800; letter-spacing: 3px; }
.room-code.big { font-size: 40px; }
.btn-share, #btn-share { margin-left: auto; }
.me-bar { display: flex; align-items: center; gap: 10px; width: 100%; }
.me { font-size: 13px; color: var(--muted); }
#btn-changelang { margin-left: auto; }
.roster { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; margin-top: 4px; }
.chip {
  background: rgba(255,255,255,.08); border-radius: 20px; padding: 5px 12px;
  font-size: 13px; display: flex; gap: 6px; align-items: center;
}
.chip.you { background: rgba(33,192,168,.18); }
.empty-hint { color: var(--muted); font-size: 14px; text-align: center; margin: auto; line-height: 1.5; padding: 0 10px; }

.feed {
  flex: 1; width: 100%; overflow-y: auto; display: flex; flex-direction: column;
  gap: 12px; padding: 14px 2px; margin: 6px 0;
}
.bubble {
  background: var(--card); border-radius: 16px; padding: 12px 14px;
  animation: pop .2s ease; max-width: 92%;
}
.bubble .from { font-size: 12px; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.bubble .text { font-size: 19px; line-height: 1.35; }
.bubble .src { font-size: 13px; color: var(--muted); margin-top: 6px; }
.bubble.rtl .text { direction: rtl; text-align: right; }
.bubble.self { background: rgba(33,192,168,.14); align-self: flex-end; }
.bubble.playing { outline: 2px solid var(--accent); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* talk */
.talk-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 10px 0 6px; }
.hint { font-size: 13px; color: var(--muted); min-height: 18px; }
.talk {
  width: 110px; height: 110px; border-radius: 50%; border: none; font-size: 44px;
  background: radial-gradient(circle at 50% 40%, var(--accent), var(--accent2));
  color: #04262e; cursor: pointer; user-select: none; touch-action: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.35); transition: transform .08s;
}
.talk.rec { transform: scale(1.12); background: radial-gradient(circle at 50% 40%, #ff8a72, var(--danger));
  animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 16px rgba(226,96,74,.15); } }

/* modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6);
  align-items: center; justify-content: center; padding: 20px; }
.modal.active { display: flex; }
.modal-box { background: var(--bg2); border-radius: 20px; padding: 24px; text-align: center;
  display: flex; flex-direction: column; gap: 14px; align-items: center; max-width: 340px; width: 100%; }
.modal-box h3 { margin: 0; font-size: 20px; }
.modal-box .lang-grid { width: 100%; }
.modal-box img { background: #fff; border-radius: 12px; padding: 8px; }
.share-link { font-size: 12px; color: var(--muted); word-break: break-all; }
.status { position: fixed; bottom: 8px; left: 0; right: 0; text-align: center;
  font-size: 12px; color: var(--muted); }
