* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #1b1e24;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #eee;
}

#hud {
  width: 1180px;
  max-width: 95vw;
  display: flex;
  justify-content: space-between;
  color: #aab;
  font-size: 14px;
}

#hint kbd {
  background: #333a45;
  border-radius: 4px;
  padding: 1px 6px;
  border: 1px solid #4a5262;
}

canvas#game {
  background: #d9d2c3;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  max-width: 95vw;
  height: auto;
}

#chat-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#chat-modal.hidden {
  display: none;
}

#chat-window {
  width: 420px;
  max-height: 70vh;
  background: #23262e;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #2c313c;
  border-bottom: 1px solid #3a4150;
}

#chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #444c5c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

#chat-header > div:nth-child(2) {
  flex: 1;
}

#chat-npc-name {
  font-weight: 600;
  font-size: 15px;
}

#chat-dept-name {
  font-size: 12px;
  color: #9aa3b2;
}

#chat-close {
  background: none;
  border: none;
  color: #9aa3b2;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}
#chat-close:hover { color: #fff; }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
}

.msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.msg.user {
  align-self: flex-end;
  background: #3f6fe0;
  color: #fff;
}

.msg.npc {
  align-self: flex-start;
  background: #333a45;
  color: #eee;
}

.msg.pending {
  opacity: 0.6;
  font-style: italic;
}

#chat-form {
  display: flex;
  border-top: 1px solid #3a4150;
}

#chat-input {
  flex: 1;
  padding: 12px;
  background: #1b1e24;
  border: none;
  color: #eee;
  font-size: 14px;
}
#chat-input:focus { outline: none; }

#chat-form button {
  padding: 0 18px;
  background: #3f6fe0;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
}
#chat-form button:hover { background: #345ec4; }
