/* ============================================================
   THÁP ĐỒNG HỒ – style.css
   Giao diện thị trấn tươi sáng thân thiện với trẻ nhỏ, tối ưu cho iPad
   ============================================================ */

: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;
  --sky: #5fb8ff;
  --ink: #2b2d42;
  --ink-soft: #5b5f7a;
  --paper: #ffffff;
  --paper-soft: #f4f6fc;
  --shadow: 0 12px 40px rgba(0, 20, 60, 0.35);
  --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);
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--sky);
  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;
}

/* Đo vùng an toàn phía dưới (tai thỏ / thanh home) từ JS */
#safe-probe { position: absolute; left: 0; bottom: 0; width: 1px; height: var(--sab); pointer-events: none; visibility: hidden; }

/* ---------- 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(10, 30, 70, 0.5); }

.panel {
  background: var(--paper);
  border-radius: 32px;
  padding: 28px 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: 900px; width: min(100%, 900px); }
.panel h1, .panel h2 {
  margin: 0 0 8px;
  font-weight: 800;
  line-height: 1.1;
}
.panel h2 { font-size: 34px; 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-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 18px;
}
.linkish {
  font-family: var(--font); font-weight: 800; font-size: inherit;
  background: none; border: none; color: var(--blue); text-decoration: underline; cursor: pointer; padding: 0; 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(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}
.title {
  font-size: clamp(42px, 8vw, 72px);
  font-weight: 800;
  line-height: 0.95;
  margin: 0;
  background: linear-gradient(180deg, #ff9f1c 0%, #ff6b35 50%, #c42b52 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.33em;
  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; }
.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: 12px;
}
.screen-head h2 { flex: 1; text-align: center; margin: 0; }
.screen-head .btn { white-space: nowrap; }
.mode-desc { font-size: 18px; margin: 0 0 14px; }
.mode-desc b { color: var(--orange-dark); }
.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: 150px;
  display: flex;
  flex-direction: column;
}
.level-card:active { transform: translateY(4px); box-shadow: 0 2px 0 #dfe3ef; }
.level-card.locked { background: linear-gradient(180deg, #f3f4f8, #e6e8f0); border-color: #d5d9e6; opacity: 0.85; }
.level-card.locked .name, .level-card.locked .desc { color: #8a8fa8; }
.level-card.shake { animation: card-shake 0.4s ease; }
.level-card .icon { font-size: 40px; line-height: 1; }
.level-card .name { font-size: 21px; font-weight: 800; margin-top: 6px; 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 .grade.gx { background: var(--red); }
.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; }
.level-card .lock-note { font-size: 13px; color: #8a8fa8; font-weight: 700; line-height: 1.2; }
.parent-note { font-size: 14px !important; color: #98a0bd !important; margin-top: 14px !important; }

/* ---------- Bài học ---------- */
.lesson-panel { text-align: left; }
.lesson-title { margin: 4px 0 10px; font-size: 28px; font-weight: 800; color: var(--orange-dark); text-align: center; line-height: 1.15; }
.lesson-body { display: grid; grid-template-columns: 250px 1fr; gap: 20px; align-items: center; }
.lesson-demo { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.clock-box { line-height: 0; }
.clock-svg { display: block; max-width: 100%; height: auto; filter: drop-shadow(0 8px 14px rgba(0,0,0,0.18)); }
.clock-svg .hand { transition: transform 1.1s cubic-bezier(0.34, 1.3, 0.64, 1); }
.clock-svg text { font-family: var(--font); }
.clock-caption {
  font-size: 26px; font-weight: 800; color: var(--blue-dark);
  background: #e8f6ff; border-radius: 999px; padding: 6px 20px; min-width: 160px; text-align: center;
}
.clock-caption.pop { animation: card-pop 0.4s ease; }
.lesson-text p { font-size: 20px; color: var(--ink); font-weight: 600; line-height: 1.4; margin: 8px 0; }
.lesson-text b { color: var(--orange-dark); }

/* ---------- 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: row; gap: 8px; align-items: center; flex-wrap: wrap; }
.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: 110px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  line-height: 1;
}
.score-box .label { display: block; font-size: 12px; letter-spacing: 2px; font-weight: 800; color: var(--ink-soft); }
.score-box .value { display: block; font-size: 30px; 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: 6px 12px; border-radius: 999px; box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  white-space: nowrap;
}
.combo-chip {
  background: linear-gradient(90deg, #ff7a00, #ffb800); color: #fff; font-weight: 800; font-size: 16px;
  padding: 5px 12px; border-radius: 999px; box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  transform-origin: left center;
  animation: chip-pop 0.3s ease;
}
@keyframes chip-pop { 0% { transform: scale(0.5); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
.progress {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.94);
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.progress .bar { width: 170px; height: 14px; background: #e6e9f3; border-radius: 999px; overflow: hidden; }
.progress .fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal), var(--green)); border-radius: 999px; transition: width 0.35s ease; }
.progress .text { font-weight: 800; font-size: 19px; color: var(--ink); min-width: 70px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
@keyframes card-pop { 0% { transform: scale(0.7); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes card-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(5px); }
}
.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; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  animation: chip-pop 0.3s ease;
}
.hint.bad { background: var(--red); }
.hint.ok { background: var(--green); color: #063b2c; }
.hint.info { background: var(--blue); }

#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 điều khiển ---------- */
#controls {
  position: absolute;
  left: 0; top: 0;
  width: 320px;
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 8px;
  padding: 8px;
  background: rgba(20, 40, 90, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  z-index: 4;
  touch-action: manipulation;
  transition: opacity 0.25s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#controls.off { visibility: hidden; opacity: 0; pointer-events: none; }
#controls .k {
  font-family: var(--font);
  font-weight: 800;
  font-size: 30px;
  line-height: 1;
  height: 62px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #e9edf8);
  color: var(--ink);
  box-shadow: 0 5px 0 #b9c1d8, 0 6px 12px rgba(0,0,0,0.25);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0;
}
#controls .k:active, #controls .k.pressed { transform: translateY(4px); box-shadow: 0 1px 0 #b9c1d8, 0 2px 6px rgba(0,0,0,0.25); }
#controls .drop {
  background: linear-gradient(180deg, var(--orange), #ff8b5a); color: #fff;
  box-shadow: 0 5px 0 var(--orange-dark), 0 6px 12px rgba(0,0,0,0.25);
  font-size: 26px; text-shadow: 0 2px 0 rgba(0,0,0,0.15);
}
#controls .drop small { font-size: 13px; letter-spacing: 1px; margin-top: 2px; }
#controls .drop:active, #controls .drop.pressed { box-shadow: 0 1px 0 var(--orange-dark); }

/* ---------- Đế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,255,255,0.7);
  -webkit-text-stroke: 4px var(--blue-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; }
}

/* ---------- Kết quả ---------- */
.result-title { font-size: 38px; margin-bottom: 2px; }
.result-title.nolife { 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(3, 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(--orange-dark); }
.review { background: #fff4d6; border-radius: 18px; padding: 8px 14px 10px; margin: 8px auto 4px; max-width: 640px; }
.review h3 { margin: 0 0 6px; font-size: 16px; color: #8a5a00; }
.review-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.review-item {
  background: #fff; border-radius: 16px; padding: 6px 8px 4px; box-shadow: 0 2px 0 #e8d5a8;
  cursor: pointer; touch-action: manipulation; display: flex; flex-direction: column; align-items: center; width: 118px;
}
.review-item .clock-svg { width: 84px; height: 84px; filter: none; }
.review-item .rv-text { font-size: 14px; font-weight: 800; color: var(--orange-dark); margin-top: 2px; text-align: center; line-height: 1.15; }
.review-item.speaking { animation: card-pop 0.4s ease; background: #fff9e6; }
.sum-note { font-size: 18px !important; color: var(--ink) !important; background: #e8f6ff; border-radius: 16px; padding: 10px 14px; margin: 10px auto 0 !important; max-width: 560px; }
.sum-note b { color: var(--blue-dark); }
.fail-info { font-size: 17px !important; }

/* ---------- Hỏi đáp ---------- */
.quiz-panel { max-width: 820px; }
.quiz-dots { display: flex; gap: 8px; min-width: 60px; }
.quiz-dots span { width: 16px; height: 16px; border-radius: 50%; background: #dfe3ef; display: inline-block; }
.quiz-dots span.done { background: var(--green); }
.quiz-dots span.cur { background: var(--orange); transform: scale(1.2); }
.quiz-q { font-size: 26px; font-weight: 800; color: var(--ink); line-height: 1.3; margin: 8px 0 12px; }
.quiz-clock { display: flex; justify-content: center; margin: 4px 0 12px; }
.quiz-choices { display: grid; grid-template-columns: 1fr; gap: 10px; max-width: 520px; margin: 0 auto; }
.choice {
  font-family: var(--font); font-weight: 800; font-size: 23px;
  border: 3px solid #e3e7f2; background: linear-gradient(180deg, #ffffff, #f4f6fc); color: var(--ink);
  border-radius: 20px; padding: 14px 18px; min-height: 60px; cursor: pointer; touch-action: manipulation;
  box-shadow: 0 5px 0 #dfe3ef; transition: transform 0.08s;
}
.choice:active { transform: translateY(3px); box-shadow: 0 2px 0 #dfe3ef; }
.choice.ok { background: #e3fff4; border-color: var(--green); color: #05603f; }
.choice.bad { background: #ffe3e8; border-color: var(--red); color: var(--red-dark); animation: card-shake 0.4s ease; }
.choice[disabled] { cursor: default; }
.quiz-feedback { margin-top: 14px; border-radius: 20px; padding: 12px 16px 6px; text-align: left; }
.quiz-feedback.ok { background: #e3fff4; }
.quiz-feedback.bad { background: #fff4d6; }
.quiz-feedback .explain { font-size: 19px; font-weight: 600; color: var(--ink); line-height: 1.4; }
.quiz-feedback .explain b { color: var(--orange-dark); }
.quiz-feedback.ok .explain b { color: var(--green-dark); }
.quiz-feedback .btn-row { margin-top: 10px; margin-bottom: 6px; }
.unlock-art { font-size: 80px; line-height: 1; margin: 6px 0; animation: badge-pulse 1.2s ease-in-out infinite; }
.quiz-done-title { font-size: 32px; font-weight: 800; color: var(--green-dark); margin: 4px 0 6px; line-height: 1.15; }
#quiz-done p { font-size: 20px; }
#quiz-done p b { color: var(--orange-dark); }

/* ---------- 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) {
  .panel { padding: 18px 14px; border-radius: 24px; }
  .panel h2 { font-size: 26px; }
  .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; }
  .score-box { min-width: 90px; padding: 5px 12px 3px; }
  .score-box .value { font-size: 24px; }
  .stage-chip { font-size: 13px; padding: 5px 10px; }
  .progress .bar { width: 100px; }
  .progress .text { font-size: 16px; min-width: 56px; }
  .hud-top {
    grid-template-columns: 1fr auto;
    grid-template-areas: "left right" "center center";
    gap: 6px 10px;
  }
  .hud-center { justify-self: center; }
  .hint { font-size: 16px; padding: 5px 14px; }
  .screen-head h2 { font-size: 22px; white-space: nowrap; }
  .screen-head .btn { font-size: 16px; padding: 10px 14px; min-height: 44px; white-space: nowrap; }
  .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: 17px; }
  .lesson-body { grid-template-columns: 1fr; gap: 10px; }
  .lesson-demo .clock-svg { width: 170px; height: 170px; }
  .lesson-title { font-size: 23px; }
  .lesson-text p { font-size: 17px; }
  .clock-caption { font-size: 21px; }
  .quiz-q { font-size: 21px; }
  .quiz-clock .clock-svg { width: 160px; height: 160px; }
  .choice { font-size: 19px; min-height: 52px; padding: 10px 14px; }
  .quiz-feedback .explain { font-size: 16px; }
  .review-item { width: 100px; }
  .review-item .clock-svg { width: 70px; height: 70px; }
  .howto-item .tx { font-size: 16px; }
  .howto-item .em { font-size: 30px; width: 40px; }
  #controls .k { height: 54px; font-size: 26px; border-radius: 14px; }
  #controls { gap: 6px; padding: 6px; border-radius: 20px; }
}
@media (max-height: 900px) {
  #summary .panel, #fail .panel { padding: 16px 26px 18px; }
  .result-title { font-size: 30px; }
  .result-score { font-size: clamp(44px, 9vw, 64px); }
  .result-stars { font-size: 38px; margin: 2px 0; }
  .stats { margin: 8px 0 4px; gap: 8px; }
  .stat { padding: 6px 4px 6px; }
  .stat .v { font-size: 22px; }
  .stat .k { font-size: 13px; }
  #summary .btn-row, #fail .btn-row { margin-top: 10px; }
  #summary .btn.big { font-size: 26px; padding: 16px 36px; min-height: 64px; }
}
@media (max-height: 520px) {
  .logo-row svg { width: 90px; height: 90px; }
  .subtitle { margin: 4px 0 10px; }
  .panel { padding: 14px 20px; }
  .howto-item { padding: 8px 12px; }
  .lesson-demo .clock-svg { width: 150px; height: 150px; }
  .quiz-clock .clock-svg { width: 130px; height: 130px; }
  #controls .k { height: 46px; font-size: 22px; }
  #controls .drop small { display: none; }
}
