/* Game Screen */
.game-header {
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: var(--bg2);
  border-bottom: 1px solid var(--card-border);
  gap: 10px;
}
.room-info {
  flex: 1;
  text-align: center;
}
.room-info h3 {
  font-size: 15px;
  font-weight: 700;
}
.room-info span {
  font-size: 11px;
  color: var(--primary);
}

.players-strip {
  display: flex;
  gap: 8px;
  padding: 10px;
  overflow-x: auto;
  background: var(--bg2);
  border-bottom: 1px solid var(--card-border);
  -webkit-overflow-scrolling: touch;
}
.players-strip .player-chip {
  flex-shrink: 0;
  width: 52px;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
}
.players-strip .player-chip img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid transparent;
  object-fit: cover;
  background: #333;
}
.players-strip .player-chip.alive img { border-color: var(--primary); }
.players-strip .player-chip.dead img {
  border-color: #666;
  filter: grayscale(1);
  opacity: 0.6;
}
.players-strip .player-chip.speaking img {
  border-color: #ffcc00;
  animation: speakPulse 1s infinite;
}

.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  position: relative;
}
.msg.own {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #000;
  border-bottom-right-radius: 4px;
}
body.rtl .msg.own { border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }
.msg.other {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-bottom-left-radius: 4px;
}
body.rtl .msg.other { border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
.msg .sender {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--primary);
}
.msg.own .sender { color: rgba(0,0,0,0.6); }
.msg .reply-preview {
  font-size: 11px;
  opacity: 0.7;
  border-left: 2px solid var(--primary);
  padding-left: 6px;
  margin-bottom: 4px;
}
body.rtl .msg .reply-preview {
  border-left: none;
  border-right: 2px solid var(--primary);
  padding-left: 0;
  padding-right: 6px;
}
.msg .reacts {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  font-size: 12px;
}

/* Voice Bar */
.voice-bar {
  padding: 10px 12px;
  background: var(--bg2);
  border-top: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.speaking-user {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.speaking-user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--primary);
}
.voice-controls {
  display: flex;
  gap: 6px;
}
.voice-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s;
}
.voice-btn.active {
  background: var(--primary);
  color: #000;
  animation: glow 1.5s infinite;
}
.voice-btn.muted {
  background: var(--danger);
}

.reactions {
  display: flex;
  gap: 4px;
}
.react-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  font-size: 16px;
  cursor: pointer;
}

/* Chat Input */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg2);
  border-top: 1px solid var(--card-border);
  padding-bottom: calc(8px + var(--safe-bottom));
}
.chat-input-bar input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

/* Clan Screen */
.clan-tabs {
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--card-border);
}
.clan-tab {
  flex: 1;
  padding: 12px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
}
.clan-tab.active {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}
.clan-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.clan-panel.hidden { display: none; }
.voice-room {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
  text-align: center;
}
.voice-users {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.voice-users .v-user {
  text-align: center;
  font-size: 11px;
}
.voice-users .v-user img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid transparent;
  object-fit: cover;
}
.voice-users .v-user.talking img {
  border-color: var(--primary);
  animation: speakPulse 1.2s infinite;
}

/* Hint */
.hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}
.hint.error { color: var(--danger); }
.hint.ok { color: var(--primary); }

/* ========== Enhanced Game UI ========== */
.phase-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.phase-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(0,212,170,0.2);
  color: var(--primary);
}
.phase-badge.phase-night {
  background: rgba(79,140,255,0.25);
  color: #7eb6ff;
}
.phase-badge.phase-voting {
  background: rgba(255,204,0,0.25);
  color: #ffcc00;
}
.phase-badge.phase-end {
  background: rgba(255,77,109,0.25);
  color: #ff4d6d;
}
.game-timer {
  font-size: 12px;
  font-weight: 700;
  background: var(--card);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text);
}
.game-timer.urgent {
  background: var(--danger);
  color: #fff;
  animation: pulse 0.6s infinite;
}

/* Player chips upgraded */
.player-chip {
  flex-shrink: 0;
  width: 58px;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
}
.chip-avatar-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  margin: 0 auto 4px;
}
.chip-avatar-wrap img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  object-fit: cover;
  background: #333;
  transition: border-color 0.3s;
}
.player-chip.alive .chip-avatar-wrap img {
  border-color: var(--primary);
}
.player-chip.dead .chip-avatar-wrap img {
  border-color: #555;
  filter: grayscale(1) brightness(0.6);
}
.player-chip.dead .chip-name { text-decoration: line-through; opacity: 0.5; }
.dead-x {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #ff4d6d;
  font-weight: 900;
  text-shadow: 0 0 6px #000;
}
.chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 58px;
}
.chip-role { font-size: 14px; margin-top: 2px; }

/* My role card */
.my-role-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 12px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(0,0,0,0.5), rgba(20,20,40,0.8));
  border: 1.5px solid var(--primary);
  border-radius: 14px;
  box-shadow: 0 0 20px rgba(0,212,170,0.15);
}
.my-role-card .role-emoji { font-size: 28px; }
.my-role-card .role-info strong { display: block; font-size: 14px; }
.my-role-card .role-info small { font-size: 11px; color: var(--text-muted); line-height: 1.3; }

/* Action panel */
.action-panel {
  margin: 0 12px 8px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  max-height: 160px;
  overflow-y: auto;
}
.action-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  text-align: center;
}
.action-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px;
}
.action-hint.ok { color: var(--primary); font-weight: 600; }
.target-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.target-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.35);
  border: 1.5px solid var(--card-border);
  border-radius: 12px;
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  min-width: 64px;
}
.target-btn img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}
.target-btn:active { transform: scale(0.93); }
.target-btn:hover, .target-btn:focus {
  border-color: var(--primary);
}
.target-btn.vote:hover { border-color: #ffcc00; }

/* Game log */
.game-log {
  max-height: 90px;
  overflow-y: auto;
  padding: 6px 12px;
  font-size: 12px;
  background: rgba(0,0,0,0.25);
  border-bottom: 1px solid var(--card-border);
}
.log-item { padding: 3px 0; color: var(--text-muted); }
.log-phase { color: var(--primary); font-weight: 600; }
.log-death { color: #ff6b81; }
.log-end { color: #ffcc00; font-weight: 700; font-size: 13px; }
.log-private { color: #7eb6ff; font-style: italic; }

/* End screen */
.end-screen {
  text-align: center;
  padding: 16px;
}
.end-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 16px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Night overlay feel */
body.night-mode .game-header,
body.night-mode .players-strip {
  background: #0a0a18;
}

/* Mafia simultaneous voice visual */
.player-chip.mafia-talk .chip-avatar-wrap img {
  border-color: #ff4d6d !important;
  box-shadow: 0 0 12px rgba(255,77,109,0.6);
  animation: speakPulse 1.2s infinite;
}
.mafia-voice-hint {
  text-align: center;
  font-size: 12px;
  color: #ff6b81;
  background: rgba(255,77,109,0.12);
  padding: 8px;
  border-radius: 10px;
  margin-bottom: 10px;
  font-weight: 600;
}
body.night-mode {
  --bg: #080812;
}
body.night-mode .game-header,
body.night-mode .players-strip,
body.night-mode .voice-bar,
body.night-mode .chat-input-bar {
  background: #0a0a18;
}

/* Voice / online polish */
.voice-bar.mafia-live {
  background: linear-gradient(90deg, rgba(255,77,109,0.2), rgba(15,15,30,0.95));
  border-top: 1px solid rgba(255,77,109,0.45);
  box-shadow: 0 -4px 24px rgba(255,77,109,0.15);
}
.voice-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #666;
  display: inline-block;
  margin-inline-end: 6px;
}
.voice-status-dot.live {
  background: #00d4aa;
  box-shadow: 0 0 8px #00d4aa;
  animation: pulse 1.2s infinite;
}
.voice-status-dot.mafia {
  background: #ff4d6d;
  box-shadow: 0 0 8px #ff4d6d;
  animation: pulse 1s infinite;
}
.conn-badge {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(0,0,0,0.65);
  color: #9a9ab0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.conn-badge.show { opacity: 1; }
.conn-badge.online { color: #00d4aa; }
.conn-badge.offline { color: #ff4d6d; }
