/* © 2026 dezignet. Все права защищены. Копировать и использовать этот код без разрешения автора запрещено. */
/* Экраны приложения, чат, голос и адаптив стола. Использует токены из styles.css */

[hidden] { display: none !important; }
input, textarea, select { user-select: text; -webkit-user-select: text; }
body:not(.mode-online) .only-online { display: none; }
body.mode-online .only-offline { display: none; }

/* ---------- Экраны ---------- */
.app-screens {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background:
    radial-gradient(ellipse 90% 60% at 50% 18%, var(--screen-glow), transparent 70%),
    var(--bg-main);
}
.screen {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: max(10px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
}
.screen.active { display: flex; flex-direction: column; gap: 14px; animation: screen-in 0.22s ease both; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.screen-top {
  flex: 0 0 auto;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.screen-title { font-size: var(--fs-lg); font-weight: 700; color: var(--text); }
.btn-lg { --control-h: 48px; width: 100%; font-size: 15px; }
.panel {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* Главный экран */
.screen-home { justify-content: space-between; }
.home-hero {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  min-height: 250px;
}
.hero-fan { position: relative; width: 300px; max-width: 86vw; height: clamp(150px, 27vh, 230px); margin-bottom: 8px; }
/* Селектор сильнее общего .card:first-child, иначе первую карту веера сдвигает вбок */
.hero-fan .card.hero-card {
  --hero-w: clamp(92px, 16vh, 138px);
  position: absolute;
  left: 50%;
  bottom: 0;
  width: var(--hero-w);
  height: calc(var(--hero-w) * 1.46);
  margin: 0 0 0 calc(var(--hero-w) / -2);
  border-radius: 9px;
  transform-origin: 50% 130%;
  transform: rotate(calc(var(--i) * 13deg));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  animation: hero-deal 0.6s var(--ease) backwards;
  animation-delay: calc((var(--i) + 2) * 60ms);
}
@keyframes hero-deal {
  from { transform: translateY(70px) rotate(0deg); opacity: 0; }
}
/* Название ниже веера валетов, на невысоких экранах отступ меньше */
.hero-title { margin-top: clamp(24px, 6vh, 50px); font-size: clamp(38px, 8vh, 60px); font-weight: 900; letter-spacing: 5px; color: var(--gold); }
.home-actions { flex: 0 0 auto; width: 100%; max-width: 380px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.home-footer { margin: 4px 0 0; color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.3; text-align: center; opacity: 0.75; }
/* Продолжить партию с ботами: две строки — что и где остановились */
.btn-continue { height: auto; min-height: 56px; flex-direction: column; gap: 3px; padding: 7px 14px; border-color: var(--gold); }
.btn-continue small { color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600; }
/* За столом жесты браузера (масштаб, прокрутка) не мешают касаниям карт */
.playfield-container { touch-action: none; }

.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  max-width: 190px;
  padding: 3px 12px 3px 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
#home-profile:not(:has(.chip-avatar)), #lobby-profile:not(:has(.chip-avatar)) { padding-left: 12px; }
.chip-avatar { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; font-size: 22px; }
.chip-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.chip-text b { font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-text small { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }

/* Формы */
.auth-panel { width: 100%; max-width: 400px; margin: auto; padding: 18px; }
.auth-panel form, .profile-card form, #profile-security form { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); font-weight: 700; color: var(--text-muted); }
.field input, .join-row input, .chat-form input, .invite-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--bg-main);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
}
.field input:focus, .join-row input:focus, .chat-form input:focus, .invite-input:focus { border-color: var(--gold); }
.form-error { min-height: 16px; color: var(--bad); font-size: var(--fs-sm); font-weight: 600; }
.form-error:empty { display: none; }
.form-hint { color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.4; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: var(--fs-xs); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-control);
  background: var(--surface-chip);
}
.segment {
  flex: 1;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: 700;
  cursor: pointer;
}
.segment.is-active { background: var(--surface-2); color: var(--text); }

/* Лобби */
.lobby-grid {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  align-content: start; /* иначе на телефоне свободная высота уходит в пустоту между панелями */
}
.join-row { display: flex; gap: 6px; }
.join-row input { text-transform: uppercase; letter-spacing: 2px; font-weight: 700; min-width: 0; }
.join-row .btn { height: 44px; --control-h: 44px; }
.list-scroll { display: flex; flex-direction: column; gap: 4px; max-height: min(58vh, 560px); overflow-y: auto; }
.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 8px;
  border-radius: var(--radius-control);
  background: var(--surface-chip);
}
.list-row.is-me { box-shadow: inset 0 0 0 1px var(--gold); }
.row-avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: 0 0 auto; font-size: 22px; }
.row-place { width: 22px; text-align: center; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 700; flex: 0 0 auto; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.row-main b { font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { font-size: var(--fs-xs); color: var(--text-muted); }
.row-value { display: flex; flex-direction: column; align-items: flex-end; flex: 0 0 auto; color: var(--text); line-height: 1.2; }
.row-value small { color: var(--text-muted); font-size: var(--fs-xs); }
.empty { padding: 26px 10px; text-align: center; color: var(--text-muted); font-size: var(--fs-md); }
.chip-accent { color: var(--gold); }
.chip-bad { color: var(--bad); }

/* Настройка стола */
.settings-stack { display: flex; flex-direction: column; gap: 12px; }
.option-group { display: flex; flex-direction: column; gap: 5px; }
.option-label { color: var(--text-muted); font-size: var(--fs-xs); font-weight: 700; }
.option-row { display: flex; flex-wrap: wrap; gap: 4px; }
.option-chip {
  min-width: 44px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
}
.option-chip.is-active { border-color: var(--gold); color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }

/* Варианты правил: свёрнуты под одной строкой, раскрываются по нажатию */
.rule-options { margin-top: 10px; }
.rules-variants { border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-chip); }
.rules-variants > summary {
  min-height: 44px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}
.rules-variants > summary::-webkit-details-marker { display: none; }
.rules-variants > summary::after { content: "▾"; color: var(--text-muted); transition: transform 0.15s ease; }
.rules-variants[open] > summary::after { transform: rotate(180deg); }
.rules-variants > summary .option-label { flex: 1 1 auto; color: var(--text); font-size: var(--fs-sm); }
.rules-variants > .settings-stack { padding: 4px 12px 12px; }
.row-rules { display: block; color: var(--gold); }
.rules-table-variants {
  margin-bottom: 10px;
  padding: 8px 12px;
  border: 1px solid var(--gold);
  border-radius: var(--radius-control);
}
.rules-table-variants b { color: var(--gold); }

/* Комната */
.room-code {
  height: 44px;
  padding: 0 14px;
  border: 1px dashed var(--gold);
  border-radius: var(--radius-control);
  background: none;
  color: var(--gold);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 3px;
  cursor: pointer;
}
.room-layout { width: 100%; max-width: 760px; margin: 0 auto; }
.room-main { display: flex; flex-direction: column; gap: 12px; }
.room-status { text-align: center; color: var(--text-muted); font-size: var(--fs-md); min-height: 18px; }
.room-seats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.room-seat {
  position: relative;
  min-height: 118px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface-1);
  text-align: center;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.room-seat.is-me { border-color: var(--gold); }
.room-seat.is-empty { border-style: dashed; background: none; color: var(--text-muted); justify-content: center; }
.room-seat.is-speaking { border-color: var(--good); box-shadow: 0 0 0 2px var(--good), 0 0 16px rgba(110, 231, 168, 0.55); }
.seat-avatar { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; font-size: 30px; line-height: 1.2; }
.seat-name { max-width: 100%; font-size: var(--fs-md); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-rating { color: var(--text-muted); font-size: var(--fs-xs); }
.seat-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.seat-badges .chip { background: var(--surface-2); }
.seat-remove { position: absolute; top: 2px; right: 2px; --control-h: 32px; color: var(--text-muted); }
.seat-reaction { position: absolute; top: 12px; font-size: 34px; pointer-events: none; animation: reaction-up 1.4s ease-out both; }
@keyframes reaction-up {
  0% { opacity: 0; transform: translateY(10px) scale(0.5); }
  20% { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0; transform: translateY(-40px) scale(1); }
}
.room-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.room-actions .btn { flex: 1; width: auto; }
.room-actions .btn-invite { flex-basis: 100%; border-color: var(--gold); color: var(--gold); }

/* Профиль */
.profile-grid {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.profile-card { align-items: stretch; }
.profile-avatar {
  width: 82px;
  height: 82px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--gold);
  border-radius: var(--radius-panel);
  background: var(--surface-2);
  font-size: 44px;
}
.avatar-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.avatar-option {
  aspect-ratio: 1;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  font-size: 20px;
  cursor: pointer;
}
.avatar-option.is-active { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 2px;
  border-radius: var(--radius-control);
  background: var(--surface-chip);
  text-align: center;
}
.stat b { font-size: var(--fs-lg); color: var(--text); }
.stat small { font-size: var(--fs-xs); color: var(--text-muted); }
.stat-wide { grid-column: 1 / -1; }
.profile-delete { margin-top: 8px; align-self: flex-start; }

/* ---------- Чат и голос ---------- */
.social-panel {
  position: fixed;
  z-index: 3000;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 100vw);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
  background: var(--surface-1);
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.45);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 0.22s var(--ease), visibility 0.22s;
}
.social-panel.open { transform: none; visibility: visible; }
.social-head { display: flex; align-items: center; justify-content: space-between; }
.social-head h2 { font-size: var(--fs-lg); color: var(--text); }
.voice-box { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: var(--radius-control); background: var(--surface-chip); }
.voice-people { display: flex; flex-direction: column; gap: 4px; }
.voice-person { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 2px 4px; border-radius: var(--radius-chip); }
.voice-person.is-speaking { box-shadow: inset 0 0 0 1.5px var(--good); }
.voice-name { flex: 1; min-width: 0; font-size: var(--fs-sm); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-person input[type=range] { width: 76px; accent-color: var(--gold); }
.voice-flag { color: var(--bad); display: inline-flex; }
.voice-person .btn { --control-h: 36px; }
.reaction-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.reaction {
  height: 38px;
  border: 0;
  border-radius: var(--radius-chip);
  background: var(--surface-2);
  font-size: 18px;
  cursor: pointer;
}
.reaction:active { transform: scale(0.9); }
.chat-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 2px; }
.chat-item { display: flex; gap: 6px; max-width: 92%; }
.chat-item.is-me { align-self: flex-end; flex-direction: row-reverse; }
.chat-avatar { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex: 0 0 auto; font-size: 17px; }
.chat-body {
  display: flex;
  flex-direction: column;
  padding: 5px 9px;
  border-radius: var(--radius-control);
  background: var(--surface-2);
  font-size: var(--fs-md);
  line-height: 1.3;
  overflow-wrap: anywhere;
  user-select: text;
  -webkit-user-select: text;
}
.chat-body b { font-size: var(--fs-xs); color: var(--gold); }
.chat-form { display: flex; gap: 6px; }
.chat-form input { min-width: 0; }
.chat-form .btn { --control-h: 44px; }
.social-toggle { position: relative; }
.unread {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--danger-hover);
  color: #fff;
  font: 700 11px/18px var(--font-ui);
  font-style: normal;
  text-align: center;
}
.voice-toggle.is-live { color: var(--good); border-color: var(--good); }

/* На широком экране в комнате чат всегда рядом */
@media (min-width: 1000px) {
  body.in-room .social-panel { transform: none; visibility: visible; box-shadow: none; }
  body.in-room .social-head .btn, body.in-room #screen-room .social-toggle { display: none; }
  body.in-room #screen-room { padding-right: 376px; }
}

/* ---------- Стол в сети ---------- */
.turn-ring {
  position: absolute;
  inset: -5px;
  border-radius: 14px;
  z-index: 4;
  pointer-events: none;
  background: conic-gradient(var(--gold) var(--part, 360deg), transparent 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  padding: 3px;
}
.turn-ring.urgent { background: conic-gradient(var(--bad) var(--part, 360deg), transparent 0); }
.avatar-wrapper.is-speaking { border-color: var(--good) !important; box-shadow: 0 0 0 2px var(--good), 0 0 16px rgba(110, 231, 168, 0.75) !important; }
.card.is-sending { --lift: -18px; opacity: 0.85; }

.result-icon { font-size: 40px; margin-bottom: 6px; }
.result-line { font-size: 16px; font-weight: 700; }
.result-accent { color: var(--gold); font-weight: 700; }
.result-accent.small { font-size: var(--fs-sm); margin-top: 4px; }
.result-prize { margin-top: 6px; }
.match-result { display: flex; justify-content: center; gap: 14px; margin-top: 8px; color: var(--text); font-weight: 700; }
.summary-name { font-weight: 700; }
.summary-score { font-size: 14px; font-weight: 700; color: var(--gold); }
.outcome.good { color: var(--good); }
.outcome.bad { color: var(--bad); }
.outcome.accent { color: var(--gold); }
.outcome.muted { color: var(--text-muted); }
.invite-input { margin-top: 8px; }
.modal-close { min-width: 44px; min-height: 44px; }
.volume-row input { min-height: 24px; }
.player-select-btn:focus-visible, .card:focus-visible, .option-chip:focus-visible, .segment:focus-visible, .avatar-option:focus-visible, .reaction:focus-visible, .room-code:focus-visible, .profile-chip:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- Уведомления ---------- */
.toast-stack {
  position: fixed;
  z-index: 12000;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(92vw, 380px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-md);
  animation: screen-in 0.2s ease both;
}
.toast.bad { border-color: var(--bad); }
.toast.good { border-color: var(--good); }
.net-banner {
  position: fixed;
  z-index: 11000;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(env(safe-area-inset-top) + 6px) 12px 6px;
  background: var(--danger);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 700;
  text-align: center;
}

/* ---------- Адаптив ---------- */
@media (max-width: 760px) {
  .lobby-grid, .profile-grid { grid-template-columns: minmax(0, 1fr); }
  .list-scroll { max-height: none; }
}

/* Невысокие телефоны: компактные места */
@media (max-height: 740px) {
  .zone-1-top { padding-top: 11px; min-height: 0; }
  .avatar-wrapper { border-radius: 12px; }
  .player-name-plate { margin-top: 2px; padding: 1px 2px 1px 5px; }
  .trick-pips { margin-top: 2px; height: 6px; }
  .trick-pips i { width: 6px; height: 6px; }
  .bot-card-fan { margin-top: 2px; height: 25px; }
  .bot-fan-card { width: 18px; height: 25px; margin-left: -12px; background-size: 5px 5px; border-width: 1px; }
  .zone-3-mid-lower { margin-bottom: 8px; }
  .user-notice-toast { padding: 2px 9px; min-height: 0; font-size: var(--fs-xs); }
  .bank-stack { height: 20px; }
  .side-stack-box { gap: 1px; }
  :root { --card-w: 44px; --card-h: 64px; --user-card-w: 95px; --user-card-h: 138px; --user-card-overlap: -47px; --avatar: 48px; }
  .action-bar .btn { --control-h: 40px; }
}

/* Совсем низкие экраны: карты в центре крупнее обычных, но не в полтора раза */
@media (max-height: 600px) and (orientation: portrait) {
  :root { --table-card-w: calc(var(--card-w) * 1.3); }
  /* Главный экран плотнее, чтобы строка об авторских правах не уходила за край */
  .home-hero { min-height: 0; }
  .hero-fan { margin-bottom: 4px; }
  .hero-title { margin-top: 8px; }
  .trick-arena { height: calc(var(--table-card-h) * 1.5); }
  .zone-2-center { min-height: calc(var(--table-card-h) * 1.5 + 30px); }
}

@media (max-width: 340px) {
  :root { --user-card-w: 86px; --user-card-h: 126px; --user-card-overlap: -45px; --card-w: 40px; --card-h: 58px; --avatar: 44px; }
  .app-header { gap: 3px; padding-left: 5px; padding-right: 4px; grid-template-columns: auto 1fr auto; }
  .brand-box { display: none; }
  .action-bar .btn:not(.btn-icon) { padding: 0 6px; font-size: var(--fs-sm); }
  .action-bar .btn-slot { min-width: 54px; }
  .zone-3-mid-lower { padding: 0 8px; }
}

@media (max-width: 340px) {
  .user-seat-labels .player-name-plate { max-width: 76px; }
}
@media (max-width: 360px) {
  .user-action-and-profile-row:has(.side-right > :nth-child(3)) .user-seat-labels { display: none; }
}
/* Редкий случай с третьей кнопкой справа («Безөк»): кнопки плотнее, чтобы строка не переносилась */
@media (max-width: 520px) {
  .user-action-and-profile-row:has(.side-right > :nth-child(3)) { gap: 5px; padding-left: 4px; padding-right: 4px; }
  .user-action-and-profile-row:has(.side-right > :nth-child(3)) .action-bar { gap: 3px; }
  .user-action-and-profile-row:has(.side-right > :nth-child(3)) .action-bar .btn:not(.btn-icon) { padding: 0 6px; font-size: var(--fs-sm); }
  .user-action-and-profile-row:has(.side-right > :nth-child(3)) .action-bar .btn-slot { min-width: 0; }
  .user-action-and-profile-row:has(.side-right > :nth-child(3)) .action-bar .btn-icon { width: 34px; min-width: 34px; }
}

/* Телефон боком: рука и кнопки в одну строку, места соперников по краям */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --header-height: 40px; --card-w: 42px; --card-h: 61px; --user-card-w: 76px; --user-card-h: 111px; --user-card-overlap: -34px; --avatar: 42px; }
  .scoreboard-sidebar { display: none; }
  .app-header .btn { --control-h: 32px; }
  .playfield-container { padding: 0 4px; }
  .felt-board { inset: 2px; border-width: 4px; border-radius: 22px; }
  .zone-1-top { padding: 7px 90px 0; }
  .player-seat { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: 3px; max-width: 142px; }
  .player-seat .player-name-plate { margin-top: 0; max-width: 104px; }
  .player-seat .trick-pips { display: none; }
  .player-seat .bot-card-fan { display: none; }
  .zone-3-mid-lower {
    position: absolute;
    width: auto;
    left: 14px;
    right: 14px;
    top: 42px;
    margin: 0;
    padding: 0;
    pointer-events: none;
    align-items: flex-start;
  }
  .zone-3-mid-lower .player-seat { flex-direction: column; flex-wrap: nowrap; width: 76px; }
  .zone-3-mid-lower .player-name-plate { max-width: 76px; padding-left: 4px; font-size: 10px; }
  .zone-3-mid-lower .seat-score { min-width: 18px; padding: 0 2px; font-size: var(--fs-xs); }
  .zone-2-center { gap: 16px; min-height: 0; }
  .table-spacer { display: none; }
  :root { --table-card-w: calc(var(--card-w) * 1.25); }
  .trick-arena { width: calc(var(--table-card-w) * 2.6); height: calc(var(--table-card-h) * 1.25); }
  .bank-stack { height: 16px; font-size: var(--fs-xs); }
  .coin-pile { transform: scale(0.7); }
  .zone-4-bottom { flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 4px; padding-bottom: 2px; }
  /* Боком: кнопки обеих сторон строкой сверху, аватар с именем под ними, всё у правого края */
  .user-action-and-profile-row { order: 2; flex: 1 1 0; max-width: none; display: grid; grid-template-columns: auto auto; grid-template-areas: "left right" "dock dock"; justify-content: end; justify-items: end; align-items: center; column-gap: 5px; row-gap: 3px; padding: 0 6px 2px; margin: 0; min-width: 0; }
  .user-row-side { min-width: 0; }
  .user-row-side.side-left { grid-area: left; }
  .user-row-side.side-right { grid-area: right; }
  .user-seat-dock { grid-area: dock; flex-direction: row; }
  .action-bar .btn { --control-h: 36px; padding: 0 8px; font-size: var(--fs-sm); }
  .action-bar .btn-slot { min-width: 58px; }
  .player-hand { order: 1; height: calc(var(--user-card-h) * 0.6 + 6px); padding: 4px 4px 0 20px; flex: 0 0 auto; }
  /* Банк и подсказка внизу по центру, между рукой и кнопками */
  .table-info { position: fixed; left: 50%; bottom: max(8px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(34vw, 260px); z-index: 30; }
  .user-notice-toast { font-size: var(--fs-xs); padding: 2px 8px; min-height: 0; }
  /* С .active, иначе общее .screen.active возвращает экран в колонку и кнопки уезжают за край */
  .screen-home.active { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .screen-home .screen-top { flex: 0 0 100%; }
  .home-hero { min-height: 0; flex: 1 1 45%; }
  .hero-fan { height: 110px; }
  .hero-fan .card.hero-card { --hero-w: 70px; }
  .hero-title { margin-top: 14px; font-size: 28px; }
  .home-actions { flex: 1 1 45%; }
}

/* ---------- Настройки: оформление, звук, удобство ---------- */
.settings-body { display: flex; flex-direction: column; gap: 14px; }
.settings-section { display: flex; flex-direction: column; gap: 9px; }
.settings-section + .settings-section { padding-top: 12px; border-top: 1px solid var(--line); }
.modal-body .settings-heading, .settings-heading {
  margin: 0;
  color: var(--gold);
  font-size: var(--fs-sm);
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.look-controls { display: flex; flex-direction: column; gap: 8px; }
.theme-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-height: var(--tap);
  padding: 6px 4px 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.theme-swatch.is-active { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.theme-swatch-felt {
  position: relative;
  width: 100%;
  aspect-ratio: 1.5;
  border: 2px solid #3a2413;
  border-radius: var(--radius-chip);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.45);
}
.theme-swatch-accent { position: absolute; left: 50%; bottom: 5px; width: 50%; height: 8px; border-radius: 4px; transform: translateX(-50%); }
.theme-swatch-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; }
.theme-swatch:focus-visible, .toggle-switch:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.toggle-switch {
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-2);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.toggle-switch::before { content: ""; position: absolute; inset: -8px; }
.toggle-switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s var(--ease), background 0.2s ease;
}
.toggle-switch.is-on { border-color: var(--gold); background: var(--gold); }
.toggle-switch.is-on i { transform: translateX(22px); background: var(--text-on-gold); }
.settings-reset { align-self: flex-start; --control-h: 36px; padding: 0 10px; color: var(--text-muted); font-size: var(--fs-sm); }
.screen-top-left { display: flex; align-items: center; gap: 6px; }

/* ---------- Подсказка новичку: карточка над кнопками, один раз в важный момент ---------- */
.coach-card {
  position: fixed;
  left: 50%;
  z-index: 960;
  width: min(340px, calc(100vw - 24px));
  padding: 12px 12px 8px;
  border: 1px solid rgba(var(--accent-rgb), 0.55);
  border-radius: var(--radius-panel);
  background: var(--surface-1);
  box-shadow: var(--shadow-md);
  transform: translateX(-50%);
  animation: coach-in 0.28s var(--ease) both;
}
.coach-card::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px;
  height: 12px;
  border-right: 1px solid rgba(var(--accent-rgb), 0.55);
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.55);
  background: var(--surface-1);
  transform: translateX(-50%) rotate(45deg);
}
.coach-text { margin: 0; color: var(--text); font-size: var(--fs-md); line-height: 1.4; }
.coach-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.coach-actions .btn { --control-h: 38px; padding: 0 12px; font-size: var(--fs-sm); }
.coach-off { color: var(--text-muted); }
@keyframes coach-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
}

/* Эмблемы аватаров в меню, чате и профиле */
.chip-avatar .avatar-emblem, .row-avatar .avatar-emblem, .seat-avatar .avatar-emblem, .chat-avatar .avatar-emblem { width: 92%; height: 92%; }
.profile-avatar .avatar-emblem { width: 62%; height: 62%; stroke-width: 1.6; }
.avatar-option-face { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; pointer-events: none; }
.avatar-option-face .avatar-emblem { width: 70%; height: 70%; }

/* ---------- Итог партии: карточка победителя ---------- */
#modal-game-over.is-win .modal-header { display: none; }
.win-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 4px 0; text-align: center; }
.win-emblem { position: relative; display: flex; align-items: center; justify-content: center; width: 150px; height: 128px; margin-bottom: 2px; }
.win-laurel { position: absolute; left: 0; top: -8px; width: 150px; height: 150px; }
.win-laurel-stem path { fill: none; stroke: var(--gold); stroke-width: 1.6; stroke-linecap: round; opacity: 0.75; }
.win-laurel-leaves ellipse { fill: var(--gold); opacity: 0.85; }
.win-emblem-face {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--avatar-bg);
  box-shadow: 0 0 0 2px var(--gold), 0 0 0 7px rgba(var(--accent-rgb), 0.16), 0 0 30px rgba(var(--accent-rgb), 0.45);
  animation: win-pop 0.5s var(--ease) both;
}
.win-emblem-face .avatar-emblem { width: 58%; height: 58%; stroke-width: 1.7; }
.win-emblem-face .avatar-emoji { font-size: 44px; }
.win-label { color: var(--gold); font-size: var(--fs-sm); font-weight: 800; letter-spacing: 1.8px; text-transform: uppercase; }
.win-card .win-name { margin: 0; max-width: 100%; color: var(--text); font-size: 28px; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.win-bank {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 6px;
  padding: 8px 16px;
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  border-radius: var(--radius-control);
  background: rgba(var(--accent-rgb), 0.09);
  color: var(--gold);
  font-size: var(--fs-lg);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.win-coin { width: 18px; height: 18px; flex: 0 0 auto; border: 1px solid #80591a; border-radius: 50%; background: linear-gradient(180deg, #ffe08a, #c8912a); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18); }
.win-badge { padding: 3px 10px; border-radius: var(--radius-chip); background: var(--surface-2); color: var(--text); font-size: var(--fs-sm); font-weight: 700; }
.win-net { margin: 2px 0 0; color: var(--text-muted); font-size: var(--fs-sm); }
@keyframes win-pop {
  from { opacity: 0; transform: scale(0.7); }
}

/* ---------- Быстрые фразы: касание своего аватара в сетевой партии ---------- */
body.mode-online #user-avatar-main { cursor: pointer; }
.phrase-pop {
  position: fixed;
  left: 50%;
  z-index: 970;
  width: min(320px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface-1);
  box-shadow: var(--shadow-md);
  transform: translateX(-50%);
  animation: coach-in 0.2s var(--ease) both;
}
.phrase-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.phrase-btn { --control-h: 44px; padding: 0 8px; font-size: var(--fs-sm); white-space: normal; line-height: 1.15; }
.phrase-reactions { display: flex; justify-content: space-between; gap: 2px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.phrase-reactions .reaction { flex: 1 1 0; min-width: 0; }
.seat-phrase { font-size: var(--fs-sm); font-weight: 800; white-space: nowrap; }
