/* Cùng bảng màu/khuôn với public/games/vua-tieng-viet/style.css (theme trang
   host khai lại bằng hex — bundle chạy độc lập trong iframe, không có
   Tailwind/CSS variables của trang host). */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family:
    'Be Vietnam Pro',
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  background: #fff8ed;
  color: #4a3b5c;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  user-select: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 16px;
  border: 2px solid #ffe1c2;
  background: #ffffff;
  box-shadow: 0 4px 0 #e7dcc7;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lives {
  display: flex;
  gap: 2px;
  font-size: 18px;
  line-height: 1;
  color: #e0554a;
}

.lives .heart.empty {
  color: #ffd8d3;
}

.timer {
  min-width: 46px;
  text-align: center;
  padding: 5px 10px;
  border-radius: 999px;
  border: 2px solid #ffe1c2;
  background: #fff8ed;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.timer.low {
  background: #ffe9e6;
  border-color: #e0554a;
  color: #c23f36;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

.play-area {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Toast dùng chung cho CẢ 2 việc: báo "phản ứng" mỗi khi ghép đúng 1 cặp
   (hiện tên sản phẩm — vừa khen vừa dạy) VÀ báo qua vòng — 2 sự kiện này
   không bao giờ trùng lúc nên dùng chung 1 phần tử cho gọn (xem
   showToast() trong game.js). */
.round-banner {
  position: absolute;
  top: 6px;
  left: 50%;
  z-index: 2;
  padding: 10px 20px;
  border-radius: 999px;
  background: #4a3b5c;
  color: #fff8ed;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -14px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.round-banner.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.bench-card {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 22px;
  border: 2px solid #ffe1c2;
  background: #ffffff;
  box-shadow: 0 4px 0 #e7dcc7;
}

.bench-hint {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #7a6a8c;
}

/* 4x3 (12 ô = 6 cặp/vòng, xem game.js — cỡ bàn lớn nhất còn đảm bảo mọi vòng
   sạch 100%, không dính "cặp giả"; xem giải thích dài ở đầu game.js). */
/* Số chất ban đầu khác nhau tuỳ vòng (3 -> 14, xem ROUNDS trong game.js) —
   auto-fit (không phải auto-fill) tự co giãn số cột vừa khít bề rộng VÀ gộp
   hết các cột trống lại (auto-fill để lại "cột ma" rỗng chiếm chỗ khi vòng
   ít chất, làm dãy ô bị dồn lệch sang trái thay vì giãn đều hết bề ngang). */
.bench {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

/* Mỗi ô là 1 chất phản ứng — icon gợi ý LOẠI chất (kim loại/khí/dung dịch...)
   nhưng KHÔNG tô màu theo đúng cặp phản ứng (sẽ lộ đáp án) — chỉ xoay vòng
   4 sắc thái trung tính cho vui mắt, giống ghep-cap-so/style.css. */
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 78px;
  padding: 8px 6px;
  border-radius: 16px;
  border: 2px solid #ffe1c2;
  background: #ffffff;
  color: #4a3b5c;
  font-family: inherit;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    opacity 0.2s ease,
    visibility 0.2s ease;
}

.tile-icon {
  font-size: 22px;
  line-height: 1;
}

.tile-label {
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
}

.tile.hue-0 {
  background: #eafaf3;
  border-color: #7bd8b0;
}

.tile.hue-1 {
  background: #eaf7fd;
  border-color: #5ec8f2;
}

.tile.hue-2 {
  background: #fff8e3;
  border-color: #ffc857;
}

.tile.hue-3 {
  background: #fff0ec;
  border-color: #ff8e6c;
}

.tile:hover:not(.matched):not(.selected):not(.wrong) {
  transform: translateY(-3px);
}

.tile.selected {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 0 0 3px rgba(74, 59, 92, 0.35);
}

.tile.wrong {
  border-color: #e0554a;
  background: #fdecea;
  box-shadow: 0 4px 0 #e0554a;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

/* Ô sản phẩm phụ (khí/rắn) — chỉ hiện thoáng qua rồi tự biến mất (game.js
   tự gỡ sau BYPRODUCT_MS, không cần người chơi thao tác), không nhận click
   (`disabled`) nên bỏ luôn con trỏ tay + hiệu ứng hover của `.tile` thường.
   Khí (`--gas`) bay lên + mờ dần; rắn (`--solid`) lắng xuống + mờ dần —
   2 hướng chuyển động ngược nhau cho dễ phân biệt trạng thái vật chất. */
.tile.byproduct {
  cursor: default;
  border-style: dashed;
}

.tile.byproduct--gas {
  background: #eaf7fd;
  border-color: #5ec8f2;
  animation: byproduct-gas 0.9s ease forwards;
}

@keyframes byproduct-gas {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-26px);
  }
}

.tile.byproduct--solid {
  background: #fff3e0;
  border-color: #d9a441;
  animation: byproduct-solid 0.9s ease forwards;
}

@keyframes byproduct-solid {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(16px);
  }
}

/* Lọ "hết tác dụng" (không còn phản ứng được với gì trên bàn) — xám, mờ
   dần tại chỗ (không bay lên/lắng xuống như khí/rắn thật) để rõ đây KHÔNG
   phải là 1 sản phẩm mới tạo ra, chỉ là dọn dẹp phần không dùng được nữa. */
.tile.byproduct--inert {
  background: #f2f0f4;
  border-color: #c9c2d6;
  color: #9b93ab;
  animation: byproduct-inert 0.7s ease forwards;
}

@keyframes byproduct-inert {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.85);
  }
}

.dialog {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(74, 59, 92, 0.45);
}

.dialog[hidden] {
  display: none;
}

.dialog-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 30px;
  max-width: 80%;
  border-radius: 26px;
  border: 2px solid #ffe1c2;
  background: #ffffff;
  box-shadow: 0 6px 0 #e7dcc7;
}

.dialog-card p {
  margin: 0;
  text-align: center;
}

#game-over-text {
  font-size: 18px;
  font-weight: 800;
}

#game-over-detail {
  font-size: 13px;
  font-weight: 600;
  color: #7a6a8c;
}

.dialog-card button {
  border: none;
  border-radius: 999px;
  padding: 9px 22px;
  font-size: 14px;
  font-weight: 700;
  color: #4a3b5c;
  background: #ff8e6c;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    opacity 0.12s ease;
}

.dialog-card button:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}
