@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-dark: #231820;
  --bg-card: #442f3f;
  --primary: #da4849;
  --primary-hover: #c33334;
  --secondary: #046997;
  --accent: #ffd700;
  --text: #ffffff;
  --text-muted: #b5b5b5;
  --success: #4caf50;
  --danger: #da4849;
  --border: #5a3f52;
  --input-bg: #1a1015;
}

body {
  font-family: 'Montserrat', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

.screen {
  display: none;
  width: 100vw;
  height: 100vh;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Лобі та кімната очікування — прокручувані якщо контент не вміщається */
#lobby.screen.active,
#waitingRoom.screen.active {
  align-items: flex-start;
  overflow-y: auto;
  padding: 20px 0;
}
#lobby .lobby-layout,
#waitingRoom .waiting-container {
  margin: auto;
}

/* === Buttons === */
.btn {
  display: inline-block;
  font-weight: 600;
  font-size: 16px;
  text-align: center;
  color: #fff;
  background: var(--primary);
  border-radius: 50px;
  padding: 16px 32px;
  border: none;
  cursor: pointer;
  transition: 0.3s;
  text-decoration: none;
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(218, 72, 73, 0.4);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--secondary);
}

.btn-secondary:hover {
  background: #03587f;
}

.btn-small {
  padding: 10px 18px;
  font-size: 14px;
  background: var(--bg-card);
  color: white;
  border: 1px solid var(--border);
  border-radius: 50px;
  cursor: pointer;
  transition: 0.3s;
}

.btn-small:hover {
  background: var(--border);
}

/* === Lobby === */
.lobby-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  max-width: 980px;
  width: 100%;
  padding: 20px;
}

.lobby-container {
  text-align: center;
  flex: 1;
  max-width: 520px;
  padding: 28px 32px;
  background: var(--bg-card);
  border-radius: 30px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* Бічна панель */
.lobby-sidebar {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-section {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.sidebar-section h3 {
  font-size: 16px;
  margin-bottom: 14px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-refresh {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: 0.2s;
}
.btn-refresh:hover { color: var(--accent); transform: rotate(90deg); }

.leaderboard-list, .public-rooms-list {
  max-height: 260px;
  overflow-y: auto;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 14px;
  transition: 0.2s;
}
.lb-row:nth-child(odd) { background: rgba(255,255,255,0.03); }
.lb-row.lb-me { background: rgba(255, 215, 0, 0.12); border: 1px solid var(--accent); }
.lb-rank { width: 28px; text-align: center; font-weight: 700; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 700; color: var(--accent); }
.lb-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 16px 0; }

.public-room-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  background: rgba(255,255,255,0.03);
  margin-bottom: 6px;
}
.pr-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-count { color: var(--text-muted); }
.pr-status { color: var(--text-muted); font-size: 11px; }

/* Профіль бейдж */
.profile-badge {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 10px;
  font-size: 13px;
  flex-wrap: wrap;
}
.profile-name { font-weight: 700; color: var(--text); }
.profile-score { color: var(--accent); font-weight: 700; }
.profile-stats { color: var(--text-muted); }

/* === Компактні налаштування створення кімнати === */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.settings-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}
.settings-item label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.compact-select {
  padding: 10px 12px;
  background: var(--input-bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: white;
  font-size: 14px;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  transition: 0.2s;
}
.compact-select:focus { border-color: var(--primary); outline: none; }
.compact-select:hover { border-color: var(--primary); }

.waiting-difficulty {
  margin: 14px 0;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
}
.waiting-difficulty > label {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.waiting-difficulty .compact-select { flex: 1; }

/* Вибір видимості гри (застаріле, залишено для сумісності) */
.visibility-selector { display: flex; gap: 8px; }
.visibility-btn {
  flex: 1;
  padding: 12px;
  background: var(--input-bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  transition: 0.3s;
}
.visibility-btn:hover { border-color: var(--primary); }
.visibility-btn.active { border-color: var(--primary); background: var(--primary); }

/* Слайдер таймера */
.timer-slider {
  width: 100%;
  accent-color: var(--primary);
}

/* Емодзі-бар */
.emoji-bar {
  position: fixed;
  bottom: 70px;
  right: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 180px;
  background: rgba(68, 47, 63, 0.9);
  padding: 8px;
  border-radius: 16px;
  z-index: 40;
  border: 1px solid var(--border);
}
.emoji-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  transition: 0.15s;
  padding: 2px 4px;
  border-radius: 8px;
}
.emoji-btn:hover { transform: scale(1.3); background: rgba(255,255,255,0.1); }

/* Емодзі-реакція що з'являється */
.emoji-reaction {
  position: fixed;
  font-size: 42px;
  z-index: 60;
  pointer-events: none;
  transform: translateX(-50%);
  animation: emoji-float 2.5s ease-out forwards;
}
@keyframes emoji-float {
  0% { opacity: 0; transform: translateX(-50%) translateY(0) scale(0.5); }
  15% { opacity: 1; transform: translateX(-50%) translateY(-20px) scale(1.2); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-90px) scale(1); }
}

/* Зміни балів */
.score-changes { margin-top: 16px; }
.score-mine { color: var(--accent); font-weight: 700; font-size: 18px; }

/* === Підсвітка планшеток під час бою === */
/* Атакуючий — синій */
.player-seat.combat-attacker .player-avatar,
.my-character-bg.combat-attacker {
  border-color: #2d7ff9 !important;
  box-shadow: 0 0 24px rgba(45, 127, 249, 0.8), 0 0 48px rgba(45, 127, 249, 0.4) !important;
  animation: pulse-attacker 1.2s infinite;
}
@keyframes pulse-attacker {
  0%, 100% { box-shadow: 0 0 18px rgba(45, 127, 249, 0.6); }
  50% { box-shadow: 0 0 34px rgba(45, 127, 249, 1), 0 0 60px rgba(45, 127, 249, 0.5); }
}

/* Ціль — фіолетовий */
.player-seat.combat-target .player-avatar,
.my-character-bg.combat-target {
  border-color: #9b4dff !important;
  box-shadow: 0 0 24px rgba(155, 77, 255, 0.8), 0 0 48px rgba(155, 77, 255, 0.4) !important;
  animation: pulse-target-combat 1.2s infinite;
}
@keyframes pulse-target-combat {
  0%, 100% { box-shadow: 0 0 18px rgba(155, 77, 255, 0.6); }
  50% { box-shadow: 0 0 34px rgba(155, 77, 255, 1), 0 0 60px rgba(155, 77, 255, 0.5); }
}

/* === Летюча карта (анімація застосування) === */
.flying-card {
  position: fixed;
  width: 70px;
  height: 105px;
  z-index: 70;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.9);
  transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1), top 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s ease;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.7);
}
.flying-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

/* Таймер пропуску ходу — зліва вгорі */
.turn-timer-badge {
  position: fixed;
  top: 16px;
  left: 16px;
  background: rgba(68, 47, 63, 0.95);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 50px;
  z-index: 38;
  border: 2px solid var(--secondary);
  display: none;
  align-items: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.turn-timer-badge.urgent {
  border-color: var(--danger);
  color: var(--danger);
  animation: pulse-urgent 0.6s infinite;
}
@keyframes pulse-urgent {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

@media (max-width: 860px) {
  .lobby-layout { flex-direction: column; align-items: center; }
  .lobby-sidebar { width: 100%; max-width: 520px; }
}

.lobby-logo {
  width: 60px;
  height: 60px;
  margin-bottom: 12px;
}

.lobby-header h1 {
  font-size: 24px;
  margin-bottom: 6px;
  color: var(--text);
  font-weight: 700;
}

.lobby-header p {
  color: var(--text-muted);
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 500;
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
}

.form-group input {
  width: 100%;
  padding: 14px 18px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: white;
  font-size: 16px;
  font-family: 'Montserrat', sans-serif;
  transition: 0.3s;
}

.form-group input:focus {
  border-color: var(--primary);
  outline: none;
}

.player-count-selector {
  display: flex;
  gap: 8px;
}

.count-btn {
  flex: 1;
  padding: 14px;
  background: var(--input-bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: white;
  font-size: 18px;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  transition: 0.3s;
}

.count-btn:hover {
  border-color: var(--primary);
}

.count-btn.active {
  border-color: var(--primary);
  background: var(--primary);
}

.lobby-actions {
  display: flex;
  gap: 14px;
  margin-top: 24px;
}

.lobby-actions .btn {
  flex: 1;
  padding: 14px 18px;
  font-size: 15px;
  white-space: nowrap;
}

.join-room-input {
  margin-top: 16px;
  display: flex;
  gap: 8px;
}

.join-room-input input {
  flex: 1;
  padding: 14px 18px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: white;
  font-family: 'Montserrat', sans-serif;
}

/* === Waiting Room === */
.waiting-container {
  text-align: center;
  max-width: 600px;
  width: 100%;
  padding: 40px;
  background: var(--bg-card);
  border-radius: 30px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.waiting-container h2 {
  color: var(--text);
  margin-bottom: 8px;
  font-size: 22px;
}

.waiting-container h2 span {
  color: var(--accent);
}

.waiting-container > p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}

.players-list {
  margin: 24px 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.player-slot {
  padding: 14px;
  background: var(--input-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  font-weight: 500;
  font-size: 14px;
}

.player-slot.occupied {
  border-color: var(--success);
  color: var(--success);
}

.player-slot.bot {
  border-color: var(--accent);
  color: var(--accent);
}

.waiting-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

/* === Chat === */
.chat-container, .game-chat {
  background: var(--input-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.game-chat {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 280px;
  max-height: 220px;
  z-index: 30;
}

.chat-messages {
  height: 140px;
  overflow-y: auto;
  padding: 12px;
  font-size: 13px;
}

.chat-messages p {
  margin-bottom: 4px;
  color: var(--text-muted);
}

.chat-input {
  display: flex;
  border-top: 1px solid var(--border);
}

.chat-input input {
  flex: 1;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: white;
  font-size: 14px;
  font-family: 'Montserrat', sans-serif;
}

.chat-input input:focus {
  outline: none;
}

/* === Game Table === */
.game-container {
  width: 100vw;
  height: 100vh;
  position: relative;
  background: radial-gradient(ellipse at center, #2d1f28 0%, #1a1015 100%);
}

.game-info {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 24px;
  background: rgba(68, 47, 63, 0.9);
  padding: 12px 28px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 500;
  z-index: 10;
  border: 1px solid var(--border);
}

.table-area {
  width: 100%;
  height: 100%;
  position: relative;
}

.table-center {
  position: absolute;
  top: 16px;
  right: 310px;
  transform: none;
}

.deck-area {
  display: flex;
  gap: 16px;
}

.card-deck, .event-deck {
  width: 80px;
  height: 120px;
  background: var(--bg-card);
  border-radius: 10px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.card-deck img, .event-deck img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.card-deck span {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

/* === Players Positions === */
.players-positions {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.player-seat {
  position: absolute;
  text-align: center;
  width: 280px;
}

.player-avatar {
  width: 160px;
  height: 110px;
  border-radius: 10px;
  border: 2px solid var(--border);
  margin: 0 auto 6px;
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.player-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.player-avatar-large {
  width: 220px;
  height: 150px;
  border-radius: 10px;
  border: 3px solid var(--accent);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.player-seat.honest .player-avatar {
  border-color: var(--success);
  box-shadow: 0 2px 10px rgba(76, 175, 80, 0.3);
}

.player-seat.corrupt .player-avatar {
  border-color: var(--danger);
  box-shadow: 0 2px 10px rgba(218, 72, 73, 0.3);
}

.player-seat.current-turn .player-avatar {
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.5);
}

.player-seat-name {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 2px;
}

.player-seat-capital {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

.player-seat-character {
  font-size: 10px;
  color: var(--text-muted);
}

/* === Player Hand === */
.player-hand {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.my-character-bg {
  position: relative;
  width: 440px;
  height: 320px;
  border-radius: 14px;
  overflow: hidden;
  border: 4px solid var(--accent);
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.3);
  margin-bottom: -100px;
  z-index: 1;
}

.my-character-bg > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: relative;
  z-index: 0;
  object-position: center center;
}

.my-char-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.7);
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  z-index: 3;
}

.my-char-name {
  font-weight: 600;
}

.my-char-capital {
  font-weight: 700;
}

.my-char-capital.honest { color: var(--success); }
.my-char-capital.corrupt { color: var(--danger); }

/* === Side Indicator (підсвітка сторони) === */
.side-indicator {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  z-index: 0;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.5s;
}

.side-indicator-left {
  left: -10px;
}

.side-indicator-right {
  right: -10px;
}

.side-indicator.active {
  opacity: 1;
  animation: side-glow 2s infinite;
}

.side-indicator-left.active {
  background: var(--danger);
  box-shadow: 0 0 12px var(--danger), 0 0 24px var(--danger);
}

.side-indicator-right.active {
  background: var(--success);
  box-shadow: 0 0 12px var(--success), 0 0 24px var(--success);
}

@keyframes side-glow {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Border на планшеті залежно від сторони */
.my-character-bg.side-corrupt {
  border-color: var(--danger);
  box-shadow: 0 0 20px rgba(218, 72, 73, 0.4);
}

.my-character-bg.side-honest {
  border-color: var(--success);
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.4);
}

/* === Capital Overlay (маркери капіталу на планшетці) === */
.capital-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  pointer-events: none;
}

.capital-marker {
  position: absolute;
  top: 9%;
  /* Розмір відносно ширини планшетки (щоб масштабувався на мобільному) */
  width: 9.5%;
  height: auto;
  aspect-ratio: 1 / 1;
  transform: translateX(-50%);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
  transition: opacity 0.3s;
}

.hand-cards {
  display: flex;
  justify-content: center;
  position: relative;
  z-index: 2;
}

.hand-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* === Action Panel === */
.action-left {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 20;
}

.action-right {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 20;
}

/* === Event Overlay === */
.event-overlay {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 33;
  flex-direction: column;
  gap: 16px;
  pointer-events: none;
}

.event-card-display {
  background: var(--bg-card);
  border: 3px solid var(--success);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(76, 175, 80, 0.4);
  animation: pulse-green 2s infinite;
  max-width: 300px;
}

.event-card-display img {
  width: 250px;
  height: auto;
  border-radius: 10px;
  margin-bottom: 12px;
}

.event-card-display p {
  font-size: 18px;
  font-weight: 700;
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 10px rgba(76, 175, 80, 0.3); }
  50% { box-shadow: 0 0 30px rgba(76, 175, 80, 0.7); }
}



/* === Game Over === */
.gameover-container {
  text-align: center;
  padding: 60px;
  background: var(--bg-card);
  border-radius: 30px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.gameover-container h1 {
  font-size: 36px;
  color: var(--text);
  margin-bottom: 16px;
  font-weight: 700;
}

.gameover-container p {
  font-size: 18px;
  margin-bottom: 32px;
  color: var(--text-muted);
  font-weight: 500;
}

/* === Responsive === */
@media (max-width: 768px) {
  .lobby-container {
    margin: 0;
    padding: 24px 18px;
    border-radius: 20px;
  }

  .lobby-layout {
    padding: 10px;
    gap: 12px;
  }

  .lobby-header h1 {
    font-size: 22px;
  }

  .lobby-logo { width: 56px; height: 56px; margin-bottom: 10px; }

  /* Карти в руці — менші на мобільному */
  .hand-card {
    width: 64px;
    height: 96px;
  }

  /* Планшет персонажа — менший */
  .my-character-bg {
    width: 300px;
    height: 210px;
    margin-bottom: -70px;
  }

  /* Чат компактніший */
  .game-chat {
    width: 160px;
    max-height: 160px;
    top: 8px;
    right: 8px;
  }
  .chat-messages { height: 100px; font-size: 11px; }

  /* Інфо-панель зверху */
  .game-info {
    font-size: 12px;
    padding: 8px 16px;
    gap: 12px;
    top: 8px;
  }

  /* Аватари інших гравців — менші */
  .player-avatar { width: 110px; height: 76px; }
  .player-seat { width: 180px; }
  .player-seat-name { font-size: 11px; }
  .player-seat-capital, .player-seat-character { font-size: 10px; }

  /* Зелене коло бою — менше */
  .combat-ring { width: 220px; height: 180px; }
  .combat-card { width: 64px; height: 96px; }
  .reaction-timer { width: 46px; height: 46px; font-size: 20px; top: -64px; }

  /* Емодзі-бар — компактний внизу */
  .emoji-bar {
    bottom: 56px;
    right: 8px;
    max-width: 140px;
    padding: 6px;
  }
  .emoji-btn { font-size: 18px; }

  /* Кнопки дій — менші */
  .action-left, .action-right { bottom: 10px; }
  .action-left .btn, .action-right .btn {
    padding: 10px 16px;
    font-size: 13px;
  }

  .player-count-selector { gap: 4px; }
  .count-btn { padding: 10px; font-size: 16px; }

  /* Профіль бейдж переносимо */
  .profile-badge { font-size: 12px; gap: 10px; }
}

/* Дуже вузькі екрани */
@media (max-width: 420px) {
  .hand-card { width: 52px; height: 78px; }
  .my-character-bg { width: 250px; height: 175px; }
  .combat-ring { width: 180px; height: 150px; }
  .combat-card { width: 54px; height: 80px; }
  .lobby-actions { flex-direction: column; }
  .lobby-actions .btn { width: 100%; }
  /* Налаштування в один стовпчик */
  .settings-grid { grid-template-columns: 1fr; }
  .lobby-container { padding: 20px 18px; }
}

/* === Gender Selector === */
.gender-selector {
  display: flex;
  gap: 8px;
}

.gender-btn {
  flex: 1;
  padding: 12px;
  background: var(--input-bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  transition: 0.3s;
}

.gender-btn:hover {
  border-color: var(--primary);
}

.gender-btn.active {
  border-color: var(--primary);
  background: var(--primary);
}

/* === Room Link (copy) === */
.room-link {
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  padding: 12px 20px;
  background: var(--input-bg);
  border-radius: 12px;
  display: inline-block;
  margin: 8px 0;
  transition: 0.2s;
  border: 1px solid var(--border);
}

.room-link:hover {
  background: var(--border);
  transform: scale(1.02);
}

.copy-hint {
  color: var(--success);
  font-size: 14px;
  font-weight: 600;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Large player avatar (me) === */
.player-seat.is-me {
  width: 520px;
}

.player-seat.is-me .player-avatar-large {
  width: 500px;
  height: 350px;
  border-radius: 12px;
  border: 3px solid var(--accent);
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.3);
  margin: 0 auto 6px;
  overflow: hidden;
}

.player-seat.is-me .player-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* === Player hand count (others) === */
.player-mini-hand {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.mini-card {
  width: 24px;
  height: 36px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.mini-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* === Larger cards for player === */
.hand-card {
  width: 100px;
  height: 150px;
  border-radius: 10px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.hand-card:first-child {
  margin-left: 0 !important;
}

.hand-card:hover {
  transform: translateY(-24px);
  border-color: var(--accent);
  z-index: 5;
  box-shadow: 0 8px 16px rgba(255, 215, 0, 0.3);
}

.hand-card.selected {
  transform: translateY(-34px);
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(218, 72, 73, 0.5);
}

/* === Combat Timer (зелене коло навколо карт + жовтогаряча блискавка) === */
.combat-timer-wrap {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 35;
}

.combat-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  height: 250px;
  border-radius: 50%;
  border: 5px solid var(--success);
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.6), inset 0 0 20px rgba(76, 175, 80, 0.3);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0%, 100% {
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.5), inset 0 0 15px rgba(76, 175, 80, 0.25);
    border-color: var(--success);
  }
  50% {
    box-shadow: 0 0 35px rgba(76, 175, 80, 0.9), inset 0 0 30px rgba(76, 175, 80, 0.5);
    border-color: #6fdb74;
  }
}

.combat-cards-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 0;
  z-index: 16;
}

.combat-main-cards {
  display: flex;
  gap: 8px;
  align-items: center;
}

.combat-pair {
  display: flex;
  gap: 0;
  align-items: center;
}

.combat-side-cards {
  display: flex;
  gap: 4px;
  margin-left: 12px;
  align-items: center;
}

.combat-card {
  width: 90px;
  height: 135px;
  border-radius: 8px;
  overflow: visible;
  border: 2px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  position: relative;
}

/* Захисні та spiymaty карти перекривають атакуючу на 50% */
.combat-card-overlap {
  margin-left: -45px; /* 50% від 90px */
  z-index: 1;
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.combat-card-overlap:nth-child(3) {
  z-index: 2;
  margin-left: -45px;
}

/* Карти під час подій — окремо з відступом, з ім'ям */
.combat-card-event {
  margin-left: 8px;
  border-color: var(--success);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.combat-card-event:first-child {
  margin-left: 0;
}

/* Підсвітка при виборі цілі */
.target-selection-active .combat-card-event {
  cursor: pointer;
  transition: 0.2s;
}

.target-selectable {
  animation: pulse-target 1s infinite;
}

@keyframes pulse-target {
  0%, 100% { box-shadow: 0 0 8px rgba(218, 72, 73, 0.4); }
  50% { box-shadow: 0 0 20px rgba(218, 72, 73, 0.9); border-color: var(--danger); }
}

/* Допомога відображається збоку від основних карт */
.combat-card-side {
  border-color: var(--secondary);
  box-shadow: 0 4px 12px rgba(4, 105, 151, 0.5);
  opacity: 0.9;
}

/* Підпис гравця під картою */
.combat-card-label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  background: rgba(0,0,0,0.7);
  padding: 1px 6px;
  border-radius: 4px;
}

.combat-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reaction-timer {
  position: absolute;
  top: -90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #231820;
  font-size: 26px;
  font-weight: 700;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 17;
  box-shadow: 0 0 20px rgba(255, 165, 0, 0.7);
  animation: pulse-orange 2s infinite;
}

@keyframes pulse-orange {
  0%, 100% { box-shadow: 0 0 15px rgba(255, 165, 0, 0.5); }
  50% { box-shadow: 0 0 30px rgba(255, 165, 0, 0.9); }
}

/* === Help Banner === */
.help-banner {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--secondary);
  color: white;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 50px;
  z-index: 42;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(4, 105, 151, 0.5);
  animation: pulse-blue 2s infinite;
  max-width: 90%;
  text-align: center;
}

@keyframes pulse-blue {
  0%, 100% { box-shadow: 0 0 10px rgba(4, 105, 151, 0.4); }
  50% { box-shadow: 0 0 24px rgba(4, 105, 151, 0.8); }
}

/* === Card Flash (інформативне відображення на 3 сек) === */
.card-flash-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 34;
  gap: 4px;
}

.flash-card {
  width: 80px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--accent);
  box-shadow: 0 4px 16px rgba(255, 215, 0, 0.4);
  transition: all 0.3s;
}

.flash-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* === Game Notification (popup сповіщення) === */
.game-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(68, 47, 63, 0.95);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  padding: 24px 40px;
  border-radius: 16px;
  z-index: 50;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  border: 2px solid var(--accent);
  text-align: center;
  max-width: 80%;
  display: none;
  animation: fadeIn 0.3s;
}
