/* Игры на компанию: лобби, стол, чат (sg/js/party.js) */

.pt {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  width: 100%;
}

.pt [hidden] {
  display: none !important;
}

.pt-setup,
.pt-lobby {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  width: 100%;
  max-width: 560px;
  padding: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pt-name {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
}

.pt-name input,
.pt input[type="text"],
.pt textarea,
.pt select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.pt-name input.pt-bad {
  border-color: var(--danger);
  animation: ws-shake 0.35s;
}

.pt-start {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.pt-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.pt-note.err {
  color: var(--danger);
}

.pt-h {
  margin: 4px 0 0;
  font-size: 1rem;
}

.pt-players {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--sp-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.pt-players li {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  min-width: 0;
  padding: 6px 6px 6px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  font-size: 0.9rem;
  font-weight: 600;
}

.pt-pname {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pt-pname small {
  color: var(--muted);
  font-weight: 500;
}

/* аватарка: первая буква имени на цвете игрока */
.pt-ava {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--c, var(--accent));
  color: #fff;
  font-size: 0.95rem;
  font-weight: 800;
}

.pt-ava i {
  position: absolute;
  top: -9px;
  right: -7px;
  font-size: 0.8rem;
  font-style: normal;
}

/* стартовый экран */
.pt-hero {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
}

.pt-hero-ico {
  display: grid;
  flex: none;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 1.6rem;
}

.pt-hero h2 {
  margin: 0;
  font-size: var(--fs-lg);
}

.pt-hero p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.pt-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  margin: var(--sp-1) 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.pt-steps li {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.35;
  counter-increment: step;
}

.pt-steps li::before {
  content: counter(step);
  display: block;
  margin-bottom: 2px;
  color: var(--accent);
  font-weight: 800;
}

@media (max-width: 480px) {
  .pt-steps {
    grid-template-columns: 1fr;
  }

  .pt-steps li::before {
    display: inline;
    margin-right: var(--sp-2);
  }
}

.pt-players li.me {
  border-color: var(--accent);
}

.pt-players li.off {
  opacity: 0.5;
}

.pt-kick {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.pt-kick:hover {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
}

.pt-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg);
}

.pt-options.ro {
  opacity: 0.8;
}

.pt-options label {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
}

.pt-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  width: 100%;
  max-width: 760px;
  padding: 6px 6px 6px 14px;
  border: 1px solid color-mix(in srgb, var(--success) 50%, var(--border));
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
  font-size: 0.9rem;
  font-weight: 600;
}

.pt-bar-text {
  flex: 1;
  min-width: 0;
}

.pt-bar .btn {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.pt-watchbox {
  width: 100%;
  max-width: 620px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.pt-watchbox p {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.pt-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: var(--sp-3);
  align-items: start;
  width: 100%;
  max-width: 1040px;
}

.pt-stage {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}

.pt-side {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
}

.pt-main:has(.pt-chat[hidden]):has(.pt-events[hidden]) {
  grid-template-columns: minmax(0, 1fr);
}

/* ---------- «Ход игры»: лента событий ---------- */

.pt-events {
  display: flex;
  flex-direction: column;
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.pt-events h3 {
  margin: var(--sp-1) 0 var(--sp-2);
  color: var(--muted);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pt-events-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 340px;
  margin: 0;
  padding: 0 var(--sp-1) 0 0;
  overflow-y: auto;
  list-style: none;
  font-size: 0.86rem;
  overscroll-behavior: contain;
}

.pt-ev {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  line-height: 1.35;
  transition: background var(--dur-slow);
}

.pt-ev.new {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.pt-ev-ico {
  flex: none;
  width: 1.3em;
  text-align: center;
}

.pt-ev-ava,
.pt-now .pt-ev-ava {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
}

.pt-ev-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.pt-who {
  font-weight: 800;
}

.pt-ev.tone-good .pt-ev-text {
  color: color-mix(in srgb, var(--success) 70%, var(--text));
}

.pt-ev.tone-bad .pt-ev-text {
  color: color-mix(in srgb, var(--danger) 75%, var(--text));
}

.pt-ev.tone-warn .pt-ev-text {
  color: color-mix(in srgb, var(--warning) 70%, var(--text));
}

.pt-ev.big {
  font-weight: 700;
}

/* «что произошло»: последнее событие крупно над столом */
.pt-now {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  min-height: 44px;
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-weight: 600;
}

.pt-now.tone-good {
  border-left-color: var(--success);
}

.pt-now.tone-bad {
  border-left-color: var(--danger);
}

.pt-now.tone-warn {
  border-left-color: var(--warning);
}

.pt-now.flash {
  animation: pt-now-in var(--dur-slow) var(--ease);
}

@keyframes pt-now-in {
  from {
    background: color-mix(in srgb, var(--accent) 22%, var(--surface));
    transform: translateY(-3px);
  }
}

.pt-chat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 520px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.pt-chat-log {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  font-size: 0.85rem;
}

.pt-chat-log p {
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}

.pt-chat-log p.sys {
  color: var(--muted);
  font-style: italic;
}

.pt-chat-log p.mine b {
  color: var(--accent);
}

.pt-chat-form {
  display: flex;
  gap: 4px;
}

.pt-chat-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px !important;
}

.pt-chat-form .btn {
  padding: 6px 12px;
}

@media (max-width: 760px) {
  .pt-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .pt-chat {
    max-height: 240px;
  }

  .pt-events-list {
    max-height: 180px;
  }

  .pt-now {
    position: sticky;
    top: 72px;
    z-index: var(--z-raised);
    box-shadow: var(--shadow-sm);
  }
}

/* телефон: строка «что произошло» пониже, чтобы стол с кнопками хода влезал в экран */
@media (max-width: 640px) {
  .pt-now {
    min-height: 38px;
    padding: 5px var(--sp-3);
    font-size: 0.9rem;
    line-height: 1.3;
  }
}

/* общие элементы стола */

.pt-seats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.pt-seat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  min-width: 92px;
  padding: 6px 10px;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.82rem;
  text-align: center;
}

.pt-seat b {
  max-width: 120px;
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pt-seat.turn {
  border-color: #fde047;
}

.pt-seat.out {
  opacity: 0.45;
}

.pt-seat.me {
  background: rgba(255, 255, 255, 0.14);
}

.pt-timer {
  display: inline-block;
  min-width: 2.2em;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.3);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: center;
}

.pt-timer.low {
  color: #fca5a5;
}

.pt-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.pt-panel h3 {
  margin: 0;
}

.pt-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.pt-choices .btn.sel {
  outline: 3px solid var(--warning);
}

.pt-big {
  font-size: 1.6rem;
  font-weight: 800;
}

.pt-muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.pt-score {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  justify-content: center;
  font-size: 0.9rem;
}

.pt-panel .pt-seat {
  background: var(--bg);
}

.pt-panel .pt-seat.turn {
  border-color: var(--accent);
}

.pt-panel .pt-seat.me {
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* голосовой чат */
.pt [data-voice].on {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 18%, var(--surface));
}

/* всплывающее изменение у игрока: «+200», «−3» */
.pt-delta {
  position: absolute;
  top: -8px;
  right: 4px;
  z-index: var(--z-raised);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  pointer-events: none;
  animation: pt-delta 1.8s var(--ease) forwards;
}

.pt-delta.up {
  background: var(--success);
}

.pt-delta.down {
  background: var(--danger);
}

@keyframes pt-delta {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  15% {
    opacity: 1;
    transform: translateY(0);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-14px);
  }
}
