/* ScreenBuddy (web) — hoạt động chung trong phòng: thanh hành động, TV, Pomodoro, bảng, thú cưng. */

/* ---------------- Thanh hành động ---------------- */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.action-bar .act-btn {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--text);
  font: 600 12.5px/1.2 "Segoe UI", system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
}

.action-bar .act-btn:hover {
  border-color: var(--accent);
}

.action-bar .act-btn.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.action-bar .act-sep {
  width: 1px;
  height: 20px;
  margin: 0 2px;
  background: var(--line);
}

.action-bar [hidden] {
  display: none;
}

/* ---------------- Lớp hoạt động trên sân khấu ---------------- */
.act-layer {
  position: absolute;
  inset: 0;
  z-index: 3; /* trên đồ trang trí (1), dưới nhân vật (5) */
  pointer-events: none;
}

.act-layer > * {
  pointer-events: auto;
}

.act-layer[hidden] {
  display: none;
}

/* ---------------- Popover ---------------- */
.act-panel {
  position: absolute;
  z-index: 65;
  width: min(340px, calc(100% - 16px));
  padding: 12px;
  border-radius: 14px;
  background: #ffffff;
  color: #1f2233;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  font: 13px/1.45 "Segoe UI", system-ui, sans-serif;
}

.act-panel .muted {
  color: #6b7085;
}

.act-panel-title {
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 14px;
}

.act-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.act-input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid #d5d7e5;
  border-radius: 9px;
  background: #ffffff;
  color: #1f2233;
  font: inherit;
}

.act-preset {
  display: block;
  width: 100%;
  margin: 6px 0;
  padding: 8px 10px;
  border: 1px solid #e3e5f0;
  border-radius: 10px;
  background: #f6f7fc;
  color: #1f2233;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.act-preset:hover {
  border-color: #6366f1;
}

/* ---------------- 📺 TV treo tường (chỉ hiện hình — điều khiển ở máy hát) ---------------- */
.tv {
  position: absolute;
  top: 6px;
  right: 10px;
  width: 262px;
  padding: 8px 8px 5px;
  border-radius: 14px;
  background: linear-gradient(160deg, #3b3346, #262033);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* Trong căn phòng: chỗ + cỡ do room.js tính (TV treo tường ⇄ màn chiếu rạp phim, chuyển có hiệu ứng). */
.room-on .tv {
  left: var(--tv-l, auto);
  top: var(--tv-t, 6px);
  right: auto;
  width: calc(var(--tv-fw, 246px) + 16px);
}

.room-on .tv-frame {
  width: var(--tv-fw, 246px);
  height: var(--tv-fh, 200px);
}

.cin-anim .tv {
  transition: left 0.9s cubic-bezier(0.3, 0.8, 0.3, 1), top 0.9s cubic-bezier(0.3, 0.8, 0.3, 1), width 0.9s cubic-bezier(0.3, 0.8, 0.3, 1), padding 0.9s ease, border-radius 0.9s ease, box-shadow 0.9s ease;
}

.cin-anim .tv-frame {
  transition: width 0.9s cubic-bezier(0.3, 0.8, 0.3, 1), height 0.9s cubic-bezier(0.3, 0.8, 0.3, 1);
}

.tv[hidden] {
  display: none;
}

/* ---------------- 🎬 Màn chiếu rạp phim ---------------- */
.room-on .tv.cinema {
  width: calc(var(--tv-fw, 246px) + 18px);
  padding: 18px 9px 9px;
  border-radius: 6px;
  background: linear-gradient(180deg, #2c2c37 0 13px, #111117 13px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 70px rgba(140, 170, 255, 0.14);
}

/* Hộp cuốn màn chiếu phía trên */
.tv.cinema::before {
  content: "";
  position: absolute;
  left: -10px;
  right: -10px;
  top: -5px;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(180deg, #e3e5ee, #a4a8b9 60%, #7f8396);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}

.room-cinema.cin-playing .tv.cinema {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 120px rgba(150, 180, 255, 0.3);
}

.tv.cinema .tv-frame {
  border-radius: 2px;
}

.tv.cinema .tv-title {
  display: none;
}

/* Núm kéo phóng to / thu nhỏ ở hai góc dưới (trên viền màn, không đè khung phát) */
.cin-grip {
  position: absolute;
  bottom: -13px;
  z-index: 2;
  display: none;
  width: 22px;
  height: 22px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #6366f1;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.15s ease;
  touch-action: none;
}

.cin-grip::before {
  content: "";
  position: absolute;
  inset: 4px;
  background:
    linear-gradient(45deg, transparent 44%, #ffffff 44% 56%, transparent 56%),
    linear-gradient(45deg, transparent 0 18%, #ffffff 18% 30%, transparent 30%) 0 0 / 100% 100%;
}

.cin-grip.l {
  left: -13px;
  cursor: nesw-resize;
}

.cin-grip.r {
  right: -13px;
  cursor: nwse-resize;
}

.cin-grip.r::before {
  transform: scaleX(-1);
}

.tv.cinema .cin-grip {
  display: block;
}

.tv.cinema:hover .cin-grip,
.tv.cinema.resizing .cin-grip {
  opacity: 1;
}

.cin-grip:hover,
.cin-grip.dragging {
  transform: scale(1.18);
}

.stage-wrap.editing .cin-grip {
  display: none;
}

/* ⛶ Cả rạp ra toàn màn hình */
.stage-wrap:fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

.tv.rolling .tv-frame {
  animation: cin-roll 1s cubic-bezier(0.3, 0.8, 0.3, 1) both;
}

@keyframes cin-roll {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0 0 0 0); }
}

/* Màn chiếu trống */
.tv-idle {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 40%, #3a3f5e, #171926 72%);
  color: #e8ebff;
  text-align: center;
}

.tv.cinema:not(.has-video):not(.sharing) .tv-idle {
  display: grid;
}

.tv-idle-icon {
  font-size: 40px;
  line-height: 1;
}

.tv-idle-text {
  font: 700 19px/1.2 "Segoe UI", system-ui, sans-serif;
}

.tv-idle-sub {
  max-width: 440px;
  font-size: 12.5px;
  opacity: 0.75;
}

/* 📺 Hình chiếu màn hình (thay chỗ YouTube, YouTube tạm dừng + ẩn) + con trỏ laze */
.tv-share {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000000;
}

.tv.sharing .tv-share {
  display: block;
}

.tv.sharing .tv-screen {
  visibility: hidden;
}

.tv.sharing .tv-frame {
  cursor: crosshair;
}

.tv-laser {
  position: absolute;
  display: none;
  pointer-events: none;
}

.tv.sharing .tv-laser {
  display: block;
}

.laser-dot {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.25s ease, left 0.06s linear, top 0.06s linear;
}

.laser-dot.on {
  opacity: 1;
}

.laser-dot.me {
  background: radial-gradient(circle, #ffffff 0 18%, #ff4d8d 32%, rgba(255, 77, 141, 0.4) 62%, transparent 72%);
  box-shadow: 0 0 14px 4px rgba(255, 77, 141, 0.5);
}

.laser-dot.peer {
  background: radial-gradient(circle, #ffffff 0 18%, #22d3ee 32%, rgba(34, 211, 238, 0.4) 62%, transparent 72%);
  box-shadow: 0 0 14px 4px rgba(34, 211, 238, 0.5);
}

.laser-name {
  position: absolute;
  left: 16px;
  top: 14px;
  padding: 1px 7px;
  border-radius: 7px;
  background: rgba(8, 10, 20, 0.78);
  color: #ffffff;
  font: 600 11px/1.35 "Segoe UI", system-ui, sans-serif;
  white-space: nowrap;
}

.laser-ring {
  position: absolute;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border: 3px solid #ff4d8d;
  border-radius: 50%;
  animation: laser-ring 0.85s ease-out forwards;
}

.laser-ring.peer {
  border-color: #22d3ee;
}

@keyframes laser-ring {
  from { transform: scale(0.3); opacity: 1; }
  to { transform: scale(1.6); opacity: 0; }
}

/* Thanh điều khiển dưới màn chiếu (ở lớp trên cùng sân khấu; tự ẩn khi đang chiếu) */
.cin-bar {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: var(--cin-bar-y, 60%);
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: max-content;
  max-width: var(--cin-bar-max, 860px);
  padding: 7px 9px;
  border-radius: 14px;
  background: rgba(16, 18, 32, 0.88);
  color: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  font: 12.5px/1.3 "Segoe UI", system-ui, sans-serif;
  transform: translateX(-50%);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.cin-bar[hidden] {
  display: none;
}

.cin-bar.faded {
  opacity: 0;
  transform: translate(-50%, -6px);
  pointer-events: none;
}

/* Màn trống: thanh nằm trong lòng màn chiếu (chưa có khung phát YouTube nên đặt đè được) */
.cin-bar.docked {
  top: auto;
  bottom: var(--cin-bar-dock, 40%);
}

.tv.cinema .tv-idle {
  padding-bottom: 62px;
}

.stage-wrap.editing .cin-bar,
.room-focus .cin-bar {
  display: none;
}

.cin-title {
  max-width: 100%;
  overflow: hidden;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0.92;
}

.cin-title:empty {
  display: none;
}

.cin-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 9px;
  border-radius: 9px;
  background: rgba(255, 196, 0, 0.16);
  color: #ffe39a;
}

.cin-status[hidden] {
  display: none;
}

.cin-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.cin-bar .tv-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.cin-bar .tv-btn:hover {
  background: rgba(255, 255, 255, 0.26);
}

.cin-bar .tv-btn.big {
  background: #6366f1;
}

.cin-bar .tv-time {
  min-width: 84px;
  color: #d7dbf0;
}

.cin-bar .tv-seek {
  flex: 1 1 auto;
  width: 170px;
  min-width: 80px;
}

.cin-bar .tv-vol {
  width: 76px;
}

.cin-btn {
  flex: none;
  padding: 6px 11px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font: 600 12.5px/1.2 "Segoe UI", system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
}

.cin-btn:hover {
  background: rgba(255, 255, 255, 0.26);
}

.cin-btn.primary {
  background: #6366f1;
}

.cin-btn.primary:hover {
  background: #5458e8;
}

.cin-btn.danger {
  background: #e5484d;
}

.cin-btn.danger:hover {
  background: #d63c41;
}

.cin-form {
  display: flex;
  flex: 1 1 auto;
  gap: 6px;
  min-width: 220px;
}

.cin-input {
  flex: 1;
  width: 250px;
  min-width: 0;
  padding: 6px 11px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font: inherit;
}

.cin-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.cin-note {
  font-size: 12px;
  opacity: 0.8;
}

/* Chất lượng hình chiếu: "📶 1080p · 30 hình/giây · 6.2 Mbps" */
.cin-q {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: help;
}

.cin-q.warn {
  background: rgba(245, 158, 11, 0.28);
  color: #ffe2a8;
}

.cin-q[hidden] {
  display: none;
}

/* YouTube yêu cầu khung phát tối thiểu 200×200 px — TV giữ đúng kích thước đó. */
.tv-frame {
  position: relative;
  width: 246px;
  height: 200px;
  overflow: hidden;
  border-radius: 9px;
  background: #000000;
}

.tv-screen,
.tv-screen iframe,
.tv-holder {
  width: 100%;
  height: 100%;
  border: 0;
}

.tv-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 10, 20, 0.72);
  font-size: 13px;
  text-align: center;
}

.tv-overlay[hidden] {
  display: none;
}

.tv-overlay.clickable {
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  background: rgba(99, 102, 241, 0.82);
}

.tv-title {
  margin: 4px 2px 0;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
}

/* ---------------- 🎶 Khung máy hát đĩa than ---------------- */
.vinyl-panel .tv-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
}

.tv-btn {
  flex: none;
  width: 32px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: #f1f2f7;
  color: #1f2233;
  font-size: 14px;
  cursor: pointer;
}

.tv-btn:hover {
  background: #e4e6f2;
}

.tv-btn.big {
  width: 38px;
  background: #6366f1;
  color: #ffffff;
}

.tv-btn.big:hover {
  background: #5458e8;
}

.tv-time {
  flex: none;
  min-width: 78px;
  color: #4b4f66;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tv-seek {
  flex: 1;
  min-width: 30px;
  accent-color: #ff4d6d;
}

.tv-vol {
  width: 96px;
  accent-color: #6366f1;
}

.vinyl-spacer {
  flex: 1;
}

.vinyl-now {
  padding: 8px 10px;
  border-radius: 10px;
  background: #f6f7fc;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vinyl-more summary {
  margin: 4px 0;
  color: #4f46e5;
  font-weight: 600;
  cursor: pointer;
}

.vinyl-records {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 6px 0 8px;
}

.act-preset.vinyl-record {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 8px;
  font-size: 12px;
  line-height: 1.25;
}

.vinyl-disc-icon {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle, #ff8fab 0 22%, #1d1b26 24% 100%);
  box-shadow: inset 0 0 0 3px #2e2b3a, inset 0 0 0 6px #1d1b26, inset 0 0 0 7px #3a3748;
}

.act-panel .btn.danger-ghost {
  background: transparent;
  color: #d64545;
}

/* ---------------- 🍅 Pomodoro ---------------- */
.pomo-clock {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 190px;
  padding: 8px 14px 10px;
  border: 4px solid #6d4c41;
  border-radius: 14px;
  background: #fffaf0;
  color: #3b3346;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.pomo-clock[hidden] {
  display: none;
}

.pomo-clock.break {
  border-color: #2f9e74;
  background: #effbf5;
}

.pomo-phase {
  font-weight: 700;
  font-size: 12px;
}

.pomo-time {
  font: 800 30px/1.1 "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  color: #d9480f;
}

.pomo-clock.break .pomo-time {
  color: #2f9e74;
}

.pomo-members {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}

.pomo-member {
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  font-size: 11px;
  white-space: nowrap;
}

.pomo-member.away {
  opacity: 0.6;
}

.room-on .pomo-clock {
  top: var(--clock-y, 10px);
  left: var(--clock-x, 50%);
  min-width: 136px;
  padding: 6px 10px 8px;
  transform: translateX(-50%) scale(var(--k, 1));
  transform-origin: 50% 0;
}

.room-on .pomo-time {
  font-size: 26px;
}

/* Rạp phim: màn chiếu chiếm giữa tường → bảng đếm giờ thu nhỏ vào góc trái (không đè lên khung phát). */
.room-on.room-cinema .pomo-clock {
  top: 8px;
  left: calc(var(--bx0, 10px) + 6px);
  transform: scale(calc(var(--k, 1) * 0.8));
  transform-origin: 0 0;
}

/* ---------------- 🎨 Bảng trắng + cờ ---------------- */
.board-badge {
  position: absolute;
  right: -8px;
  bottom: -10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font: 700 11px/1.4 "Segoe UI", sans-serif;
  animation: board-pulse 1.2s ease-in-out infinite;
}

.board-badge[hidden] {
  display: none;
}

@keyframes board-pulse {
  50% { transform: scale(1.1); }
}

.board-overlay {
  position: absolute;
  z-index: 60;
  inset: 3% 5%;
  display: flex;
  flex-direction: column;
  border: 8px solid #6d4c41;
  border-radius: 14px;
  background: #ffffff;
  color: #1f2233;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  font: 13px/1.4 "Segoe UI", system-ui, sans-serif;
}

.board-overlay[hidden] {
  display: none;
}

.board-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid #ebebf2;
}

.board-tabs {
  display: flex;
  flex: 1;
  gap: 4px;
}

.board-tab {
  padding: 6px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #4b4f66;
  font: 600 13px/1.2 "Segoe UI", sans-serif;
  cursor: pointer;
}

.board-tab.active {
  background: #eef0ff;
  color: #4f46e5;
}

.board-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: #f1f2f7;
  color: #1f2233;
  font-size: 14px;
  cursor: pointer;
}

.board-body {
  flex: 1;
  min-height: 0;
  container: boardbody / size;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  overflow: auto;
}

.board-canvas-wrap {
  width: min(100cqw - 10px, (100cqh - 60px) * 1.6, 760px);
}

.board-canvas {
  display: block;
  border-radius: 6px;
  background: #fbfbf7;
  box-shadow: inset 0 0 0 1px #e6e6ee;
  cursor: crosshair;
  touch-action: none;
}

.board-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.board-color {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  cursor: pointer;
}

.board-color.selected {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #6366f1;
}

.board-width {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #e3e5f0;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.board-width span {
  display: block;
  border-radius: 50%;
  background: #1f2233;
}

.board-width.selected {
  border-color: #6366f1;
  background: #eef0ff;
}

.board-sep {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: #e3e5f0;
}

/* Bảng và popover luôn nền trắng → nút có màu riêng, không theo giao diện tối. */
.board-overlay .btn.secondary,
.act-panel .btn.secondary {
  background: #eef0ff;
  color: #4f46e5;
}

.board-overlay .btn.ghost,
.act-panel .btn.ghost {
  background: #f1f2f7;
  color: #1f2233;
}

.board-overlay .btn.danger-ghost {
  background: transparent;
  color: #d64545;
}

.game-start {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: auto;
  max-width: 360px;
  text-align: center;
}

.game-start-icon {
  font-size: 40px;
}

.game-status {
  font-weight: 700;
  font-size: 15px;
}

.game-status.my-turn {
  color: #16a36a;
}

.game-grid {
  display: grid;
  container-type: inline-size;
  gap: 3px;
  width: min(100cqw - 10px, 100cqh - 96px, 460px);
  aspect-ratio: 1;
  padding: 3px;
  border-radius: 8px;
  background: #d9dbe7;
}

/* Ô vuông đều nhau; cỡ quân cờ theo cỡ ô (100cqw = bề rộng bàn cờ). */
.game-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: #ffffff;
  font: 800 calc(100cqw / var(--n, 3) * 0.55) / 1 "Segoe UI", sans-serif;
  cursor: pointer;
}

.game-grid.size-12 .game-cell {
  border-radius: 2px;
}

.game-cell:disabled {
  cursor: default;
}

.game-cell:not(:disabled):hover {
  background: #eef0ff;
}

.game-cell.x {
  color: #ef4444;
}

.game-cell.o {
  color: #3b82f6;
}

.game-cell.last {
  box-shadow: inset 0 0 0 2px #f59e0b;
}

.game-cell.win {
  background: #fff3bf;
}

/* ---------------- 🎯 Vẽ & đoán ---------------- */
/* Bốn tab trong một hàng: màn hình hẹp thì cuộn ngang thay vì tràn ra ngoài. */
.board-tabs {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.board-tabs::-webkit-scrollbar {
  display: none;
}

.board-tab {
  position: relative;
  flex: none;
  white-space: nowrap;
}

.board-tab-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: board-pulse 1.2s ease-in-out infinite;
}

@media (max-width: 520px) {
  .board-tab {
    padding: 6px 9px;
    font-size: 12px;
  }
}

/* Khung vẽ nhỏ gọn: chừa chỗ cho thanh trạng thái, hàng chữ gạch dưới và ô nhập đoán. */
.board-canvas-wrap.compact {
  width: max(180px, min(100cqw - 10px, (100cqh - 290px) * 1.6, 640px));
}

.board-canvas.readonly {
  cursor: default;
  touch-action: auto;
}

.board-locknote {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 520px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #fff7e0;
  color: #7a5200;
  text-align: center;
}

.guess {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

/* Ba khối của màn vẽ / lộ từ: top (trạng thái, từ, đồng hồ) · main (khung vẽ) · low (nút, lần đoán, ô nhập). Màn hẹp xếp dọc. */
.guess-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

/* Chữ / ô gạch dưới co theo bề rộng khối này (không theo cả bảng) */
.guess-pane.top {
  container-type: inline-size;
}

/* Màn rộng (máy tính): khung vẽ bên trái, trạng thái + từ + lần đoán + ô nhập bên phải. */
@container boardbody (min-width: 780px) {
  .guess.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "main top" "main low";
    align-items: start;
    gap: 10px 22px;
    max-width: 1080px;
  }

  .guess-pane.main {
    grid-area: main;
    align-self: center;
  }

  .guess-pane.top {
    grid-area: top;
  }

  .guess-pane.low {
    grid-area: low;
    min-height: 0;
  }

  .guess.split .board-canvas-wrap.compact {
    width: max(240px, min(100%, (100cqh - 80px) * 1.6));
  }

  .guess.split .guess-timerrow,
  .guess.split .guess-list,
  .guess.split .guess-say {
    width: 100%;
  }

  .guess.split .guess-list {
    max-height: 30cqh;
  }
}

/* Màn chọn từ / chờ / lộ từ: canh giữa theo chiều dọc cho đỡ trống phía dưới (màn đang vẽ thì canh trên cùng). */
.guess.center {
  margin-block: auto;
}

.guess-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.guess-grow {
  flex: 1;
}

.guess-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eef0ff;
  color: #4f46e5;
  font-weight: 700;
  font-size: 12px;
}

.guess-chip.good {
  background: #e3f7ec;
  color: #11804f;
}

.guess-chip.soft {
  background: #f1f2f7;
  color: #4b4f66;
}

.guess-quit {
  padding: 3px 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #8a8fa6;
  font: 600 12px/1.4 "Segoe UI", sans-serif;
  cursor: pointer;
}

.guess-quit:hover {
  background: #f1f2f7;
  color: #d64545;
}

.guess-title {
  font-weight: 800;
  font-size: 20px;
}

.guess-sub {
  color: #4b4f66;
}

.guess-rounds {
  display: flex;
  gap: 6px;
}

.guess-round {
  padding: 6px 14px;
  border: 2px solid #e3e5f0;
  border-radius: 999px;
  background: #ffffff;
  color: #4b4f66;
  font: 700 13px/1.2 "Segoe UI", sans-serif;
  cursor: pointer;
}

.guess-round.selected {
  border-color: #6366f1;
  background: #eef0ff;
  color: #4f46e5;
}

/* Đồng hồ vẽ: thanh chạy ngược, vàng khi còn ít, đỏ + nhấp nháy khi sắp hết. */
.guess-timerrow {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(100%, 520px);
}

.guess-timer {
  flex: 1;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9ebf5;
}

.guess-timer-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #16a36a;
  transition: width 0.25s linear, background-color 0.4s;
}

.guess-timer[data-level="warn"] .guess-timer-fill {
  background: #f59e0b;
}

.guess-timer[data-level="danger"] .guess-timer-fill {
  background: #ef4444;
  animation: board-pulse 0.6s ease-in-out infinite;
}

.guess-time {
  min-width: 52px;
  font: 700 13px/1 "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Người vẽ: từ của mình ở trên, thật to. */
.guess-wordbox {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 4px 10px;
  max-width: 100%;
  padding: 6px 16px;
  border-radius: 14px;
  background: #eef0ff;
}

.guess-wordlabel,
.guess-lv {
  color: #6b6f89;
  font-size: 12px;
  font-weight: 600;
}

.guess-word {
  color: #4f46e5;
  font-weight: 800;
  font-size: clamp(20px, 6cqw, 30px);
  overflow-wrap: anywhere;
}

/* Người đoán: hàng ô gạch dưới — chữ đã được gợi ý hiện trong ô. */
.guess-mask {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 6px 18px;
  min-height: 30px;
}

.guess-group {
  display: inline-flex;
  gap: 4px;
}

.guess-letter {
  display: inline-grid;
  place-items: end center;
  width: clamp(16px, 4.6cqw, 28px);
  height: clamp(26px, 7cqw, 38px);
  border-bottom: 3px solid #1f2233;
  font-weight: 800;
  font-size: clamp(16px, 5cqw, 26px);
  line-height: 1.1;
  text-transform: uppercase;
}

.guess-letter.shown {
  color: #4f46e5;
  border-bottom-color: #6366f1;
}

.guess-meta {
  color: #6b6f89;
  font-size: 12px;
}

.guess-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Các lần đoán: như khung chat nhỏ. */
.guess-list {
  width: min(100%, 520px);
  max-height: 96px;
  min-height: 30px;
  overflow-y: auto;
  padding: 5px 8px;
  border-radius: 10px;
  background: #f6f7fb;
  box-shadow: inset 0 0 0 1px #e6e6ee;
}

.guess-empty {
  padding: 4px 0;
  color: #8a8fa6;
  font-size: 12px;
  text-align: center;
}

.guess-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  padding: 1px 0;
  font-size: 13px;
}

.guess-by {
  color: #8a8fa6;
  font-size: 11px;
  font-weight: 700;
}

.guess-line.mine .guess-by {
  color: #6366f1;
}

.guess-text {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.guess-tag {
  color: #d97706;
  font-size: 12px;
  font-weight: 700;
}

.guess-line.ok .guess-tag {
  color: #11804f;
}

/* Ô nhập đoán dính đáy vùng cuộn → bàn phím điện thoại hiện lên vẫn thấy ô nhập. */
.guess-say {
  position: sticky;
  bottom: -10px;
  z-index: 2;
  display: flex;
  gap: 6px;
  width: min(100%, 520px);
  padding: 6px 0 4px;
  background: #ffffff;
}

.guess-say .guess-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 2px solid #d9dcec;
  border-radius: 10px;
  background: #ffffff;
  color: #1f2233;
  font: 16px/1.2 "Segoe UI", system-ui, sans-serif; /* ≥ 16px: iOS không tự phóng to khi bấm vào ô */
}

.guess-say .guess-input::placeholder {
  color: #9a9db3;
}

.guess-say .guess-input:focus {
  border-color: #6366f1;
  outline: none;
}

/* Đang chọn từ */
.guess-wait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 18px 0;
  text-align: center;
}

.guess-wait-icon {
  font-size: 44px;
  animation: board-pulse 1.6s ease-in-out infinite;
}

.guess-wait-text {
  font-weight: 700;
  font-size: 15px;
}

.guess-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: min(100%, 560px);
}

.guess-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 96px;
  padding: 12px 8px;
  border: 2px solid #e3e5f0;
  border-radius: 14px;
  background: #ffffff;
  color: #1f2233;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}

.guess-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: #6366f1;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.22);
}

.guess-card-lv {
  padding: 2px 10px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
}

.guess-card.lv-easy .guess-card-lv {
  background: #16a36a;
}

.guess-card.lv-medium .guess-card-lv {
  background: #d97706;
}

.guess-card.lv-hard .guess-card-lv {
  background: #e11d48;
}

.guess-card-word {
  font-weight: 800;
  font-size: 18px;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

/* Màn lộ từ + tổng kết */
.guess-banner {
  padding: 6px 16px;
  border-radius: 999px;
  background: #f1f2f7;
  font-weight: 800;
  font-size: 15px;
  text-align: center;
}

.guess-banner.solved {
  background: #e3f7ec;
  color: #11804f;
}

.guess-banner.timeout {
  background: #fff3d6;
  color: #9a5b00;
}

.guess-reveal-label {
  color: #8a8fa6;
  font-size: 12px;
}

.guess-bigword {
  color: #4f46e5;
  font-weight: 800;
  font-size: clamp(24px, 8cqw, 40px);
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.guess-final {
  margin: auto;
}

.guess-history {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: min(100%, 420px);
  max-height: 34cqh;
  overflow-y: auto;
}

.guess-hrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 10px;
  background: #f6f7fb;
}

.guess-hrow.solved {
  background: #e9f8f0;
}

.guess-hword {
  flex: 1;
  font-weight: 700;
}

.guess-hmeta {
  color: #8a8fa6;
  font-size: 12px;
}

/* Pháo giấy nhẹ khi đoán đúng */
.guess-confetti {
  position: absolute;
  z-index: 70;
  inset: 0;
  overflow: hidden;
  border-radius: 6px;
  pointer-events: none;
}

.guess-confetti span {
  position: absolute;
  top: -8%;
  animation: guess-fall 2.2s ease-in forwards;
}

@keyframes guess-fall {
  0% { top: -8%; transform: rotate(0deg); opacity: 1; }
  85% { opacity: 1; }
  100% { top: 105%; transform: rotate(380deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .guess-confetti { display: none; }
  .guess-wait-icon,
  .guess-timer[data-level="danger"] .guess-timer-fill,
  .board-tab-dot { animation: none; }
}

/* Khung hẹp (điện thoại): thẻ từ xếp dọc, bớt khoảng cách. */
@container boardbody (max-width: 480px) {
  .guess {
    gap: 6px;
  }

  .guess-cards {
    grid-template-columns: 1fr;
  }

  .guess-card {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    min-height: 0;
    padding: 10px 14px;
  }

  .guess-card-word {
    text-align: left;
  }

  .guess-list {
    max-height: 72px;
  }
}

/* ---------------- 🐾 Thú cưng ---------------- */
.pet {
  position: absolute;
  z-index: 5;
  bottom: 4px;
  left: 20px;
  width: 92px;
  height: 70px;
  transition-property: left;
  transition-timing-function: linear;
  cursor: pointer;
}

.pet[hidden] {
  display: none;
}

.pet-art {
  width: 100%;
  height: 100%;
}

.pet-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  transition: transform 0.25s ease;
}

.pet.face-left .pet-svg {
  transform: scaleX(-1);
}

.pet-name {
  position: absolute;
  left: 50%;
  bottom: -2px;
  transform: translateX(-50%);
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(22, 24, 38, 0.65);
  color: #ffffff;
  font: 600 10px/1.5 "Segoe UI", sans-serif;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.pet:hover .pet-name {
  opacity: 1;
}

.pet-bubble {
  position: absolute;
  top: -22px;
  right: 2px;
  min-width: 0;
  font-size: 18px;
  line-height: 1;
  animation: pet-think 2.4s ease-in-out infinite;
}

.pet-bubble:empty {
  display: none;
}

@keyframes pet-think {
  0%, 100% { transform: translateY(0); opacity: 0.85; }
  50% { transform: translateY(-4px); opacity: 1; }
}

.pet-eyes-happy,
.pet-eyes-x {
  display: none;
}

.pet.happy .pet-eyes-open,
.pet.eating .pet-eyes-open {
  display: none;
}

.pet.happy .pet-eyes-happy,
.pet.eating .pet-eyes-happy {
  display: inline;
}

.pet-tail {
  animation: pet-wag 1.2s ease-in-out infinite;
}

.pet.happy .pet-tail,
.pet.walking .pet-tail {
  animation-duration: 0.4s;
}

@keyframes pet-wag {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(12deg); }
}

.pet.walking .pet-body {
  animation: pet-bob 0.36s ease-in-out infinite;
}

.pet.walking .pet-leg-b1,
.pet.walking .pet-leg-f2 {
  animation: pet-step 0.36s ease-in-out infinite;
}

.pet.walking .pet-leg-b2,
.pet.walking .pet-leg-f1 {
  animation: pet-step 0.36s ease-in-out -0.18s infinite;
}

@keyframes pet-bob {
  50% { transform: translateY(-2px); }
}

@keyframes pet-step {
  0%, 100% { transform: rotate(-22deg); }
  50% { transform: rotate(22deg); }
}

.pet.eating .pet-head {
  animation: pet-eat 0.3s ease-in-out 6;
}

@keyframes pet-eat {
  0%, 100% { transform: rotate(10deg) translateY(4px); }
  50% { transform: rotate(22deg) translateY(8px); }
}

.pet.happy .pet-body {
  animation: pet-hop 0.5s ease-in-out 3;
}

@keyframes pet-hop {
  50% { transform: translateY(-8px); }
}

.pet.status-hungry .pet-body {
  filter: saturate(0.8);
}

/* Xỉu: nằm ngửa, chân chổng lên trời, mắt ✕ (vui thôi — cho ăn là tỉnh). */
.pet.status-fainted .pet-body {
  transform: translateY(44px) rotate(180deg);
  transform-origin: 58px 40px;
  transform-box: view-box;
}

.pet.status-fainted .pet-eyes-open,
.pet.status-fainted .pet-eyes-happy {
  display: none;
}

.pet.status-fainted .pet-eyes-x {
  display: inline;
}

.pet.status-fainted .pet-tail {
  animation: none;
}

.pet-fx {
  position: absolute;
  top: 0;
  font-size: 16px;
  pointer-events: none;
  animation: pet-fx 1.8s ease-out forwards;
  opacity: 0;
}

@keyframes pet-fx {
  0% { opacity: 0; transform: translateY(0) scale(0.6); }
  20% { opacity: 1; transform: translateY(-8px) scale(1); }
  100% { opacity: 0; transform: translateY(-46px) scale(1.1); }
}

.pet-status {
  margin-bottom: 4px;
  font-weight: 600;
}

.pet-species {
  display: flex;
  gap: 6px;
  margin: 10px 0 4px;
}

.pet-choice {
  flex: 1;
  padding: 8px 6px;
  border: 1.5px solid #e3e5f0;
  border-radius: 10px;
  background: #f6f7fc;
  color: #1f2233;
  font: 600 13px/1.2 "Segoe UI", sans-serif;
  cursor: pointer;
}

.pet-choice.selected {
  border-color: #6366f1;
  background: #eef0ff;
}

/* ---------------- Biệt danh ---------------- */
.friend-real {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 400;
}

.sound-toggle {
  min-width: 40px;
}

/* Ô nhập trong popover / hộp thoại nền trắng: không theo màu giao diện tối của trang. */
.act-panel .act-input,
.sbs-pop .sbs-input {
  background: #ffffff;
  color: #1f2233;
  border: 1px solid #d5d7e5;
}

.act-panel .act-input::placeholder,
.sbs-pop .sbs-input::placeholder {
  color: #9a9db3;
}
