* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f2f5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body {
  height: 100vh;
}

.top-bar {
  flex: 0 0 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0084ff;
  color: white;
  padding: 0 20px;
  font-size: 1.4em;
  font-weight: 600;
  user-select: none;
}

.left-side {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.site-name {
  font-weight: 700;
  font-size: 1.5em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#onlineCount {
  font-weight: 500;
  font-size: 1em;
  white-space: nowrap;
}

.right-side {
  display: flex;
  gap: 12px;
}

.next-button {
  background: #006400; /* dark green */
  border: none;
  color: white;
  padding: 8px 20px;
  border-radius: 9999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1em;
  transition: background-color 0.3s;
  height: 40px;
  align-self: center;
  flex-shrink: 0;
}

.next-button:hover {
  background-color: #004b00;
}

.change-name-btn {
  background: #8b0000; /* dark red */
  border: none;
  color: white;
  padding: 8px 20px;
  border-radius: 9999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1em;
  transition: background-color 0.3s;
  height: 40px;
  align-self: center;
  flex-shrink: 0;
}

.change-name-btn:hover {
  background-color: #5a0000;
}

.chat-container {
  flex: 1 1 auto;
  padding: 12px 15px;
  overflow-y: auto;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #888 #e0e0e0;
}

.chat-container::-webkit-scrollbar {
  width: 8px;
}

.chat-container::-webkit-scrollbar-thumb {
  background-color: #888;
  border-radius: 4px;
}

.message-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  max-width: 90vw;
  word-wrap: break-word;
}

.message-wrapper.you {
  justify-content: flex-end;
}

.message-content {
  background: #e4e6eb;
  padding: 10px 16px;
  border-radius: 20px;
  white-space: pre-wrap;
  max-width: 80vw;
  font-size: 1em;
  color: #000;
  line-height: 1.3;
  word-break: break-word;
}

.message-content.you {
  background: #0084ff;
  color: white;
}

.timestamp {
  font-size: 0.8em;
  color: #666;
  flex-shrink: 0;
  user-select: none;
}

.chat-input {
  flex: 0 0 60px;
  display: flex;
  padding: 8px 15px;
  background: white;
  border-top: 1px solid #ccc;
  gap: 10px;
}

.chat-input input {
  flex: 1;
  padding: 12px;
  border-radius: 20px;
  border: 1px solid #ccc;
  outline: none;
  font-size: 1em;
}

.chat-input input:disabled {
  background: #e9ecef;
  cursor: not-allowed;
}

.chat-input button {
  padding: 12px 20px;
  background: #0084ff;
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1em;
  user-select: none;
  flex-shrink: 0;
}

.chat-input button:disabled {
  background: #a1c1f7;
  cursor: not-allowed;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal-content {
  width: 100%;
  max-width: 400px;
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.1);
  border-radius: 12px;
  background: white;
}

.modal-content input {
  padding: 16px;
  font-size: 1.3em;
  border: 1px solid #ccc;
  border-radius: 8px;
  outline-offset: 2px;
}

.modal-content button {
  padding: 16px;
  font-size: 1.3em;
  background: #0084ff;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.system-message {
  text-align: center;
  color: #888;
  font-style: italic;
  user-select: none;
  font-size: 0.95em;
}

/* === Mobile Responsive === */
@media (max-width: 600px) {
  .top-bar {
    padding: 0 10px;
    font-size: 1.1em;
    height: 50px;
  }

  .site-name {
    font-size: 1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 55vw;
  }

  #onlineCount {
    display: none;
  }

  .left-side > *:not(.site-name) {
    display: none;
  }

  .right-side {
    display: flex;
    flex-direction: row;
    gap: 8px;
    padding: 0;
    margin-left: auto;
    align-items: center;
  }

  .right-side > *:not(.change-name-btn):not(.next-button) {
    display: none;
  }

  .change-name-btn,
  .next-button {
    padding: 8px 16px;
    font-size: 1em;
    height: 36px;
    border-radius: 18px;
    min-width: 100px;
    margin: 0;
    flex-shrink: 0;
    white-space: nowrap;
  }
}
