/* v1.8.2 — compact private-room chat beside the turn banner. */
.game-hud .turn-banner{
  display:flex!important;
  align-items:center;
  gap:clamp(4px,.55vw,8px);
  min-width:0;
  overflow:visible!important;
}
.game-hud .turn-banner>div:first-child{flex:0 1 auto;min-width:68px}
.turn-chat{
  position:relative;
  z-index:175;
  display:flex;
  align-items:center;
  gap:4px;
  width:clamp(190px,27vw,375px);
  min-width:0;
  margin-left:auto;
  color:#f5dfb8;
}
.turn-chat button,.turn-chat input{font:700 10px/1 Inter,"Noto Sans SC","Microsoft YaHei",system-ui,sans-serif}
.chat-toggle,.chat-compose button{
  flex:0 0 27px;
  width:27px;
  height:27px;
  min-width:27px;
  padding:0;
  display:grid;
  place-items:center;
  border:1px solid #745333;
  border-radius:8px;
  color:#f1c76f;
  background:linear-gradient(180deg,#332319,#19130f);
  box-shadow:inset 0 1px #fff1;
}
.chat-toggle{position:relative;font-size:14px}
.chat-toggle.has-message:after{
  content:"";
  position:absolute;
  right:-2px;
  top:-2px;
  width:6px;
  height:6px;
  border-radius:50%;
  background:#49d98a;
  border:1px solid #152019;
  box-shadow:0 0 7px #49d98a99;
}
.turn-chat.open .chat-toggle{border-color:#d0a14d;background:linear-gradient(180deg,#5a3920,#29190f)}
.chat-compose{
  flex:1 1 150px;
  min-width:0;
  height:27px;
  display:flex;
  align-items:center;
  overflow:hidden;
  border:1px solid #5c4634;
  border-radius:8px;
  background:#0d0b09d9;
  box-shadow:inset 0 1px 7px #0009;
}
.chat-compose:focus-within{border-color:#b8873e;box-shadow:0 0 0 2px #b8873e22,inset 0 1px 7px #0009}
.chat-compose input{
  flex:1 1 auto;
  width:1%;
  min-width:0;
  height:100%;
  padding:0 7px;
  border:0;
  outline:0;
  color:#f7ead1;
  background:transparent;
}
.chat-compose input::placeholder{color:#9e8b73;font-weight:600}
.chat-compose button{
  border-width:0 0 0 1px;
  border-radius:0;
  background:#39251a;
  font-size:12px;
}
.chat-compose button:disabled{opacity:.45}
.chat-latest{
  flex:0 1 125px;
  min-width:0;
  display:flex;
  gap:4px;
  align-items:baseline;
  overflow:hidden;
  white-space:nowrap;
  font-size:8px;
  color:#cdb798;
}
.chat-latest b{flex:0 0 auto;max-width:45px;overflow:hidden;text-overflow:ellipsis;color:#e9c77f}
.chat-latest span{overflow:hidden;text-overflow:ellipsis}
.chat-history{
  position:absolute;
  z-index:190;
  top:calc(100% + 6px);
  right:0;
  width:min(330px,72vw);
  max-height:min(220px,54dvh);
  padding:8px;
  border:1px solid #89643e;
  border-radius:11px;
  background:linear-gradient(155deg,#211811f5,#0d0b09fa);
  box-shadow:0 14px 35px #000c,inset 0 1px #fff1;
  backdrop-filter:blur(12px);
}
.chat-history-head{display:flex;align-items:center;justify-content:space-between;padding:1px 2px 6px;color:#edc87d;font-size:10px;letter-spacing:.04em}
.chat-history-head small{color:#8f7a62;font-size:7px}
.chat-history-list{display:flex;flex-direction:column;gap:5px;max-height:min(177px,44dvh);overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin}
.chat-message{align-self:flex-start;max-width:88%;display:flex;flex-direction:column;gap:2px;padding:5px 7px;border:1px solid #4c3b2e;border-radius:8px 8px 8px 2px;background:#2a1d15;color:#f1e4cf}
.chat-message strong{font-size:7px;color:#d5ac68}
.chat-message span{font-size:10px;line-height:1.28;overflow-wrap:anywhere}
.chat-message.mine{align-self:flex-end;border-color:#78552f;border-radius:8px 8px 2px 8px;background:#4a2f1c}
.chat-empty{padding:16px 6px;text-align:center;color:#9e8870;font-size:9px}

.game-hud .turn-banner.ai-active .ai-turn-status{min-width:min(235px,32vw)!important}
.game-hud .turn-banner.ai-active .turn-chat{width:clamp(165px,22vw,285px)}

@media(max-width:1050px){.chat-latest{display:none}.turn-chat{width:clamp(165px,25vw,265px)}}
@media(orientation:landscape) and (max-height:520px){
  .game-hud .turn-banner{gap:3px}
  .game-hud .turn-banner>div:first-child{min-width:56px}
  .turn-chat{width:clamp(140px,24vw,215px);gap:2px}
  .game-hud .turn-banner.ai-active .ai-turn-status{min-width:min(175px,29vw)!important}
  .game-hud .turn-banner.ai-active .turn-chat{width:clamp(125px,20vw,180px)}
  .chat-toggle,.chat-compose button{flex-basis:23px;width:23px;min-width:23px;height:23px;border-radius:6px}
  .chat-toggle{font-size:12px}
  .chat-compose{height:23px;border-radius:6px}
  .chat-compose input{padding-inline:5px;font-size:8px}
  .chat-compose button{border-radius:0;font-size:10px}
  .chat-history{top:calc(100% + 4px);width:min(290px,67vw);max-height:47dvh;padding:6px}
  .chat-history-list{max-height:calc(47dvh - 29px)}
  .chat-message{padding:4px 6px}.chat-message span{font-size:9px}
}
@media(orientation:landscape) and (max-width:760px){
  .turn-chat{width:145px}
  .game-hud .turn-banner.ai-active .ai-turn-status{min-width:min(145px,27vw)!important}
  .game-hud .turn-banner.ai-active .turn-chat{width:125px}
}
@media(orientation:landscape) and (max-height:350px){
  .game-hud .turn-banner>div:first-child{min-width:48px}
  .turn-chat{width:132px}.game-hud .turn-banner.ai-active .turn-chat{width:112px}
  .game-hud .turn-banner.ai-active .ai-turn-status{min-width:min(125px,25vw)!important}
}
@media(prefers-reduced-motion:reduce){.chat-toggle.has-message:after{box-shadow:none}}
