/* 2-player lobby + HUD additions (on top of style.css) */

.panel h1 small {
  display: block;
  font-size: 0.42em;
  color: var(--accent-2);
  letter-spacing: 0.2em;
  margin-top: 0.2em;
}

.field {
  display: flex;
  align-items: center;
  gap: 0.8em;
  justify-content: center;
  margin: 0 0 1em;
}
.field span { color: var(--muted); }
input {
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.55em 0.8em;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
input:focus { border-color: var(--accent-2); }
.error { color: #ff8fa3; min-height: 1.3em; margin: 0.8em 0 0; }
button.small { padding: 0.4em 1em; font-size: 0.85em; }

.room-sub { color: var(--muted); font-size: 0.9em; margin: 0 0 1em; }

.roles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1em;
  margin-bottom: 1em;
}
.role-card {
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  padding: 0.9em;
  cursor: pointer;
  display: grid;
  gap: 0.3em;
  justify-items: center;
  text-align: center;
}
.role-card:hover:not(:disabled) { border-color: var(--accent-2); }
.role-card .emoji { font-size: 2.2em; }
.role-card small { color: var(--muted); line-height: 1.4; }
.role-card .owner { font-style: normal; font-size: 0.85em; color: var(--muted); }
.role-card.mine { border-color: var(--accent); background: rgba(255, 77, 109, 0.15); }
.role-card.mine .owner { color: #fff; font-weight: 800; }
.role-card.taken { opacity: 0.55; cursor: not-allowed; }
.role-card.ready .owner::after { content: ' ✅'; }

.room-actions { display: flex; justify-content: center; gap: 0.5em; }
#btn-ready.on { background: #2fbf71; box-shadow: 0 6px 20px rgba(47, 191, 113, 0.4); }
.countdown { font-size: 2.4em; font-weight: 900; margin: 0.3em 0 0; min-height: 1.2em; color: var(--accent-2); }

.howto .controls { grid-template-columns: 1fr; }

.result {
  border-radius: 14px;
  padding: 0.8em 1em;
  margin-bottom: 1em;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
}
.result h2 { margin: 0 0 0.2em; }
.result.win { border-color: #2fbf71; background: rgba(47, 191, 113, 0.15); }
.result.lose { border-color: var(--accent); background: rgba(255, 77, 109, 0.12); }
.result p { margin: 0.2em 0; color: var(--muted); }

/* HUD */
.bar.stamina { width: 18cqw; height: 2.2em; }
.bar.stamina .fill { background: linear-gradient(90deg, #2b8f6a, #7ee0a6); }
.bar.blood.low .fill, .bar.stamina.low .fill { animation: blink 0.6s steps(2) infinite; }
.bar.blood { width: 18cqw; }
@keyframes blink { 50% { opacity: 0.35; } }

/* human touch controls */
#touch-human {
  position: absolute;
  left: 2cqw; right: 2cqw; bottom: 3cqh;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
#touch-human .dpad { display: flex; gap: 2cqw; pointer-events: auto; }

@media (max-width: 700px) {
  .roles { grid-template-columns: 1fr; }
}
.countdown.dim { font-size: 1em; font-weight: 600; color: var(--muted); }

/* ping (round trip to the server) */
.ping { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ping.good { color: #7ee0a6; }
.ping.ok { color: var(--accent-2); }
.ping.bad { color: #ff8fa3; }

/* lobby: room list */
.lobby-top {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6em 1em;
  margin-bottom: 0.8em;
}
.lobby-top .field { margin: 0; }
.room-list-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9em;
  margin: 0 0.3em 0.3em;
}
.room-list {
  display: grid;
  align-content: start;
  gap: 0.4em;
  min-height: 5em;
  max-height: 34cqh;
  overflow-y: auto;
  margin-bottom: 1em;
  padding: 0.3em;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
}
.room-list .empty { color: var(--muted); margin: 1.4em 0; }
.room-row {
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.55em 0.9em;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15em 1em;
  text-align: left;
  cursor: pointer;
}
.room-row:hover:not(:disabled) { border-color: var(--accent-2); }
.room-row:disabled { opacity: 0.5; cursor: not-allowed; }
.room-row .room-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-row .room-meta { grid-column: 1 / -1; color: var(--muted); font-size: 0.85em; }

/* create / password dialogs */
.field.stack {
  flex-direction: column;
  align-items: stretch;
  gap: 0.3em;
  text-align: left;
}
.field.stack small { color: var(--muted); }

/* room */
.room-title { margin: 0 0 0.3em; overflow-wrap: anywhere; }
.chat-box { margin-top: 0.6em; text-align: left; }
.chat-log {
  list-style: none;
  margin: 0 0 0.4em;
  padding: 0.5em 0.8em;
  height: 7.5em;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  font-size: 0.9em;
  line-height: 1.5;
  -webkit-user-select: text;
  user-select: text;
}
#chat-input { width: 100%; }
.chat-log li, #chat-feed li { overflow-wrap: anywhere; }
.chat-log .sys, #chat-feed .sys { color: var(--muted); font-style: italic; }
.who { color: var(--accent-2); margin-right: 0.45em; }
.mine .who { color: var(--accent); }

/* chat during a match: under the top HUD row, lines fade unless the input is open */
#chat-hud {
  position: absolute;
  top: 7cqh;
  left: 1.2cqw;
  width: min(40cqw, 520px);
  pointer-events: none;
  font-size: max(11px, 1.25cqw);
}
#chat-feed {
  list-style: none;
  margin: 0 0 0.4em;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25em;
}
#chat-feed li {
  background: var(--chip);
  border-radius: 10px;
  padding: 0.25em 0.7em;
  max-width: 100%;
  text-shadow: 0 1px 2px #000;
  transition: opacity 1.5s;
}
#chat-feed li.fading { opacity: 0; }
#chat-feed li.gone { display: none; }
#chat-hud.open #chat-feed li { opacity: 1; display: block; }
#chat-hud-input { width: 100%; pointer-events: auto; background: rgba(0, 0, 0, 0.6); }
