:root {
  --sky1: #7cc8ff;
  --sky2: #dff3ff;
  --ink: #23395b;
  --accent: #ff5e7e;
  --accent2: #ffb627;
  --good: #2bb673;
  --card: rgba(255, 255, 255, 0.92);
  --bs: 86px; /* kích thước bóng, JS cập nhật theo màn hình */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Baloo 2', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(var(--sky1), var(--sky2));
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
.hidden { display: none !important; }

/* ---------- Mây trôi ---------- */
.clouds { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.cloud {
  position: absolute; width: 140px; height: 44px; background: #fff; border-radius: 40px; opacity: .85;
  animation: drift linear infinite;
}
.cloud::before, .cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 64px; height: 64px; top: -32px; left: 22px; }
.cloud::after { width: 48px; height: 48px; top: -22px; left: 72px; }
.c1 { top: 14%; animation-duration: 60s; }
.c2 { top: 42%; animation-duration: 85s; animation-delay: -30s; transform: scale(.7); }
.c3 { top: 70%; animation-duration: 70s; animation-delay: -50s; transform: scale(1.2); }
@keyframes drift { from { left: -200px; } to { left: 110%; } }

/* ---------- Màn hình ---------- */
.screen { position: relative; z-index: 1; height: 100%; }
#menu, #result { display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.panel {
  background: var(--card); border-radius: 28px; padding: 28px 24px; width: min(560px, 100%);
  text-align: center; box-shadow: 0 12px 0 rgba(35, 57, 91, .12), 0 20px 40px rgba(35, 57, 91, .15);
}
h1 { font-size: clamp(2rem, 7vw, 2.8rem); line-height: 1.1; }
h2 { font-size: 1.1rem; margin: 18px 0 8px; opacity: .8; }
.sub { opacity: .75; }

.choices { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.choices button {
  background: #eef6ff; border-radius: 16px; padding: 10px 16px; font-size: 1.1rem; font-weight: 700;
  border: 3px solid transparent; transition: transform .12s, border-color .12s;
  display: flex; flex-direction: column; align-items: center; line-height: 1.2;
}
.choices button small { font-size: .75rem; font-weight: 500; opacity: .7; }
.choices button:hover { transform: translateY(-2px); }
.choices button.active { border-color: var(--accent); background: #fff0f3; }

.big {
  margin-top: 22px; background: var(--accent); color: #fff; font-size: 1.4rem; font-weight: 800;
  padding: 12px 32px; border-radius: 999px; box-shadow: 0 6px 0 #d43c5c; transition: transform .1s, box-shadow .1s;
}
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #d43c5c; }
.big.ghost { background: #eef6ff; color: var(--ink); box-shadow: 0 6px 0 #c5d8ee; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.best { margin-top: 12px; font-weight: 700; color: #b07a00; min-height: 1.5em; }

/* ---------- HUD ---------- */
#game { display: flex; flex-direction: column; }
.hud { display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.icon {
  background: var(--card); width: 44px; height: 44px; border-radius: 14px; font-size: 1.3rem;
  box-shadow: 0 3px 0 rgba(35, 57, 91, .15); flex-shrink: 0;
}
.icon.off { opacity: .4; }
.progress { flex: 1; min-width: 0; }
.bar { height: 14px; background: rgba(255, 255, 255, .7); border-radius: 99px; overflow: hidden; }
#progressFill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 99px; transition: width .4s; }
#progressText { font-size: .85rem; font-weight: 700; }
.score { background: var(--card); padding: 6px 14px; border-radius: 14px; font-size: 1.2rem; font-weight: 800; white-space: nowrap; }
.combo { font-weight: 800; color: #e8590c; font-size: 1.1rem; white-space: nowrap; }
.combo:empty { display: none; }

.question {
  align-self: center; background: var(--card); border-radius: 24px; padding: 6px 32px; margin: 4px 16px 0;
  font-size: clamp(2.2rem, 9vw, 3.6rem); font-weight: 800; letter-spacing: 2px; cursor: pointer;
  box-shadow: 0 6px 0 rgba(35, 57, 91, .12); position: relative; z-index: 3;
}
.question .qmark { color: var(--accent); display: inline-block; min-width: 1ch; }
.question.solved .qmark { color: var(--good); }
.question.bump { animation: bump .4s; }
@keyframes bump { 40% { transform: scale(1.12); } }

/* ---------- Sân chơi & bóng ---------- */
.field { position: relative; flex: 1; overflow: hidden; }
.balloon { position: absolute; left: 0; top: 0; will-change: transform; touch-action: none; }
.balloon .body {
  width: var(--bs); height: calc(var(--bs) * 1.2); position: relative;
  border-radius: 50% 50% 48% 48% / 55% 55% 45% 45%;
  background: radial-gradient(circle at 30% 26%, rgba(255, 255, 255, .7) 0 8%, transparent 9%), var(--c);
  box-shadow: inset -8px -10px 0 rgba(0, 0, 0, .12);
  display: grid; place-items: center; cursor: pointer;
  font-size: calc(var(--bs) * .4); font-weight: 800; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}
.balloon .body::before { /* nút thắt */
  content: ''; position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
  border: 7px solid transparent; border-top: 0; border-bottom: 9px solid var(--c);
}
.balloon .body::after { /* dây */
  content: ''; position: absolute; top: calc(100% + 2px); left: 50%; width: 2px; height: 44px;
  background: rgba(35, 57, 91, .35);
}
.balloon.wrong { pointer-events: none; }
.balloon.wrong .body { animation: shake .4s; filter: grayscale(1); opacity: .45; }
.balloon.hint .body { animation: glow .7s infinite alternate; }
.balloon.pop .body { animation: pop .22s forwards; }
.balloon.away { pointer-events: none; transition: opacity .4s; opacity: 0; }
@keyframes shake { 20%, 60% { transform: translateX(-8px) rotate(-6deg); } 40%, 80% { transform: translateX(8px) rotate(6deg); } }
@keyframes glow { to { box-shadow: inset -8px -10px 0 rgba(0, 0, 0, .12), 0 0 0 5px #fff, 0 0 28px 10px #ffe066; transform: scale(1.08); } }
@keyframes pop { to { transform: scale(1.5); opacity: 0; } }

.spark {
  position: absolute; width: 12px; height: 12px; border-radius: 50%; pointer-events: none;
  animation: spark .6s ease-out forwards;
}
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }

.float {
  position: absolute; font-size: 1.8rem; font-weight: 800; color: var(--good); pointer-events: none;
  text-shadow: 0 2px 0 #fff; animation: floatUp .9s ease-out forwards;
}
@keyframes floatUp { to { transform: translateY(-70px); opacity: 0; } }

/* Đồng hồ thử thách sắp hết giờ */
.hurry #progressFill { background: #ff4d4d; animation: blink .5s infinite alternate; }
.hurry #progressText { color: #e03131; }
@keyframes blink { to { opacity: .5; } }

/* ---------- Kết quả ---------- */
.stars { font-size: 4rem; margin: 10px 0; letter-spacing: 6px; }
.stars span { display: inline-block; filter: grayscale(1); opacity: .3; }
.stars span.on { filter: none; opacity: 1; animation: starIn .5s backwards; }
.stars span:nth-child(2) { animation-delay: .25s; }
.stars span:nth-child(3) { animation-delay: .5s; }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.3); } }
.stat { font-size: 1.2rem; }

.confetti {
  position: fixed; top: -20px; width: 10px; height: 16px; z-index: 10; pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (max-width: 520px) {
  :root { --bs: 68px; }
  .hud { gap: 6px; padding: 8px 12px; }
  .icon { width: 38px; height: 38px; font-size: 1.1rem; }
  .score { padding: 4px 10px; font-size: 1rem; }
}
