/* Cùng bảng màu/khuôn với public/games/ghep-cap-so/style.css và
   public/games/luyen-tu-vung-anh/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: 10px;
  padding: 10px;
}

/* Bản đồ thế giới trang trí (mỗi châu lục 1 màu, xem game.js) — nằm dưới
   cùng nhờ là phần tử đầu tiên trong <body> (thứ tự DOM quyết định lớp vẽ,
   không cần z-index). Độ mờ đủ thấp để không đè lên độ tương phản của chữ
   nổi trực tiếp trên nền (prompt/tên nước không có nền trắng riêng). */
.map-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0.22;
  pointer-events: none;
}

/* `position: relative` trên `.topbar`/`.timer-track`/`.stage`/`.answer-area`/
   `.feedback` (mọi con trực tiếp của <body> ngoài `.map-bg`/`.game-over`) —
   bắt buộc để vẽ TRÊN `.map-bg` (position: absolute): phần tử có position
   luôn vẽ sau/trên phần tử static dù đứng trước trong DOM. Trước khi thêm,
   lỗi này vẫn tồn tại nhưng không thấy rõ vì `.map-bg` chỉ opacity 0.22 (chữ
   vẫn đọc được, chỉ bị ám màu bản đồ rất nhẹ) — phát hiện khi debug lỗi
   tương tự nhưng rõ rệt hơn hẳn ở fruit-box/style.css (opacity 0.85). */
.topbar {
  position: relative;
  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;
}

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

/* Icon Heart/HeartCrack (lucide, xem game.js) đổi qua lại theo mạng còn/hết
   — màu đặt ở đây vì SVG dùng `stroke="currentColor"`. Nhịp đập nhẹ liên tục
   nhắc "chỉ có 1 mạng", không cần tắt thủ công lúc thua (icon đổi hình luôn,
   animation vẫn chạy nhưng vô hại trên icon đã vỡ). */
.lives-stat {
  display: inline-flex;
  align-items: center;
  color: #e0554a;
  animation: heartbeat 1.6s ease-in-out infinite;
}

@keyframes heartbeat {
  0%,
  100% {
    transform: scale(1);
  }
  15% {
    transform: scale(1.2);
  }
  30% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.12);
  }
  60% {
    transform: scale(1);
  }
}

.timer-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: #ffe9d3;
  overflow: hidden;
  flex-shrink: 0;
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: #7bd8b0;
  transition:
    width 0.1s linear,
    background 0.2s ease;
}

.timer-bar.warn {
  background: #ffc857;
}

.timer-bar.danger {
  background: #e0554a;
  animation: timer-pulse 0.5s ease-in-out infinite;
}

@keyframes timer-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.prompt-text {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #4a3b5c;
}

.stage-display.name-display {
  font-size: min(6vh, 40px);
  font-weight: 800;
  font-family: 'Fredoka', 'Be Vietnam Pro', sans-serif;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Ảnh cờ lấy từ flagcdn.com (game.js) — nền trắng + bo góc + đổ bóng để làm
   thành 1 "thẻ" nổi trên nền bản đồ màu, không phụ thuộc tỉ lệ khung hình
   thật của từng lá cờ (khác nhau theo nước). */
.flag-img {
  height: min(22vh, 150px);
  width: auto;
  max-width: 90%;
  border-radius: 10px;
  background: #ffffff;
  padding: 6px;
  box-shadow: 0 4px 0 #e7dcc7;
  object-fit: contain;
}

.answer-area {
  position: relative;
  flex-shrink: 0;
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
}

.choice-btn {
  padding: 14px 10px;
  border-radius: 20px;
  border: 3px solid #ffe1c2;
  background: #ffffff;
  color: #4a3b5c;
  font-family: inherit;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 0 #e7dcc7;
  animation: pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  transition:
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.15s ease,
    color 0.15s ease;
}

/* Mỗi ô 1 màu kẹo riêng (không phân biệt chọn cờ/chọn tên — cùng 1 bộ 4 màu)
   cho "ngộ nghĩnh" hơn khối trắng đơn điệu trước đây; `.choices` luôn đúng 4
   nút (`CHOICE_COUNT` trong game.js) nên nth-child(1..4) phủ hết. */
.choices .choice-btn:nth-child(1) {
  background: #ffd6e8;
  border-color: #ff8fc2;
}

.choices .choice-btn:nth-child(2) {
  background: #d2f5e3;
  border-color: #4fd1a5;
}

.choices .choice-btn:nth-child(3) {
  background: #fff3c4;
  border-color: #ffc93c;
}

.choices .choice-btn:nth-child(4) {
  background: #d3e8ff;
  border-color: #5fa8ff;
}

.choice-btn:nth-child(2) {
  animation-delay: 0.05s;
}

.choice-btn:nth-child(3) {
  animation-delay: 0.1s;
}

.choice-btn:nth-child(4) {
  animation-delay: 0.15s;
}

@keyframes pop-in {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  70% {
    transform: scale(1.08);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

.choice-btn.flag-choice {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flag-thumb {
  height: 44px;
  width: auto;
  border-radius: 6px;
  box-shadow: 0 2px 0 #e7dcc7;
}

.choice-btn:not(:disabled):hover {
  transform: scale(1.06) translateY(-2px);
}

.choice-btn:not(:disabled):active {
  transform: scale(0.94) translateY(1px);
  box-shadow: 0 2px 0 #e7dcc7;
}

.choices .choice-btn.correct {
  background: #7bd8b0;
  color: #ffffff;
  border-color: #7bd8b0;
}

.choices .choice-btn.wrong {
  background: #e0554a;
  color: #ffffff;
  border-color: #e0554a;
  animation: shake 0.3s ease;
}

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

.type-form {
  display: flex;
  gap: 8px;
  max-width: 420px;
  margin: 0 auto;
}

.type-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 999px;
  border: 2px solid #ffe1c2;
  background: #ffffff;
  color: #4a3b5c;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
}

.type-input:focus {
  outline: none;
  border-color: #ffc857;
}

.type-submit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 3px solid #ff8fc2;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 800;
  color: #4a3b5c;
  background: #ffd6e8;
  cursor: pointer;
  transition:
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.12s ease;
}

.type-submit:not(:disabled):hover {
  transform: scale(1.06) translateY(-1px);
  opacity: 0.92;
}

.type-submit:not(:disabled):active {
  transform: scale(0.94);
}

.feedback {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  text-align: center;
  padding: 8px 14px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
}

.feedback-flag {
  height: 22px;
  width: auto;
  border-radius: 4px;
  vertical-align: middle;
}

.feedback.correct {
  background: #eafff5;
  color: #2f9e6f;
}

.feedback.wrong {
  background: #fdeceb;
  color: #c73f34;
}

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

.game-over[hidden] {
  display: none;
}

.game-over-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 30px;
  border-radius: 26px;
  border: 2px solid #ffe1c2;
  background: #ffffff;
  box-shadow: 0 6px 0 #e7dcc7;
}

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

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

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

.game-over button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 3px solid #ffc93c;
  border-radius: 999px;
  padding: 9px 22px;
  font-size: 15px;
  font-weight: 800;
  color: #4a3b5c;
  background: #fff3c4;
  cursor: pointer;
  transition:
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.12s ease;
}

.game-over button:hover {
  transform: scale(1.08) translateY(-1px);
  opacity: 0.92;
}

.game-over button:active {
  transform: scale(0.94);
}
