/* ==========================================================================
   HISTORY & CIVICS 6 — WEBSITE MAROON & GOLD 3D THEME
   Matches the 2nd reference image design & color combination
   ========================================================================== */

:root {
  --sis-maroon: #851013;
  --sis-maroon-dark: #5a0a0c;
  --sis-maroon-deep: #3d0607;
  --sis-maroon-light: #a8181c;
  --sis-gold: #d4a017;
  --sis-gold-bright: #f59e0b;
  --sis-gold-dark: #b45309;
  --sis-cream: #fff8f0;
}

/* ---------- Launcher Background & Maroon/Gold Floating Spheres ---------- */
body.launcher {
  background-image: url('../assets/ui/launcher-bg-v2.webp') !important;
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
}

body:not(.launcher) {
  background: linear-gradient(120deg, #fbe8e8 0%, #fff9ee 48%, #f9dada 100%) !important;
}

.bg-spheres {
  opacity: 0.55;
}

.sphere-blue-1 {
  background: radial-gradient(circle at 30% 30%, #ffffff 0%, #fca5a5 16%, #b91c1c 55%, #851013 85%, #3d0607 100%) !important;
  box-shadow: 0 15px 35px rgba(133, 16, 19, 0.26) !important;
}

.sphere-pink-1 {
  background: radial-gradient(circle at 30% 30%, #ffffff 0%, #fde68a 16%, #f59e0b 55%, #b45309 85%, #451a03 100%) !important;
  box-shadow: 0 12px 28px rgba(180, 83, 9, 0.25) !important;
}

.sphere-blue-2 {
  background: radial-gradient(circle at 30% 30%, #ffffff 0%, #fde68a 16%, #f59e0b 55%, #b45309 85%, #451a03 100%) !important;
  box-shadow: 0 10px 22px rgba(180, 83, 9, 0.22) !important;
}

.sphere-pink-2 {
  background: radial-gradient(circle at 30% 30%, #ffffff 0%, #fca5a5 16%, #b91c1c 55%, #851013 85%, #3d0607 100%) !important;
  box-shadow: 0 20px 45px rgba(133, 16, 19, 0.28) !important;
}

/* ---------- Top Header Bar (.app-header) in Royal Maroon & Gold ---------- */
.app-header,
.gk-header-outer {
  min-height: 64px;
  padding: 10px 0 !important;
  background: linear-gradient(180deg, #9e1519 0%, #851013 55%, #5a0a0c 100%) !important;
  border-bottom: 4px solid #d4a017 !important;
  box-shadow: 0 8px 20px rgba(90, 10, 12, 0.28), inset 0 2px 3px rgba(255, 255, 255, 0.22) !important;
}

.app-header .container {
  margin-left: auto;
  margin-right: auto;
  padding-left: 15px;
  padding-right: 15px;
  box-sizing: border-box;
}

.app-header .chap-topbar-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.header-left,
.header-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* Back Button Pill (Royal Blue 3D) */
.chap-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: #ffffff !important;
  text-decoration: none !important;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 55%, #1d4ed8 100%) !important;
  border: 2.5px solid #ffffff !important;
  border-bottom: 5px solid #ffffff !important;
  border-radius: 20px !important;
  padding: 5px 16px 7px !important;
  box-shadow: 0 4px 10px rgba(30, 58, 138, 0.3), inset 0 2px 3px rgba(255, 255, 255, 0.35) !important;
  text-shadow: 0 2px 0 rgba(30, 58, 138, 0.55) !important;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.chap-back-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.chap-back-btn:active {
  transform: translateY(1px);
}

/* Class Badge Pill (Warm Gold/Amber 3D) */
.lvl-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: #ffffff !important;
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 55%, #b45309 100%) !important;
  border: 2.5px solid #ffffff !important;
  border-bottom: 5px solid #ffffff !important;
  border-radius: 20px !important;
  padding: 5px 16px 7px !important;
  box-shadow: 0 4px 10px rgba(69, 26, 3, 0.3), inset 0 2px 3px rgba(255, 255, 255, 0.35) !important;
  text-shadow: 0 2px 0 rgba(120, 53, 15, 0.55) !important;
}

/* Round Header Tool Buttons */
.header-btn,
.topbar .iconbtn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #fff8f0) !important;
  border: 2.5px solid #ffffff !important;
  border-bottom: 5px solid #e2c08d !important;
  color: #851013 !important;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.14) !important;
}

.lang-select-pill {
  background: #fff8f0 !important;
  border: 2px solid #d4a017 !important;
  border-bottom: 5px solid #b45309 !important;
  color: #5a0a0c !important;
}

.custom-dropdown-list {
  border: 2.5px solid #d4a017 !important;
}

.custom-dropdown-item.selected {
  background: #fcf1f1 !important;
  color: #851013 !important;
}

/* ---------- Hub Title Badges & Chapter Cards (#chapScr) ---------- */
#chapScr.on {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

#chapScr .hub {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  max-width: 780px !important;
  width: 100% !important;
  margin: 0 auto !important;
  padding: 14px 14px 8vh !important;
}

#chapScr .hub-title-section {
  margin-bottom: 14px !important;
}

/* Hide big floating HISTORY text so it matches the 2nd reference image */
#chapScr .hub-logo-text {
  display: none !important;
}

/* Main 3D Capsule Badge — Website Royal Maroon & Gold */
.hub-main-badge {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 9px 30px 12px !important;
  margin: 0 0 7px !important;
  font-family: 'Fredoka', sans-serif !important;
  font-weight: 800 !important;
  font-size: clamp(18px, 2.8vw, 24px) !important;
  color: #ffffff !important;
  background: linear-gradient(180deg, #b91c1c 0%, #851013 52%, #5a0a0c 100%) !important;
  border: 3.5px solid #f59e0b !important;
  border-bottom: 7px solid #3d0607 !important;
  border-radius: 20px !important;
  box-shadow: 0 8px 18px rgba(61, 6, 7, 0.32), inset 0 2px 4px rgba(255, 255, 255, 0.28) !important;
  text-shadow: 0 3px 0 rgba(45, 4, 5, 0.55) !important;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

/* Sub 3D Capsule Badge — Website Warm Gold & Amber */
.hub-sub-badge {
  display: inline-block !important;
  padding: 6px 20px 8px !important;
  margin: 0 !important;
  font-family: 'Fredoka', sans-serif !important;
  font-weight: 700 !important;
  font-size: clamp(12px, 1.8vw, 14px) !important;
  color: #ffffff !important;
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 55%, #b45309 100%) !important;
  border: 2px solid #fde68a !important;
  border-bottom: 5px solid #78350f !important;
  border-radius: 15px !important;
  box-shadow: 0 6px 12px rgba(120, 53, 15, 0.25), inset 0 2px 3px rgba(255, 255, 255, 0.3) !important;
  text-shadow: 0 1.5px 0 rgba(92, 40, 10, 0.55) !important;
}

/* Chapter Cards Grid (Centered between characters, Maroon & Gold theme) */
#chapCards {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 10px 14px !important;
  max-width: 740px !important;
  width: 100% !important;
  margin: 0 auto !important;
}

#chapCards .pcard.chapter-card {
  --theme-c1: #851013;
  --theme-c2: #5a0a0c;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 11px !important;
  width: 100% !important;
  min-height: 86px !important;
  padding: 9px 13px !important;
  color: #1e293b !important;
  text-align: left !important;
  background: linear-gradient(180deg, #ffffff 55%, rgba(252, 241, 241, 0.55) 100%), #ffffff !important;
  border: 2.5px solid #851013 !important;
  border-bottom: 7px solid #5a0a0c !important;
  border-radius: 20px !important;
  box-shadow: 0 8px 18px rgba(61, 6, 7, 0.14), inset 0 2px 4px #ffffff !important;
  transition: transform 0.14s ease, box-shadow 0.14s ease !important;
}

#chapCards .pcard.chapter-card:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 12px 24px rgba(133, 16, 19, 0.22), inset 0 2px 4px #ffffff !important;
}

#chapCards .pcard.chapter-card .ic {
  flex: 0 0 46px !important;
  width: 46px !important;
  height: 46px !important;
  border-radius: 50% !important;
  background: radial-gradient(circle at 35% 30%, #fffbeb 0%, #fde68a 100%) !important;
  border: 2px solid rgba(133, 16, 19, 0.22) !important;
  color: #851013 !important;
  font-size: 22px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.1), inset 0 2px 4px rgba(255, 255, 255, 0.6) !important;
}

#chapCards .pcard.chapter-card .tx {
  flex: 1 !important;
  min-width: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 2px !important;
}

#chapCards .pcard.chapter-card .tt {
  font-family: 'Fredoka', sans-serif !important;
  font-weight: 700 !important;
  font-size: clamp(13.5px, 1.5vw, 15.5px) !important;
  line-height: 1.2 !important;
  color: #1e293b !important;
}

#chapCards .pcard.chapter-card .dd {
  display: block !important;
  font-family: 'Outfit', sans-serif !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  color: #64748b !important;
  line-height: 1.25 !important;
}

#chapCards .pcard.chapter-card .chapter-progress-track {
  display: block;
  width: 100%;
  max-width: 185px;
  height: 5px;
  margin: 2px 0 1px !important;
  border-radius: 99px;
  background: #f3e2c3 !important;
  box-shadow: inset 0 1px 2px rgba(90, 10, 12, 0.12);
  overflow: hidden;
}

#chapCards .pcard.chapter-card .chapter-progress-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #851013, #f59e0b) !important;
}

#chapCards .pcard.chapter-card .pill {
  display: inline-block !important;
  margin-top: 2px !important;
  align-self: flex-start !important;
  background: #fff8f0 !important;
  color: #851013 !important;
  border-radius: 12px !important;
  font-family: 'Outfit', sans-serif !important;
  font-size: 10px !important;
  font-weight: 800 !important;
  padding: 1.5px 9px !important;
  border: 1.5px solid #851013 !important;
}

#chapCards .pcard.chapter-card .arrow-circle {
  flex: 0 0 32px !important;
  width: 32px !important;
  height: 32px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #851013, #5a0a0c) !important;
  color: #ffffff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 14px !important;
  font-weight: bold !important;
  box-shadow: 0 3px 0 #3d0607, inset 0 1px 2px rgba(255, 255, 255, 0.35) !important;
}

/* ---------- Inner Game Screen (#gameScr) Maroon & Gold Theme ---------- */
.card-shell {
  border: 3px solid rgba(255, 255, 255, 0.96) !important;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(255, 248, 240, 0.84)) !important;
  box-shadow: 0 24px 60px rgba(90, 10, 12, 0.18), inset 0 2px 5px rgba(255, 255, 255, 0.95) !important;
}

.card-shell::before {
  background:
    radial-gradient(circle at 4% 82%, rgba(212, 160, 23, 0.16) 0 9%, transparent 9.2%),
    radial-gradient(circle at 98% 28%, rgba(133, 16, 19, 0.12) 0 8%, transparent 8.2%),
    linear-gradient(135deg, rgba(255, 248, 235, 0.55), rgba(252, 241, 241, 0.5)) !important;
}

.topbar {
  border-bottom: 6px solid rgba(133, 16, 19, 0.1) !important;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 248, 242, 0.94)) !important;
}

.topbar .lvl {
  max-width: 29%;
  border: 2.5px solid #f59e0b !important;
  border-bottom: 5px solid #3d0607 !important;
  background: linear-gradient(180deg, #a8181c, #851013) !important;
  color: #ffffff !important;
  box-shadow: 0 6px 14px rgba(90, 10, 12, 0.25) !important;
}

.topbar .gname {
  font-size: 17px;
  color: #5a0a0c !important;
}

.dots .dot.done {
  border-color: #851013 !important;
  background: #851013 !important;
}

.dots .dot.cur {
  border-color: #ffffff !important;
  background: #d4a017 !important;
  box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.4) !important;
}

.statpill {
  background: #fff8f0 !important;
  border: 2px solid #f3e2c3 !important;
}

.statpill b {
  color: #851013 !important;
}

.statpill small {
  color: #b45309 !important;
}

.gbody {
  border: 4px solid rgba(255, 255, 255, 0.98) !important;
  border-bottom: 10px solid #e6d5c3 !important;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(255, 251, 245, 0.95)) !important;
  box-shadow: 0 20px 42px rgba(90, 10, 12, 0.12), inset 0 3px 8px rgba(255, 255, 255, 0.98) !important;
}

.qbig {
  color: #851013 !important;
  text-shadow: 0 2px 0 rgba(212, 160, 23, 0.25), 0 5px 12px rgba(133, 16, 19, 0.14) !important;
}

.qsub {
  color: #5a0a0c !important;
  background: #fff8f0 !important;
  border: 2px solid #f3e2c3 !important;
  border-bottom: 4px solid #e2c08d !important;
}

.bottombar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 248, 240, 0.94)) !important;
}

.bbtn.back,
.bbtn.hint {
  border: 3px solid #ffffff !important;
  border-bottom: 6px solid #e2c08d !important;
  background: linear-gradient(180deg, #ffffff, #fff8f0) !important;
  color: #5a0a0c !important;
}

.bbtn.next {
  background: linear-gradient(180deg, #a8181c, #851013) !important;
  border: 3px solid #ffffff !important;
  border-bottom: 6px solid #4a0709 !important;
  color: #ffffff !important;
  box-shadow: 0 8px 16px rgba(133, 16, 19, 0.28) !important;
  text-shadow: 0 2px 0 rgba(61, 6, 7, 0.45) !important;
}

.progpill {
  color: #851013 !important;
  border: 3px solid #fcf1f1 !important;
  border-bottom: 5px solid #e5b8b9 !important;
  box-shadow: 0 5px 12px rgba(133, 16, 19, 0.12) !important;
}

.chip {
  background: linear-gradient(180deg, #a8181c, #851013) !important;
  border-bottom-color: #4a0709 !important;
}

/* Preserve the established interface while allowing Class 6 answer lengths. */
#gameScr .cards3 .opt,
#gameScr .cards3 .opt:has(img),
#gameScr .cards3 .opt:has(.ct-visual) {
  min-height: 138px;
  max-height: none;
  height: 100%;
  padding: 14px 12px 36px;
}

#gameScr .cards3 .otext {
  font-size: 17px !important;
  line-height: 1.35;
  overflow-wrap: normal !important;
  flex-shrink: 0;
  max-height: none;
  word-break: normal;
  hyphens: auto;
}

#gameScr .gbody > .qimg {
  flex-shrink: 0;
  max-width: 90%;
  height: clamp(140px, 24vh, 225px);
}

#gameScr .mitem {
  overflow-wrap: normal;
  min-height: 88px;
}

#gameScr .mitem img {
  height: 65px;
  width: 80px;
  object-fit: contain;
}

#gameScr .gbody > * {
  flex-shrink: 0;
}

#gameScr .written-answer {
  min-height: 110px;
  resize: vertical;
}

#gameScr .gbody > .book-diagram {
  width: min(760px, 100%);
  max-width: 100%;
  height: auto;
  max-height: 350px;
  animation: none;
}

#gameScr .gbody:not(:has(> .qimg)) > .written-answer {
  margin-top: 20px;
}

#gameScr .written-answer,
#gameScr .sample-answer {
  max-width: 850px;
}

#gameScr .sample-answer {
  width: 100%;
  line-height: 1.6;
  box-sizing: border-box;
}

#gameScr .pick img {
  height: 90px;
  object-fit: contain;
  max-width: 100%;
}

#gameScr .ogrid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#gameScr .ocard {
  min-height: 230px;
}

#gameScr .ocard img {
  height: 140px;
}

.case-source {
  width: min(850px, 100%);
  box-sizing: border-box;
  background: #fff8f0;
  border: 1px solid #f3e2c3;
  border-radius: 16px;
  padding: 12px 18px;
  text-align: left;
  line-height: 1.55;
  font-size: 16px;
  color: #5a0a0c;
}

.case-source summary {
  cursor: pointer;
  font-weight: 700;
}

.case-source p {
  margin: 8px 0 0;
}

#gameScr .cards3 {
  align-items: stretch;
}

#gameScr .cards3 .opt {
  aspect-ratio: auto;
  height: auto;
  min-height: 150px;
}

#gameScr .cards3 .opt.txt,
#gameScr .cards3:has(> .opt:nth-child(2):last-child) .opt.txt {
  height: auto;
  min-height: 150px;
  max-height: none;
  padding: 16px 12px 40px;
}

@media (max-width: 900px) {
  #chapScr .hub {
    max-width: 680px !important;
    padding: 14px 12px 40px !important;
  }
  #chapCards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 760px) {
  #gameScr .topbar .lvl {
    max-width: 65%;
    font-size: 11px;
  }
  #gameScr .topbar .gname {
    max-width: 100%;
    font-size: 14px;
  }
  #gameScr .cards3 .opt {
    min-height: 130px;
  }
  #gameScr .cards3 .otext {
    font-size: 15px !important;
  }
  #gameScr .ogrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #gameScr .ocard {
    min-height: 200px;
  }
  #gameScr .ocard img {
    height: 110px;
  }
  #gameScr .qbig {
    font-size: 21px;
  }
  #gameScr .mitem {
    font-size: 14px;
    min-height: 92px;
    padding: 8px;
  }
  #gameScr .mitem img {
    width: 55px;
    height: 55px;
  }
}

@media (max-width: 600px) {
  #chapCards {
    grid-template-columns: 1fr !important;
  }
  #gameScr .gbody > .qimg {
    height: 150px;
  }
  #gameScr .topbar {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 43px 38px 38px;
    gap: 5px;
    align-items: center;
  }
  #gameScr .topbar #menuBtn {
    grid-column: 1;
    grid-row: 1;
  }
  #gameScr .topbar #lvl {
    grid-column: 2;
    grid-row: 1;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
    padding: 7px;
  }
  #gameScr .topbar .statpill {
    grid-column: 3;
    grid-row: 1;
    min-width: 0;
    padding: 4px;
  }
  #gameScr .topbar #sndBtn {
    grid-column: 4;
    grid-row: 1;
  }
  #gameScr .topbar .settings-wrapper-outer {
    grid-column: 5;
    grid-row: 1;
  }
  #gameScr .topbar #gname {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    max-width: 100%;
    text-align: center;
    margin: 2px 0;
  }
  #gameScr .topbar #dots {
    display: none;
  }
  #gameScr .topbar .iconbtn,
  #gameScr .topbar .header-btn {
    width: 36px;
    height: 36px;
    min-width: 0;
  }
  .case-source {
    font-size: 14px;
    padding: 10px 12px;
  }
}

/* Single-Chapter Centered Layout & Reference UI Enhancements */
.app-header .container,
#chapScr .app-header .container {
  padding-left: 15px !important;
  padding-right: 15px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  box-sizing: border-box !important;
}

#chapScr .chap-back-btn {
  display: inline-flex !important;
}

#chapScr .hub {
  max-width: 980px !important;
  width: 100% !important;
  margin: 0 auto !important;
  padding: 20px 16px 11vh !important;
}

#chapScr .hub-title-section {
  margin-bottom: 22px !important;
}

.hub-main-badge {
  padding: 10px 32px 13px !important;
  margin: 0 0 8px !important;
  font-size: clamp(18px, 3vw, 25px) !important;
  border: 3.5px solid #f59e0b !important;
  border-bottom: 8px solid #3d0607 !important;
  border-radius: 20px !important;
}

.hub-sub-badge {
  padding: 7px 22px 9px !important;
  font-size: clamp(12.5px, 2vw, 14.5px) !important;
  border: 2px solid #fde68a !important;
  border-bottom: 5px solid #78350f !important;
  border-radius: 15px !important;
}

#chapCards,
#chapCards:has(> :only-child) {
  display: flex !important;
  justify-content: center !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 4px auto 0 !important;
  padding-top: 0 !important;
}

#chapCards .pcard.chapter-card {
  --theme-c1: #851013;
  --theme-c2: #5a0a0c;
  position: relative !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 14px !important;
  width: min(100%, 470px) !important;
  max-width: 470px !important;
  min-height: 112px !important;
  padding: 14px 18px !important;
  color: #1e293b !important;
  text-align: left !important;
  background: linear-gradient(180deg, #ffffff 55%, rgba(252, 241, 241, 0.5) 100%), #ffffff !important;
  border: 3px solid #851013 !important;
  border-bottom: 8px solid #5a0a0c !important;
  border-radius: 22px !important;
  box-shadow: 0 10px 22px rgba(61, 6, 7, 0.14), inset 0 2px 4px #ffffff !important;
}

#chapCards .pcard.chapter-card .ic {
  flex: 0 0 58px !important;
  width: 58px !important;
  height: 58px !important;
  border-radius: 50% !important;
  background: #fff8f0 !important;
  border: 2.5px solid #851013 !important;
  overflow: hidden !important;
  padding: 0 !important;
  box-shadow: 0 4px 10px rgba(90, 10, 12, 0.18) !important;
}

#chapCards .pcard.chapter-card .ic img.book-card-img {
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  object-fit: contain !important;
  object-position: center center !important;
  border-radius: 50% !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
}

#chapCards .pcard.chapter-card .tx {
  gap: 3px !important;
}

#chapCards .pcard.chapter-card .tt {
  font-size: clamp(15.5px, 2.2vw, 18px) !important;
  line-height: 1.22 !important;
}

#chapCards .pcard.chapter-card .dd {
  font-size: 12.5px !important;
  line-height: 1.3 !important;
  margin-top: 1px !important;
}

#chapCards .pcard.chapter-card .chapter-progress-track {
  width: 100% !important;
  max-width: 220px !important;
  height: 6px !important;
  margin: 4px 0 2px !important;
}

#chapCards .pcard.chapter-card .pill {
  margin-top: 3px !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  padding: 2px 10px !important;
  border-radius: 12px !important;
  border: 1.5px solid #851013 !important;
}

#chapCards .pcard.chapter-card .arrow-circle {
  flex: 0 0 36px !important;
  width: 36px !important;
  height: 36px !important;
  font-size: 16px !important;
  box-shadow: 0 3px 0 #5a0a0c, inset 0 1px 2px rgba(255, 255, 255, 0.35) !important;
}

/* Inner Game Shell & 3D Answer Tiles Matching Reference UI */
#gameScr .topbar .gname {
  display: none !important;
}

#gameScr .gbody {
  justify-content: flex-start !important;
  padding-top: clamp(16px, 2.4vh, 24px) !important;
  padding-bottom: clamp(18px, 2.8vh, 28px) !important;
  gap: clamp(12px, 2vh, 20px) !important;
}

#gameScr .gbody > .qimg,
#gameScr img,
#gameScr .qimg,
#gameScr .ocard img,
#gameScr .opt img,
#gameScr .mitem img,
#gameScr .pick img {
  animation: none !important;
  transform: none !important;
}

#gameScr .gbody > .qimg {
  width: auto !important;
  height: auto !important;
  max-width: min(640px, 94%) !important;
  max-height: clamp(190px, 30dvh, 265px) !important;
  margin-top: auto !important;
  margin-bottom: auto !important;
  display: block !important;
  object-fit: contain !important;
  background: #ffffff !important;
  padding: 0 !important;
  overflow: hidden !important;
  border-radius: 16px !important;
  border: 3px solid #f3e2c3 !important;
  box-shadow: 0 8px 20px rgba(90, 10, 12, 0.12) !important;
}

#gameScr .gbody > .cards3 {
  margin-top: auto !important;
  margin-bottom: clamp(6px, 1.4vh, 14px) !important;
}

#gameScr .gbody:not(:has(> .qimg)) {
  justify-content: flex-start !important;
}

#gameScr .gbody:not(:has(> .qimg)) > .cards3 {
  margin-top: auto !important;
  margin-bottom: auto !important;
}

#gameScr .gbody:not(:has(> .qimg)) > .cards3 .opt,
#gameScr .gbody:not(:has(> .qimg)) > .cards3 .opt.txt {
  min-height: 142px !important;
}

#gameScr .cards3 .opt,
#gameScr .cards3 .opt.txt {
  min-height: 138px !important;
  padding: 14px 12px 36px !important;
  border-radius: 22px !important;
  border: 3px solid #ffffff !important;
  border-bottom: 10px solid #2FA85C !important;
  background: linear-gradient(170deg, #ffffff 0%, #F3FCF4 40%, #E4F8EA 100%) !important;
  box-shadow: 0 14px 26px rgba(57, 74, 125, 0.12), inset 0 2px 6px rgba(255, 255, 255, 0.9) !important;
  color: #243449 !important;
}

#gameScr .cards3 .opt:nth-child(4n+2),
#gameScr .cards3 .opt.txt:nth-child(4n+2) {
  border-bottom-color: #F0932B !important;
  background: linear-gradient(170deg, #ffffff 0%, #FFF7E8 40%, #FDEECF 100%) !important;
}

#gameScr .cards3 .opt:nth-child(4n+3),
#gameScr .cards3 .opt.txt:nth-child(4n+3) {
  border-bottom-color: #8E4FD0 !important;
  background: linear-gradient(170deg, #ffffff 0%, #F7F0FE 40%, #EFE2FC 100%) !important;
}

#gameScr .cards3 .opt:nth-child(4n+4),
#gameScr .cards3 .opt.txt:nth-child(4n+4) {
  border-bottom-color: #3E8BF3 !important;
  background: linear-gradient(170deg, #ffffff 0%, #EDF5FF 40%, #DEEBFC 100%) !important;
}

#gameScr .cards3 .opt .radio,
#gameScr .cards3 .opt.txt .radio {
  bottom: 10px !important;
  width: 24px !important;
  height: 24px !important;
  border: 2px solid #ffffff !important;
  box-shadow: inset 0 2px 4px rgba(45,61,99,.18), 0 2px 4px rgba(0,0,0,0.08) !important;
}

#gameScr .cards3 .opt.correct,
#gameScr .cards3 .opt.txt.correct {
  background: linear-gradient(170deg, #ffffff 0%, #E5FBEC 40%, #C9F5DA 100%) !important;
  border-color: #ffffff !important;
  border-bottom-color: #17A657 !important;
}

#gameScr .cards3 .opt.wrong,
#gameScr .cards3 .opt.txt.wrong {
  background: linear-gradient(170deg, #ffffff 0%, #FFEDF1 40%, #FDD5DE 100%) !important;
  border-color: #ffffff !important;
  border-bottom-color: #E8355F !important;
}

#gameScr .cards3 .otext {
  font-family: "Segoe UI", Arial, sans-serif !important;
  font-weight: 600 !important;
  font-size: 17px !important;
  line-height: 1.35 !important;
  color: #243449 !important;
}

#gameScr .mcol:first-child .mitem {
  border: 3px solid #ffffff !important;
  border-bottom: 6px solid #851013 !important;
  border-radius: 18px !important;
  background: linear-gradient(145deg, #fffafa, #fce8e8) !important;
  color: #5a0a0c !important;
  box-shadow: 0 8px 16px rgba(90, 10, 12, 0.12), inset 0 2px 4px #fff !important;
}

#gameScr .mcol:last-child .mitem {
  border: 3px solid #ffffff !important;
  border-bottom: 6px solid #b45309 !important;
  border-radius: 18px !important;
  background: linear-gradient(145deg, #fffdf7, #fef3c7) !important;
  color: #78350f !important;
  box-shadow: 0 8px 16px rgba(90, 10, 12, 0.12), inset 0 2px 4px #fff !important;
}

/* Match the Columns: fill vertical height cleanly on both desktop and mobile (no bottom gap) */
#gameScr .gbody:has(> .qimg):has(> .mwrap),
#gameScr .gbody:has(> .mwrap) {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding-top: clamp(18px, 3vh, 28px) !important;
  padding-bottom: clamp(20px, 3.5vh, 32px) !important;
  gap: clamp(14px, 2.5vh, 24px) !important;
}

#gameScr .gbody:has(> .qimg):has(> .mwrap) > .qimg {
  align-self: center !important;
  width: auto !important;
  height: auto !important;
  max-width: min(440px, 90%) !important;
  max-height: clamp(105px, 15vh, 140px) !important;
}

#gameScr .gbody:has(> .qimg):has(> .mwrap) > .qpill,
#gameScr .gbody:has(> .mwrap) > .qpill {
  align-self: center !important;
  margin: 0 auto !important;
  flex: 0 0 auto !important;
}

#gameScr .gbody:has(> .qimg):has(> .mwrap) > .mwrap,
#gameScr .gbody:has(> .mwrap) > .mwrap {
  width: 100% !important;
  max-width: 740px !important;
  flex: 1 1 auto !important;
  margin: 0 auto !important;
  display: flex !important;
  align-items: stretch !important;
  justify-content: center !important;
  gap: clamp(14px, 2.4vw, 24px) !important;
}

#gameScr .mcol {
  flex: 1 1 0 !important;
  max-width: 350px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  gap: clamp(8px, 1.4vh, 16px) !important;
}

#gameScr .mitem {
  flex: 1 1 0 !important;
  height: auto !important;
  min-height: clamp(50px, 7.6vh, 96px) !important;
  max-height: 116px !important;
  padding: 10px 16px !important;
  font-family: 'Baloo 2', 'Fredoka', sans-serif !important;
  font-weight: 800 !important;
  font-size: clamp(15px, 2vw, 18px) !important;
}

#gameScr .gbody:has(> .case-source) {
  gap: 7px !important;
  padding-top: 10px !important;
}

#gameScr .gbody:has(> .case-source) > .qimg {
  height: auto !important;
  max-height: clamp(102px, 14.5vh, 136px) !important;
}

#gameScr .gbody:has(> .case-source) .case-source {
  padding: 8px 14px !important;
  font-size: 14.5px !important;
  line-height: 1.4 !important;
}

#gameScr .gbody:has(> .case-source) .cards3 .opt {
  min-height: 94px !important;
  padding: 10px 10px 28px !important;
}

#gameScr .gbody:has(> .lines) {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: clamp(10px, 1.8vh, 18px) !important;
  padding-top: clamp(16px, 2.5vh, 26px) !important;
  padding-bottom: clamp(18px, 2.8vh, 28px) !important;
}

#gameScr .gbody:has(> .lines) > .hintline {
  flex: 0 0 auto !important;
  padding: 8px 22px 10px !important;
  border-radius: 20px !important;
  background: #fff8f0 !important;
  border: 2px solid #f3e2c3 !important;
  border-bottom: 4px solid #e2c08d !important;
  color: #5a0a0c !important;
  font-family: 'Fredoka', sans-serif !important;
  font-weight: 700 !important;
  font-size: clamp(14.5px, 1.8vw, 16.5px) !important;
}

#gameScr .gbody:has(> .lines) > .qimg {
  height: auto !important;
  max-height: clamp(98px, 13.5vh, 128px) !important;
}

#gameScr .gbody:has(> .lines) .lines {
  flex: 1 1 auto !important;
  width: 100% !important;
  max-width: 760px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-evenly !important;
  gap: clamp(8px, 1.4vh, 14px) !important;
  margin: 0 auto !important;
}

#gameScr .gbody:has(> .lines) .line {
  display: block !important;
  text-align: start !important;
  min-height: clamp(48px, 7.2vh, 72px) !important;
  padding: clamp(8px, 1.4vh, 14px) 18px !important;
  font-size: clamp(15px, 1.9vw, 18px) !important;
  border-radius: 18px !important;
  border: 3px solid #ffffff !important;
  border-bottom: 6px solid #e2c08d !important;
  background: linear-gradient(145deg, #ffffff, #fffdf9) !important;
  color: #2b1112 !important;
  box-shadow: 0 8px 16px rgba(90, 10, 12, 0.08), inset 0 2px 4px #ffffff !important;
}

#gameScr .gbody:has(> .lines) .line.cur {
  border-bottom-color: #851013 !important;
  background: linear-gradient(145deg, #fffafa, #fce8e8) !important;
}

#gameScr .gbody:has(> .lines) .line .blank {
  border-bottom: 3px dashed #851013 !important;
  color: #851013 !important;
  margin: 0 4px !important;
}

#gameScr .gbody:has(> .lines) .bank {
  flex: 0 0 auto !important;
  gap: 12px !important;
  margin-top: 4px !important;
  margin-bottom: 4px !important;
}

#gameScr .gbody:has(> .lines) .chip {
  padding: 10px 20px !important;
  font-size: clamp(15px, 1.8vw, 17px) !important;
}

#gameScr .sample-answer {
  width: min(850px, 100%);
  box-sizing: border-box;
  background: #fff8f0;
  border: 2px solid #f3e2c3;
  border-radius: 16px;
  padding: 10px 16px;
  margin: 4px auto;
  text-align: left;
  line-height: 1.55;
  font-size: 15px;
  color: #5a0a0c;
}

#gameScr .sample-answer summary {
  cursor: pointer;
  font-weight: 700;
  color: #851013;
}

#gameScr .sample-answer p {
  margin: 8px 0 0;
  white-space: pre-line;
}

@media (max-width: 720px) {
  #gameScr .cards3:has(> .opt:nth-child(4):last-child),
  #gameScr .cards3:has(> .opt:nth-child(2):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }
  #gameScr .gbody:has(> .mwrap) > .mwrap {
    gap: 10px !important;
  }
  #gameScr .mitem {
    min-height: clamp(68px, 10.5vh, 92px) !important;
    padding: 8px 10px !important;
    font-size: 14.5px !important;
  }
}

@media (max-width: 600px) {
  #chapCards:has(> :only-child) {
    max-width: 94% !important;
    grid-template-columns: 1fr !important;
  }
  #gameScr .gbody > .qimg {
    height: auto !important;
    max-height: clamp(130px, 21vh, 180px) !important;
    max-width: 96% !important;
  }
  #gameScr .cards3:has(> .opt:nth-child(4):last-child),
  #gameScr .cards3:has(> .opt:nth-child(2):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  #gameScr .cards3 .opt,
  #gameScr .cards3 .opt.txt {
    min-height: 98px !important;
    padding: 10px 10px 30px !important;
  }
  #gameScr .gbody:not(:has(> .qimg)) > .cards3 .opt,
  #gameScr .gbody:not(:has(> .qimg)) > .cards3 .opt.txt {
    min-height: 112px !important;
  }
  #gameScr .cards3 .otext {
    font-size: 13.5px !important;
    line-height: 1.3 !important;
  }
  #gameScr .sample-answer {
    font-size: 13.5px;
    padding: 8px 12px;
  }
}


.blank.curblank { border-color: #C71F26 !important; background: #FFF2CC !important; color: #851013 !important; box-shadow: 0 0 0 3px rgba(199, 31, 38, 0.18) !important; }

/* ==========================================================================
   RTL (URDU / ARABIC) DROPDOWN FIX & FULL MOBILE + DESKTOP RESPONSIVENESS
   ========================================================================== */

/* 1. Keep Topbars, Bottombar, and Language Dropdown Menu in LTR layout
      even when Urdu/Arabic (dir=rtl) is active so settings dropdown never
      flips to the left edge or gets clipped off-screen! */
html[dir="rtl"] .app-header .chap-topbar-inner,
html[dir="rtl"] .gk-header,
html[dir="rtl"] #gameScr .topbar,
html[dir="rtl"] #gameScr .bottombar,
html[dir="rtl"] .settings-wrapper-outer,
html[dir="rtl"] .lang-dropdown-container,
html[dir="rtl"] .custom-dropdown-list,
html[dir="rtl"] .custom-dropdown-item,
html[dir="rtl"] .lang-select-pill {
  direction: ltr !important;
}

.app-header,
.gk-header-outer,
#gameScr .topbar,
.settings-wrapper-outer {
  overflow: visible !important;
  z-index: 50 !important;
}

.lang-dropdown-container {
  right: 0 !important;
  left: auto !important;
  z-index: 9999 !important;
}

.lang-dropdown-container.open {
  width: 168px !important;
  right: 0 !important;
  left: auto !important;
}

.custom-dropdown-list {
  right: 0 !important;
  left: auto !important;
  width: 185px !important;
  min-width: 185px !important;
  max-width: calc(100vw - 24px) !important;
  z-index: 10000 !important;
  box-sizing: border-box !important;
}

.custom-dropdown-item {
  direction: ltr !important;
  text-align: left !important;
  justify-content: flex-start !important;
  padding: 9px 14px !important;
  gap: 10px !important;
  white-space: nowrap !important;
}

.custom-dropdown-item .lang-name {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* Proper Urdu / RTL typography inside question & answer elements */
html[dir="rtl"] .qbig,
html[dir="rtl"] .qsub,
html[dir="rtl"] .qpill,
html[dir="rtl"] .hintline,
html[dir="rtl"] #gameScr .cards3 .otext,
html[dir="rtl"] #gameScr .mitem,
html[dir="rtl"] #gameScr .line,
html[dir="rtl"] .pcard .tx {
  direction: rtl !important;
  line-height: 1.55 !important;
}

html[dir="rtl"] #chapCards .pcard.chapter-card .tx,
html[dir="rtl"] #listCards .pcard .tx {
  align-items: flex-start !important;
  text-align: right !important;
}

/* 2. Exact Game 1, 2, 3 Answer Box Layout:
      - Desktop (> 720px): 4 boxes in 1 row for MCQs, 2 boxes in 1 row for True/False
      - Tablet & Mobile (<= 720px, including all phones): 2x2 grid (2 columns), never 1 column
      - Radio circle always centered at the bottom of each 3D card */
#gameScr .cards3:has(> .opt:nth-child(4):last-child) {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  max-width: 840px !important;
}

#gameScr .cards3:has(> .opt:nth-child(2):last-child) {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  max-width: 580px !important;
}

#gameScr .cards3 .opt,
#gameScr .cards3 .opt.txt {
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
}

#gameScr .cards3 .opt .radio,
#gameScr .cards3 .opt.txt .radio,
#gameScr .cards3:has(> .opt:nth-child(2):last-child) .opt.txt .radio {
  left: 50% !important;
  right: auto !important;
  top: auto !important;
  bottom: 10px !important;
  transform: translateX(-50%) !important;
}

@media (max-width: 720px) {
  #gameScr .cards3,
  #gameScr .cards3:has(> .opt:nth-child(4):last-child),
  #gameScr .cards3:has(> .opt:nth-child(2):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
    max-width: 100% !important;
  }
}

@media (max-width: 600px) {
  #gameScr .cards3,
  #gameScr .cards3:has(> .opt:nth-child(4):last-child),
  #gameScr .cards3:has(> .opt:nth-child(2):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    max-width: 100% !important;
  }
  #gameScr .cards3 .opt .radio,
  #gameScr .cards3 .opt.txt .radio,
  #gameScr .cards3:has(> .opt:nth-child(2):last-child) .opt.txt .radio {
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: 8px !important;
    transform: translateX(-50%) !important;
    width: 22px !important;
    height: 22px !important;
  }
}

html[dir="rtl"] #chapCards .pcard.chapter-card,
html[dir="rtl"] #listCards .pcard {
  direction: ltr !important;
}

html[dir="rtl"] #chapCards .pcard.chapter-card .tx,
html[dir="rtl"] #listCards .pcard .tx {
  direction: rtl !important;
  align-items: flex-end !important;
  text-align: right !important;
}

html[dir="rtl"] #gameScr .gbody:has(> .lines) .line {
  direction: rtl !important;
  text-align: right !important;
  line-height: 1.8 !important;
}

/* ==========================================================================
   FULL MOBILE, TABLET & DESKTOP RESPONSIVE POLISH (ALL SCREENS & GAMES)
   ========================================================================== */

/* 1. Global Header & Container Responsiveness */
@media (max-width: 575.98px) {
  .app-header,
  .gk-header-outer {
    min-height: 56px !important;
    padding: 8px 0 !important;
  }
  .app-header .container,
  #chapScr .app-header .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .app-header .chap-topbar-inner,
  .gk-header {
    gap: 6px !important;
  }
  .header-left,
  .header-right,
  .gk-hl,
  .gk-hr {
    gap: 6px !important;
  }
  .chap-back-btn,
  .lvl-badge {
    font-size: 12px !important;
    padding: 5px 12px 6px !important;
    border-bottom-width: 4px !important;
  }
  .header-btn {
    width: 38px !important;
    height: 38px !important;
    font-size: 16px !important;
    border-bottom-width: 4px !important;
  }
}

/* 2. Chapter Hub (#chapScr) & Activity List (#listScr) Responsiveness */
.hub-main-badge,
.hub-sub-badge {
  max-width: 100% !important;
  box-sizing: border-box !important;
  word-wrap: break-word !important;
}

#listScr #listCards .pcard {
  height: auto !important;
  min-height: 100px !important;
}

@media (max-width: 600px) {
  #chapScr .hub {
    padding: 16px 12px 6vh !important;
  }
  #chapScr .hub-title-section,
  #listScr .hub-title-section {
    margin-bottom: 16px !important;
    padding: 0 4px !important;
  }
  .hub-main-badge,
  #listScr .hub-main-badge {
    padding: 8px 18px 11px !important;
    font-size: clamp(15px, 4.3vw, 20px) !important;
    border-bottom-width: 6px !important;
    border-radius: 16px !important;
    line-height: 1.25 !important;
  }
  .hub-sub-badge,
  #listSubBadge {
    padding: 6px 14px 8px !important;
    font-size: clamp(11.5px, 3.2vw, 13.5px) !important;
    border-bottom-width: 4px !important;
    border-radius: 13px !important;
    line-height: 1.3 !important;
  }
  #chapCards,
  #chapCards:has(> :only-child) {
    max-width: 100% !important;
    padding: 0 2px !important;
  }
  #chapCards .pcard.chapter-card {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 98px !important;
    padding: 12px 14px !important;
    gap: 12px !important;
    border-radius: 20px !important;
  }
  #chapCards .pcard.chapter-card .ic {
    flex: 0 0 52px !important;
    width: 52px !important;
    height: 52px !important;
  }
  #chapCards .pcard.chapter-card .tt {
    font-size: clamp(15px, 4.2vw, 17px) !important;
  }
  #chapCards .pcard.chapter-card .dd {
    font-size: 11.5px !important;
  }
  #listScr .hub {
    padding: 14px 12px 28px !important;
  }
  #listScr .hub-logo-emoji {
    font-size: 40px !important;
    margin-bottom: 8px !important;
  }
  #listScr #listCards {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    margin-top: 14px !important;
  }
  #listScr #listCards .pcard {
    min-height: 88px !important;
    padding: 12px 14px !important;
  }
}

/* 3. Game Screen (#gameScr) Shell, Topbar & Bottombar on Tablet & Mobile */
@media (min-width: 601px) and (max-width: 720px) {
  #gameScr .topbar .statpill {
    margin-left: auto !important;
  }
}

@media (max-width: 600px) {
  #gameScr {
    padding: 6px !important;
  }
  #gameScr .card-shell {
    height: calc(100dvh - 12px) !important;
    max-height: calc(100dvh - 12px) !important;
    border-radius: 20px !important;
  }
  #gameScr .topbar {
    display: grid !important;
    grid-template-columns: 38px minmax(0, 1fr) auto 38px 38px !important;
    gap: 6px !important;
    align-items: center !important;
    min-height: 54px !important;
    padding: 7px 10px 8px !important;
    border-radius: 18px 18px 0 0 !important;
  }
  #gameScr .topbar #lvl {
    font-size: 11px !important;
    padding: 6px 10px 7px !important;
    text-align: center !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  #gameScr .topbar .statpill {
    padding: 4px 8px !important;
    min-width: 46px !important;
  }
  #gameScr .topbar .statpill b {
    font-size: 13px !important;
  }
  #gameScr .topbar .iconbtn,
  #gameScr .topbar .header-btn {
    width: 38px !important;
    height: 38px !important;
    font-size: 16px !important;
  }
  #gameScr .gbody {
    margin: 6px 8px !important;
    padding: 10px 10px 12px !important;
    gap: 6px !important;
    border-radius: 18px !important;
    border-bottom-width: 6px !important;
  }
  #gameScr .qbig {
    font-size: clamp(16.5px, 4.5vw, 20px) !important;
    line-height: 1.3 !important;
    padding: 0 4px !important;
  }
  #gameScr .qsub {
    font-size: clamp(12px, 3.3vw, 13.5px) !important;
    padding: 5px 14px !important;
  }
  #gameScr .gbody > .qimg {
    max-height: clamp(110px, 18.5dvh, 160px) !important;
    max-width: 94% !important;
    border-radius: 14px !important;
  }
  #gameScr .gbody:has(> .qimg) > .cards3 .opt,
  #gameScr .gbody:has(> .qimg) > .cards3 .opt.txt {
    min-height: clamp(84px, 13dvh, 104px) !important;
    padding: 8px 8px 26px !important;
  }
  #gameScr .gbody:not(:has(> .qimg)) > .cards3 .opt,
  #gameScr .gbody:not(:has(> .qimg)) > .cards3 .opt.txt {
    min-height: clamp(100px, 15.5dvh, 122px) !important;
    padding: 10px 8px 28px !important;
  }
  /* Fill in the Blanks mobile fit */
  #gameScr .gbody:has(> .lines) {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    gap: 6px !important;
  }
  #gameScr .gbody:has(> .lines) > .hintline {
    padding: 5px 14px 7px !important;
    font-size: 13px !important;
  }
  #gameScr .gbody:has(> .lines) .lines {
    gap: 6px !important;
  }
  #gameScr .gbody:has(> .lines) .line {
    min-height: 0 !important;
    padding: 7px 12px !important;
    font-size: clamp(13px, 3.6vw, 15px) !important;
    line-height: 1.45 !important;
    border-radius: 14px !important;
    border-bottom-width: 4px !important;
  }
  #gameScr .gbody:has(> .lines) .bank {
    gap: 7px !important;
  }
  #gameScr .gbody:has(> .lines) .chip {
    padding: 7px 13px !important;
    font-size: clamp(13px, 3.5vw, 15px) !important;
    border-radius: 13px !important;
    border-bottom-width: 5px !important;
  }
  /* Match the Columns mobile fit */
  #gameScr .gbody:has(> .mwrap) {
    padding-top: 10px !important;
    padding-bottom: 12px !important;
    gap: 10px !important;
  }
  #gameScr .gbody:has(> .mwrap) > .qpill {
    font-size: clamp(14px, 3.8vw, 16px) !important;
    padding: 6px 14px 8px !important;
  }
  #gameScr .mcol {
    gap: 6px !important;
  }
  #gameScr .mitem {
    min-height: clamp(44px, 6.8dvh, 72px) !important;
    padding: 6px 8px !important;
    font-size: clamp(13px, 3.5vw, 15px) !important;
    line-height: 1.25 !important;
    border-radius: 14px !important;
    border-bottom-width: 5px !important;
  }
  /* Bottombar mobile fit — never wraps or overflows */
  #gameScr .bottombar {
    min-height: 56px !important;
    padding: 7px 8px 9px !important;
    gap: 5px !important;
    flex-wrap: nowrap !important;
  }
  #gameScr .bottombar .bbtn {
    min-height: 38px !important;
    padding: 6px 10px 7px !important;
    font-size: clamp(11.5px, 3.3vw, 13px) !important;
    border-radius: 11px !important;
    border-bottom-width: 4px !important;
    white-space: nowrap !important;
  }
  #gameScr .bottombar .progpill {
    padding: 5px 10px !important;
    font-size: clamp(11px, 3.1vw, 12.5px) !important;
    white-space: nowrap !important;
  }
  #gameScr .bottombar .navgrp {
    gap: 5px !important;
    flex-shrink: 0 !important;
  }
}

/* ==========================================================================
   4. EXTRA RESPONSIVE ENHANCEMENTS (LAPTOPS, TABLETS, SMALL PHONES, LANDSCAPE)
   ========================================================================== */

/* Keep Game Topbar on a single clean row across all devices */
#gameScr .topbar {
  flex-wrap: nowrap !important;
}

#gameScr .topbar #lvl {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

/* Tablet & Medium Screens (601px – 991px) */
@media (min-width: 601px) and (max-width: 991px) {
  #chapScr .hub {
    max-width: 92vw !important;
    padding: 18px 16px 8vh !important;
  }
  #gameScr {
    padding: 10px !important;
  }
  #gameScr .card-shell {
    max-width: 96vw !important;
    height: calc(100dvh - 20px) !important;
    max-height: calc(100dvh - 20px) !important;
  }
  #gameScr .topbar {
    min-height: 62px !important;
    padding: 8px 14px 10px !important;
    gap: 8px !important;
  }
  #gameScr .topbar .lvl {
    max-width: 46% !important;
    font-size: 12px !important;
    padding: 6px 14px 8px !important;
  }
  #gameScr .gbody {
    margin: 10px 14px !important;
    padding: 14px 16px 18px !important;
  }
  #gameScr .cards3:has(> .opt:nth-child(4):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    max-width: 640px !important;
    gap: 14px !important;
  }
  #gameScr .cards3 .opt,
  #gameScr .cards3 .opt.txt {
    min-height: 112px !important;
    padding: 12px 12px 32px !important;
  }
}

@media (max-width: 820px) {
  #gameScr .topbar .dots {
    display: none !important;
  }
  #gameScr .topbar .statpill {
    margin-left: auto !important;
  }
}

/* Short-Height Desktops & Laptops (e.g. 1366x768, 1440x800, 1280x720) */
@media (min-width: 601px) and (max-height: 820px) {
  #gameScr {
    padding: 8px 14px !important;
  }
  #gameScr .card-shell {
    height: calc(100dvh - 16px) !important;
    max-height: calc(100dvh - 16px) !important;
  }
  #gameScr .topbar {
    min-height: 56px !important;
    padding: 6px 16px 8px !important;
  }
  #gameScr .bottombar {
    min-height: 58px !important;
    padding: 7px 16px 9px !important;
  }
  #gameScr .gbody {
    margin: 8px 18px !important;
    padding: 12px 20px 14px !important;
    gap: clamp(8px, 1.4dvh, 14px) !important;
  }
  #gameScr .qbig {
    font-size: clamp(18px, 2vw, 22px) !important;
    line-height: 1.3 !important;
  }
  #gameScr .qsub {
    font-size: 13px !important;
    padding: 4px 14px !important;
  }
  #gameScr .gbody > .qimg {
    max-height: clamp(165px, 26dvh, 225px) !important;
  }
  #gameScr .cards3 .opt,
  #gameScr .cards3 .opt.txt {
    min-height: clamp(98px, 15.5dvh, 124px) !important;
    padding: 10px 10px 30px !important;
  }
  #gameScr .gbody:not(:has(> .qimg)) > .cards3 .opt,
  #gameScr .gbody:not(:has(> .qimg)) > .cards3 .opt.txt {
    min-height: clamp(110px, 17dvh, 134px) !important;
  }
  #gameScr .cards3 .otext {
    font-size: clamp(14.5px, 1.4vw, 16.5px) !important;
  }
  #gameScr .mitem {
    min-height: clamp(46px, 7.2dvh, 72px) !important;
    padding: 8px 14px !important;
    font-size: clamp(14px, 1.5vw, 16.5px) !important;
  }
  #gameScr .gbody:has(> .lines) .line {
    min-height: clamp(40px, 6.2dvh, 58px) !important;
    padding: 7px 14px !important;
    font-size: clamp(14px, 1.5vw, 16.5px) !important;
  }
  #gameScr .gbody:has(> .lines) .chip {
    padding: 7px 16px !important;
    font-size: 14.5px !important;
  }
}

/* Small Phones (<= 400px width, e.g. iPhone SE / Galaxy S / narrow Android) */
@media (max-width: 400px) {
  .chap-back-btn,
  .lvl-badge {
    font-size: 11px !important;
    padding: 4px 10px 5px !important;
  }
  .header-btn,
  #gameScr .topbar .iconbtn {
    width: 34px !important;
    height: 34px !important;
    font-size: 14px !important;
  }
  .hub-main-badge {
    padding: 7px 12px 9px !important;
    font-size: clamp(13.5px, 4.2vw, 16.5px) !important;
  }
  .hub-sub-badge {
    padding: 5px 10px 7px !important;
    font-size: clamp(10.5px, 3.1vw, 12px) !important;
  }
  #chapCards .pcard.chapter-card {
    padding: 10px 11px !important;
    gap: 10px !important;
    min-height: 86px !important;
  }
  #chapCards .pcard.chapter-card .ic {
    flex: 0 0 46px !important;
    width: 46px !important;
    height: 46px !important;
  }
  #chapCards .pcard.chapter-card .tt {
    font-size: 14px !important;
  }
  #chapCards .pcard.chapter-card .arrow-circle {
    flex: 0 0 30px !important;
    width: 30px !important;
    height: 30px !important;
    font-size: 13px !important;
  }
  #gameScr .topbar {
    grid-template-columns: 34px minmax(0, 1fr) auto 34px 34px !important;
    gap: 4px !important;
    padding: 6px 8px 7px !important;
  }
  #gameScr .qbig {
    font-size: clamp(15px, 4.3vw, 17.5px) !important;
  }
  #gameScr .gbody > .qimg {
    max-height: clamp(96px, 16.5dvh, 135px) !important;
  }
  #gameScr .cards3 {
    gap: 8px !important;
  }
  #gameScr .gbody:has(> .qimg) > .cards3 .opt,
  #gameScr .gbody:has(> .qimg) > .cards3 .opt.txt {
    min-height: clamp(76px, 12dvh, 94px) !important;
    padding: 6px 6px 24px !important;
    border-radius: 16px !important;
    border-bottom-width: 6px !important;
  }
  #gameScr .cards3 .otext {
    font-size: 12.5px !important;
    line-height: 1.25 !important;
  }
  #gameScr .mitem {
    font-size: 12.5px !important;
    padding: 5px 6px !important;
  }
  #gameScr .bottombar .bbtn {
    padding: 5px 8px 6px !important;
    font-size: 11px !important;
  }
  #gameScr .bottombar .progpill {
    padding: 4px 8px !important;
    font-size: 10.5px !important;
  }
}

/* Mobile Landscape Orientation (short viewport height <= 540px) */
@media (max-height: 540px) and (orientation: landscape) {
  #chapScr .hub {
    padding: 10px 14px 16px !important;
  }
  #chapScr .hub-title-section {
    margin-bottom: 10px !important;
  }
  #gameScr {
    padding: 4px 8px !important;
  }
  #gameScr .card-shell {
    height: calc(100dvh - 8px) !important;
    max-height: calc(100dvh - 8px) !important;
  }
  #gameScr .topbar {
    min-height: 44px !important;
    padding: 4px 10px 5px !important;
  }
  #gameScr .bottombar {
    min-height: 46px !important;
    padding: 4px 10px 6px !important;
  }
  #gameScr .gbody {
    margin: 4px 8px !important;
    padding: 6px 12px 8px !important;
    gap: 5px !important;
  }
  #gameScr .qbig {
    font-size: 15px !important;
    line-height: 1.2 !important;
  }
  #gameScr .qsub {
    display: none !important;
  }
  #gameScr .gbody > .qimg {
    max-height: clamp(70px, 20dvh, 105px) !important;
  }
  #gameScr .cards3,
  #gameScr .cards3:has(> .opt:nth-child(4):last-child) {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 8px !important;
    max-width: 100% !important;
  }
  #gameScr .cards3 .opt,
  #gameScr .cards3 .opt.txt,
  #gameScr .gbody:has(> .qimg) > .cards3 .opt,
  #gameScr .gbody:not(:has(> .qimg)) > .cards3 .opt {
    min-height: 68px !important;
    padding: 6px 6px 22px !important;
    border-bottom-width: 5px !important;
  }
  #gameScr .cards3 .otext {
    font-size: 12px !important;
    line-height: 1.2 !important;
  }
}

/* End Screen / Celebration Overlay Modal Responsiveness */
#endOv .endcard,
#endOv .modal-card {
  width: min(92vw, 430px) !important;
  max-height: 90dvh !important;
  overflow-y: auto !important;
  box-sizing: border-box !important;
  padding: clamp(18px, 3.5vw, 28px) clamp(16px, 3vw, 24px) !important;
}

/* Keep chapter card circular icon 100% full-bleed cover, while question images (.qimg) show 100% complete */
#chapCards .pcard.chapter-card .ic img.book-card-img {
  object-fit: cover !important;
}
#gameScr .gbody > .qimg {
  object-fit: contain !important;
}

/* Chapter-specific UI Background Image (from BG/class-1.png .. class-8.png) */
body.launcher {
  background-image: url('../assets/ui/chapter-bg.png?v=bg2') !important;
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
}

body:not(.launcher) {
  background: linear-gradient(120deg, #fbe8e8 0%, #fff9ee 48%, #f9dada 100%) !important;
}

/* ==========================================================================
   5. NOTEBOOK LINE-MATCHING (FULL-WIDTH COVERAGE + SVG CONNECTOR LINES)
   ========================================================================== */
#gameScr .topbar .statpill {
  display: flex !important;
}

#gameScr .gbody:has(> .qimg):has(> .mwrap),
#gameScr .gbody:has(> .mwrap) {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: space-between !important;
  padding: clamp(18px, 3vh, 28px) clamp(18px, 3vw, 38px) clamp(22px, 3.5vh, 32px) !important;
  gap: clamp(14px, 2.2vh, 22px) !important;
}

#gameScr .gbody:has(> .qimg):has(> .mwrap) > .mwrap,
#gameScr .gbody:has(> .mwrap) > .mwrap {
  position: relative !important;
  width: 100% !important;
  max-width: 100% !important;
  flex: 1 1 auto !important;
  margin: 0 auto !important;
  display: flex !important;
  align-items: stretch !important;
  justify-content: space-between !important;
  gap: clamp(80px, 18vw, 240px) !important;
}

#gameScr .mwrap .match-svg {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none !important;
  z-index: 4 !important;
  overflow: visible !important;
}

#gameScr .mcol {
  position: relative !important;
  z-index: 2 !important;
  flex: 0 1 clamp(210px, 33%, 300px) !important;
  width: clamp(210px, 33%, 300px) !important;
  max-width: 300px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  gap: clamp(12px, 2vh, 22px) !important;
}

#gameScr .mitem {
  position: relative !important;
  flex: 0 0 auto !important;
  height: 54px !important;
  min-height: 54px !important;
  max-height: 58px !important;
  padding: 8px 18px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-family: 'Segoe UI', 'Outfit', 'Nunito', sans-serif !important;
  font-weight: 600 !important;
  font-size: clamp(14px, 1.2vw, 15.5px) !important;
  line-height: 1.25 !important;
  letter-spacing: 0.1px !important;
  border-radius: 13px !important;
  user-select: none !important;
  touch-action: none !important;
  cursor: pointer !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease !important;
}

#gameScr .mitem .mtext {
  text-align: center !important;
  width: 100% !important;
}

/* Notebook connector dots on inner edges of Column A and Column B */
#gameScr .mitem .mdot {
  position: absolute !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 14px !important;
  height: 14px !important;
  border-radius: 50% !important;
  background: #ffffff !important;
  border: 3px solid #851013 !important;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15) !important;
  z-index: 5 !important;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease !important;
}

#gameScr .mcol-l .mitem .mdot-r {
  right: -8px !important;
  border-color: #851013 !important;
}

#gameScr .mcol-r .mitem .mdot-l {
  left: -8px !important;
  border-color: #b45309 !important;
}

#gameScr .mitem.sel .mdot {
  background: #2563eb !important;
  border-color: #1d4ed8 !important;
  transform: translateY(-50%) scale(1.2) !important;
}

#gameScr .mitem.done .mdot {
  border-color: #ffffff !important;
  transform: translateY(-50%) scale(1.1) !important;
}

#gameScr .mcol:first-child .mitem {
  border: 1.5px solid #f0cfd0 !important;
  border-bottom: 4px solid #851013 !important;
  background: linear-gradient(180deg, #ffffff 0%, #fdf3f3 100%) !important;
  color: #4a0e10 !important;
  box-shadow: 0 4px 10px rgba(90, 10, 12, 0.06), inset 0 1px 0 #ffffff !important;
}

#gameScr .mcol:last-child .mitem {
  border: 1.5px solid #f2dfb6 !important;
  border-bottom: 4px solid #b45309 !important;
  background: linear-gradient(180deg, #ffffff 0%, #fef9ed 100%) !important;
  color: #5c2808 !important;
  box-shadow: 0 4px 10px rgba(180, 83, 9, 0.06), inset 0 1px 0 #ffffff !important;
}

#gameScr .mcol .mitem.done {
  border-color: var(--pair-color, #16a34a) !important;
  border-bottom-color: var(--pair-color, #15803d) !important;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%) !important;
  color: #14532d !important;
  opacity: 1 !important;
}

#gameScr .mcol .mitem:hover:not(.done) {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 16px rgba(90, 10, 12, 0.11), inset 0 1px 0 #ffffff !important;
}

#gameScr .mcol .mitem.sel {
  border-color: #2563eb !important;
  border-bottom-color: #1d4ed8 !important;
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%) !important;
  color: #1e3a8a !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16), 0 6px 14px rgba(30, 58, 138, 0.1) !important;
}

@media (min-width: 601px) and (max-width: 991px) {
  #gameScr .gbody:has(> .mwrap) {
    padding: clamp(16px, 2.5vh, 24px) clamp(16px, 2.5vw, 28px) !important;
    gap: 14px !important;
  }
  #gameScr .gbody:has(> .mwrap) > .mwrap {
    gap: clamp(90px, 16vw, 170px) !important;
  }
  #gameScr .mcol {
    flex: 0 0 38% !important;
    width: 38% !important;
    max-width: 38% !important;
    justify-content: space-evenly !important;
    gap: clamp(14px, 2.2dvh, 24px) !important;
  }
  #gameScr .mitem {
    height: clamp(58px, 7.8dvh, 78px) !important;
    min-height: clamp(58px, 7.8dvh, 78px) !important;
    max-height: 82px !important;
    padding: 8px 14px !important;
    font-size: clamp(14.5px, 1.9vw, 16.5px) !important;
  }
}

@media (max-width: 600px) {
  /* Even vertical distribution on Mobile Portrait MCQ (.cards3) */
  #gameScr .gbody:has(> .cards3) {
    justify-content: space-evenly !important;
    padding: 12px 10px 14px !important;
  }
  #gameScr .gbody > .qimg {
    max-height: clamp(145px, 24dvh, 210px) !important;
    max-width: 94% !important;
  }
  #gameScr .gbody:has(> .qimg) > .cards3 .opt,
  #gameScr .gbody:has(> .qimg) > .cards3 .opt.txt {
    min-height: clamp(92px, 14dvh, 114px) !important;
    padding: 10px 8px 28px !important;
  }
  /* Mobile Portrait Notebook Line-Matching (.mwrap) */
  #gameScr .gbody:has(> .mwrap) {
    padding: 12px 10px 14px !important;
    gap: 10px !important;
  }
  #gameScr .gbody:has(> .mwrap) > .mwrap {
    gap: clamp(52px, 16vw, 76px) !important;
  }
  #gameScr .mcol {
    flex: 0 0 39% !important;
    width: 39% !important;
    max-width: 39% !important;
    justify-content: space-evenly !important;
    gap: 12px !important;
  }
  #gameScr .mitem {
    height: clamp(68px, 10.5dvh, 84px) !important;
    min-height: clamp(68px, 10.5dvh, 84px) !important;
    max-height: 88px !important;
    padding: 8px 10px !important;
    font-size: clamp(12.5px, 3.3vw, 14px) !important;
    line-height: 1.25 !important;
    border-radius: 13px !important;
    border-bottom-width: 4px !important;
  }
  #gameScr .mitem .mdot {
    width: 13px !important;
    height: 13px !important;
    border-width: 2.5px !important;
  }
  #gameScr .mcol-l .mitem .mdot-r {
    right: -7px !important;
  }
  #gameScr .mcol-r .mitem .mdot-l {
    left: -7px !important;
  }
}

/* Mobile Landscape Orientation (short viewport height <= 540px) — Zero Vertical Overflow */
@media (max-height: 540px) and (orientation: landscape) {
  #gameScr .gbody:has(> .lines) {
    padding: 6px 14px 8px !important;
    gap: 6px !important;
    justify-content: space-evenly !important;
  }
  #gameScr .gbody:has(> .lines) > .hintline,
  #gameScr .gbody:has(> .lines) > .qpill {
    padding: 3px 12px 4px !important;
    font-size: 12px !important;
  }
  #gameScr .gbody:has(> .lines) .lines {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px 10px !important;
    flex: 0 1 auto !important;
  }
  #gameScr .gbody:has(> .lines) .line {
    min-height: 0 !important;
    padding: 5px 10px !important;
    font-size: 12px !important;
    line-height: 1.3 !important;
    border-radius: 10px !important;
    border-bottom-width: 3px !important;
  }
  #gameScr .gbody:has(> .lines) .slot {
    min-width: 68px !important;
    height: 22px !important;
    padding: 1px 6px !important;
    font-size: 11.5px !important;
  }
  #gameScr .gbody:has(> .lines) .bank {
    gap: 6px !important;
    padding: 2px 0 !important;
  }
  #gameScr .gbody:has(> .lines) .chip {
    padding: 4px 12px !important;
    font-size: 12px !important;
    border-radius: 10px !important;
    border-bottom-width: 3px !important;
  }
  #gameScr .gbody:has(> .mwrap) {
    padding: 6px 16px 8px !important;
    gap: 5px !important;
  }
  #gameScr .gbody:has(> .mwrap) > .qpill {
    padding: 3px 12px 4px !important;
    font-size: 12px !important;
  }
  #gameScr .gbody:has(> .mwrap) > .mwrap {
    gap: clamp(90px, 18vw, 180px) !important;
  }
  #gameScr .mcol {
    flex: 0 0 36% !important;
    width: 36% !important;
    max-width: 36% !important;
    justify-content: space-between !important;
    gap: 5px !important;
  }
  #gameScr .mitem {
    height: clamp(32px, 8.8dvh, 38px) !important;
    min-height: 32px !important;
    max-height: 38px !important;
    padding: 3px 12px !important;
    font-size: 12px !important;
    line-height: 1.15 !important;
    border-radius: 10px !important;
    border-bottom-width: 3px !important;
  }
  #gameScr .mitem .mdot {
    width: 11px !important;
    height: 11px !important;
    border-width: 2px !important;
  }
  #gameScr .mcol-l .mitem .mdot-r {
    right: -6px !important;
  }
  #gameScr .mcol-r .mitem .mdot-l {
    left: -6px !important;
  }
}


/* ==========================================================================
   6. TRANSPARENT CUTOUT (.png) & FULL DESKTOP + MOBILE RESPONSIVE PERFECTION
   ========================================================================== */
#gameScr .gbody > .qimg[src$=".png"] {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  filter: drop-shadow(0 8px 18px rgba(45, 20, 10, 0.14)) !important;
}

/* Desktop & Large Screens (>= 992px): lock card-shell to viewport & give Match columns generous width */
@media (min-width: 992px) {
  #gameScr {
    padding: 14px 20px !important;
  }
  #gameScr .card-shell {
    max-width: min(960px, 95vw) !important;
    height: calc(100dvh - 28px) !important;
    max-height: calc(100dvh - 28px) !important;
  }
  #gameScr .gbody {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  #gameScr .gbody:has(> .mwrap) > .mwrap {
    gap: clamp(70px, 14vw, 180px) !important;
  }
  #gameScr .mcol {
    flex: 0 1 clamp(240px, 37%, 340px) !important;
    width: clamp(240px, 37%, 340px) !important;
    max-width: 340px !important;
  }
  #gameScr .mitem {
    height: auto !important;
    min-height: clamp(54px, 7.2dvh, 68px) !important;
    max-height: none !important;
    padding: 9px 18px !important;
  }
}

@media (min-width: 721px) {
  #gameScr .cards3:has(> .opt:nth-child(3):last-child) {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    max-width: 760px !important;
  }
}

/* Tablet Portrait & Landscape (601px - 991px) */
@media (min-width: 601px) and (max-width: 991px) {
  #gameScr .gbody {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  #gameScr .gbody:has(> .mwrap) > .mwrap {
    gap: clamp(64px, 13vw, 140px) !important;
  }
  #gameScr .mcol {
    flex: 0 0 40% !important;
    width: 40% !important;
    max-width: 40% !important;
  }
  #gameScr .mitem {
    height: auto !important;
    min-height: clamp(56px, 7.6dvh, 76px) !important;
    max-height: none !important;
    padding: 8px 14px !important;
  }
}

/* Mobile Portrait (<= 600px) */
@media (max-width: 600px) {
  #gameScr .gbody {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  #gameScr .gbody:has(> .mwrap) > .mwrap {
    gap: clamp(28px, 10vw, 52px) !important;
  }
  #gameScr .mcol {
    flex: 0 0 42.5% !important;
    width: 42.5% !important;
    max-width: 42.5% !important;
    gap: clamp(8px, 1.5dvh, 12px) !important;
  }
  #gameScr .mitem {
    height: auto !important;
    min-height: clamp(54px, 8.8dvh, 76px) !important;
    max-height: none !important;
    padding: 7px 9px !important;
    font-size: clamp(12px, 3.2vw, 13.8px) !important;
    line-height: 1.24 !important;
  }
}

/* Short-Height Mobile Portrait (e.g. 360x640, 375x667) — guarantee zero vertical scroll */
@media (max-width: 600px) and (max-height: 700px) {
  #gameScr .gbody {
    padding: 8px 8px 10px !important;
    gap: 5px !important;
  }
  #gameScr .qbig {
    font-size: clamp(15px, 4.2vw, 17.5px) !important;
    line-height: 1.22 !important;
  }
  #gameScr .qsub {
    padding: 3px 12px !important;
    font-size: 11.5px !important;
  }
  #gameScr .gbody > .qimg {
    max-height: clamp(105px, 19dvh, 145px) !important;
  }
  #gameScr .gbody:has(> .qimg) > .cards3 .opt,
  #gameScr .gbody:has(> .qimg) > .cards3 .opt.txt {
    min-height: clamp(72px, 11.8dvh, 88px) !important;
    padding: 6px 6px 24px !important;
  }
  #gameScr .gbody:has(> .lines) {
    padding: 7px 8px 8px !important;
    gap: 5px !important;
  }
  #gameScr .gbody:has(> .lines) > .hintline {
    padding: 4px 12px 5px !important;
    font-size: 12px !important;
  }
  #gameScr .gbody:has(> .lines) .lines {
    gap: 5px !important;
  }
  #gameScr .gbody:has(> .lines) .line {
    padding: 6px 10px !important;
    font-size: clamp(12.2px, 3.4vw, 13.8px) !important;
    line-height: 1.35 !important;
  }
  #gameScr .gbody:has(> .lines) .bank {
    gap: 6px !important;
  }
  #gameScr .gbody:has(> .lines) .chip {
    padding: 5px 11px !important;
    font-size: 12.5px !important;
  }
  #gameScr .gbody:has(> .mwrap) {
    padding: 8px 8px 10px !important;
    gap: 6px !important;
  }
  #gameScr .gbody:has(> .mwrap) > .qpill {
    padding: 4px 12px 6px !important;
    font-size: 13px !important;
  }
  #gameScr .mitem {
    min-height: clamp(48px, 8.2dvh, 64px) !important;
    padding: 6px 8px !important;
    font-size: clamp(11.8px, 3.2vw, 13px) !important;
  }
}

/* Mobile Landscape (short height <= 540px): ensure Chapter Hub & Match items fit 100% */
@media (max-height: 540px) and (orientation: landscape) {
  .app-header,
  .gk-header-outer {
    min-height: 46px !important;
    padding: 5px 0 !important;
  }
  #chapScr .hub {
    padding: 8px 14px 12px !important;
  }
  #chapScr .hub-title-section {
    margin-bottom: 8px !important;
  }
  .hub-main-badge {
    padding: 5px 18px 7px !important;
    font-size: clamp(14px, 2.5vw, 18px) !important;
    border-bottom-width: 5px !important;
  }
  .hub-sub-badge {
    padding: 4px 14px 5px !important;
    font-size: clamp(11px, 1.8vw, 13px) !important;
    border-bottom-width: 4px !important;
  }
  #chapCards .pcard.chapter-card {
    min-height: 78px !important;
    padding: 8px 14px !important;
  }
  #chapCards .pcard.chapter-card .ic {
    flex: 0 0 46px !important;
    width: 46px !important;
    height: 46px !important;
  }
  #gameScr .mcol {
    flex: 0 0 39% !important;
    width: 39% !important;
    max-width: 39% !important;
  }
  #gameScr .mitem {
    height: auto !important;
    min-height: clamp(32px, 8.5dvh, 42px) !important;
    max-height: none !important;
    padding: 4px 10px !important;
    font-size: 11.5px !important;
    line-height: 1.15 !important;
  }
}

/* ==========================================================================
   7. COMPLETE DESKTOP, TABLET & MOBILE RESPONSIVENESS (ALL 16 CHAPTERS + SINGLE CHAPTER)
   ========================================================================== */
#chapScr.on {
  height: 100dvh !important;
  max-height: 100dvh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  justify-content: flex-start !important;
}
#chapScr .app-header {
  position: sticky !important;
  top: 0 !important;
  z-index: 60 !important;
  flex-shrink: 0 !important;
}
/* Multi-chapter hub (16 chapters in 3-col grid on desktop, 2-col on tablet, 1-col on mobile) */
#chapScr:has(#chapCards.multi-chapters) .hub {
  flex: 0 0 auto !important;
  justify-content: flex-start !important;
  max-width: 1180px !important;
  width: 100% !important;
  margin: 0 auto !important;
  padding: clamp(14px, 2.2vh, 24px) clamp(12px, 2vw, 24px) 48px !important;
}
#chapScr #chapCards.multi-chapters {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 12px 14px !important;
  max-width: 1140px !important;
  width: 100% !important;
  margin: 6px auto 0 !important;
}
#chapScr #chapCards.multi-chapters .pcard.chapter-card {
  width: 100% !important;
  max-width: 100% !important;
  min-height: 88px !important;
  padding: 10px 12px !important;
  gap: 10px !important;
  box-sizing: border-box !important;
  text-decoration: none !important;
}
#chapScr #chapCards.multi-chapters .pcard.chapter-card .ic {
  flex: 0 0 48px !important;
  width: 48px !important;
  height: 48px !important;
}
#chapScr #chapCards.multi-chapters .pcard.chapter-card .tt {
  font-size: clamp(13.5px, 1.3vw, 15.5px) !important;
  line-height: 1.2 !important;
}
#chapScr #chapCards.multi-chapters .pcard.chapter-card .dd {
  font-size: 11px !important;
}
#chapScr #chapCards.multi-chapters .pcard.chapter-card .arrow-circle {
  flex: 0 0 32px !important;
  width: 32px !important;
  height: 32px !important;
  font-size: 14px !important;
}
@media (min-width: 961px) {
  #chapScr #chapCards.multi-chapters {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  }
  #chapScr #chapCards.multi-chapters .pcard.chapter-card {
    grid-column: span 2 !important;
  }
  #chapScr #chapCards.multi-chapters .pcard.chapter-card:nth-child(3n + 1):last-child {
    grid-column: 3 / span 2 !important;
  }
  #chapScr #chapCards.multi-chapters .pcard.chapter-card:nth-child(3n + 1):nth-last-child(2) {
    grid-column: 2 / span 2 !important;
  }
}
@media (max-width: 960px) {
  #chapScr #chapCards.multi-chapters {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
    max-width: 740px !important;
  }
  #chapScr #chapCards.multi-chapters .pcard.chapter-card:nth-child(2n + 1):last-child {
    grid-column: 1 / -1 !important;
    max-width: calc(50% - 6px) !important;
    justify-self: center !important;
  }
}
@media (max-width: 640px) {
  #chapScr #chapCards.multi-chapters {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    max-width: 520px !important;
  }
  #chapScr #chapCards.multi-chapters .pcard.chapter-card {
    min-height: 82px !important;
    padding: 10px 13px !important;
    gap: 11px !important;
  }
}

/* Single-chapter hub: vertically centered exactly like UMA reference */
#chapScr:not(:has(#chapCards.multi-chapters)) .hub {
  flex: 1 1 auto !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  max-width: 980px !important;
  width: 100% !important;
  margin: 0 auto !important;
  padding: 20px 16px 11vh !important;
}
#chapScr:not(:has(#chapCards.multi-chapters)) #chapCards {
  display: flex !important;
  justify-content: center !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 4px auto 0 !important;
}
#chapScr:not(:has(#chapCards.multi-chapters)) #chapCards .pcard.chapter-card {
  width: min(100%, 470px) !important;
  max-width: 470px !important;
  min-height: 112px !important;
  padding: 14px 18px !important;
}

/* MCQ Option Boxes (.cards3): 2, 3, or 4 options on Desktop, Tablet & Mobile */
#gameScr .cards3 .opt,
#gameScr .cards3 .opt.txt {
  height: auto !important;
  max-height: none !important;
  box-sizing: border-box !important;
}
@media (max-width: 720px) {
  #gameScr .cards3:has(> .opt:nth-child(3):last-child) > .opt:nth-child(3) {
    grid-column: 1 / -1 !important;
    width: calc(50% - 5px) !important;
    max-width: calc(50% - 5px) !important;
    justify-self: center !important;
  }
}
@media (max-width: 480px) {
  #gameScr .cards3 .opt,
  #gameScr .cards3 .opt.txt {
    min-height: clamp(74px, 11.5dvh, 96px) !important;
    padding: 8px 8px 26px !important;
  }
  #gameScr .cards3 .otext {
    font-size: clamp(12.5px, 3.4vw, 14px) !important;
    line-height: 1.26 !important;
  }
}

/* Notebook Line-Matching (.mwrap.notebook-match): flexible multi-line height on all screens */
#gameScr .mwrap.notebook-match .mcol {
  justify-content: space-evenly !important;
}
#gameScr .mwrap.notebook-match .mitem {
  height: auto !important;
  min-height: clamp(46px, 6.8dvh, 64px) !important;
  max-height: none !important;
  padding: clamp(7px, 1.1dvh, 11px) clamp(12px, 1.8vw, 18px) !important;
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
}
#gameScr .mwrap.notebook-match .mitem .mtext {
  display: block !important;
  width: 100% !important;
  line-height: 1.25 !important;
  font-size: clamp(13px, 1.25vw, 15.5px) !important;
}
@media (max-width: 600px) {
  #gameScr .gbody:has(> .mwrap.notebook-match) {
    padding: 10px 8px 12px !important;
    gap: 8px !important;
  }
  #gameScr .gbody:has(> .mwrap.notebook-match) > .mwrap.notebook-match {
    gap: clamp(32px, 10vw, 56px) !important;
  }
  #gameScr .mwrap.notebook-match .mcol {
    flex: 0 0 43% !important;
    width: 43% !important;
    max-width: 43% !important;
    gap: clamp(6px, 1.2dvh, 10px) !important;
  }
  #gameScr .mwrap.notebook-match .mitem {
    min-height: clamp(42px, 6.5dvh, 58px) !important;
    padding: 6px 9px !important;
    border-radius: 11px !important;
  }
  #gameScr .mwrap.notebook-match .mitem .mtext {
    font-size: clamp(11.5px, 3.1vw, 13.2px) !important;
    line-height: 1.2 !important;
  }
}

/* Fill in the Blanks (.lines + .bank): scales cleanly for 3 to 7 lines */
#gameScr .gbody:has(> .lines) {
  padding: clamp(10px, 1.8dvh, 18px) clamp(10px, 2vw, 22px) !important;
  gap: clamp(6px, 1.2dvh, 12px) !important;
}
#gameScr .gbody:has(> .lines) .lines {
  gap: clamp(5px, 1dvh, 10px) !important;
}
#gameScr .gbody:has(> .lines) .line {
  min-height: 0 !important;
  padding: clamp(6px, 1.1dvh, 11px) clamp(12px, 1.8vw, 18px) !important;
  font-size: clamp(13.5px, 1.55vw, 17px) !important;
  line-height: 1.35 !important;
}
#gameScr .gbody:has(> .lines) .bank {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: center !important;
  gap: clamp(6px, 1vw, 10px) !important;
}
#gameScr .gbody:has(> .lines) .chip {
  padding: clamp(6px, 1dvh, 9px) clamp(12px, 1.6vw, 18px) !important;
  font-size: clamp(13px, 1.45vw, 16px) !important;
}
@media (max-width: 600px) {
  #gameScr .gbody:has(> .lines) .line {
    padding: 6px 10px !important;
    font-size: clamp(12.5px, 3.4vw, 14.5px) !important;
    line-height: 1.3 !important;
    border-radius: 12px !important;
  }
  #gameScr .gbody:has(> .lines) .chip {
    padding: 6px 11px !important;
    font-size: clamp(12px, 3.3vw, 13.8px) !important;
    border-radius: 11px !important;
  }
}

/* ==========================================================================
   8. UNIFIED MOBILE, TABLET & DESKTOP RESPONSIVE OVERRIDES (ALL GAMES)
   ========================================================================== */

/* Global viewport safety — zero horizontal overflow on any device */
html,
body {
  width: 100% !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
  -webkit-text-size-adjust: 100% !important;
}

.scr,
.scr.on,
.app-header,
.gk-header-outer {
  width: 100% !important;
  max-width: 100vw !important;
  box-sizing: border-box !important;
}

.app-header .container,
#chapScr .app-header .container,
#listScr .app-header .container {
  width: 100% !important;
  max-width: 1240px !important;
  padding-left: clamp(12px, 3vw, 24px) !important;
  padding-right: clamp(12px, 3vw, 24px) !important;
  margin-left: auto !important;
  margin-right: auto !important;
  box-sizing: border-box !important;
}

/* Fix mobile browser fixed-background jitter */
@media (max-width: 991.98px) {
  html body,
  html body.launcher,
  html body:not(.launcher),
  #chapScr,
  #listScr,
  #gameScr,
  #coverScr {
    background-attachment: scroll !important;
  }
}

/* Activity List Screen (#listScr) full viewport scroll & responsive grid */
#listScr.on {
  display: flex !important;
  flex-direction: column !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

#listScr .app-header {
  position: sticky !important;
  top: 0 !important;
  z-index: 60 !important;
  flex-shrink: 0 !important;
}

#listScr .hub {
  width: 100% !important;
  max-width: 1140px !important;
  margin: 0 auto !important;
  padding: clamp(14px, 2.2vh, 24px) clamp(12px, 2.5vw, 24px) 40px !important;
  box-sizing: border-box !important;
}

#listScr #listCards {
  width: 100% !important;
  max-width: 1100px !important;
  margin: 18px auto 0 !important;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 14px 16px !important;
  box-sizing: border-box !important;
}

@media (max-width: 900px) {
  #listScr #listCards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px 14px !important;
  }
}

@media (max-width: 600px) {
  #listScr #listCards {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
}

/* Desktop & Tablet Stage Fit — Zero inner scrollbar in .gbody */
#gameScr .gbody {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

#gameScr .gbody::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

@media (min-width: 601px) {
  #gameScr .gbody {
    padding-top: clamp(10px, 1.8dvh, 18px) !important;
    padding-bottom: clamp(12px, 2dvh, 20px) !important;
    gap: clamp(8px, 1.4dvh, 14px) !important;
  }
  #gameScr .gbody > .qimg {
    max-height: clamp(150px, 25dvh, 230px) !important;
  }
  #gameScr .gbody > .cards3 {
    margin-top: auto !important;
    margin-bottom: 4px !important;
  }
  #gameScr .gbody:has(> .qimg) > .cards3 .opt,
  #gameScr .gbody:has(> .qimg) > .cards3 .opt.txt {
    min-height: clamp(102px, 14.5dvh, 126px) !important;
    padding: 12px 12px 32px !important;
  }
}

/* Picture-Rich Fill-in-the-Blanks (1-2 lines + 4K image, e.g. 1-50 & 1-100) */
#gameScr .gbody:has(> .lines):has(> .qimg):not(:has(.line:nth-child(3))) > .qimg {
  max-height: clamp(150px, 26dvh, 235px) !important;
  max-width: min(600px, 94%) !important;
}

@media (max-width: 600px) {
  #gameScr .gbody:has(> .lines):has(> .qimg):not(:has(.line:nth-child(3))) > .qimg {
    max-height: clamp(125px, 22dvh, 185px) !important;
    max-width: 95% !important;
  }
}

/* Mobile Responsive Overrides for Both Single-Chapter and Multi-Chapter Hubs */
@media (max-width: 640px) {
  #chapScr:not(:has(#chapCards.multi-chapters)) .hub {
    padding: 16px 14px 7vh !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  #chapScr:not(:has(#chapCards.multi-chapters)) #chapCards {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }
  #chapScr:not(:has(#chapCards.multi-chapters)) #chapCards .pcard.chapter-card {
    width: 100% !important;
    max-width: min(100%, 430px) !important;
    min-height: 96px !important;
    padding: 12px 14px !important;
    gap: 12px !important;
    box-sizing: border-box !important;
  }
  #chapScr #chapCards.multi-chapters {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    max-width: 520px !important;
    width: 100% !important;
  }
  #chapScr #chapCards.multi-chapters .pcard.chapter-card,
  #chapScr #chapCards.multi-chapters .pcard.chapter-card:nth-child(2n + 1):last-child,
  #chapScr #chapCards.multi-chapters .pcard.chapter-card:nth-child(3n + 1):last-child,
  #chapScr #chapCards.multi-chapters .pcard.chapter-card:nth-child(3n + 1):nth-last-child(2) {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: 100% !important;
    justify-self: stretch !important;
    min-height: 82px !important;
    padding: 10px 13px !important;
    gap: 11px !important;
  }
  .hub-title-section {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 4px !important;
    box-sizing: border-box !important;
  }
  .hub-main-badge,
  #listScr .hub-main-badge {
    max-width: 100% !important;
    padding: 8px 16px 10px !important;
    font-size: clamp(14.5px, 4.3vw, 19.5px) !important;
    line-height: 1.25 !important;
    white-space: normal !important;
    text-align: center !important;
  }
  .hub-sub-badge,
  #listSubBadge {
    max-width: 100% !important;
    padding: 6px 14px 8px !important;
    font-size: clamp(11.5px, 3.2vw, 13.5px) !important;
    line-height: 1.3 !important;
    white-space: normal !important;
    text-align: center !important;
  }
}

/* Extra-Small Phones (320px - 390px) */
@media (max-width: 390px) {
  .app-header .chap-topbar-inner {
    gap: 4px !important;
  }
  .header-left,
  .header-right {
    gap: 5px !important;
  }
  .chap-back-btn,
  .lvl-badge {
    font-size: 11px !important;
    padding: 4px 9px 5px !important;
  }
  #chapScr:not(:has(#chapCards.multi-chapters)) #chapCards .pcard.chapter-card {
    padding: 10px 12px !important;
    gap: 10px !important;
    min-height: 88px !important;
  }
  #chapScr:not(:has(#chapCards.multi-chapters)) #chapCards .pcard.chapter-card .ic {
    flex: 0 0 46px !important;
    width: 46px !important;
    height: 46px !important;
  }
  #chapScr:not(:has(#chapCards.multi-chapters)) #chapCards .pcard.chapter-card .tt {
    font-size: 14.5px !important;
  }
}
