/* ============================================================
   MÊ CUNG ĐỒNG HỒ – style.css
   Giao diện đêm trăng thân thiện với trẻ nhỏ, tối ưu cho iPad (cảm ứng)
   ============================================================ */

:root {
  --font: "Baloo 2", "Arial Rounded MT Bold", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --orange: #ff6b35;
  --orange-dark: #d84f1d;
  --teal: #2ec4b6;
  --teal-dark: #1e9a8e;
  --yellow: #ffd166;
  --yellow-dark: #e0a800;
  --purple: #7b5ea7;
  --purple-dark: #5a3f85;
  --green: #06d6a0;
  --green-dark: #04a67c;
  --red: #ef476f;
  --red-dark: #c42b52;
  --blue: #118ab2;
  --blue-dark: #0c6a8a;
  --night: #121a4a;
  --ink: #2b2d42;
  --ink-soft: #5b5f7a;
  --paper: #ffffff;
  --paper-soft: #f4f6fc;
  --shadow: 0 12px 40px rgba(0, 10, 40, 0.45);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --pad-w: 214px;
  --pad-key: 66px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  font-family: var(--font);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- Màn hình (overlay) ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sat) + 12px) calc(var(--sar) + 12px) calc(var(--sab) + 12px) calc(var(--sal) + 12px);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.25s ease;
  z-index: 5;
}
.screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.screen > * { pointer-events: auto; }
.screen.dim { background: rgba(5, 8, 35, 0.6); }

.panel {
  background: var(--paper);
  border-radius: 32px;
  padding: 26px 30px;
  max-width: 760px;
  width: min(100%, 760px);
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  box-shadow: var(--shadow);
  text-align: center;
  position: relative;
}
.panel.wide { max-width: 920px; width: min(100%, 920px); }
.panel h1, .panel h2 { margin: 0 0 8px; font-weight: 800; line-height: 1.1; }
.panel h2 { font-size: 32px; color: var(--ink); }
.panel p { margin: 6px 0; font-size: 19px; color: var(--ink-soft); font-weight: 600; }

/* ---------- Nút bấm ---------- */
.btn {
  font-family: var(--font);
  font-weight: 800;
  font-size: 24px;
  line-height: 1;
  border: none;
  border-radius: 999px;
  padding: 18px 34px;
  min-height: 62px;
  color: #fff;
  background: linear-gradient(180deg, var(--orange) 0%, #ff8b5a 100%);
  box-shadow: 0 7px 0 var(--orange-dark), 0 12px 24px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn:active, .btn.pressed { transform: translateY(5px); box-shadow: 0 2px 0 var(--orange-dark), 0 4px 10px rgba(0, 0, 0, 0.18); }
.btn.big { font-size: 32px; padding: 22px 46px; min-height: 78px; }
.btn.teal { background: linear-gradient(180deg, var(--teal), #4fd8cb); box-shadow: 0 7px 0 var(--teal-dark), 0 12px 24px rgba(0,0,0,0.18); }
.btn.teal:active { box-shadow: 0 2px 0 var(--teal-dark), 0 4px 10px rgba(0,0,0,0.18); }
.btn.purple { background: linear-gradient(180deg, var(--purple), #9b7fc7); box-shadow: 0 7px 0 var(--purple-dark), 0 12px 24px rgba(0,0,0,0.18); }
.btn.purple:active { box-shadow: 0 2px 0 var(--purple-dark), 0 4px 10px rgba(0,0,0,0.18); }
.btn.green { background: linear-gradient(180deg, var(--green), #3ee8b8); box-shadow: 0 7px 0 var(--green-dark), 0 12px 24px rgba(0,0,0,0.18); }
.btn.green:active { box-shadow: 0 2px 0 var(--green-dark), 0 4px 10px rgba(0,0,0,0.18); }
.btn.blue { background: linear-gradient(180deg, var(--blue), #2aa8d4); box-shadow: 0 7px 0 var(--blue-dark), 0 12px 24px rgba(0,0,0,0.18); }
.btn.blue:active { box-shadow: 0 2px 0 var(--blue-dark), 0 4px 10px rgba(0,0,0,0.18); }
.btn.ghost { background: #f1f3fa; color: var(--ink); text-shadow: none; box-shadow: 0 6px 0 #cfd4e6, 0 8px 16px rgba(0,0,0,0.08); }
.btn.ghost:active { box-shadow: 0 2px 0 #cfd4e6; }
.btn.small { font-size: 19px; padding: 12px 22px; min-height: 50px; }
.btn[disabled] { opacity: 0.45; cursor: default; filter: grayscale(0.4); }
.btn-row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 18px; }
.link-btn {
  background: none; border: none; padding: 0; color: var(--blue); font-family: var(--font); font-weight: 700; font-size: inherit;
  text-decoration: underline; cursor: pointer; touch-action: manipulation;
}

/* ---------- Menu chính ---------- */
#menu .panel { background: rgba(255, 255, 255, 0.95); padding: 22px 30px 26px; }
.logo-row { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.logo-row svg { width: 150px; height: 150px; filter: drop-shadow(0 10px 14px rgba(0,0,0,0.25)); animation: logo-bob 3s ease-in-out infinite; }
@keyframes logo-bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-10px) rotate(3deg); }
}
.title {
  font-size: clamp(42px, 8vw, 72px);
  font-weight: 800;
  line-height: 0.95;
  margin: 0;
  background: linear-gradient(180deg, #ffb703 0%, #ff6b35 50%, #7b5ea7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,0.12));
  letter-spacing: -1px;
}
.title small {
  display: block; font-size: 0.34em; letter-spacing: 3px; color: var(--blue-dark);
  background: none; -webkit-text-fill-color: var(--blue-dark);
}
.subtitle { font-size: 21px; color: var(--ink-soft); margin: 10px 0 18px; font-weight: 700; }
.menu-options { display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.chip-group { display: inline-flex; background: #eef1f8; border-radius: 999px; padding: 5px; gap: 4px; flex-wrap: wrap; justify-content: center; }
.chip-group button {
  font-family: var(--font); font-weight: 800; font-size: 17px; border: none; background: transparent; color: var(--ink-soft);
  padding: 9px 16px; min-height: 42px; border-radius: 999px; cursor: pointer; touch-action: manipulation;
}
.chip-group button.on, .chip-group button:active { background: #fff; color: var(--orange-dark); box-shadow: 0 3px 8px rgba(0,0,0,0.12); }
.chip-label { font-size: 17px; font-weight: 800; color: var(--ink-soft); margin-right: 4px; }
.toggle-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.toggle {
  font-family: var(--font); font-weight: 800; font-size: 16px; border: 3px solid #dfe3ef; background: #f1f3fa; color: var(--ink-soft);
  padding: 8px 14px; min-height: 42px; border-radius: 999px; cursor: pointer; touch-action: manipulation; transition: transform 0.08s;
}
.toggle:active { transform: scale(0.96); }
.toggle.on { background: #e3fff4; border-color: var(--green); color: #05603f; }
.toggle.off { text-decoration: line-through; opacity: 0.8; }
.toggle[disabled] { opacity: 0.5; cursor: default; text-decoration: none; }
.footer-note { margin-top: 14px; font-size: 15px; color: #98a0bd; font-weight: 700; }
.footer-note a { color: var(--blue); text-decoration: none; }

/* ---------- Chọn màn ---------- */
.screen-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.screen-head h2 { flex: 1; text-align: center; margin: 0; }
.mode-desc { font-size: 18px; margin: 0 0 14px; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; text-align: left; }
.level-card {
  position: relative;
  background: linear-gradient(180deg, #ffffff, #f4f6fc);
  border: 3px solid #e3e7f2;
  border-radius: 24px;
  padding: 16px 16px 14px;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 6px 0 #dfe3ef;
  transition: transform 0.08s;
  min-height: 160px;
  display: flex;
  flex-direction: column;
}
.level-card:active { transform: translateY(4px); box-shadow: 0 2px 0 #dfe3ef; }
.level-card.locked { background: #eef0f6; opacity: 0.7; }
.level-card.locked .icon { filter: grayscale(1) opacity(0.5); }
.level-card.current { border-color: var(--yellow); box-shadow: 0 6px 0 var(--yellow-dark), 0 0 0 4px rgba(255, 209, 102, 0.35); }
.level-card .icon { font-size: 40px; line-height: 1; }
.level-card .lock { position: absolute; left: 14px; top: 12px; font-size: 24px; line-height: 1; }
.level-card .num { font-size: 13px; font-weight: 800; color: var(--ink-soft); letter-spacing: 1px; }
.level-card .name { font-size: 22px; font-weight: 800; margin-top: 2px; line-height: 1.15; }
.level-card .desc { font-size: 15px; color: var(--ink-soft); font-weight: 600; margin-top: 2px; }
.level-card .grade { position: absolute; top: 12px; right: 12px; font-size: 13px; font-weight: 800; color: #fff; background: var(--purple); border-radius: 999px; padding: 4px 10px; }
.level-card .grade.g2 { background: var(--blue); }
.level-card .grade.g3 { background: var(--purple); }
.level-card .meta { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 10px; font-size: 16px; font-weight: 800; }
.level-card .best { color: var(--orange-dark); }
.level-card .stars { color: #ffbf1f; letter-spacing: 2px; font-size: 20px; }
.level-card .stars .off { color: #d5d9e6; }
.parent-note { font-size: 14px; color: #98a0bd; margin: 14px 0 0; font-weight: 700; }

/* ---------- Bài học ---------- */
.lesson-body { display: flex; gap: 22px; align-items: center; text-align: left; margin-top: 6px; }
.lesson-clock { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 200px; }
.lesson-clock svg.clock-svg { width: clamp(160px, 24vw, 230px); height: auto; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.15)); }
.lesson-clock svg.digital-svg { width: clamp(150px, 22vw, 210px); height: auto; }
.lesson-clock .read { font-size: 24px; font-weight: 800; color: var(--orange-dark); text-align: center; min-height: 1.3em; line-height: 1.2; }
.lesson-clock .read small { display: block; font-size: 16px; color: var(--ink-soft); }
.lesson-text { flex: 1; display: grid; gap: 10px; }
.lesson-text p { margin: 0; background: #f6f7fb; border-radius: 18px; padding: 10px 14px; font-size: 18px; line-height: 1.35; color: var(--ink); font-weight: 700; }
.lesson-text p b { color: var(--orange-dark); }
.lesson-demos { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.lesson-demos button {
  font-family: var(--font); font-weight: 800; font-size: 17px; border: 3px solid #e4e8f3; background: #f6f7fb; color: var(--ink-soft);
  padding: 8px 16px; border-radius: 999px; cursor: pointer; touch-action: manipulation; min-height: 44px;
}
.lesson-demos button.on { background: var(--yellow); border-color: var(--yellow-dark); color: #6a4a00; }
.svg-flip { animation: hand-swing 0.6s ease; }
@keyframes hand-swing { 0% { transform: scale(0.94); } 60% { transform: scale(1.03); } 100% { transform: scale(1); } }

/* ---------- Học xem giờ ---------- */
.learn-body { display: flex; gap: 24px; align-items: center; justify-content: center; text-align: left; margin-top: 6px; }
.learn-clock svg { width: clamp(180px, 30vw, 280px); height: auto; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.15)); }
.learn-info { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; min-width: 240px; }
.learn-read { font-size: clamp(28px, 4vw, 40px); font-weight: 800; color: var(--orange-dark); text-align: center; line-height: 1.1; }
.learn-alt { font-size: 18px; font-weight: 700; color: var(--ink-soft); text-align: center; min-height: 1.3em; }
.learn-digital svg { width: 150px; height: auto; }
.learn-steps { margin-top: 4px; }

/* ---------- HUD ---------- */
#hud { align-items: flex-start; justify-content: stretch; padding: calc(var(--sat) + 8px) calc(var(--sar) + 10px) 0 calc(var(--sal) + 10px); z-index: 3; }
#hud > * { pointer-events: none; }
.hud-top { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; grid-template-areas: "left center right"; align-items: start; gap: 10px; }
.hud-left { grid-area: left; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.hud-center { grid-area: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hud-right { grid-area: right; display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.score-box { background: rgba(255,255,255,0.94); border-radius: 18px; padding: 6px 16px 4px; min-width: 120px; box-shadow: 0 4px 14px rgba(0,0,0,0.25); line-height: 1; }
.score-box .label { display: block; font-size: 13px; letter-spacing: 2px; font-weight: 800; color: var(--ink-soft); }
.score-box .value { display: block; font-size: 34px; font-weight: 800; color: var(--orange-dark); transition: transform 0.1s; }
.score-box .value.bump { transform: scale(1.18); }
.stage-chip { background: var(--purple); color: #fff; font-weight: 800; font-size: 15px; padding: 5px 12px; border-radius: 999px; box-shadow: 0 3px 10px rgba(0,0,0,0.25); white-space: nowrap; }
.power-chip { background: linear-gradient(90deg, #ff7a00, #ffb800); color: #fff; font-weight: 800; font-size: 15px; padding: 5px 12px; border-radius: 999px; box-shadow: 0 3px 10px rgba(0,0,0,0.25); animation: chip-pop 0.3s ease; white-space: nowrap; }
@keyframes chip-pop { 0% { transform: scale(0.5); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }

.target-card {
  position: relative;
  background: #fff;
  border-radius: 24px;
  padding: 8px 54px 8px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 0 #dfe3ef, 0 14px 30px rgba(0,0,0,0.3);
  min-width: 300px;
  max-width: min(92vw, 640px);
  transition: transform 0.15s ease, background 0.2s;
  pointer-events: auto;
}
.target-card .target-label { font-size: 13px; letter-spacing: 2px; font-weight: 800; color: var(--ink-soft); display: block; }
.target-text { font-size: clamp(18px, 2.6vw, 26px); font-weight: 800; color: var(--ink); line-height: 1.15; text-align: center; }
.target-text b { color: var(--orange-dark); font-size: 1.25em; white-space: nowrap; }
.target-clock svg { width: 84px; height: 84px; display: block; }
.speak-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%; border: none; background: #eef1f8; font-size: 20px; cursor: pointer; touch-action: manipulation;
  box-shadow: 0 3px 0 #cfd4e6;
}
.speak-btn:active { transform: translateY(calc(-50% + 2px)); box-shadow: 0 1px 0 #cfd4e6; }
.target-card.pop { animation: card-pop 0.35s ease; }
@keyframes card-pop { 0% { transform: scale(0.7); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
.target-card.shake { animation: card-shake 0.4s ease; background: #ffe3e8; }
@keyframes card-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(5px); }
}
.target-card.ok { background: #e3fff4; }

.hint {
  background: rgba(43,45,66,0.92); color: #fff; font-weight: 800; font-size: 20px;
  padding: 6px 18px; border-radius: 999px; box-shadow: 0 6px 16px rgba(0,0,0,0.3);
  max-width: 92vw; text-align: center; animation: chip-pop 0.3s ease;
}
.hint.bad { background: var(--red); }
.hint.ok { background: var(--green); color: #063b2c; }
.hint.info { background: var(--blue); }
.lives { display: flex; gap: 4px; background: rgba(255,255,255,0.92); border-radius: 999px; padding: 6px 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
.lives span { font-size: 26px; line-height: 1; transition: transform 0.2s, filter 0.2s; display: inline-block; }
.lives span.lost { filter: grayscale(1) opacity(0.35); transform: scale(0.8); }
.lives.hit { animation: lives-hit 0.45s ease; }
@keyframes lives-hit { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-4px); } }

#btn-pause {
  pointer-events: auto;
  width: 56px; height: 56px; min-height: 56px; padding: 0; font-size: 24px; border-radius: 50%;
  background: rgba(255,255,255,0.94); color: var(--ink); box-shadow: 0 5px 0 #cfd4e6, 0 8px 16px rgba(0,0,0,0.2); text-shadow: none;
}
#btn-pause:active { box-shadow: 0 1px 0 #cfd4e6; }

/* ---------- Nút di chuyển (D-pad) ---------- */
#dpad {
  position: absolute;
  right: calc(var(--sar) + 12px);
  bottom: calc(var(--sab) + 12px);
  width: var(--pad-w);
  height: var(--pad-w);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  grid-template-areas: ". up ." "left center right" ". down .";
  gap: 6px;
  z-index: 4;
  touch-action: manipulation;
  transition: opacity 0.25s;
}
#dpad.off { visibility: hidden; opacity: 0; pointer-events: none; }
#dpad .d {
  font-family: var(--font); font-weight: 800; font-size: 30px; line-height: 1;
  border: none; border-radius: 20px;
  background: rgba(255,255,255,0.92); color: var(--ink);
  box-shadow: 0 5px 0 #b9c1d8, 0 6px 12px rgba(0,0,0,0.25);
  cursor: pointer; touch-action: manipulation; padding: 0;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
#dpad .d:active, #dpad .d.pressed { transform: translateY(4px); box-shadow: 0 1px 0 #b9c1d8, 0 2px 6px rgba(0,0,0,0.25); background: #fff4d6; }
#dpad .up { grid-area: up; } #dpad .down { grid-area: down; } #dpad .left { grid-area: left; } #dpad .right { grid-area: right; }
#dpad .center { grid-area: center; background: rgba(255,255,255,0.3); box-shadow: none; font-size: 26px; pointer-events: none; }
@media (max-aspect-ratio: 1/1) {
  #dpad { right: auto; left: 50%; transform: translateX(-50%); }
}

/* ---------- Đếm ngược ---------- */
#countdown { pointer-events: none; }
#countdown .count {
  font-size: clamp(120px, 28vw, 260px); font-weight: 800; color: #fff;
  text-shadow: 0 8px 0 rgba(0,0,0,0.25), 0 0 40px rgba(255,209,102,0.7);
  -webkit-text-stroke: 4px var(--purple-dark); line-height: 1; animation: count-pop 1s ease both;
}
#countdown .count.go { color: var(--yellow); -webkit-text-stroke: 4px var(--red-dark); font-size: clamp(90px, 20vw, 190px); }
@keyframes count-pop {
  0% { transform: scale(0.2); opacity: 0; }
  25% { transform: scale(1.2); opacity: 1; }
  70% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ---------- Hỏi đáp ---------- */
.quiz-progress { background: var(--purple); color: #fff; font-weight: 800; font-size: 16px; padding: 8px 14px; border-radius: 999px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.quiz-progress .dot { width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,0.35); display: inline-block; }
.quiz-progress .dot.done { background: var(--green); }
.quiz-progress .dot.now { background: var(--yellow); transform: scale(1.2); }
.quiz-intro { font-size: 17px; margin: 0 0 8px; }
.quiz-q { font-size: clamp(20px, 3vw, 27px); font-weight: 800; color: var(--ink); margin: 4px 0 10px; line-height: 1.3; }
.quiz-q b { color: var(--orange-dark); }
.quiz-clock { display: flex; justify-content: center; margin: 2px 0 12px; }
.quiz-clock svg.clock-svg { width: clamp(130px, 22vw, 190px); height: auto; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.15)); }
.quiz-clock svg.digital-svg { width: clamp(150px, 24vw, 210px); height: auto; }
.quiz-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.quiz-options .opt {
  font-family: var(--font); font-weight: 800; font-size: 21px; line-height: 1.2;
  border: 3px solid #e3e7f2; background: linear-gradient(180deg, #ffffff, #f4f6fc);
  border-radius: 20px; padding: 14px 12px; min-height: 66px; color: var(--ink);
  cursor: pointer; touch-action: manipulation; box-shadow: 0 5px 0 #dfe3ef;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.08s;
}
.quiz-options .opt:active { transform: translateY(3px); box-shadow: 0 2px 0 #dfe3ef; }
.quiz-options .opt svg.clock-svg { width: clamp(96px, 16vw, 136px); height: auto; }
.quiz-options .opt svg.digital-svg { width: clamp(120px, 18vw, 156px); height: auto; }
.quiz-options .opt.right { background: #e3fff4; border-color: var(--green); box-shadow: 0 5px 0 var(--green-dark); }
.quiz-options .opt.wrong { background: #ffe3e8; border-color: var(--red); animation: card-shake 0.4s ease; }
.quiz-options .opt.dim { opacity: 0.45; }
.quiz-options .opt[disabled] { cursor: default; }
.quiz-feedback { margin-top: 12px; border-radius: 20px; padding: 12px 16px 14px; text-align: left; animation: chip-pop 0.3s ease; }
.quiz-feedback.ok { background: #e3fff4; }
.quiz-feedback.bad { background: #fff4d6; }
.fb-title { font-size: 22px; font-weight: 800; }
.quiz-feedback.ok .fb-title { color: var(--green-dark); }
.quiz-feedback.bad .fb-title { color: #a05a00; }
.fb-text { font-size: 18px; font-weight: 700; color: var(--ink); margin-top: 4px; line-height: 1.35; }
.quiz-feedback .btn-row { margin-top: 10px; }

/* ---------- Kết quả ---------- */
.result-title { font-size: 40px; margin-bottom: 2px; }
.result-title.win { color: var(--green-dark); }
.result-title.lose { color: var(--red); }
.result-score { font-size: clamp(56px, 12vw, 92px); font-weight: 800; line-height: 1; color: var(--orange-dark); margin: 4px 0 0; }
.result-score-label { font-size: 16px; letter-spacing: 3px; color: var(--ink-soft); font-weight: 800; }
.result-stars { font-size: 52px; line-height: 1; margin: 6px 0; letter-spacing: 4px; color: #ffbf1f; }
.result-stars .off { color: #dfe3ef; }
.result-stars .on { display: inline-block; animation: star-in 0.5s ease both; }
.result-stars .on:nth-child(2) { animation-delay: 0.2s; }
.result-stars .on:nth-child(3) { animation-delay: 0.4s; }
@keyframes star-in { 0% { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.3) rotate(10deg); } 100% { transform: scale(1) rotate(0); } }
.record-badge {
  display: inline-block; background: linear-gradient(90deg, #ffb300, #ff6b35); color: #fff; font-weight: 800; font-size: 20px;
  padding: 6px 18px; border-radius: 999px; margin: 6px 0 4px; animation: badge-pulse 1s ease-in-out infinite; box-shadow: 0 6px 16px rgba(255, 120, 0, 0.35);
}
@keyframes badge-pulse { 50% { transform: scale(1.06); } }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0 8px; }
.stat { background: #f4f6fc; border-radius: 18px; padding: 10px 6px 8px; }
.stat .v { font-size: 30px; font-weight: 800; line-height: 1; }
.stat .k { font-size: 14px; font-weight: 800; color: var(--ink-soft); margin-top: 4px; }
.stat.ok .v { color: var(--green-dark); }
.stat.bad .v { color: var(--red); }
.stat.combo .v { color: var(--purple); }
.stat.acc .v { color: var(--blue); }
.takeaway { background: #fff4d6; border-radius: 18px; padding: 10px 14px; margin: 8px auto 4px; max-width: 600px; text-align: left; font-size: 17px; font-weight: 700; color: #6a4a00; line-height: 1.35; }
.takeaway b { color: var(--orange-dark); }
.unlock-note { background: #e3fff4; color: #05603f; border-radius: 18px; padding: 8px 14px; font-weight: 800; font-size: 17px; margin: 6px auto 0; max-width: 600px; }

/* ---------- Hướng dẫn ---------- */
.howto-list { text-align: left; display: grid; gap: 12px; margin: 10px 0 6px; }
.howto-item { display: flex; gap: 14px; align-items: center; background: #f6f7fb; border-radius: 20px; padding: 12px 16px; }
.howto-item .em { font-size: 38px; line-height: 1; width: 52px; text-align: center; flex-shrink: 0; }
.howto-item .tx { font-size: 19px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.howto-item .tx b { color: var(--orange-dark); }
.tip { margin-top: 12px; font-size: 16px; color: var(--ink-soft); font-weight: 700; background: #fff4d6; border-radius: 16px; padding: 10px 14px; }

/* ---------- Toast ---------- */
#toast {
  position: absolute; left: 50%; bottom: calc(var(--sab) + 22px); transform: translateX(-50%);
  background: rgba(43,45,66,0.92); color: #fff; font-weight: 800; font-size: 18px;
  padding: 12px 22px; border-radius: 999px; pointer-events: none; opacity: 0; transition: opacity 0.3s; z-index: 20; max-width: 90%; text-align: center;
}
#toast.show { opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  :root { --pad-w: 180px; }
  .panel { padding: 18px 14px; border-radius: 24px; }
  .panel h2 { font-size: 24px; }
  .btn { font-size: 20px; padding: 14px 24px; }
  .btn.big { font-size: 26px; padding: 18px 34px; min-height: 66px; }
  .logo-row svg { width: 110px; height: 110px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .score-box { min-width: 90px; padding: 5px 12px 3px; }
  .score-box .value { font-size: 24px; }
  .stage-chip { font-size: 13px; }
  .lives span { font-size: 20px; }
  .target-card { padding: 6px 44px 6px 14px; min-width: 200px; gap: 10px; }
  .target-text { font-size: 17px; }
  .target-clock svg { width: 60px; height: 60px; }
  .hud-top { grid-template-columns: 1fr 1fr; grid-template-areas: "left right" "center center"; gap: 6px 10px; }
  .hud-left { flex-direction: row; align-items: center; }
  .hud-center { justify-self: center; }
  .hint { font-size: 16px; padding: 5px 14px; }
  .screen-head h2 { font-size: 21px; }
  .screen-head .btn { font-size: 15px; padding: 10px 12px; min-height: 44px; }
  .mode-desc { font-size: 16px; }
  .level-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .level-card { min-height: 130px; padding: 12px; }
  .level-card .name { font-size: 18px; }
  .lesson-body, .learn-body { flex-direction: column; gap: 12px; }
  .lesson-text p { font-size: 16px; padding: 8px 12px; }
  .quiz-options { gap: 8px; }
  .quiz-options .opt { font-size: 18px; padding: 10px 8px; min-height: 56px; }
  .fb-text { font-size: 16px; }
  #dpad .d { font-size: 24px; border-radius: 16px; }
}
@media (max-height: 900px) {
  #result .panel { padding: 16px 26px 18px; }
  .result-title { font-size: 32px; }
  .result-score { font-size: clamp(48px, 9vw, 72px); }
  .result-stars { font-size: 40px; margin: 2px 0; }
  .stats { margin: 8px 0 4px; gap: 8px; }
  .stat { padding: 6px 4px 6px; }
  .stat .v { font-size: 24px; }
  .stat .k { font-size: 13px; }
  #result .btn-row { margin-top: 10px; }
  #result .btn.big { font-size: 24px; padding: 14px 30px; min-height: 60px; }
}
@media (max-height: 560px) {
  :root { --pad-w: 150px; }
  .logo-row svg { width: 90px; height: 90px; }
  .subtitle { margin: 4px 0 10px; }
  .panel { padding: 14px 20px; }
  .howto-item { padding: 8px 12px; }
  .lesson-clock svg.clock-svg { width: 130px; }
  .quiz-clock svg.clock-svg { width: 110px; }
  .quiz-options .opt svg.clock-svg { width: 80px; }
  .target-card { padding: 4px 44px 4px 14px; }
  .target-clock svg { width: 54px; height: 54px; }
}
