/* --- page-level --- */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f2f5;
  color: #222;
  margin: 0;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
}

/* --- landing page container --- */
.page-wrap {
  width: 100%;
  max-width: 980px;
  text-align: center;
}

/* --- header --- */
h1 {
  text-align: center;
  margin: 0 0 16px;
  font-size: 2rem;
  color: #333;
}

/* --- landing page text --- */
p {
  font-size: 1rem;
  margin-bottom: 20px;
  color: #555;
}

/* --- buttons --- */
button {
  padding: 10px 20px;
  margin: 0 10px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.2s ease;
}

button:hover {
  opacity: 0.9;
}

button:nth-of-type(1) {
  background: #007bff;
  color: white;
}

button:nth-of-type(2) {
  background: #28a745;
  color: white;
}

/* --- chat container --- */
.chat-container {
  width: 500px;
  margin: 0 auto;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  height: 72vh;
  min-height: 480px;
}

/* --- online bar --- */
#onlineCount {
  padding: 8px 16px;
  background: #fafafa;
  border-bottom: 1px solid #eee;
  font-weight: 600;
  text-align: center;
  color: #333;
}
/* --- chat area --- */
#chatBox {
  flex: 1;
  padding: 16px;
  background: linear-gradient(#e9ded6, #e5ddd5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- message bubble --- */
.message {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 18px;
  position: relative;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.message.self {
  align-self: flex-end;
  background: #dcf8c6;
  border-bottom-right-radius: 6px;
  text-align: right;
}

.message.other {
  align-self: flex-start;
  background: #ffffff;
  border-bottom-left-radius: 6px;
  text-align: left;
}

.message.self::after,
.message.other::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 0;
  height: 0;
  border: 8px solid transparent;
}

.message.self::after {
  right: -6px;
  border-left-color: #dcf8c6;
  border-right: 0;
  border-bottom: 0;
}

.message.other::after {
  left: -6px;
  border-right-color: #ffffff;
  border-left: 0;
  border-bottom: 0;
}

.meta {
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 4px;
  color: #333;
}

.text {
  font-size: 0.8rem;
  line-height: 1.4;
}

.timestamp {
  font-size: 0.65rem;
  color: #777;
  align-self: flex-end;
  margin-top: 4px;
}

/* --- system messages --- */
.message.system {
  align-self: center;
  background: #fff3cd; /* optional light background */
  border-radius: 8px;
  padding: 6px 10px;
  max-width: 60%;
  font-size: 0.8rem;
  color: #777; /* same as timestamp */
  font-weight: 400;
}

/* --- reactions --- */
.reactions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 4px;
  align-items: center;
}

.reactions span {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.7rem;
  user-select: none;
}

.reactions span:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* --- message form --- */
#messageForm {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #eee;
  background: #fafafa;
}

#message {
  flex: 1;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid #ddd;
  outline: none;
}

#submit,
#leave {
  padding: 9px 12px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: #007bff;
  color: white;
  font-weight: 600;
}

#leave {
  background: #dc3545;
}

#submit:hover {
  background: #0062d6;
}

#leave:hover {
  background: #b52d3a;
}

.chat-mode-buttons {
  display: flex;
  flex-direction: column; /* stack vertically */
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.chat-mode-buttons button {
  min-width: 140px;
  margin: 0;
}

/* --- responsive --- */
@media (max-width: 480px) {
  .chat-container {
    width: 100%;
    height: 86vh;
  }

  .message {
    max-width: 85%;
    padding: 8px 10px;
  }

  .text {
    font-size: 0.9rem;
  }

  .timestamp {
    font-size: 0.6rem;
  }

  .reactions span {
    font-size: 0.6rem;
    padding: 1px 3px;
  }
}
