:root {
  color-scheme: only light;
  forced-color-adjust: none;
  --bg-top: #b4d2ee;
  --bg-mid: #c8dcee;
  --bg-bot: #dae4ee;
  --surface: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.14);
  --text: #f3f6fc;
  --muted: rgba(243, 246, 252, 0.7);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% 43%, #9591d4 0%, #6d69b0 55%, #4a4784 100%);
}

#scene-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ===== TOP HUD ===== */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

#top-meta {
  display: none;
}

#level-pill {
  display: none;
}

/* ===== COLOR BOXES (HỘP KIỂU ĐỒNG HỒ BÁO THỨC — theo mẫu của Bình) ===== */
#boxes {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 4px auto 0;
  padding: 33px 9px 16px;
  width: max-content;
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
  border-radius: 18px;
  /* [Claude] bình 5/12 00:15: bỏ khung bao quanh 4 đồng hồ */
  background: none;
  box-shadow: none;
  pointer-events: auto;
}

.box {
  position: relative;
  isolation: isolate;
  /* [Claude] bình 4/12 22:26: đinh trong đồng hồ hơi nhỏ -> đồng hồ 82 -> 90px, đinh theo tỉ lệ hộp */
  --bw: min(20.5vw, 86px);
  width: var(--bw);
  height: var(--bw);
  margin: 0;
  padding: 0;
  border-radius: 50%;
  box-sizing: border-box;
  --c: #64748b;
  /* [Claude] bình 4/12: vỏ đồng hồ trông nhạt hơn đinh -> vỏ đậm hơn 9% cho khớp đinh có bóng sáng tối */
  --cr: color-mix(in srgb, var(--c) 91%, #000);
  --dk: color-mix(in srgb, var(--c) 58%, #000);
  --lt: color-mix(in srgb, var(--c) 75%, #fff);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* [Claude] bình 4/12: đồng hồ = ảnh Gemini của bình (ui/dongho-*.png), tô sẵn 8 màu + bản khoá "MỞ KHÓA".
   Ảnh căn sao cho mặt kem (tâm 538,813 r434 trên ảnh 1070x1390 gốc) trùng mặt 70px giữa hộp 82px -> lỗ đinh giữ nguyên. */
.box::before {
  content: "";
  position: absolute;
  /* bình 4/12 23:01: viền dày thêm 50% (ảnh kéo viền ra ngoài, mặt kem giữ nguyên) */
  left: -6.85%;
  top: -33.9%;
  width: 113.11%;
  height: 144.58%;
  z-index: -1;
  pointer-events: none;
  background: var(--img, url(ui/dongho-trong.png?v=2)) center / 100% 100% no-repeat;
  image-rendering: -webkit-optimize-contrast;
  backface-visibility: hidden;
  transform: translateZ(0);
  will-change: transform;
}
.box[data-ci="0"] { --img: url(ui/dongho-0.png?v=2); }
.box[data-ci="1"] { --img: url(ui/dongho-1.png?v=2); }
.box[data-ci="2"] { --img: url(ui/dongho-2.png?v=2); }
.box[data-ci="3"] { --img: url(ui/dongho-3.png?v=2); }
.box[data-ci="4"] { --img: url(ui/dongho-4.png?v=2); }
.box[data-ci="5"] { --img: url(ui/dongho-5.png?v=2); }
.box[data-ci="6"] { --img: url(ui/dongho-6.png?v=2); }
.box[data-ci="7"] { --img: url(ui/dongho-7.png?v=2); }
.box[data-ci="8"] { --img: url(ui/dongho-8.png?v=2); }
.box[data-ci="9"] { --img: url(ui/dongho-9.png?v=2); }
.box.locked { --img: url(ui/dongho-khoa.png?v=2); }
.box.locked .lock-plus, .box.locked small { visibility: hidden; }

.slot {
  position: absolute;
  z-index: 2;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  /* [Claude] bình 4/12: lỗ đen nhìn ghê -> lỗ cùng màu nền game (xanh slate) */
  background: radial-gradient(circle at 50% 40%, #252d40 50%, #323d57); /* lỗ = màu nền xanh than */
  box-shadow:
    0 0 0 1.5px #d9c8a6,
    0 1px 0 1.5px rgba(255, 255, 255, 0.6),
    inset 0 2px 3px rgba(20, 26, 40, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* [Claude] bình 4/12: 3 lỗ xa nhau hơn để 3 đinh không dính liền (cũ 29/71 37, 50 71) */
/* bình 5/12 07:19: lật ngược: 1 lỗ trên, 2 lỗ dưới (lật quanh tâm mặt đồng hồ ở 49.8%) */
.slot:nth-child(1) { left: 50%; top: 26.2%; }
.slot:nth-child(2) { left: 29.7%; top: 61.3%; }
.slot:nth-child(3) { left: 70.3%; top: 61.3%; }

.slot b {
  width: calc(var(--bw) * 0.39); /* 35px ở hộp 90px, 3 đinh hở ~3px */
  height: calc(var(--bw) * 0.39);
  display: block;
  flex: none;
}

.slot b svg,
.buf-slot b svg,
.fly-screw svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4));
}

/* Locked Box */
.box.locked {
  --c: #9aa6b8;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
}

.box.locked .lock-plus {
  /* [Claude] bình 4/12: dấu + to hơn (nút xanh 34px, thanh + vẽ SVG bo tròn) */
  position: relative;
  z-index: 2;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  /* bình: xanh cũ xấu -> xanh nõn chuối kiểu game mẫu, viền xanh đậm */
  background: linear-gradient(#a6e41a, #8bd232 55%, #72c030);
  border: 2px solid #3f9412;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 -3px rgba(40, 110, 10, 0.35), inset 0 2px rgba(255, 255, 255, 0.45), 0 1.5px 0 #2f760c;
}
.box.locked .lock-plus svg {
  width: 27px;
  height: 27px;
  display: block;
  filter: drop-shadow(0 0 1px #3a8c10) drop-shadow(0 1.2px 0 #3a8c10);
}

.box.locked small {
  /* [Claude] chữ "MỞ" nét to đều, trắng viền đậm như game mẫu */
  position: relative;
  z-index: 2;
  font-family: "Fredoka", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.5px;
  color: #fff8e6; /* bình: màu chữ cũ xấu -> kem, viền xanh than đậm + bóng nổi khối như game mẫu */
  -webkit-text-stroke: 4px #263752;
  paint-order: stroke fill;
  text-shadow: 0 2.5px 0 #263752;
  margin-top: 3px;
}

.box.empty {
  opacity: 0.38;
}

/* ===== BUFFER TRAY (5 ô tròn theo mẫu của Bình) ===== */
#buffer-wrap {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

#buffer-tray {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 30px;
  pointer-events: auto;
}

/* [Claude] ô chờ sắp đầy: nhấp nháy nhẹ 3 lần */
#buffer-tray.tray-warn .buf-slot {
  /* [Claude] bình: chớp mạnh và nhiều hơn (6 lần, sáng cam đỏ, phồng to) */
  animation: trayWarn 0.42s ease-in-out 6;
}
@keyframes trayWarn {
  0%, 100% { transform: scale(1); box-shadow: none; }
  50% {
    transform: scale(1.28);
    border-color: #ff6b3d;
    box-shadow: 0 0 0 3px rgba(255, 107, 61, 0.95), 0 0 18px 5px rgba(255, 90, 40, 0.75);
    background-color: rgba(255, 107, 61, 0.38);
  }
}

.buf-slot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.2px solid #ffffff;
  background: rgba(255, 255, 255, 0.65);
  box-shadow:
    0 2px 6px rgba(30, 41, 59, 0.16),
    inset 0 1px 2px rgba(30, 41, 59, 0.12);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.buf-slot:has(b) {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.buf-slot.drilled {
  animation: drillReveal 0.72s cubic-bezier(0.2, 1.45, 0.38, 1) both;
}

@keyframes drillReveal {
  0% {
    transform: perspective(240px) rotateY(95deg) scale(0.35);
    border-color: #fef08a;
    background: radial-gradient(circle, rgba(110, 231, 183, 0.75), rgba(16, 185, 129, 0.15));
    box-shadow: 0 0 22px 6px rgba(52, 211, 153, 0.9);
    filter: brightness(1.85);
    opacity: 0;
  }
  42% {
    transform: perspective(240px) rotateY(-14deg) scale(1.26);
    border-color: #6ee7b7;
    background: radial-gradient(circle, rgba(110, 231, 183, 0.38), transparent 72%);
    box-shadow: 0 0 18px 4px rgba(52, 211, 153, 0.7);
    filter: brightness(1.3);
    opacity: 1;
  }
  70% {
    transform: perspective(240px) rotateY(6deg) scale(0.94);
    border-color: #34d399;
    box-shadow: 0 0 10px 1px rgba(52, 211, 153, 0.38);
    filter: brightness(1.08);
  }
  100% {
    transform: none;
    border-color: rgba(226, 232, 255, 0.78);
    filter: none;
    opacity: 1;
  }
}

.buf-drill {
  position: relative;
  width: 24px;
  height: 24px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  border: 2px dashed #6ee7b7;
  background: radial-gradient(circle at 35% 30%, rgba(74, 222, 128, 0.42), rgba(16, 185, 129, 0.16));
  color: #ecfdf5;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.35), inset 0 1px 3px rgba(255, 255, 255, 0.35);
  animation: drillIdlePulse 2.4s ease-in-out infinite;
  transition: transform 0.14s ease, background 0.2s ease;
}

@keyframes drillIdlePulse {
  0%, 100% { box-shadow: 0 0 10px rgba(52, 211, 153, 0.28), inset 0 1px 3px rgba(255, 255, 255, 0.32); }
  50% { box-shadow: 0 0 16px rgba(110, 231, 183, 0.62), inset 0 1px 4px rgba(255, 255, 255, 0.5); }
}

.buf-drill:active {
  transform: scale(0.9);
}

.buf-drill.drilling {
  animation: drillSpinShake 0.34s ease-in forwards !important;
  border-color: #fef08a;
  background: radial-gradient(circle, #fef08a, #10b981);
  color: #064e3b;
}

@keyframes drillSpinShake {
  0%   { transform: scale(1) rotate(0deg); filter: brightness(1.2); }
  20%  { transform: translate(-2px, 1px) scale(1.12) rotate(75deg); filter: brightness(1.5); }
  45%  { transform: translate(2px, -1.5px) scale(1.16) rotate(175deg); filter: brightness(1.8); }
  72%  { transform: translate(-1.5px, 1.5px) scale(1.06) rotate(290deg); filter: brightness(2.1); }
  100% { transform: scale(0.25) rotate(420deg); filter: brightness(2.4); opacity: 0; }
}

.drVortex {
  position: fixed;
  pointer-events: none;
  z-index: 13;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #fef08a;
  border-right-color: #6ee7b7;
  box-shadow: 0 0 14px rgba(110, 231, 183, 0.75);
}

.drSpark {
  position: fixed;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 14;
}

.drRing {
  position: fixed;
  pointer-events: none;
  z-index: 13;
  border-radius: 50%;
  border: 3.5px solid #6ee7b7;
  box-shadow: 0 0 14px rgba(52, 211, 153, 0.8);
}

.buf-slot b {
  width: 34px; /* [Claude] bình 4/12: đinh to hơn, lỗ giữ nguyên (28px) */
  height: 34px;
  display: block;
  flex: none;
}


/* [Claude] Dec 3: bỏ kiểu lỗ chờ của Claude, dùng kiểu của Antigravity (bình chọn) */

/* ===== TIMER BAR (tạm ẩn theo yêu cầu của bình) ===== */
#timer-bar {
  display: none;
  position: relative;
  width: min(82vw, 340px);
  height: 16px;
  border-radius: 999px;
  background: rgba(8, 15, 30, 0.56);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.55), 0 0 0 1.5px rgba(255, 255, 255, 0.14);
  overflow: hidden;
  transition: opacity 0.6s ease, height 0.6s ease;
}

#timer-bar .tf {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0) 55%),
    linear-gradient(90deg, var(--t1, #16a34a), var(--t2, #4ade80));
  box-shadow: 0 0 10px var(--t2, #4ade80);
  transition: width 0.25s linear;
  overflow: hidden;
}

#timer-bar .tf::after {
  content: "";
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 68px;
  left: -68px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.78), transparent);
  transform: skewX(-20deg);
  animation: tsw 1.7s cubic-bezier(0.4, 0, 0.3, 1) infinite;
}

#timer-bar .tt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  letter-spacing: 0.3px;
}

#timer-bar.lo {
  animation: tsh 0.5s ease-in-out infinite;
}

#timer-bar.lo .tf {
  animation: tpl 0.8s ease-in-out infinite alternate;
}

#timer-bar.out {
  opacity: 0;
  height: 0;
}

/* ===== PRESERVED ANIMATIONS FROM REPO ===== */
.fly-screw {
  position: fixed;
  width: 34px;
  height: 34px;
  pointer-events: none;
  z-index: 12;
  will-change: transform;
}

.slot b.pop,
.buf-slot b.pop {
  animation: pop 0.3s ease-out;
}

@keyframes pop {
  0% { transform: scale(1.62); }
  55% { transform: scale(0.8); }
  100% { transform: scale(1); }
}

.box.dn {
  animation: dn2 0.72s cubic-bezier(0.3, 0.7, 0.4, 1) forwards !important;
  z-index: 6;
  /* [Claude] bình 4/12 23:30: viền trắng tròn không khớp hình đồng hồ ảnh -> bỏ, thay bằng quầng sáng ôm theo hình đồng hồ */
  filter: drop-shadow(0 0 6px var(--c)) drop-shadow(0 0 3px #fff);
}

@keyframes dn2 {
  0% { transform: scale(1); }
  14% { transform: scale(1.24) rotate(-8deg); filter: brightness(1.25) drop-shadow(0 0 7px var(--c)) drop-shadow(0 0 3px #fff); }
  28% { transform: scale(0.9) rotate(6deg); }
  42% { transform: scale(1.12) rotate(-3deg); filter: brightness(1.15) drop-shadow(0 0 7px var(--c)) drop-shadow(0 0 3px #fff); }
  62% { transform: scale(1.04) rotate(0); opacity: 1; }
  100% { transform: translateY(-80px) scale(0.35) rotate(14deg); opacity: 0; }
}

.box.in {
  animation: din 0.55s cubic-bezier(0.3, 1.7, 0.5, 1);
}

@keyframes din {
  0% { transform: translateY(-58px) scale(0.4); opacity: 0; }
  100% { transform: none; opacity: 1; }
}

.box.locked.ring {
  animation: ulRing 0.5s ease-in-out !important;
}

@keyframes ulRing {
  /* [Claude] bình 4/12: đồng hồ giờ là ảnh -> rung nhẹ rồi thu lại, không loé trắng */
  0%, 100% { transform: none; }
  12% { transform: rotate(-9deg) scale(1.04); }
  24% { transform: rotate(8deg) scale(1.06); }
  36% { transform: rotate(-7deg) scale(1.07); }
  48% { transform: rotate(6deg) scale(1.07); }
  60% { transform: rotate(-4deg) scale(1.05); }
  72% { transform: rotate(2deg) scale(1.02); }
  100% { transform: scale(0.82); }
}

.box.locked.ring .lock-plus {
  animation: ulPlus 0.5s ease-in forwards;
}

@keyframes ulPlus {
  60% { transform: scale(1.25); }
  100% { transform: scale(0) rotate(180deg); opacity: 0; }
}

.box.unl {
  animation: ulFlip 0.55s ease-out both !important;
  z-index: 6;
}

@keyframes ulFlip {
  /* [Claude] bình 4/12: bỏ lật 3D + loé trắng (ảnh đồng hồ bị trắng bệch), thay bằng nảy ra */
  0% { transform: scale(0.82); }
  40% { transform: scale(1.14); }
  65% { transform: scale(0.96); }
  85% { transform: scale(1.03); }
  100% { transform: none; }
}

.fxp {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 14;
  will-change: transform, opacity;
}

.fxr {
  position: fixed;
  pointer-events: none;
  z-index: 13;
  border-radius: 50%;
  border: 5px solid var(--c);
  box-shadow: 0 0 18px var(--c);
}

.ulRay {
  position: fixed;
  pointer-events: none;
  z-index: 5;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, var(--c) 0 10deg, transparent 10deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 18%, transparent 70%);
  mask: radial-gradient(circle, #000 18%, transparent 70%);
}

.ulGlow {
  position: fixed;
  pointer-events: none;
  z-index: 5;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0, var(--c) 35%, transparent 70%);
}

.ulLock {
  position: fixed;
  pointer-events: none;
  z-index: 14;
  font-size: 30px;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.35));
}

.ulSp {
  position: fixed;
  pointer-events: none;
  z-index: 14;
  color: #fff6c8;
  text-shadow: 0 0 8px #ffd34d;
}

@keyframes tsw { to { left: calc(100% + 20px); } }
@keyframes tpl { to { filter: brightness(1.45); } }
@keyframes tsh {
  0%, 100% { transform: none; }
  25% { transform: translateX(-2px) rotate(-0.4deg); }
  75% { transform: translateX(2px) rotate(0.4deg); }
}

/* ===== TOAST & COMBO ===== */
#toast {
  position: fixed;
  left: 0;
  right: 0;
  top: 196px;
  text-align: center;
  pointer-events: none;
  z-index: 10;
  font-size: 13.5px;
  font-weight: 700;
  color: #fef08a;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.75);
  transition: opacity 0.25s ease;
}

#toast.warn {
  color: #fca5a5;
}

#combo-pill {
  position: fixed;
  left: 0;
  right: 0;
  top: 218px;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 11;
  opacity: 0;
}

#combo-pill .bd {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--a), var(--b));
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  font: italic 800 18px/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.6px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

#combo-pill .bd::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: shine 0.9s 0.2s ease-out forwards;
}

@keyframes shine { to { left: 130%; } }

#urgency-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  opacity: 0;
  box-shadow: inset 0 0 70px 18px rgba(255, 48, 72, 0.58);
}

/* ===== PROGRESS BADGE & QUICK SKIP ===== */
#top-left-bar {
  position: fixed;
  left: 14px;
  top: 180px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#progress-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1.5px solid #94a3b8;
  font-size: 13px;
  font-weight: 800;
  color: #1e293b;
  box-shadow: 0 3px 10px rgba(30, 41, 59, 0.14);
  pointer-events: none;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  min-width: 36px;
  padding: 0 9px;
  margin: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1.5px solid #94a3b8;
  color: #1e293b;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: 0 3px 10px rgba(30, 41, 59, 0.14);
  transition: transform 0.14s ease, background 0.2s ease;
}

.pill-btn:active {
  transform: scale(0.92);
}

/* ===== FLOATING ACTION BUTTONS ===== */
#controls-right {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 40px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 6;
  background: transparent;
}

.fab {
  position: relative;
  width: 52px;
  height: 52px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(20, 30, 48, 0.86);
  color: #fff;
  font-size: 22px;
  display: grid;
  place-items: center;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.32);
  transition: transform 0.14s ease, background 0.2s ease, border-color 0.2s ease;
}

.fab:active {
  transform: scale(0.92);
}

.fab-sm {
  width: 44px;
  height: 44px;
  font-size: 18px;
}

.fab b {
  position: absolute;
  right: -3px;
  top: -3px;
  min-width: 21px;
  height: 21px;
  padding: 0 4px;
  border-radius: 999px;
  background: #f59e0b;
  color: #111827;
  font-size: 12px;
  font-weight: 800;
  line-height: 21px;
  text-align: center;
}

.fab.active {
  background: radial-gradient(circle, #3b82f6, #1d4ed8);
  border-color: #93c5fd;
  box-shadow: 0 0 18px rgba(96, 165, 250, 0.7);
}

/* [Claude] búa */
#btn-hammer.active {
  background: radial-gradient(circle, #fb7185, #e11d48);
  border-color: #fecdd3;
  box-shadow: 0 0 18px rgba(251, 113, 133, 0.75);
  animation: hmPulse 1s ease-in-out infinite;
}
@keyframes hmPulse { 50% { transform: scale(1.08); } }

/* [Claude] nút búa + kính lúp kiểu đồ chơi */
.fab.fab-toy {
  width: 60px;
  height: 60px;
  border: 3px solid #fff;
  background: radial-gradient(circle at 35% 28%, #ffffff 0 18%, #fff4e0 55%, #ffd9a8 100%);
  box-shadow: 0 5px 0 #d9a066, 0 9px 16px rgba(0, 0, 0, 0.35);
}
.fab.fab-toy:active { transform: translateY(3px) scale(0.94); }
.fab-ic { display: block; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45)); }
.fab.fab-toy b { background: #ff5c8a; color: #fff; border: 2px solid #fff; height: 23px; line-height: 19px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); }

/* [Claude] bình: 2 nút cùng tông màu xanh đen, nằm ngang giữa đáy màn hình */
#controls-right { left: 50%; right: auto; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); flex-direction: row; gap: 28px; }
.hammer-fx .hm.hm-img { left: -30px; top: 0; transform-origin: 43% 94%; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.35)); }
.fab-img { object-fit: contain; -webkit-user-drag: none; user-select: none; }
#btn-hammer.fab-toy, #btn-xray.fab-toy { background: radial-gradient(circle at 35% 28%, #5d74a8 0 12%, #34497a 50%, #1f2d52 100%); box-shadow: 0 5px 0 #121b33, 0 9px 16px rgba(0, 0, 0, 0.4); }
#btn-hammer.fab-toy:active, #btn-xray.fab-toy:active { box-shadow: 0 2px 0 #121b33, 0 4px 10px rgba(0, 0, 0, 0.3); }
#btn-xray.fab-toy.active, #btn-hammer.fab-toy.active { background: radial-gradient(circle at 35% 28%, #7088c0 0 12%, #4560a0 50%, #2a3c6e 100%); border-color: #fde68a; box-shadow: 0 0 0 4px rgba(253, 224, 71, 0.75), 0 5px 0 #121b33, 0 0 22px rgba(253, 224, 71, 0.7); }

.hammer-fx {
  position: fixed;
  width: 0;
  height: 0;
  z-index: 30;
  pointer-events: none;
}
.hammer-fx .hm {
  position: absolute;
  left: -48px;
  top: 0;
  transform-origin: 50% 92%;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.35));
  opacity: 0;
}
.hm-ring {
  position: absolute;
  left: -44px;
  top: -44px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 16px rgba(253, 224, 71, 0.8);
}
.hm-flash {
  position: absolute;
  left: -38px;
  top: -38px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: radial-gradient(circle, #fffbe8 0 30%, rgba(253, 224, 71, 0.7) 55%, transparent 72%);
}
.hm-star, .hm-dust { position: absolute; left: 0; top: 0; }
.hm-star::before { content: '★'; font-size: 22px; text-shadow: 0 2px 3px rgba(0, 0, 0, 0.3); }
.hm-dust { width: 16px; height: 16px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); }

#hint-bar {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
  z-index: 4;
}

/* ===== MODAL ===== */
#modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 16, 28, 0.74);
  backdrop-filter: blur(6px);
  z-index: 20;
}

#modal.show {
  display: flex;
}

.modal-card {
  width: min(88vw, 340px);
  padding: 26px 22px;
  border-radius: 24px;
  background: linear-gradient(180deg, #273754 0%, #192439 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  text-align: center;
}

#modal-icon {
  font-size: 42px;
  margin-bottom: 6px;
}

#modal-title {
  margin: 0 0 8px;
  font-size: 24px;
}

#modal-sub {
  margin: 0 0 20px;
  font-size: 14px;
  color: #fde68a;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-primary,
.btn-secondary {
  border: 0;
  border-radius: 14px;
  padding: 11px 20px;
  font: 700 15px/1 "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(180deg, #4ade80, #16a34a);
  color: #fff;
  box-shadow: 0 4px 0 #15803d;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.14);
  color: #f8fafc;
}

/* ===== LOADER OVERLAY ===== */
#loader-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  z-index: 25;
}

#loader-overlay.show {
  display: flex;
}

.loader-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-radius: 18px;
  background: rgba(24, 36, 58, 0.92);
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: #5eead4;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* [Claude] bình 5/12: nút búa + kính lúp theo ảnh Gemini (viền xanh, mặt kem, số đỏ) -> ảnh ui/nut-bua.png, ui/nut-kinh.png */
#btn-hammer.fab-toy, #btn-xray.fab-toy, #btn-hammer.fab-toy:active, #btn-xray.fab-toy:active { width: 66px; height: 66px; border: 0; background: none; box-shadow: none; overflow: visible; }
.fab-full { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; user-select: none; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.45)); }
#btn-hammer.fab-toy b, #btn-xray.fab-toy b { right: -4px; top: -4px; min-width: 24px; height: 24px; line-height: 24px; border: 0; border-radius: 50%; background: radial-gradient(circle at 40% 30%, #f47466, #e0473a 60%, #c83a2e); color: #fff; font-size: 14px; font-weight: 800; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15), 0 2px 3px rgba(0, 0, 0, 0.35); z-index: 1; }
#btn-hammer.fab-toy.active, #btn-xray.fab-toy.active { background: none; border: 0; box-shadow: none; }
#btn-hammer.fab-toy.active .fab-full, #btn-xray.fab-toy.active .fab-full { filter: drop-shadow(0 0 4px #fde047) drop-shadow(0 0 10px rgba(253, 224, 71, 0.8)); }

/* [Claude] bình 5/12 14:04: khói/bọt trắng lúc búa đập và lúc đinh bung ra */
.puff { position: fixed; z-index: 29; pointer-events: none; border-radius: 50%;
  background: radial-gradient(circle at 40% 36%, #ffffff 0 48%, rgba(244, 247, 255, 0.95) 62%, rgba(230, 236, 250, 0) 71%);
  box-shadow: inset -3px -4px 6px rgba(170, 185, 215, 0.35); }

/* ===== [Claude] bình 6/12 10:30: Ban Ngày Dịu Mắt (pastel) — HUD đồng bộ nền sáng ===== */
html, body { background: #c9d9ea; }
#progress-badge, .pill-btn {
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1.5px solid #94A3B8;
  color: #1E293B;
  box-shadow: 0 3px 10px rgba(30, 41, 59, 0.14);
}
/* bình 6/12 11:53: lỗ chờ kiểu "lỗ khuyết chìm" (đồng hồ giữ nguyên); 12:03: bỏ viền trắng cứng -> mép khắc chìm mềm
   (viền tối mảnh + vệt sáng mép dưới như lỗ khoét trên nhựa); lỗ thứ 6 (+) xanh ngọc có hiệu ứng thở + gợn sóng */
.buf-slot {
  border: 1.5px solid rgba(30, 41, 59, 0.28);
  background: radial-gradient(circle at 50% 38%, rgba(30, 41, 59, 0.42), rgba(30, 41, 59, 0.26) 75%);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.35), 0 1.5px 0 rgba(255, 255, 255, 0.7);
}
.buf-drill {
  border: none !important;
  background: radial-gradient(circle at 35% 30%, #4ade80, #10B981 60%, #059669) !important;
  color: #fff !important;
  font-weight: 900 !important;
  text-shadow: 0 1px 1px rgba(6, 78, 59, 0.5) !important;
  box-shadow: 0 2px 5px rgba(6, 95, 70, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.5);
  animation: congTho 1.8s ease-in-out infinite;
}
.buf-drill::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(16, 185, 129, 0.75);
  animation: congGon 1.8s ease-out infinite;
  pointer-events: none;
}
@keyframes congTho {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.12); filter: brightness(1.12); }
}
@keyframes congGon {
  0% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(1.9); opacity: 0; }
}
.buf-drill.drilling::after { display: none; }
.buf-slot:has(b) { border-color: transparent; background: transparent; box-shadow: none; }
/* lỗ trên mặt đồng hồ: xám xanh nhạt hợp nền sáng (không còn xanh than) */
.slot {
  background: radial-gradient(circle at 50% 40%, #9aa8bd 50%, #b8c4d4);
  box-shadow: 0 0 0 1.5px #d9c8a6, 0 1px 0 1.5px rgba(255, 255, 255, 0.6), inset 0 2px 3px rgba(30, 41, 59, 0.35);
}

/* [Claude] bình 6/12 12:30: đồng hồ đủ 3 đinh = kết hợp GIF mẫu (đồng hồ reo: rung lắc nhanh, vạch reo ((( ))) cạnh 2 chuông,
   sao vàng lấp lánh trên viền) + hiệu ứng cũ (nảy to, vòng sóng + pháo giấy, bay lên mờ dần). Tổng 1.0s. */
.box.dn { animation: dn3 1s linear forwards !important; }
@keyframes dn3 {
  0%   { transform: none; }
  5%   { transform: translateY(-2px) rotate(-8deg) scale(1.08); filter: drop-shadow(0 0 6px #ffd54a) drop-shadow(0 0 3px #fff); }
  10%  { transform: translateY(-3px) rotate(8deg) scale(1.1); }
  15%  { transform: translateY(-3px) rotate(-8deg) scale(1.1); }
  20%  { transform: translateY(-3px) rotate(8deg) scale(1.1); }
  25%  { transform: translateY(-3px) rotate(-7deg) scale(1.1); }
  30%  { transform: translateY(-3px) rotate(7deg) scale(1.1); }
  35%  { transform: translateY(-3px) rotate(-5deg) scale(1.1); }
  40%  { transform: translateY(-2px) rotate(4deg) scale(1.1); filter: brightness(1.08) drop-shadow(0 0 7px #ffd54a) drop-shadow(0 0 3px #fff); }
  48%  { transform: scale(1.26) rotate(0); filter: brightness(1.25) drop-shadow(0 0 8px var(--c)) drop-shadow(0 0 3px #fff); animation-timing-function: ease-out; }
  58%  { transform: scale(0.93); }
  68%  { transform: scale(1.06); filter: brightness(1.1) drop-shadow(0 0 6px var(--c)) drop-shadow(0 0 3px #fff); }
  76%  { transform: scale(1.03); opacity: 1; animation-timing-function: cubic-bezier(0.5, 0, 0.8, 0.4); }
  100% { transform: translateY(-80px) scale(0.35) rotate(14deg); opacity: 0; filter: drop-shadow(0 0 6px var(--c)); }
}
/* vạch reo cạnh chuông (2 vòng cung mỗi bên) */
.reng { position: fixed; left: 0; top: 0; opacity: 0; pointer-events: none; z-index: 13; border-radius: 50%;
  border: 3px solid transparent; filter: drop-shadow(0 0 2px rgba(255, 190, 40, 0.8)); }
.reng.l { border-left-color: #ffb21e; }
.reng.r { border-right-color: #ffb21e; }
.lapl { position: fixed; left: 0; top: 0; opacity: 0; pointer-events: none; z-index: 14; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  background: radial-gradient(circle, #fff 0 18%, #ffe27a 30%, rgba(255, 200, 40, 0) 62%);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%); }
