/* ---------- Chơi online ---------- */
.net-state { justify-self: end; width: 12px; height: 12px; border-radius: 50%; background: #9a8a7c; margin-right: 6px; }
.net-state.open { background: #4cd07a; box-shadow: 0 0 0 3px rgba(76, 208, 122, .25); }
.net-state.connecting { background: var(--accent); animation: pulse 1s infinite; }
.net-state.closed { background: #ff5a4e; }

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-weight: 600; }
.field input, .join-row input {
  font: inherit; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  min-width: 0;
}
.field input:focus, .join-row input:focus, .chat-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.box .btn-wide { margin-top: 6px; }
.field-label { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 4px; }
.ol-public { font-size: 14px; margin-top: 4px; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; }
#ol-code { text-transform: uppercase; letter-spacing: 3px; font-weight: 700; }

.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-item {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 10px 12px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card); text-align: left; width: 100%;
}
.room-item:hover { border-color: var(--accent); }
.room-item .avatar { width: 36px; height: 36px; grid-row: span 2; }
.room-item .h { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-item .meta { font-size: 12.5px; color: var(--muted); grid-column: 2; }
.room-item .go { grid-row: 1 / span 2; grid-column: 3; color: var(--primary); font-weight: 700; }
.server-box { margin-top: 24px; color: var(--muted); }
.server-box summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.server-box .join-row { margin-top: 6px; }

/* Đồng hồ trên thanh người chơi */
.player-bar { grid-template-columns: 40px minmax(0, 1fr) auto auto; }
.clock {
  font: 700 17px/1 ui-monospace, "SF Mono", Consolas, monospace; font-variant-numeric: tabular-nums;
  padding: 6px 8px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted);
}
.player-bar.turn .clock { color: var(--text); border-color: var(--accent); }
.clock.low { color: #fff !important; background: var(--red); border-color: var(--red); }
.pname .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; vertical-align: middle; background: #4cd07a; }
.pname .dot.off { background: #ff5a4e; }

/* Bảng phòng + chat */
.online-panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.room-code-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.room-code-row b { letter-spacing: 3px; font-size: 18px; color: var(--primary); }
.btn-sm { padding: 8px 12px; font-size: 13.5px; border-radius: 10px; }
.chat-log { max-height: 140px; overflow: auto; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.chat-log:empty { display: none; }
.chat-log .msg { padding: 5px 10px; border-radius: 12px; background: var(--bg2); align-self: flex-start; max-width: 85%; overflow-wrap: anywhere; }
.chat-log .msg.me { align-self: flex-end; background: rgba(215, 155, 47, .22); }
.chat-log .msg.sys { align-self: center; background: none; color: var(--muted); font-size: 12.5px; padding: 0; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; min-width: 0; font: inherit; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); }

.box-note { margin: 0; }
.section-title .count { text-transform: none; letter-spacing: 0; font-weight: 600; }
#ol-code { letter-spacing: 4px; font-variant-numeric: tabular-nums; }
.room-item .seats {
  grid-row: 1 / span 2; grid-column: 3; font-weight: 800; font-variant-numeric: tabular-nums;
  padding: 4px 10px; border-radius: 999px; background: rgba(47, 125, 79, .14); color: var(--ok);
}
.room-item.full { opacity: .6; cursor: default; }
.room-item.full .seats { background: var(--bg2); color: var(--muted); }
.room-item.full:hover { border-color: var(--line); }

.join-requests { display: flex; flex-direction: column; gap: 6px; }
.join-requests:empty { display: none; }
.join-req {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; align-items: center;
  padding: 8px 10px; border-radius: 10px; background: rgba(215, 155, 47, .16); border: 1px solid rgba(215, 155, 47, .5);
}
.join-req span { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Người xem */
.watchers { color: var(--muted); font-size: 13px; font-weight: 600; margin-left: 6px; }
.watchers:empty { display: none; }
.watch-note { margin: 0; }
.room-item .seats.watch { background: rgba(30, 90, 170, .14); color: #2f6fc0; }
.room-item.full { opacity: 1; cursor: pointer; }
.room-item.full:hover { border-color: var(--accent); }
.room-item .eye { color: var(--muted); }
#controls-play.spectating .ctl:not(#btn-flip):not(#btn-sit) { display: none; }
#controls-play.spectating { grid-template-columns: repeat(2, 1fr); }

/* Tỉ số trong phòng + thành tích online */
.score-row {
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 6px 10px; border-radius: 10px;
  background: var(--bg2); border: 1px solid var(--line); font-weight: 600; flex-wrap: wrap;
}
.score-row .nm { max-width: 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-row .sc { font: 800 20px/1 ui-monospace, Consolas, monospace; color: var(--primary); }
.score-row .dr { color: var(--muted); font-size: 13px; }
.ol-stats { margin: 12px 0 0; }
.ol-stats .stat b { font-size: 20px; }
.status.warn { color: var(--accent); }

/* lỗi tên trùng */
.field-err { margin: -4px 0 10px; font-size: 13px; color: var(--red); }
#ol-name.bad { border-color: var(--red); outline-color: var(--red); }
