/* 처음 화면·대기방·채팅 등 HTML로 그리는 화면. 게임 캔버스 위에 겹친다. */
#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  color: #f4efe4;
  font-size: 15px;
}
#ui .hidden { display: none !important; }
#ui button, #ui input, #ui select {
  font: inherit;
  color: inherit;
}
#ui button {
  background: #3a3124;
  border: 1px solid #7a6440;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
}
#ui button:hover:not(:disabled) { background: #4a3e2c; border-color: #c6a15a; }
#ui button:disabled { opacity: 0.45; cursor: default; }
#ui button.primary { background: #6a4a22; border-color: #c6a15a; color: #fff4d8; }
#ui button.small { padding: 3px 8px; font-size: 13px; }
#ui input, #ui select {
  background: #16140f;
  border: 1px solid #5a4c34;
  border-radius: 5px;
  padding: 7px 9px;
}
#ui input:focus, #ui select:focus { outline: none; border-color: #c6a15a; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 6, 5, 0.55);
  pointer-events: auto;
}
.card {
  background: rgba(22, 20, 15, 0.96);
  border: 1px solid #7a6440;
  border-radius: 12px;
  padding: 26px 30px;
  min-width: 380px;
  max-width: 560px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.card h1 { margin: 0 0 4px; font-size: 32px; color: #f0e2bc; letter-spacing: 2px; text-align: center; }
.card h2 { margin: 0 0 14px; font-size: 22px; color: #f0e2bc; }
.card .sub { margin: 0 0 22px; text-align: center; color: #b3a790; font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.row > input { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.note { font-size: 13px; color: #b3a790; margin: 6px 0; }
.error { font-size: 13px; color: #e59080; min-height: 18px; margin: 6px 0 0; }
.divider { border-top: 1px solid #3a3124; margin: 14px 0; }

#room-list { max-height: 320px; overflow-y: auto; margin: 6px 0 12px; }
.room-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid #3a3124;
  border-radius: 7px;
  margin-bottom: 6px;
  background: rgba(40, 34, 24, 0.6);
}
.room-row .info { flex: 1; }
.room-row .name { font-size: 16px; color: #f0e2bc; }
.room-row .meta { font-size: 12px; color: #b3a790; }
.room-row .status-playing { color: #e0a15a; }

#score-list { max-height: 340px; overflow-y: auto; margin: 8px 0 12px; }
.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid #3a3124;
}
.score-row .rank { width: 28px; color: #f6d870; font-weight: bold; }
.score-row .info { flex: 1; }
.score-row .pts { font-size: 18px; color: #f0e2bc; font-weight: bold; }
.score-now { font-size: 18px; color: #f6d870; margin: 10px 0 4px; }

#credits-text {
  white-space: pre-wrap;
  font-size: 12px;
  max-height: 380px;
  overflow-y: auto;
  background: #0f0e0b;
  padding: 10px;
  border-radius: 6px;
  color: #d9d0c0;
}

/* 대기방 옆 창 */
#lobby-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 300px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: rgba(16, 15, 11, 0.92);
  border: 1px solid #7a6440;
  border-radius: 10px;
  padding: 14px;
  pointer-events: auto;
}
#lobby-panel h3 { margin: 0 0 8px; font-size: 17px; color: #f0e2bc; }
#lobby-panel .section { margin-top: 12px; }
#lobby-panel .label { font-size: 12px; color: #b3a790; margin-bottom: 4px; }
.code-box {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.code-box .code { font-size: 20px; letter-spacing: 3px; color: #f6d870; font-weight: bold; }
.code-box .fold { margin-left: auto; }
#lobby-panel.folded { width: auto; min-width: 250px; padding: 10px 12px; }
#lobby-panel.folded .section { margin-top: 0; }
#lobby-panel.folded .actions { margin-top: 8px; }
.member {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  background: rgba(40, 34, 24, 0.55);
  margin-bottom: 4px;
}
.member .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.member img { width: 22px; height: 22px; border-radius: 50%; }
.member .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .tag { font-size: 12px; color: #9fdc8a; }
.member .tag.wait { color: #b3a790; }
.member.off { opacity: 0.5; }
.classes { display: flex; gap: 4px; flex-wrap: wrap; }
.classes button { padding: 4px 8px; font-size: 13px; }
.classes button.on { border-color: #f6d870; background: #5a4424; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 5px 0; font-size: 14px; }
.setting select, .setting input { padding: 4px 6px; font-size: 13px; }
.setting input[type=text] { width: 150px; }
.actions { display: flex; gap: 8px; margin-top: 14px; }
.actions button { flex: 1; }

/* 채팅 */
#chat {
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: 360px;
  pointer-events: none;
}
#chat-log {
  max-height: 180px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-size: 14px;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}
#chat-log .line { margin: 1px 0; transition: opacity 1s; }
#chat-log .line.old { opacity: 0; }
#chat.open #chat-log .line.old { opacity: 0.85; }
#chat-log .sys { color: #b3a790; font-style: italic; }
#chat-input { width: 100%; box-sizing: border-box; margin-top: 4px; pointer-events: auto; }

/* 결과·일시정지 창 */
.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}
.modal .card { text-align: center; }
.modal .card h2 { text-align: center; font-size: 30px; }
.result-players { margin: 12px 0; text-align: left; }

#toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(22, 20, 15, 0.95);
  border: 1px solid #c6a15a;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  pointer-events: none;
}
