:root { 
  --primary: #0070f3; 
  --bg: #f4f7f9; 
}

* { 
  box-sizing: border-box; 
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
}

html, body { 
  margin: 0; 
  padding: 0; 
  width: 100%; 
  height: 100%; 
  height: 100dvh; 
  overflow: hidden; 
  background: var(--bg); 
}

.page { 
  display: none; 
  height: 100%; 
  width: 100%; 
}

.active { 
  display: flex !important; 
}

#auth-page { 
  flex-direction: column; 
  justify-content: center; 
  align-items: center; 
  background: var(--primary); 
  padding: 20px; 
  overflow-y: auto; 
}

.auth-card { 
  background: white; 
  padding: 30px; 
  border-radius: 15px; 
  box-shadow: 0 5px 15px rgba(0,0,0,0.2); 
  width: 100%; 
  max-width: 360px; 
}

input, select, textarea { 
  display: block; 
  width: 100%; 
  padding: 10px 12px; 
  margin-bottom: 10px; 
  border: 1px solid #ddd; 
  border-radius: 8px; 
  font-size: 15px; 
  outline: none; 
}

button { 
  width: 100%; 
  padding: 10px 12px; 
  border: none; 
  border-radius: 8px; 
  background: var(--primary); 
  color: white; 
  cursor: pointer; 
  font-weight: bold; 
}

.disclaimer-box { 
  background: #f8f9fa; 
  border: 1px solid #e9ecef; 
  border-radius: 8px; 
  padding: 10px; 
  margin-bottom: 12px; 
  font-size: 12px; 
  color: #6c757d; 
  max-height: 100px; 
  overflow-y: auto; 
  line-height: 1.4; 
}

/* 🔞 18歲勾選框樣式 */
.age-check-container {
  margin-bottom: 12px;
  padding: 0 2px;
}

.age-check-label {
  font-size: 13px;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.age-check-label input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.auth-switch-links {
  display: flex; 
  justify-content: space-between; 
  margin-top: 12px; 
  font-size: 14px;
}

#chat-page { 
  height: 100%; 
  width: 100%; 
  display: flex; 
  flex-direction: row; 
  position: relative; 
  overflow: hidden; 
}

#sidebar { 
  width: 250px; 
  background: white; 
  border-right: 1px solid #ddd; 
  display: flex; 
  flex-direction: column; 
  flex-shrink: 0; 
  z-index: 200; 
  transition: transform 0.3s ease; 
}

#sidebar.collapsed { 
  transform: translateX(-100%); 
  position: absolute; 
  height: 100%; 
}

.sidebar-header {
  padding: 12px 15px; 
  font-weight: bold; 
  background: #0052b4; 
  color: white; 
  display: flex; 
  justify-content: space-between; 
  align-items: center;
}

.close-sidebar-btn {
  background: none; 
  border: none; 
  color: white; 
  font-size: 15px; 
  cursor: pointer; 
  width: auto; 
  padding: 0;
}

@media (max-width: 768px) {
  #sidebar { 
    position: absolute; 
    height: 100%; 
    transform: translateX(-100%); 
  }
  #sidebar:not(.collapsed) { 
    transform: translateX(0); 
    box-shadow: 5px 0 15px rgba(0,0,0,0.2); 
  }
}

#user-list { 
  flex: 1; 
  overflow-y: auto; 
}

.user-item { 
  display: flex; 
  align-items: center; 
  padding: 10px 15px; 
  border-bottom: 1px solid #eee; 
  cursor: pointer; 
  white-space: nowrap; 
}

.user-item:hover, .user-item.selected { 
  background: #e7f3ff; 
}

.avatar-container { 
  width: 34px; 
  height: 34px; 
  margin-right: 10px; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  flex-shrink: 0; 
  cursor: pointer; 
}

.avatar-container svg { 
  width: 100%; 
  height: 100%; 
  border-radius: 50%; 
  display: block; 
  pointer-events: none; 
}

#main { 
  flex: 1; 
  display: flex; 
  flex-direction: column; 
  background: #fff; 
  min-width: 0; 
  height: 100%; 
  position: relative; 
}

#chat-header { 
  height: 48px; 
  min-height: 48px; 
  display: flex; 
  background: #0070f3; 
  color: white; 
  align-items: center; 
  padding: 0 15px; 
  flex-shrink: 0; 
  z-index: 10; 
}

#toggle-menu { 
  background: rgba(255,255,255,0.15); 
  border: none; 
  color: white; 
  width: 32px; 
  height: 32px; 
  border-radius: 6px; 
  cursor: pointer; 
  font-size: 15px; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  margin-right: 10px; 
  flex-shrink: 0; 
}

#chat-title { 
  font-weight: bold; 
  font-size: 15px;
  display: flex; 
  align-items: baseline; 
  gap: 8px; 
  flex-wrap: wrap;
}

#online-count {
  font-size: 0.85rem; 
  font-weight: normal; 
  color: rgba(255, 255, 255, 0.9);
}

.chat-messages-container { 
  flex: 1; 
  position: relative; 
  display: flex; 
  flex-direction: column; 
  min-height: 0; 
  background: #f0f2f5; 
}

#messages { 
  flex: 1; 
  overflow-y: auto; 
  padding: 12px 15px; 
  display: flex; 
  flex-direction: column; 
  gap: 8px; 
  min-height: 0; 
}

#scroll-to-bottom-btn { 
  display: none; 
  position: absolute; 
  bottom: 12px; 
  left: 50%; 
  transform: translateX(-50%); 
  background: #0070f3; 
  color: white; 
  border: none; 
  padding: 6px 14px; 
  border-radius: 20px; 
  font-size: 12px; 
  font-weight: bold; 
  box-shadow: 0 4px 10px rgba(0,0,0,0.2); 
  cursor: pointer; 
  z-index: 20; 
  align-items: center; 
  gap: 6px; 
  width: auto;
}

#scroll-to-bottom-btn:hover { 
  background: #005bb5; 
}

.msg-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  align-self: flex-start !important;
  flex-direction: row !important;
}

@media (max-width: 768px) {
  .msg-wrapper {
    align-self: flex-start;
  }
  .msg-wrapper.mine {
    align-self: flex-end !important;
    flex-direction: row-reverse !important;
  }
}

.msg { 
  background: white; 
  padding: 6px 10px; 
  border-radius: 12px; 
  box-shadow: 0 1px 2px rgba(0,0,0,0.05); 
  max-width: calc(100% - 44px); 
}

.msg.mine { 
  background: #dcf8c6; 
  color: #000; 
}

.msg.private { 
  border: 2px solid #ff4757; 
  background: #fff5f5; 
}

.msg.mine.private { 
  background: #fee2e2; 
  border: 2px solid #ff4757; 
}

.sys-msg { 
  align-self: center; 
  font-size: 12px; 
  color: #666; 
  background: rgba(0,0,0,0.05); 
  padding: 2px 10px; 
  border-radius: 10px; 
  max-width: 100%; 
  margin: 4px 0; 
}

.msg-meta { 
  font-size: 12px; 
  color: #777; 
  margin-bottom: 2px; 
  display: flex; 
  align-items: center; 
  gap: 6px; 
  flex-wrap: wrap; 
}

.reply-tag { 
  font-size: 0.7rem; 
  color: #0070f3; 
  cursor: pointer; 
  background: rgba(0, 112, 243, 0.08); 
  padding: 1px 4px; 
  border-radius: 4px; 
  font-weight: 500; 
}

.reply-tag:hover { 
  background: rgba(0, 112, 243, 0.2); 
  text-decoration: underline; 
}

.msg-text { 
  font-size: 14px; 
  line-height: 1.35; 
  word-break: break-word; 
  white-space: pre-wrap; 
}

.msg-text a { 
  color: #0070f3; 
  text-decoration: underline; 
}

.msg-text img { 
  max-width: 100%; 
  border-radius: 6px; 
  margin-top: 4px; 
  display: block; 
}

.msg-text p { 
  margin: 0 !important; 
  padding: 0 !important; 
}

.msg-text table { 
  border-collapse: collapse; 
  width: 100%; 
  margin: 4px 0; 
  font-size: 13px; 
}

.msg-text th, .msg-text td { 
  border: 1px solid #cbd5e1; 
  padding: 4px 6px; 
  text-align: left; 
}

.msg-text th { 
  background: rgba(0, 112, 243, 0.08); 
  color: #0070f3; 
}

.msg-text hr { 
  border: none; 
  border-top: 1px dashed #cbd5e1; 
  margin: 2px 0 !important; 
}

.msg-text > p:first-child:has(+ hr),
.msg-text > p:has(+ hr) {
  margin: 0 0 2px 0 !important;
  padding-left: 8px;
  border-left: 3px solid #0070f3;
  color: #555;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 0 4px 4px 0;
  padding-top: 1px;
  padding-bottom: 1px;
}

#input-bar { 
  padding: 8px 12px; 
  background: #d5e7ffff; 
  border-top: 1px solid #ddd; 
  flex-shrink: 0; 
  z-index: 10; 
}

.status-row { 
  font-size: 12px; 
  color: #555; 
  margin-bottom: 6px; 
  display: flex; 
  align-items: center; 
  gap: 10px; 
  flex-wrap: wrap; 
}

.input-row { 
  display: flex; 
  gap: 8px; 
  align-items: flex-end; 
  position: relative; 
}

.upload-btn {
  width: auto; 
  padding: 4px 8px; 
  font-size: 12px; 
  background: #6c757d; 
  margin-bottom: 0;
}

.emoji-btn {
  width: 40px; 
  height: 40px; 
  margin-bottom: 0; 
  padding: 0; 
  background: #f8f9fa; 
  border: 1px solid #ddd; 
  border-radius: 8px; 
  font-size: 18px;
  color: #333;
}

.emoji-picker {
  display: none; 
  position: absolute; 
  bottom: 52px; 
  left: 0; 
  background: white; 
  border: 1px solid #ddd; 
  padding: 8px; 
  border-radius: 12px; 
  box-shadow: 0 4px 15px rgba(0,0,0,0.15); 
  z-index: 300; 
  width: 310px; 
  max-height: 200px; 
  overflow-y: auto; 
  grid-template-columns: repeat(6, 1fr); 
  gap: 4px; 
  text-align: center; 
  font-size: 20px;
}

.emoji-picker span {
  cursor: pointer;
  user-select: none;
}

#msg-input {
  margin-bottom: 0; 
  flex: 1; 
  height: 60px; 
  padding: 8px 10px; 
  resize: none;
}

.send-btn {
  width: 75px; 
  height: 60px; 
  margin-bottom: 0; 
  padding: 0;
}

/* 🎱 六合彩三色波樣式 */
.marksix-container {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin: 6px 0;
}

.marksix-ball {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #ffffff;
  font-weight: bold;
  font-size: 16px;
  box-shadow: inset -2px -2px 6px rgba(0,0,0,0.3), 0 2px 5px rgba(0,0,0,0.2);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.ball-red { background-color: #e74c3c; }
.ball-blue { background-color: #3498db; }
.ball-green { background-color: #2ecc71; }

/* 指令選擇器樣式 */
.command-picker {
  display: none;
  position: absolute;
  bottom: 70px;
  left: 50px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
  z-index: 300;
  width: 280px;
  max-height: 200px;
  overflow-y: auto;
}

.command-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.command-item.active {
  background: #e2e8f0;
}

.command-item .cmd-title {
  font-weight: bold;
  color: #3498db;
}

.command-item .desc {
  font-size: 12px;
  color: #666;
}
