/* ===== Переменные темы ===== */
:root {
  --bg: #0c0f12;
  --bg-soft: #131820;
  --surface: #161c25;
  --surface-2: #1d2531;
  --border: #2a3441;
  --border-strong: #3b4a5c;

  --text: #e8edf3;
  --text-muted: #93a1b2;
  --text-dim: #6d7c8d;

  --accent: #f0a02a;
  --accent-soft: #ffc466;
  --accent-ink: #1a1206;
  --danger: #ff6b5e;
  --success: #7fd48b;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, .85);
  --ring: 0 0 0 3px rgba(240, 160, 42, .28);
  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать любой заданный display */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* ===== Фон ===== */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 520px at 15% -10%, rgba(240, 160, 42, .14), transparent 70%),
    radial-gradient(760px 480px at 100% 0%, rgba(80, 140, 220, .12), transparent 65%),
    linear-gradient(180deg, #0e1319 0%, #0a0d11 100%);
}

.bg-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    0deg, rgba(255, 255, 255, .022) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

/* ===== Шапка ===== */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid rgba(42, 52, 65, .7);
  background: rgba(12, 15, 18, .82);
  backdrop-filter: blur(10px);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
  border-radius: 10px;
}

.logo:hover .logo__text {
  color: var(--accent-soft);
}

.logo:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.logo__mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(160deg, var(--accent-soft), var(--accent));
  color: var(--accent-ink);
  font-size: 17px;
  box-shadow: 0 8px 22px -10px rgba(240, 160, 42, .9);
}

.logo__text {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .2em;
}

.app-bar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* ===== Выбор языка: кнопка с текущим языком, по клику — список ===== */
.lang-menu {
  position: relative;
  flex: none;
}

.lang-menu__current {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.lang-menu__current::-webkit-details-marker { display: none; }
.lang-menu__current:hover { border-color: var(--border-strong); }
.lang-menu__current:focus-visible { outline: none; box-shadow: var(--ring); }
.lang-menu__now { display: inline-flex; align-items: center; gap: 6px; }
.lang-menu__caret { color: var(--text-muted); font-size: 10px; transition: transform .2s var(--ease); }
.lang-menu[open] .lang-menu__caret { transform: rotate(180deg); }

.lang-menu__list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100%;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: rgba(29, 37, 49, .98);
  box-shadow: var(--shadow);
  animation: lang-menu-in .15s var(--ease) both;
}

@keyframes lang-menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.lang-switch__option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  white-space: nowrap;
  cursor: pointer;
}

.lang-switch__option:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.lang-switch__option[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.lang-switch__option:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}


/* плавная смена языка: текст гаснет и проявляется */
.page,
.site-footer,
.logo__text,
.game-badge {
  transition: opacity .18s var(--ease);
}

body.is-lang-switching .page,
body.is-lang-switching .site-footer,
body.is-lang-switching .logo__text,
body.is-lang-switching .game-badge {
  opacity: 0;
}


.app-bar__profile {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.app-bar__nick {
  max-width: 34vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 600;
}

/* ===== Аватары ===== */
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-2);
  color: var(--text-dim);
  font-weight: 700;
}

.avatar svg { display: block; width: 100%; height: 100%; }

.avatar--sm { width: 30px; height: 30px; font-size: 13px; }
.avatar--md { width: 44px; height: 44px; font-size: 16px; }
.avatar--lg { width: 56px; height: 56px; font-size: 20px; }

/* ===== Страница и карточки ===== */
.page {
  flex: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 18px 14px calc(28px + env(safe-area-inset-bottom));
}

.screen[hidden] { display: none; }

.screen.is-active { animation: screen-in .26s var(--ease) both; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.card {
  padding: 22px 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, 0) 40%), var(--surface);
  box-shadow: var(--shadow);
}

.card--center { text-align: center; }

.card__title {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.25;
}

.card__subtitle {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.card__hint {
  margin: 12px 0 0;
  color: var(--text-dim);
  font-size: 12.5px;
}

/* ===== Переключатель режимов (пока один — «Вход») ===== */
.auth-switch {
  position: relative;
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
}

.auth-switch__thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: var(--thumb-w, calc(100% - 8px));
  height: calc(100% - 8px);
  border-radius: 999px;
  background: linear-gradient(160deg, var(--accent-soft), var(--accent));
  box-shadow: 0 10px 24px -12px rgba(240, 160, 42, .95);
  transform: translateX(var(--thumb-x, 0px));
  transition: transform .32s var(--ease), width .32s var(--ease);
  will-change: transform;
}

.auth-switch__option {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 9px 8px;
  border-radius: 999px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 15px;
}

.auth-switch__option.is-active { color: var(--accent-ink); }

/* ===== Формы ===== */
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.field__input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px обязателен: иначе iOS зумит страницу при фокусе */
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}

.field__input::placeholder { color: var(--text-dim); }
.field__input:hover { border-color: #4a5b70; }

.field__input:focus {
  outline: none;
  border-color: var(--accent);
  background: #10151c;
  box-shadow: var(--ring);
}

.field__input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 107, 94, .18);
}

.field__hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.field__hint.is-ok { color: var(--success); }
.field__hint.is-bad { color: var(--danger); }

.field__error {
  margin: 0;
  font-size: 12.5px;
  color: var(--danger);
}

.field__error:empty { display: none; }

/* ===== Кнопки ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  padding: 13px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease), opacity .16s var(--ease);
}

.btn:active { transform: translateY(1px) scale(.995); }

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn--lg { min-height: 56px; font-size: 16.5px; }

.btn--primary {
  background: linear-gradient(160deg, var(--accent-soft), var(--accent));
  color: var(--accent-ink);
  box-shadow: 0 14px 30px -16px rgba(240, 160, 42, .95);
}

.btn--primary:hover {
  box-shadow: 0 18px 38px -16px rgba(240, 160, 42, 1);
  filter: brightness(1.04);
}

.btn--secondary {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.btn--secondary:hover { background: #24303e; }

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn--ghost:hover { color: var(--text); border-color: var(--border-strong); }

.btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.btn + .btn { margin-top: 10px; }

.link-button {
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--accent-soft);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.link-button:hover { color: var(--accent); text-decoration: underline; }

.link-button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 6px;
}

/* ===== Разделитель ===== */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-dim);
  font-size: 12.5px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===== Плашка профиля ===== */
.profile-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.profile-chip__text { flex: 1; min-width: 0; }

.profile-chip__label {
  margin: 0;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
}

.profile-chip__nick {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Сетка животных ===== */
.animal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.animal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color .16s var(--ease), background .16s var(--ease), transform .16s var(--ease);
}

.animal-card__art {
  display: block;
  width: 100%;
  aspect-ratio: 1;
}

.animal-card__art svg { display: block; width: 100%; height: 100%; }

.animal-card__name {
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

.animal-card:hover { border-color: var(--border-strong); }

.animal-card.is-selected {
  border-color: var(--accent);
  background: rgba(240, 160, 42, .1);
  color: var(--text);
  box-shadow: var(--ring);
}

.animal-card:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* ===== Экран игры ===== */
.conn-status {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.conn-status--lost {
  border-color: rgba(255, 107, 94, .55);
  background: rgba(255, 107, 94, .1);
  color: #ffd9d5;
}

.conn-status--warn {
  border-color: rgba(240, 160, 42, .5);
  background: rgba(240, 160, 42, .1);
  color: var(--accent-soft);
}

.game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.game-head__label {
  margin: 0;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
}

.game-head__code {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--accent-soft);
}

.counter {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 84px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.counter__value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
}

.counter__label {
  font-size: 11.5px;
  color: var(--text-dim);
}

.link-box {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.link-box__label {
  display: block;
  margin-bottom: 6px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
}

.link-box__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #10151c;
  color: var(--accent-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.link-box__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.link-box__actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.link-box__actions .btn { min-height: 44px; font-size: 14px; }

.list-title {
  margin: 24px 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-dim);
}

.list-hint {
  margin: -4px 0 10px;
  color: var(--text-dim);
  font-size: 12px;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  animation: player-in .22s var(--ease) both;
}

@keyframes player-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

.player--me {
  border-color: rgba(240, 160, 42, .55);
  background: rgba(240, 160, 42, .08);
}

.player__info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.player__nick {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player__tag {
  font-size: 11.5px;
  color: var(--accent-soft);
}

/* игрок без связи: остаётся в игре и может вернуться */
.player__offline {
  font-size: 11.5px;
  color: var(--text-dim);
}

.player__offline::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--danger);
  vertical-align: 1px;
}

.badge {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(240, 160, 42, .16);
  color: var(--accent-soft);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* Крестик «убрать игрока» — только у хоста */
.player__kick {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease);
}

.player__kick:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.player__kick.is-confirming {
  border-color: var(--danger);
  background: var(--danger);
  color: #2a0f0c;
  font-size: 12.5px;
}

.player__kick:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 107, 94, .3);
}

.empty-note {
  margin: 12px 0 0;
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13.5px;
  text-align: center;
}

.empty-note[hidden] { display: none; }

/* ===== Выбор профессии ===== */
.prof__picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 8px;
}

.prof__arrow {
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}

.prof__arrow:hover,
.prof__arrow:focus-visible { border-color: var(--accent); color: var(--accent-soft); }

.prof__card {
  flex: 1;
  min-width: 0;
  min-height: 230px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 20px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.prof__sphere {
  margin: 0;
  color: var(--text-dim);
  font-size: 12.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.prof__name { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.25; }
.prof__skills { margin: 0; color: var(--text-muted); font-size: 14.5px; line-height: 1.5; }
.prof__avg { margin: 6px 0 0; color: var(--text-muted); font-size: 14px; }
.prof__avg b { color: var(--accent-soft); }
.prof__counter { min-height: 1.4em; margin: 0 0 14px; color: var(--text-dim); font-size: 13px; }
#prof-accept { width: 100%; }

/* ===== Стол игры ===== */
/* На столе нужно место под карточки игроков — расширяем страницу */
.page:has(> #screen-table.is-active) { max-width: 1040px; }

#screen-table { padding-bottom: 72px; }
/* transform в общей анимации экрана ломает position: fixed у нижней панели — здесь только прозрачность */
#screen-table.is-active { animation-name: screen-fade; }
@keyframes screen-fade { from { opacity: 0; } }

.catastrophe {
  margin: 0 0 16px;
  padding: 14px 18px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: rgba(255, 107, 94, .08);
  text-align: center;
}

.catastrophe__label {
  margin: 0 0 4px;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.catastrophe__name {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
}

.round-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.round-box__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.round-box__title { margin: 0; font-size: 20px; font-weight: 700; }
.round-box__step { margin: 0; color: var(--text-muted); font-size: 14.5px; line-height: 1.5; }

.progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  overflow: hidden;
}

.progress__bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
  transition: width .3s var(--ease);
}

.round-box__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
}

.round-box__stats div { padding: 8px 10px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, .04); }
.round-box__stats dt { color: var(--text-dim); font-size: 12px; line-height: 1.3; }
.round-box__stats dd { margin: 2px 0 0; font-size: 18px; font-weight: 700; }

.round-box__host { display: flex; flex-direction: column; gap: 8px; }
.round-box__host .btn { width: 100%; }
.vote-end { display: flex; flex-direction: column; gap: 8px; }
.vote-end[hidden] { display: none; }

.seat-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.seat {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.seat--me { border-color: rgba(240, 160, 42, .55); background: rgba(240, 160, 42, .08); }
.seat--out { opacity: .55; }
.seat__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.seat__out { font-size: 11.5px; color: var(--danger); }

.traits {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 0;
  font-size: 14px;
}

.traits dt { color: var(--text-muted); }
.traits dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.traits__hidden { color: var(--text-dim); letter-spacing: .1em; }

.my-cards { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }

.my-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.my-card--open { opacity: .8; }
.my-card__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.my-card__name { color: var(--text-muted); font-size: 12.5px; }
.my-card__value { font-weight: 600; overflow-wrap: anywhere; }
.my-card__status { flex: none; color: var(--success); font-size: 12.5px; }
.my-card__status--closed { color: var(--text-dim); }
.my-card__open { flex: none; width: auto; min-height: 38px; padding: 0 14px; }
.my-card__open.is-confirming { background: var(--danger); color: #fff; }
.btn--ghost.is-confirming { border-color: var(--danger); color: var(--danger); }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: var(--surface-2);
}

.tabbar__btn {
  min-height: 54px;
  border: 0;
  border-top: 2px solid transparent;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tabbar__btn.is-active { color: var(--accent-soft); border-top-color: var(--accent); }
.tabbar__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }

/* ===== Готовность ===== */
/* Текст сверху, кнопка на всю ширину снизу: в узкой карточке
   кнопка с width: 100% не помещается рядом с текстом. */
.ready-box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  margin: 18px 0 0;
  padding: 16px 18px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  transition: border-color .2s var(--ease), background .2s var(--ease);
}

.ready-box__text {
  min-width: 0;
  text-align: center;
}

.ready-box__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.ready-box__subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.5;
}

.ready-box #ready-button,
.ready-box #start-button {
  width: 100%;
  min-height: 50px;
}

.ready-box.is-started {
  border-color: rgba(127, 212, 139, .55);
  background: rgba(127, 212, 139, .1);
}

.ready-box.is-started .ready-box__title { color: var(--success); }

#ready-button.is-ready {
  background: rgba(127, 212, 139, .16);
  border: 1px solid rgba(127, 212, 139, .5);
  color: var(--success);
  box-shadow: none;
}

#ready-button.is-ready:hover { filter: brightness(1.1); }

.player--ready {
  border-color: rgba(127, 212, 139, .4);
}

.player__ready {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(127, 212, 139, .16);
  color: var(--success);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

#leave-game { margin-top: 22px; }

/* ===== Поиск игры ===== */
.spinner {
  display: block;
  width: 34px;
  height: 34px;
  margin: 0 auto 16px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Тост ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: min(92vw, 460px);
  padding: 12px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(29, 37, 49, .97);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  animation: toast-in .2s var(--ease) both;
}

.toast[hidden] { display: none; }

/* Кнопка «Игра» — возврат в текущую игру с главной (правый нижний угол) */
.game-badge {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 19;
  padding: 10px 18px;
  border: 2px solid var(--accent);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 10px 26px -12px rgba(240, 160, 42, .8);
  animation: badge-in .2s var(--ease) both;
  transition: background .15s var(--ease), color .15s var(--ease);
}

@keyframes badge-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.game-badge:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.game-badge:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.game-badge[hidden] { display: none; }

/* пока видна кнопка «Игра», тост поднимается над ней */
.game-badge:not([hidden]) ~ .toast {
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}
.toast--error { border-color: rgba(255, 107, 94, .6); color: #ffd9d5; }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ===== Сповіщення про відкриту карту (зверху) ===== */
.reveal-feed {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 21;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(calc(100vw - 32px), 420px);
  transform: translateX(-50%);
  pointer-events: none;
}

.reveal-note {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 10px 10px;
  border: 1px solid var(--accent);
  border-radius: 16px;
  background: rgba(29, 37, 49, .97);
  color: var(--text);
  box-shadow: var(--shadow);
  animation: reveal-in .3s var(--ease) both;
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}

.reveal-note.is-leaving { opacity: 0; transform: translateY(-10px); }
.reveal-note .avatar { flex: none; }
.reveal-note__text { display: flex; flex-direction: column; min-width: 0; }
.reveal-note__who { color: var(--text-dim); font-size: 12px; font-weight: 600; }
.reveal-note__trait { color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.reveal-note__value { font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }

@keyframes reveal-in {
  from { opacity: 0; transform: translateY(-16px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* ===== Подвал ===== */
.site-footer {
  padding: 4px 16px calc(16px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

.site-footer p { margin: 0; }

/* ===== Меньше движения ===== */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
