:root {
  color-scheme: dark;
  --felt: #123225;
  --felt-2: #184532;
  --panel: #1b241f;
  --panel-2: #26352d;
  --line: rgba(245, 232, 196, 0.17);
  --text: #f6ecd2;
  --muted: #b9ad91;
  --gold: #e2b95d;
  --gold-2: #f5d989;
  --danger: #e36b6b;
  --ok: #79d99a;
  --wine: #8d2f3c;
  --amber: #c7833b;
  --black: #141414;
  --red: #b63131;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(226, 185, 93, 0.12), transparent 28rem),
    linear-gradient(155deg, #0d2018 0%, var(--felt) 45%, #08130f 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  padding: 0 14px;
  background: var(--gold);
  color: #211909;
  font-weight: 800;
}

button:disabled {
  opacity: 0.45;
}

.plain-button {
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.app {
  width: min(1040px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
}

.screen {
  display: grid;
  gap: 14px;
}

.topbar,
.panel,
.player,
.card-zone,
.log {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 36, 31, 0.88);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--gold);
  color: #211909;
  font-weight: 950;
}

.brand h1,
.panel h2 {
  margin: 0;
  font-size: 1.05rem;
}

.brand p,
.hint,
.muted {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.status {
  color: var(--gold-2);
  font-size: 0.88rem;
  text-align: right;
}

.join {
  min-height: 100dvh;
  align-content: center;
}

.join-card {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: 18px;
}


.fields {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: rgba(226, 185, 93, 0.72);
}

.room-code {
  letter-spacing: 0.18em;
  font-weight: 900;
}

.web-code {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(226, 185, 93, 0.45);
  border-radius: 8px;
  background: rgba(226, 185, 93, 0.12);
  color: var(--gold-2);
  text-align: center;
  letter-spacing: 0.22em;
  font-size: 2rem;
  font-weight: 950;
}

.notice {
  min-height: 1.2em;
  color: var(--ok);
  font-weight: 800;
}

.error {
  color: var(--danger);
  min-height: 1.2em;
}

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

.player {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px;
  min-width: 0;
}

.player.active {
  border-color: rgba(226, 185, 93, 0.8);
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold);
  color: #211909;
  font-weight: 950;
}

.avatar.offline {
  background: var(--panel-2);
  color: var(--muted);
}

.player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.player-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.score {
  margin-left: auto;
  color: var(--gold-2);
  font-weight: 950;
}

.table {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
}

.table-main {
  display: grid;
  gap: 12px;
}

.card-zone {
  min-height: 212px;
  padding: 12px;
  background:
    radial-gradient(circle at center, rgba(226, 185, 93, 0.13), transparent 22rem),
    rgba(16, 47, 34, 0.88);
}

.phase {
  padding: 12px;
}

.phase-title {
  margin: 0 0 8px;
  color: var(--gold-2);
  font-weight: 950;
}

.phase-help {
  margin: 0 0 12px;
  color: #e4d4ad;
  line-height: 1.45;
}

.lobby-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.lobby-count {
  flex: 0 0 auto;
  min-width: 54px;
  border: 1px solid rgba(226, 185, 93, 0.42);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--gold-2);
  text-align: center;
  font-weight: 950;
}

.invite-panel {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  border: 1px solid rgba(245, 232, 196, 0.14);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.invite-line {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 8px;
  align-items: stretch;
}

.icon-button {
  min-width: 48px;
  padding: 0;
  font-size: 1.25rem;
}

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

.seat-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  border: 1px solid rgba(245, 232, 196, 0.14);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.seat-row.empty {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.025);
}

.seat-row strong,
.seat-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat-row strong {
  font-size: 0.9rem;
}

.seat-row span {
  color: var(--muted);
  font-size: 0.78rem;
}

.actions,
.stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

.danger {
  border: 1px solid rgba(227, 107, 107, 0.58);
  background: transparent;
  color: var(--danger);
}

.number {
  min-width: 78px;
  text-align: center;
  color: var(--gold-2);
  font-size: 1.45rem;
  font-weight: 950;
}

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hand {
  align-items: flex-end;
}

.card {
  position: relative;
  width: 58px;
  height: 82px;
  border: 1px solid rgba(0, 0, 0, 0.28);
  border-radius: 8px;
  background: #fff8e7;
  color: var(--black);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
  font-weight: 900;
  user-select: none;
  overflow: hidden;
}

.card.red {
  color: var(--red);
}

.card.playable {
  cursor: pointer;
  transform: translateY(-4px);
  outline: 2px solid rgba(226, 185, 93, 0.75);
}

.card.selected {
  transform: translateY(-12px);
  outline: 3px solid var(--ok);
}

.card-corner {
  position: absolute;
  top: 5px;
  left: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card-rank {
  font-size: 1rem;
  font-weight: 900;
}

.card-pip {
  font-size: 0.82rem;
  margin-top: 1px;
}

.card-big {
  position: absolute;
  right: 5px;
  bottom: 3px;
  font-size: 1.7rem;
  line-height: 1;
  opacity: 0.9;
}

.card-back {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, #7d1720, #d4ab51);
  color: #fff2d2;
}

.card-back .card-corner,
.card-back .card-big {
  display: none;
}

.trick {
  display: flex;
  justify-content: center;
  gap: 14px;
  min-height: 94px;
}

.played {
  display: grid;
  gap: 6px;
  justify-items: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.side {
  display: grid;
  gap: 12px;
  align-content: start;
}

.log {
  padding: 12px;
}

.log h2 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.log-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.86rem;
}

.results {
  display: grid;
  gap: 8px;
}

.result-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.positive {
  color: var(--ok);
}

.negative {
  color: var(--danger);
}

.game-app {
  width: min(900px, 100%);
  min-height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) 12px max(8px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% 42%, rgba(26, 101, 58, 0.42), transparent 20rem),
    linear-gradient(180deg, #0b3a22 0%, #062716 62%, #041e12 100%);
}

.game-shell {
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 8px;
  min-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: visible;
}

.game-error {
  border: 1px solid rgba(227, 107, 107, 0.55);
  border-radius: 14px;
  padding: 8px 10px;
  background: rgba(141, 47, 60, 0.28);
  color: #ffc4c4;
  font-weight: 800;
}

.players-apk {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.apk-player {
  display: grid;
  justify-items: center;
  align-content: start;
  min-height: 0;
  border-color: rgba(183, 219, 190, 0.22);
  border-radius: 16px;
  padding: 6px 8px 5px;
  background: rgba(7, 42, 25, 0.76);
  box-shadow: none;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.apk-player.active {
  border-width: 2px;
  border-color: rgba(247, 219, 119, 0.96);
  background: rgba(23, 101, 55, 0.76);
  animation: turnPulse 900ms ease-in-out infinite alternate;
}

.apk-player.you {
  border-color: rgba(238, 203, 100, 0.58);
}

.apk-player-name {
  display: grid;
  grid-template-columns: 24px 7px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  width: 100%;
  color: var(--text);
  font-size: clamp(0.82rem, 2.8vw, 1rem);
  font-weight: 900;
}

.apk-player-name span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

.online-dot.offline {
  background: var(--danger);
}

/* Счёт и мета бок о бок — карточка ниже, пустот меньше. */
.apk-player-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 2px;
  min-width: 0;
}

.apk-score {
  color: var(--gold-2);
  font-size: clamp(1.35rem, 5vw, 1.9rem);
  line-height: 1;
  font-weight: 950;
}

.apk-player-meta {
  display: grid;
  min-width: 0;
  text-align: left;
  color: rgba(246, 236, 210, 0.76);
  font-size: clamp(0.68rem, 2.5vw, 0.82rem);
  font-weight: 800;
  line-height: 1.3;
}

.apk-player-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.apk-bolts {
  font-size: 0.8rem;
  line-height: 1;
  letter-spacing: -2px;
}

.apk-badges {
  display: flex;
  min-height: 0;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin-top: 4px;
}
.apk-badges:empty { margin-top: 0; }

.apk-badge {
  border-radius: 8px;
  padding: 3px 9px;
  background: var(--gold);
  color: #211909;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
}

.danger-badge {
  background: #f59b95;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(4, auto) 1fr;
  gap: 8px;
  align-items: center;
}

.status-chip {
  min-height: 38px;
  border: 1px solid rgba(183, 219, 190, 0.24);
  border-radius: 10px;
  padding: 8px 13px;
  background: rgba(7, 42, 25, 0.68);
  color: var(--text);
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.status-chip.accent {
  border-color: var(--gold);
  background: var(--gold);
  color: #211909;
}

.status-target {
  justify-self: end;
}

.apk-table {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto;
  gap: clamp(8px, 1.2dvh, 12px);
  min-height: 0;
}

.apk-pool {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: clamp(300px, 46dvh, 480px);
  height: clamp(300px, 46dvh, 480px);
  border: 1px solid rgba(183, 219, 190, 0.28);
  border-radius: 32px;
  padding: 18px;
  background:
    radial-gradient(circle at center, rgba(19, 102, 57, 0.55), transparent 18rem),
    rgba(5, 48, 27, 0.72);
  box-shadow: inset 0 0 40px rgba(9, 30, 20, 0.42);
}

.table-watermark {
  color: rgba(246, 236, 210, 0.16);
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 0;
}

.pool-caption {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  color: rgba(246, 236, 210, 0.75);
  text-align: center;
  font-weight: 800;
}

.talon-backs,
.deck-stack,
.pool-talon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.talon-backs .card,
.deck-stack .card {
  margin-left: -28px;
}

.talon-backs .card:first-child,
.deck-stack .card:first-child {
  margin-left: 0;
}

.talon-backs .raised {
  transform: translateY(-8px);
}

.deck-stack .cut-card {
  margin-left: 14px;
}

.apk-trick {
  position: relative;
  width: 100%;
  min-height: 100%;
}

.apk-trick .played {
  position: absolute;
}

.played-0 {
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
}

.played-1 {
  left: 18px;
  top: 12px;
}

.played-2 {
  right: 18px;
  top: 12px;
}

.game-app .panel.phase {
  position: relative;
  z-index: 3;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.game-app .phase-title,
.game-app .phase-help {
  display: none;
}

.game-app .phase p:not(.muted) {
  margin: 0 0 6px;
  color: var(--text);
  font-size: clamp(0.95rem, 2.2vw, 1.12rem);
}

.game-app .phase .muted {
  color: rgba(246, 236, 210, 0.74);
  font-size: 0.98rem;
  text-align: center;
}

.game-app .actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.game-app .actions button:first-child:last-child {
  grid-column: 1 / -1;
}

.game-app .stepper {
  display: grid;
  grid-template-columns: 0.9fr 1.5fr 0.9fr 0.9fr;
  gap: 10px;
  margin: 6px 0 8px;
}

.game-app .number {
  min-width: 0;
  color: var(--gold-2);
  font-size: clamp(2.5rem, 10vw, 3.9rem);
  line-height: 1;
}

.game-app button {
  min-height: 46px;
  border-radius: 28px;
  font-size: clamp(0.96rem, 2.2vw, 1.12rem);
}

.game-app .ghost {
  border-color: rgba(183, 219, 190, 0.3);
  background: rgba(4, 31, 18, 0.4);
}

.game-app .danger {
  border: 1px solid rgba(245, 155, 149, 0.72);
  border-radius: 28px;
  color: #ffb3ad;
}

.hand-dock {
  position: relative;
  z-index: 2;
  min-width: 0;
}

.game-app .cards.hand {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 0;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  /* Запас сверху: выбранная карта поднимается на -20px (.game-app .card.selected),
     иначе overflow-y:hidden срезает её верхний край. */
  padding: 26px 0 8px;
  scrollbar-width: none;
}

.game-app .cards.hand::-webkit-scrollbar {
  display: none;
}

.game-app .hand .card + .card {
  margin-left: clamp(-38px, -7vw, -18px);
}

.game-app .card {
  flex: 0 0 auto;
  width: clamp(68px, 11vw, 96px);
  height: auto;
  aspect-ratio: 0.68;
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(255, 247, 221, 0.98));
  color: #20222a;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.28);
  transition: transform 160ms ease, outline-color 160ms ease;
}

.game-app .card.red {
  color: #d52e48;
}

.game-app .card-corner {
  top: 6px;
  left: 7px;
}

.game-app .card-rank {
  font-size: clamp(1.05rem, 2.7vw, 1.45rem);
  line-height: 1;
}

.game-app .card-pip {
  font-size: clamp(0.85rem, 2.2vw, 1.18rem);
  margin-top: 2px;
}

.game-app .card-big {
  right: 7px;
  bottom: 5px;
  font-size: clamp(1.75rem, 4.6vw, 2.7rem);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.26));
}

.game-app .card-back {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 55% 45%, rgba(255, 255, 255, 0.10), transparent 1.8rem),
    linear-gradient(145deg, #7d1f2d, #a23041);
  color: rgba(255, 255, 255, 0.18);
}

.game-app .card-back::after {
  content: "♠";
  font-size: 2.4rem;
}

.game-app .card.playable {
  cursor: pointer;
  transform: translateY(-10px);
  outline: 2px solid rgba(245, 217, 137, 0.82);
}

.game-app .card.selected {
  transform: translateY(-20px);
  outline: 3px solid var(--ok);
}

.avatar.small {
  width: 24px;
  height: 24px;
  object-fit: cover;
}

img.avatar {
  display: block;
}

.bottom-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  padding-top: 2px;
}

.bottom-bar .plain-button {
  min-height: 40px;
  padding: 0 4px;
  color: var(--gold-2);
  font-size: clamp(0.95rem, 3.3vw, 1.1rem);
}

.bottom-message {
  min-width: 0;
  color: rgba(246, 236, 210, 0.78);
  font-size: clamp(0.9rem, 3.2vw, 1rem);
  line-height: 1.25;
}

.journal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 14px;
  background: rgba(0, 0, 0, 0.38);
}

.journal-sheet {
  width: min(620px, 100%);
  max-height: min(78dvh, 680px);
  overflow: auto;
  border: 1px solid rgba(183, 219, 190, 0.26);
  border-radius: 18px;
  padding: 14px;
  background: #0b2c1c;
}

.journal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.journal-head h2,
.journal-grid h3 {
  margin: 0 0 10px;
  color: var(--gold-2);
}

.journal-grid {
  display: grid;
  gap: 14px;
}

@keyframes turnPulse {
  from {
    box-shadow: 0 0 0 rgba(245, 217, 137, 0);
  }
  to {
    box-shadow: 0 0 18px rgba(245, 217, 137, 0.18);
  }
}

@media (min-width: 761px) {
  .game-app {
    width: min(1040px, calc(100% - 24px));
    padding-block: 10px;
  }

  .game-shell {
    gap: 8px;
  }

  .apk-player {
    min-height: 0;
    border-radius: 18px;
    padding: 7px 10px 6px;
  }

  .apk-score {
    font-size: 2rem;
  }

  .apk-badges {
    min-height: 0;
  }

  .status-chip {
    min-height: 34px;
    padding: 6px 12px;
  }

  .apk-table {
    gap: 8px;
  }

  .apk-pool {
    min-height: clamp(210px, 30dvh, 320px);
    height: clamp(210px, 30dvh, 320px);
    border-radius: 26px;
  }

  .pool-caption {
    bottom: 18px;
  }

  .game-app .phase p:not(.muted) {
    margin-bottom: 6px;
    font-size: 1rem;
  }

  .game-app .phase .muted {
    font-size: 0.95rem;
  }

  .game-app .stepper {
    grid-template-columns: 96px 112px 96px 96px;
    justify-content: start;
    gap: 9px;
    margin: 6px 0 8px;
  }

  .game-app .actions {
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 10px;
  }

  .game-app button {
    min-height: 44px;
  }

  .game-app .card {
    width: clamp(62px, 7.5vw, 84px);
    padding: 7px;
  }

  .game-app .hand .card + .card {
    margin-left: clamp(-30px, -3.4vw, -16px);
  }

  .game-app .cards.hand {
    /* Запас под поднятую карту: .game-app .card.selected = translateY(-20px). */
    padding-top: 26px;
  }

  .bottom-bar {
    min-height: 40px;
  }
}

@media (max-width: 760px) {
  .app {
    padding-inline: 10px;
  }

  .players {
    grid-template-columns: 1fr;
  }

  .game-app {
    padding-inline: 8px;
  }

  .game-app .players-apk {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .game-app .apk-player {
    min-height: 0;
    border-radius: 14px;
    padding-inline: 6px;
  }

  /* На узких карточках счёт и мета не влезают в строку — складываем колонкой. */
  .game-app .apk-player-body {
    flex-direction: column;
    gap: 1px;
  }

  .game-app .apk-player-meta {
    text-align: center;
  }

  .game-app .apk-badge {
    padding: 2px 6px;
    font-size: 0.72rem;
  }

  .game-app .status-row {
    grid-template-columns: repeat(3, auto) 1fr;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .game-app .status-row::-webkit-scrollbar {
    display: none;
  }

  .game-app .status-chip {
    min-height: 34px;
    padding: 7px 10px;
  }

  .game-app .apk-pool {
    min-height: clamp(320px, 52dvh, 520px);
    height: clamp(320px, 52dvh, 520px);
    border-radius: 30px;
  }

  .game-app .apk-table {
    gap: 6px;
  }

  .game-app .phase p:not(.muted) {
    margin-bottom: 6px;
    font-size: 1rem;
  }

  .game-app button {
    min-height: 46px;
  }

  .seat-plan {
    grid-template-columns: 1fr;
  }

  .table {
    grid-template-columns: 1fr;
  }

  .side {
    grid-row: auto;
  }

  .card {
    width: 51px;
    height: 74px;
  }

  .game-app .card {
    width: clamp(78px, 21vw, 104px);
    height: auto;
  }

  .topbar {
    align-items: flex-start;
  }
}

/* ============ Взятки: показ и анимации ============ */

/* Появление только что сыгранной карты — «падает» на стол. */
.card-drop {
  animation: cardDrop 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes cardDrop {
  0% { opacity: 0; transform: translateY(-16px) scale(0.94); }
  100% { opacity: 1; transform: none; }
}
@keyframes fadeInPool { from { opacity: 0; } to { opacity: 1; } }

/* Завершённая взятка держится на столе; карта победителя подсвечена. */
.trick-held { animation: fadeInPool 0.2s ease; }
.game-app .card.card-win,
.card.card-win {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  box-shadow: 0 0 0 4px rgba(226, 185, 93, 0.28), 0 12px 22px rgba(0, 0, 0, 0.42);
  animation: winPulse 0.9s ease;
}
.played.played-win span { color: var(--gold); font-weight: 700; }
.pool-caption.pool-win { color: var(--gold); font-weight: 700; font-size: 0.95rem; }
@keyframes winPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.09); }
  100% { transform: scale(1); }
}

/* ============ Журнал: карты взяток ============ */
.jtrick {
  list-style: none;
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid rgba(245, 232, 196, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}
.jtrick-head { font-size: 0.9rem; margin-bottom: 6px; color: var(--text); }
.jtrick-head b { color: var(--gold); margin-right: 4px; }
.jtrick-pts { color: var(--gold); font-weight: 700; margin-left: 4px; }
.jtrick-cards { display: flex; gap: 8px; flex-wrap: wrap; }
.jtrick-card { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.jtrick-card > span { font-size: 0.62rem; color: rgba(245, 232, 196, 0.6); }
.game-app .jtrick .card,
.journal-overlay .jtrick .card {
  width: 40px;
  min-width: 40px;
  height: 57px;
  border-radius: 6px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  transform: none;
  margin: 0;
}
.jtrick .card-big { display: none; }
.jtrick .card-corner { top: 3px; left: 4px; }
.jtrick .card-rank { font-size: 0.82rem; }
.jtrick .card-pip { font-size: 0.66rem; }
.jtrick-card.jtrick-win .card { outline: 2px solid var(--gold); }

@media (prefers-reduced-motion: reduce) {
  .card-drop, .card-win, .trick-held { animation: none !important; }
}

/* Регионные обёртки прозрачны для верстки — дети участвуют в game-shell как раньше.
   reg-players и reg-hand НЕ включены: это реальные контейнеры со своими стилями. */
#reg-error, #reg-status, #reg-pool, #reg-phase, #reg-bottom, #reg-journal, #reg-main {
  display: contents;
}

/* Явное окно завершённой взятки — в центре пула (там пусто: карты по краям/снизу). */
.trick-info {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 22px;
  border: 1px solid var(--gold);
  border-radius: 14px;
  background: rgba(18, 28, 21, 0.94);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(226, 185, 93, 0.16);
  text-align: center;
  white-space: nowrap;
  animation: trickInfoPop 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.trick-info-title { color: var(--gold-2); font-weight: 800; font-size: 1.08rem; }
.trick-info-sub { color: var(--text); font-size: 0.95rem; opacity: 0.92; }
@keyframes trickInfoPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Победитель взятки: бейдж «берёт», имя золотом — не сливается с остальными. */
.take-badge {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--gold);
  color: #211909;
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  vertical-align: middle;
}
.played-name { color: var(--muted); }
.played.played-win .played-name { color: var(--gold-2); font-weight: 800; }

@media (prefers-reduced-motion: reduce) {
  .trick-info { animation: none !important; }
}

/* ============ FLIP-полёт сыгранной карты ============ */
/* Новейшая карта в взятке прилетает со стороны игрока, который её сыграл:
   моя (played-0) — снизу из руки, левый (played-1) — сверху-слева,
   правый (played-2) — сверху-справа. */
.apk-trick .played-0 .card-drop { animation: flyFromBottom 0.36s cubic-bezier(0.2, 0.75, 0.2, 1); }
.apk-trick .played-1 .card-drop { animation: flyFromLeft 0.36s cubic-bezier(0.2, 0.75, 0.2, 1); }
.apk-trick .played-2 .card-drop { animation: flyFromRight 0.36s cubic-bezier(0.2, 0.75, 0.2, 1); }

@keyframes flyFromBottom {
  0%   { opacity: 0; transform: translateY(150px) rotate(-4deg) scale(0.92); }
  100% { opacity: 1; transform: none; }
}
@keyframes flyFromLeft {
  0%   { opacity: 0; transform: translate(-190px, -120px) rotate(6deg) scale(0.92); }
  100% { opacity: 1; transform: none; }
}
@keyframes flyFromRight {
  0%   { opacity: 0; transform: translate(190px, -120px) rotate(-6deg) scale(0.92); }
  100% { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .apk-trick .played-0 .card-drop,
  .apk-trick .played-1 .card-drop,
  .apk-trick .played-2 .card-drop { animation: none !important; }
}

/* ============ Плашка марьяжа ============ */
.marriage-toast {
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  border: 1px solid var(--gold);
  border-radius: 16px;
  background: rgba(18, 28, 21, 0.96);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6), 0 0 0 5px rgba(226, 185, 93, 0.16);
  animation: marriagePop 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.marriage-suit { font-size: 2.6rem; line-height: 1; color: var(--text); }
.marriage-suit.red { color: #e5484d; }
.marriage-title { color: var(--gold-2); font-weight: 800; font-size: 1.12rem; }
.marriage-title b { color: var(--gold); }
.marriage-who { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
@keyframes marriagePop {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(0.9); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .marriage-toast { animation: none !important; } }

/* ============ Всплески событий сдачи (жопы, бочка, заказ, 555) ============ */
.event-toast {
  position: fixed;
  top: 34%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: grid;
  gap: 8px;
  width: max-content;
  max-width: min(92vw, 420px);
  pointer-events: none;
}

.event-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border: 1px solid var(--gold);
  border-radius: 14px;
  background: rgba(18, 28, 21, 0.96);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(226, 185, 93, 0.14);
  opacity: 0;
  animation: eventPop 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.event-chip.red { border-color: #e5484d; box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(229, 72, 77, 0.18); }

.event-icon { font-size: 1.5rem; line-height: 1; }

.event-text { color: var(--text); font-weight: 800; font-size: 0.98rem; }
.event-text b { color: var(--gold-2); }
.event-chip.red .event-text { color: #ffb9b9; }

@keyframes eventPop {
  0%   { opacity: 0; transform: translateY(-12px) scale(0.88); }
  100% { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .event-chip { animation: none !important; opacity: 1; } }

/* ============ Стартовый экран ============ */
.start-app {
  display: grid;
  align-content: center;
  min-height: 100dvh;
}

.start {
  display: grid;
  gap: 14px;
  width: min(440px, 100%);
  margin: 0 auto;
}

.start-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.start-brand .brand-mark {
  width: 52px;
  height: 52px;
  flex: none;
  font-size: 0.95rem;
}

.start-brand h1 {
  margin: 0;
  color: var(--gold-2);
  font-size: 1.5rem;
  line-height: 1.15;
}

.start-brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.start-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented button {
  min-height: 44px;
}

.segmented-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.segmented-3 button {
  padding: 0 4px;
  white-space: nowrap;
  font-size: clamp(0.82rem, 3.9vw, 1rem);
}

.level-hint {
  margin: 0;
  min-height: 1.3em;
}

.hero-button,
.wide-button {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 100%;
  padding: 10px 14px;
  line-height: 1.2;
}

.hero-button {
  min-height: 72px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  box-shadow: 0 12px 28px -14px rgba(226, 185, 93, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  font-size: 1.25rem;
  font-weight: 900;
}

.wide-button {
  min-height: 60px;
  border-radius: 12px;
  font-size: 1.05rem;
}

.hero-button small,
.wide-button small {
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.78;
}

.link-button {
  min-height: 44px;
  padding: 0 4px;
  background: transparent;
  color: var(--gold-2);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.join-inline {
  display: grid;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.start-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 14px;
  font-size: 0.9rem;
}

.start-links a {
  color: var(--muted);
}

.start-links .link-button {
  min-height: 40px;
}

.start-links .start-support {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 12px;
  color: var(--gold-2);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.start-support img {
  width: 20px;
  height: 20px;
}

.start-support:hover {
  background: var(--panel-2);
  border-color: var(--gold);
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold-2);
  outline-offset: 2px;
}

/* ============ Как играть ============ */
.rules-overlay {
  z-index: 70;
  place-items: center;
}

.rules-sheet {
  max-height: min(86dvh, 720px);
}

.rules-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 1.3rem;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.45;
}

.rules-list strong {
  color: var(--gold-2);
}

/* ============ Лобби ============ */
.game-app .lobby-panel .hero-button {
  min-height: 68px;
  margin-top: 4px;
  border-radius: 14px;
  font-size: 1.15rem;
}

.game-app .lobby-panel .actions {
  grid-template-columns: 1fr;
}

.game-app .invite-line .icon-button {
  border-radius: 8px;
  min-height: 100%;
}

.game-app .web-code {
  font-size: clamp(1.5rem, 8vw, 2rem);
}

.lobby-panel .actions .plain-button {
  min-height: 40px;
}

/* ============ Показ прикупа соперникам ============ */
.talon-toast {
  position: fixed;
  top: 32%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 16px 22px;
  border: 2px solid var(--gold);
  border-radius: 18px;
  background: rgba(18, 28, 21, 0.97);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  animation: marriagePop 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.talon-toast-title {
  color: var(--gold-2);
  font-size: 1.3rem;
  font-weight: 900;
}

.talon-toast-cards {
  display: flex;
  gap: 8px;
}

.talon-toast-who {
  color: var(--text);
  font-size: 0.95rem;
}

@media (prefers-reduced-motion: reduce) {
  .talon-toast { animation: none !important; }
}

@media (max-width: 360px) {
  .start-card { padding: 12px; }
  .hero-button { font-size: 1.12rem; }
  .talon-toast { padding: 12px 14px; }
}
