:root {
  --bg: #10141c;
  --panel: #1a212e;
  --panel2: #232c3d;
  --text: #e8ecf3;
  --muted: #8b95a7;
  --accent: #f5b942;
  --red: #e74c3c;
  --blue: #3b82f6;
  --green: #22c55e;
  --yellow: #eab308;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.mono { font-family: 'Consolas', monospace; letter-spacing: 2px; }

.screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }

.card {
  background: var(--panel);
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
}

h1 { margin: 0 0 6px; font-size: 30px; }
.sub { color: var(--muted); margin: 0 0 18px; }

input, button {
  font: inherit;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #39435a;
  background: var(--panel2);
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--accent); }
button { cursor: pointer; transition: filter .15s; }
button:hover { filter: brightness(1.15); }
button.primary { background: var(--accent); color: #201500; font-weight: 600; border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }

.row { display: flex; gap: 10px; margin-top: 12px; }
.row input { flex: 1; }
#code { text-transform: uppercase; letter-spacing: 4px; width: 130px; text-align: center; }

.err { color: #ff7676; min-height: 20px; margin-top: 10px; font-size: 14px; }

.rules { margin-top: 16px; color: var(--muted); font-size: 14px; }
.rules summary { cursor: pointer; color: var(--accent); }
.rules ul { padding-left: 18px; line-height: 1.5; }

#lobbyPlayers { list-style: none; padding: 0; margin: 0 0 14px; }
#lobbyPlayers li { padding: 8px 12px; background: var(--panel2); border-radius: 8px; margin-bottom: 6px; }
#teamsRow { display: block; margin: 10px 0 16px; color: var(--muted); cursor: pointer; }

/* --- игровой экран --- */
#game.screen {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px;
  gap: 10px;
}

#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border-radius: 12px;
  padding: 10px 16px;
  flex-wrap: wrap;
  gap: 8px;
}
#roomInfo { color: var(--muted); font-size: 14px; letter-spacing: 1px; }
#turnInfo { font-weight: 600; }

#main { display: flex; gap: 12px; align-items: stretch; flex: 1; min-height: 0; }
#boardWrap { flex: 1; display: flex; align-items: center; justify-content: center; min-width: 0; }
#board { width: 100%; max-width: 640px; max-height: calc(100vh - 210px); height: auto; }

#side {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#playersPanel { display: flex; flex-direction: column; gap: 6px; }
.playerRow {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 14px;
}
.playerRow .dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.playerRow.active { outline: 2px solid var(--accent); }
.playerRow .tag { margin-left: auto; color: var(--muted); font-size: 12px; }
.playerRow.offline { opacity: .5; }

#msg { color: var(--muted); font-size: 14px; line-height: 1.45; min-height: 20px; }
#msg .warn { color: var(--accent); }

#choices { display: flex; gap: 8px; flex-wrap: wrap; }
#actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

#hand {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--panel);
  border-radius: 14px;
  padding: 12px;
  min-height: 96px;
  align-items: center;
}

.playCard {
  width: 72px;
  height: 100px;
  border-radius: 10px;
  background: linear-gradient(160deg, #f7f3ea, #e8e0cf);
  color: #26221a;
  border: 2px solid #c9bfa6;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
  text-align: center;
  line-height: 1.15;
  flex-shrink: 0;
}
.playCard small { font-size: 11px; font-weight: 500; color: #6b6250; }
.playCard.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,185,66,.35); transform: translateY(-6px); }
.playCard:disabled { filter: grayscale(.7); opacity: .6; }

.choiceBtn { background: var(--panel2); border: 1px solid #39435a; }
.choiceBtn:hover { border-color: var(--accent); }

@media (max-width: 860px) {
  #main { flex-direction: column; }
  #side { width: 100%; flex-direction: row; flex-wrap: wrap; }
  #playersPanel { flex: 1; min-width: 200px; }
  #actions { margin-top: 0; }
  #board { max-height: 60vh; }
}
