/* Переиспользуемые кусочки интерфейса. Если элемент нужен больше чем в одном
   экране — он живёт здесь. Специфика экранов — в screens.css. */

/* ── карточка ────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
  padding: var(--gap);
}
.card-soft {
  background: var(--card-2);
  box-shadow: none;
  border: 1.5px solid var(--line);
}

/* ── кнопки ──────────────────────────────────────────────────────────────── */
.btn {
  appearance: none;
  border: none;
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--sh-1);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur),
    opacity var(--dur), background var(--dur);
}
.btn:active:not(:disabled) {
  transform: scale(0.96);
  box-shadow: var(--sh-press);
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.btn-block {
  width: 100%;
}
.btn-lg {
  min-height: 54px;
  font-size: 18px;
}
.btn-ghost {
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--line);
}
.btn-soft {
  background: var(--accent-soft);
  color: var(--accent-ink);
  box-shadow: none;
}
.btn-seat {
  background: var(--seat, var(--accent));
}
.btn-icon {
  min-width: var(--tap);
  padding: 0 12px;
  font-size: 20px;
}
.btn-mint {
  background: var(--mint);
}
.btn-peach {
  background: var(--peach);
}

/* ── поля ────────────────────────────────────────────────────────────────── */
.field {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 16px;
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
  background: var(--card);
  outline: none;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.field-code {
  text-align: center;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  font-size: 28px;
  font-weight: 800;
  text-transform: uppercase;
  border-radius: var(--r);
}

/* ── аватарки и игроки ───────────────────────────────────────────────────── */
.ava {
  width: 42px;
  height: 42px;
  border-radius: var(--r-pill);
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--seat-soft, var(--accent-soft));
  border: 2.5px solid var(--seat, var(--accent));
  flex: none;
  position: relative;
}
.ava-sm {
  width: 30px;
  height: 30px;
  font-size: 16px;
  border-width: 2px;
}
.ava.is-off {
  filter: grayscale(0.7);
  opacity: 0.55;
}
/* Зелёная точка «в сети» */
.ava.is-on::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid var(--card);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
}
.pill-seat {
  background: var(--seat-soft);
  color: var(--seat-ink);
}
.pill-warn {
  background: #ffe9ec;
  color: #c2566a;
}

/* ── всплывашки ──────────────────────────────────────────────────────────── */
#toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 10px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, var(--max-w));
  pointer-events: none;
}
.toast {
  background: var(--card);
  border-radius: var(--r-pill);
  padding: 11px 18px;
  box-shadow: var(--sh-2);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  animation: toast-in var(--dur) var(--ease);
  border: 2px solid var(--line);
}
.toast.ok {
  border-color: var(--mint);
}
.toast.warn {
  border-color: var(--warn);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-14px);
  }
}
.toast.is-out {
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.25s;
}

/* ── слой эффектов (конфетти, сердечки) ──────────────────────────────────── */
#fx {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}

/* ── нижняя шторка чата ──────────────────────────────────────────────────── */
#sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-height: 82vh;
  background: var(--card);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--sh-2);
  transform: translateY(102%);
  transition: transform 0.28s var(--ease);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
#sheet.is-open {
  transform: translateY(0);
}
#sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 49;
  background: rgba(75, 58, 87, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
}
#sheet-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}
.sheet-grip {
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  margin: 10px auto 4px;
  flex: none;
}

/* ── чат ─────────────────────────────────────────────────────────────────── */
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  -webkit-overflow-scrolling: touch;
}
.bubble {
  max-width: 78%;
  padding: 9px 14px;
  border-radius: var(--r);
  background: var(--card-2);
  border: 1.5px solid var(--line);
  align-self: flex-start;
  word-break: break-word;
  white-space: pre-wrap;
  animation: bubble-in 0.2s var(--ease);
}
.bubble.mine {
  align-self: flex-end;
  background: var(--seat-soft);
  border-color: var(--seat);
}
.bubble.sticker {
  font-size: 44px;
  padding: 2px 10px;
  background: none;
  border: none;
  line-height: 1.1;
}
.bubble.system {
  align-self: center;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 2px;
}
@keyframes bubble-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
}

.chat-bar {
  display: flex;
  gap: 8px;
  padding: 8px 12px 12px;
  border-top: 1.5px solid var(--line);
  flex: none;
}
.sticker-row {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 12px;
  flex: none;
  scrollbar-width: none;
}
.sticker-row::-webkit-scrollbar {
  display: none;
}
.sticker-btn {
  border: none;
  background: none;
  font-size: 26px;
  padding: 3px 5px;
  cursor: pointer;
  border-radius: var(--r-sm);
  flex: none;
  transition: transform var(--dur) var(--ease);
}
.sticker-btn:active {
  transform: scale(1.3);
}

/* ── плавающая кнопка чата ───────────────────────────────────────────────── */
.fab-row {
  position: fixed;
  right: 14px;
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fab {
  width: 54px;
  height: 54px;
  border-radius: var(--r-pill);
  border: none;
  background: var(--card);
  box-shadow: var(--sh-2);
  font-size: 24px;
  cursor: pointer;
  display: grid;
  place-items: center;
  position: relative;
  transition: transform var(--dur) var(--ease);
}
.fab:active {
  transform: scale(0.9);
}
.fab-hug {
  background: linear-gradient(140deg, var(--p0), var(--accent));
}
.badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--p0);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
  border: 2px solid var(--card);
}

/* ── статус соединения ───────────────────────────────────────────────────── */
#conn {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-140%);
  z-index: 61;
  background: var(--warn);
  color: #fff;
  padding: 6px 16px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 800;
  transition: transform var(--dur) var(--ease);
  pointer-events: none;
}
#conn.is-shown {
  transform: translateX(-50%) translateY(0);
}
