:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #111827cc;
  --panel-border: #334155;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --self: linear-gradient(135deg, #2563eb, #1d4ed8);
  --other: #1f2937;
  --accent: #3b82f6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(circle at top, #1e293b, #0b1020 55%);
  color: var(--text);
}

.bg-glow {
  position: fixed;
  inset: -30% auto auto -20%;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, #3b82f655, #3b82f600 70%);
  pointer-events: none;
}

.app { max-width: 980px; margin: 0 auto; padding: 18px; position: relative; }
.app-header h1 { margin: 0; font-size: clamp(1.3rem, 3vw, 2rem); }
.subtitle { margin-top: 6px; color: var(--muted); }

.panel {
  background: var(--panel);
  backdrop-filter: blur(5px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px;
  margin-top: 16px;
  box-shadow: 0 10px 25px #02061766;
}
.hidden { display: none !important; }
.join-card { max-width: 520px; }
.field { margin-bottom: 12px; }
label, .field-label { display: block; margin-bottom: 6px; color: #cbd5e1; }

input, button {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #475569;
  padding: 11px;
  font-size: .98rem;
  color: var(--text);
  background: #0f172a;
}
input:focus { outline: 2px solid #2563eb66; border-color: #3b82f6; }
button {
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  font-weight: 600;
}
button.secondary {
  background: #334155;
  width: auto;
  white-space: nowrap;
}
button.danger {
  background: #7f1d1d;
  width: auto;
  margin-top: 8px;
}

.chat-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.meta-line { color: var(--muted); margin-bottom: 4px; }
.nick-editor { min-width: min(100%, 300px); }
.nick-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.chat-area {
  height: 58vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid #334155;
  border-radius: 12px;
  background: #0b1220a8;
}

.msg {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 13px;
  word-break: break-word;
  border: 1px solid #334155;
}
.msg.self {
  align-self: flex-end;
  background: var(--self);
  border: 1px solid #60a5fa66;
}
.msg.other {
  align-self: flex-start;
  background: var(--other);
}
.msg.sender-color-0 { background: #2f3f72; }
.msg.sender-color-1 { background: #5b2f72; }
.msg.sender-color-2 { background: #2f7258; }
.msg.sender-color-3 { background: #72562f; }
.msg.sender-color-4 { background: #6a2f3d; }
.msg.sender-color-5 { background: #2f6372; }
.msg.sender-color-6 { background: #4f2f72; }
.msg.sender-color-7 { background: #3f5f2f; }
.msg.sender-color-8 { background: #725f2f; }
.msg.sender-color-9 { background: #2f7270; }
.msg.sender-color-10 { background: #6b3a2f; }
.msg.sender-color-11 { background: #2f4d72; }
.meta { font-size: .74rem; color: #cbd5e1; margin-bottom: 5px; }

.composer {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-top: 12px;
}
.composer button { width: 110px; }
#emoji-btn { width: 56px; padding: 10px 0; }

.emoji-picker {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.emoji-picker button {
  width: auto;
  min-width: 42px;
  padding: 8px 10px;
  background: #1e293b;
  border: 1px solid #334155;
}
.emoji-panel {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 142px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0b1220;
  width: min(340px, 88vw);
  max-height: 180px;
  overflow-y: auto;
  z-index: 20;
  box-shadow: 0 8px 20px #02061799;
}
.emoji-panel button {
  width: auto;
  min-width: 42px;
  padding: 8px 10px;
  background: #1e293b;
  border: 1px solid #334155;
}

.status { color: #fca5a5; min-height: 1.2em; margin-top: 10px; }

@media (max-width: 760px) {
  .app { padding: 12px; }
  .panel { padding: 14px; }
  .chat-area { height: 62vh; }
  .msg { max-width: 92%; }
  .nick-editor { width: 100%; }
  .composer { grid-template-columns: 1fr 46px 112px; gap: 6px; }
  .composer button { width: 100%; }
  #emoji-btn { width: 46px; padding: 8px 0; }
  .emoji-panel {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: 126px;
    width: calc(100% - 20px);
    max-width: 360px;
    max-height: 170px;
  }
}


.verify-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #334155;
  border-radius: 10px;
  color: #cbd5e1;
  background: #0f172a;
}


/* Force-hide legacy manual captcha controls (old cached markup safety). */
.captcha-row,
#captcha-question,
#captcha-answer,
#refresh-captcha-btn {
  display: none !important;
}

.hint {
  margin: 6px 0 0;
  font-size: .86rem;
  color: #93c5fd;
}
.hint.bad { color: #fca5a5; }
.hint.good { color: #86efac; }

.debug-log {
  white-space: pre-wrap;
  margin: 10px 0 0;
  font-size: .82rem;
  color: #cbd5e1;
  max-height: 220px;
  overflow: auto;
}
