html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: #18181b;
  color: #f3f4f6;
  font-family: 'Segoe UI', Arial, sans-serif;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  min-width: 100vw;
  box-sizing: border-box;
  overflow: hidden;
}

.chat-container {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  background: #23232a;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 14px 16px;
  border-bottom: 1px solid #333;
  font-size: 1.08em;
  font-weight: bold;
  background: #24242c;
  border-radius: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
  user-select: none;
}

.change-name-btn {
  background: none;
  border: none;
  color: #a5b4fc;
  cursor: pointer;
  font-size: 1em;
  padding: 0 0 0 12px;
  text-decoration: underline;
  height: 36px;
  min-width: 44px;
  transition: color 0.2s;
}

.change-name-btn:hover {
  color: #818cf8;
}

#online-count {
  font-size: 1em;
  color: #a5b4fc;
  margin-left: 10px;
}

#messages {
  flex: 1 1 0%;
  overflow-y: auto;
  padding: 12px 10px;
  margin: 0;
  list-style: none;
  background: #23232a;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  scrollbar-color: #444 #18181b;
  scrollbar-width: thin;
}

#messages li {
  margin-bottom: 9px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #31313a;
  color: #f3f4f6;
  word-break: break-word;
  max-width: 85%;
  box-shadow: 0 1px 6px #0005;
  font-size: 1em;
  align-self: flex-start;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: background 0.15s;
}

#messages li.me {
  background: #475569;
  align-self: flex-end;
  color: #e0e7ef;
}

.msg-time {
  font-size: 0.85em;
  color: #a3a3a3;
  opacity: 0.8;
  margin-top: 2px;
  align-self: flex-end;
}

.chat-form {
  display: flex;
  padding: 10px 10px 14px 10px;
  border-top: 1px solid #333;
  background: #24242c;
  border-radius: 0;
  min-height: 56px;
}

.chat-form input[type="text"] {
  flex: 1;
  padding: 13px 10px;
  border: none;
  border-radius: 8px;
  background: #18181b;
  color: #f3f4f6;
  font-size: 1em;
  outline: none;
  margin-right: 10px;
  min-width: 0;
  transition: background 0.16s;
}

.chat-form input[type="text"]:focus {
  background: #222229;
}

.chat-form button {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 24px;
  font-size: 1em;
  min-height: 45px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chat-form button+button {
  margin-left: 10px;
}

.chat-form button:hover {
  background: #1d4ed8;
}

/* Name modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(24, 24, 27, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
  width: 100vw;
  height: 100vh;
}

.modal-content {
  background: #23232a;
  padding: 30px 18px 20px 18px;
  border-radius: 12px;
  box-shadow: 0 2px 24px #000a;
  text-align: center;
  width: 90vw;
  max-width: 350px;
}

.modal-content label {
  font-size: 1.05em;
  display: block;
  margin-bottom: 14px;
  color: #f3f4f6;
}

.modal-content input[type="text"] {
  padding: 13px 10px;
  font-size: 1em;
  border-radius: 8px;
  border: none;
  outline: none;
  width: 96%;
  background: #18181b;
  color: #f3f4f6;
  margin-bottom: 14px;
}

.modal-content button {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 0;
  font-size: 1em;
  width: 100%;
  min-height: 42px;
  cursor: pointer;
}

/* GIF Modal (overlay) */
#gif-modal.modal {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  z-index: 100;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(24,24,27,0.93);
  width: 100vw;
  height: 100vh;
}

/* กล่อง modal-content */
.gif-modal-content {
  background: #23232a;
  border-radius: 14px;
  padding: 22px 18px 18px 18px;
  box-shadow: 0 2px 24px #000a;
  min-width: 250px;
  max-width: 600px;
  width: 96vw;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
}

/* Header input + ปุ่มปิด */
.gif-modal-header {
  display: flex;
  align-items: center;
  gap: 0; /* ถ้าไม่มีปุ่ม X */
  margin-bottom: 12px;
}
.gif-search {
  flex: 1;
  padding: 13px 12px;
  border: none;
  border-radius: 8px;
  background: #18181b;
  color: #f3f4f6;
  font-size: 1.04em;
  outline: none;
  transition: background 0.16s;
  min-width: 0;
  height: 44px;
  width: 100%;
}
.gif-search:focus {
  background: #222229;
}
.gif-close-btn {
  background: none;
  border: none;
  color: #a5b4fc;
  font-size: 1.4em;
  cursor: pointer;
  padding: 3px 12px;
  border-radius: 7px;
  transition: background 0.13s, color 0.13s;
  line-height: 1;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gif-close-btn:hover {
  background: #31313a;
  color: #fff;
}

/* Grid GIF */
.gif-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  overflow-y: auto;
  justify-content: flex-start;
  min-height: 70px;
  max-height: 44vh;
  padding-bottom: 2px;
}
.gif-grid img {
  cursor: pointer;
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 9px;
  border: 1.5px solid #26262d;
  background: #26262d;
  box-shadow: 0 1px 6px #0003;
  transition: border 0.14s, box-shadow 0.13s;
}
.gif-grid img:hover {
  border-color: #818cf8;
  box-shadow: 0 2px 14px #6366f166;
}

/* Responsive (mobile) */
@media (max-width: 600px) {
  .gif-modal-content {
    max-width: 99vw;
    min-width: 0;
    padding: 10px 4vw 10px 4vw;
  }
  .gif-grid img {
    width: 70px;
    height: 70px;
  }
  .gif-search, .gif-close-btn {
    height: 38px;
    font-size: 1em;
  }
}