:root {
  --bg-a: #0f1d2a;
  --bg-b: #14283a;
  --panel: rgba(8, 18, 28, 0.82);
  --border: rgba(142, 181, 206, 0.36);
  --text: #eff8fe;
  --muted: #9fb6c7;
  --accent: #ffb76b;
  --accent-2: #70dcc3;
  --red: #f07b7b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, #21415a 0%, transparent 34%),
    radial-gradient(circle at 88% 92%, #243c5f 0%, transparent 36%),
    linear-gradient(145deg, var(--bg-a), var(--bg-b));
}

.durak-page {
  width: min(1100px, 95vw);
  margin: 0 auto;
  padding: 1.2rem 0 2.2rem;
}

.topbar,
.setup-panel,
.status-grid,
.players-wrap,
.table-wrap,
.actions-wrap,
.hand-wrap,
.log-wrap {
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--panel);
}

.topbar {
  padding: 0.95rem 1rem;
}

.back-link {
  color: var(--accent-2);
  text-decoration: none;
  font-size: 0.92rem;
}

.back-link:hover,
.back-link:focus-visible {
  text-decoration: underline;
}

.topbar h1 {
  margin: 0.35rem 0 0;
  font-size: clamp(1.85rem, 5vw, 2.65rem);
  font-family: "Fraunces", Georgia, serif;
}

.topbar p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.setup-panel {
  margin-top: 0.8rem;
  padding: 0.85rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.62rem;
}

.setup-panel label {
  color: var(--muted);
  font-size: 0.92rem;
}

select,
button {
  border: 0;
  border-radius: 0.62rem;
  font-family: inherit;
}

select {
  padding: 0.52rem 0.62rem;
  background: #203347;
  color: var(--text);
}

button {
  padding: 0.55rem 0.85rem;
  font-weight: 700;
  cursor: pointer;
  color: #0b1621;
  background: linear-gradient(135deg, #ffc68e, #f8a95f);
}

button.secondary {
  color: #d9e8f4;
  background: linear-gradient(130deg, #30495e, #273c4e);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.status-grid {
  margin-top: 0.8rem;
  padding: 0.8rem 1rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.status-item {
  border: 1px solid rgba(140, 179, 205, 0.28);
  border-radius: 0.72rem;
  padding: 0.55rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.status-item.wide {
  grid-column: span 1;
}

.label {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.players-wrap,
.table-wrap,
.actions-wrap,
.hand-wrap,
.log-wrap {
  margin-top: 0.8rem;
  padding: 0.8rem 1rem 1rem;
}

h2 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}

.players-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.55rem;
}

.player-chip {
  border: 1px solid rgba(145, 180, 202, 0.32);
  border-radius: 0.72rem;
  padding: 0.58rem;
  display: grid;
  gap: 0.22rem;
  background: rgba(9, 18, 27, 0.75);
}

.player-name {
  font-weight: 700;
}

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

.role-pill {
  display: inline-block;
  width: fit-content;
  border-radius: 999px;
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.role-attack {
  background: rgba(255, 192, 117, 0.2);
  color: #ffd1a2;
}

.role-defend {
  background: rgba(116, 220, 200, 0.2);
  color: #a9f4e5;
}

.role-out {
  background: rgba(204, 119, 119, 0.2);
  color: #ffb6b6;
}

.table-area {
  min-height: 92px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.pair-stack {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  align-items: center;
}

.actions-area {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  min-height: 36px;
}

.hand-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.card {
  width: 74px;
  height: 104px;
  border-radius: 0.55rem;
  border: 1px solid rgba(10, 18, 24, 0.35);
  background: #faf0e4;
  color: #1c222c;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.card:hover {
  transform: translateY(-2px);
}

.card .inner {
  display: grid;
  place-items: center;
  gap: 0.08rem;
}

.rank {
  font-size: 1.15rem;
  font-weight: 700;
}

.suit {
  font-size: 1.2rem;
}

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

.card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.card.selected {
  outline: 2px solid rgba(120, 230, 206, 0.9);
  outline-offset: 2px;
}

#game-log {
  margin: 0;
  padding-left: 1rem;
  max-height: 220px;
  overflow-y: auto;
  color: var(--muted);
  line-height: 1.35;
}

@media (max-width: 780px) {
  .status-grid {
    grid-template-columns: 1fr;
  }

  .status-item.wide {
    grid-column: span 1;
  }
}
