/* Mobile-only layout adaptation. Desktop HTML, CSS, renderer, and palette unchanged. */
@media (max-width:767px) {
  /* Home, drill setup and performance */
  body:not(.exam-page) .shell { width:100%; max-width:100%; padding-left:12px; padding-right:12px; box-sizing:border-box; }
  body:not(.exam-page) .topbar .top-shell { gap:6px; }
  body:not(.exam-page) .brand {font-size:17px; min-width:0;}
  body:not(.exam-page) .site-nav { width:100%; }
  body:not(.exam-page) .nav-item { min-height:42px; }
  body:not(.exam-page) .main-grid { display:grid; grid-template-columns:minmax(0,1fr); }
  body:not(.exam-page) .panel { min-width:0; }
  body:not(.exam-page) .setting-title { gap:5px; }
  body:not(.exam-page) .topic-grid { grid-template-columns:1fr; }
  body:not(.exam-page) .mode-options { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body:not(.exam-page) .mode-card { min-width:0; }
  body:not(.exam-page) .allocation-row { flex-wrap:wrap; }
  body:not(.exam-page) .allocation-controls { width:100%; align-items:stretch; }
  body:not(.exam-page) .allocation-controls select,
  body:not(.exam-page) .allocation-controls input { width:100%; }
  body:not(.exam-page) .stat-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body:not(.exam-page) .performance-grid { grid-template-columns:minmax(0,1fr); }
  body:not(.exam-page) .stat .number {overflow-wrap:anywhere;}
  body:not(.exam-page) .movement-endpoints {flex-wrap:wrap;}
  body:not(.exam-page) .trend-controls {display:flex;flex-wrap:wrap;gap:8px;}
  body:not(.exam-page) .trend-controls label { flex:1 1 130px; min-width:0; }
  body:not(.exam-page) .trend-controls select { max-width:100%; width:100%; }
  body:not(.exam-page) .history-page-buttons { flex-wrap:wrap; justify-content:center; }
  body:not(.exam-page) .history-pagination { flex-wrap:wrap; gap:10px; justify-content:center; }
  body:not(.exam-page) .table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
  body:not(.exam-page) .modal {padding:12px;}
  body:not(.exam-page) .modal-box { max-height:calc(100dvh - 24px); overflow:auto; padding:18px; }
  body:not(.exam-page) .modal-box .actions { flex-wrap:wrap; }
  body:not(.exam-page) .modal-box .actions button { min-height:44px; }
  body:not(.exam-page) .resume-row {flex-wrap:wrap;}
  body:not(.exam-page) .resume-btn {min-height:44px;display:inline-flex;align-items:center;}
  body:not(.exam-page) .hero p {font-size:14px;line-height:1.5;}

  /* Results: keep the original cards and tables intact, scroll wide ones. */
  .result-main { padding:12px 10px !important; overflow-x:hidden; }
  .result-inner {width:100%;max-width:100%;gap:12px;min-width:0;}
  .result-card { padding:14px 12px; min-width:0; overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .result-header-inner {flex-wrap:wrap;gap:8px;}
  .result-actions {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;}
  .result-actions button {width:100%;min-height:44px;padding:9px 8px;}
  .overall-score-box { flex-wrap:wrap;gap:12px; }
  .overall-score {font-size:36px;}
  .overall-stats {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;}
  .stat-box {min-width:0;padding:10px 4px;}
  .charts-wrap {flex-direction:column;gap:14px;}
  .chart-box {max-width:100%;width:100%;min-width:0;overflow-x:auto;}
  .chart-box svg {max-width:100%;height:auto;}
  .result-table {min-width:570px;}
  .time-table,.history-table {min-width:490px;}
  .result-card .table-scroll,.trend-chart-wrap {overflow-x:auto;-webkit-overflow-scrolling:touch;}

  /* Original exam, with phone-size canvas instead of hard 900px minimum. */
  body.exam-page {zoom:1!important;}
  body.exam-page #screen-exam { position:fixed!important;inset:0!important;width:100%!important;height:100dvh!important;max-height:100dvh!important;overflow:hidden!important;background:#fff; }
  body.exam-page #wrapper {width:100%!important;height:100%!important;min-width:0!important;overflow:hidden!important;}
  body.exam-page #minwidth {min-width:0!important;width:100%!important;height:100%!important;overflow:hidden!important;}
  body.exam-page #candidateConsoleId {width:100%!important;max-width:100%!important;min-width:0!important;}
  body.exam-page #questionContent {width:100%!important;max-width:100%!important;min-width:0!important;overflow:hidden!important;}
  body.exam-page .headergrup {width:100%!important;min-width:0!important;}
  body.exam-page #sub-header {display:flex!important;width:100%!important;min-width:0!important;min-height:43px!important;height:auto!important;align-items:center;gap:7px;box-sizing:border-box;background:#333!important;padding:5px 9px!important;}
  body.exam-page #sub-header .exam_name {display:block!important;min-width:0;flex:1 1 auto;float:none!important;width:auto!important;}
  body.exam-page #sub-header .test-header {font-size:12px!important;line-height:1.25;color:#ffdc00;display:block;white-space:normal;}
  body.exam-page #sub-header .helpinstruction_div {display:flex!important;gap:6px!important;float:none!important;flex:0 0 auto;align-items:center;}
  body.exam-page #sub-header .instruction_div,body.exam-page #sub-header .viewquestion_div {float:none!important;display:block!important;}
  body.exam-page #sub-header #VI,body.exam-page #sub-header #viewQPButton {font-size:11px!important;min-height:34px!important;padding:4px 6px!important;white-space:nowrap;}
  body.exam-page #sub-header .time-details_new {display:none!important;}
  body.exam-page #sub-header .skipLink_div {display:none!important;}
  body.exam-page #analyse-top-bar {float:none!important;margin:0!important;max-width:100%;display:flex;gap:7px!important;flex-wrap:wrap;order:2;}
  body.exam-page.bankdrills-analyse-mode #sub-header {flex-wrap:wrap!important;}
  body.exam-page.bankdrills-analyse-mode #sub-header .exam_name {flex:1 1 auto!important;}
  body.exam-page.bankdrills-analyse-mode #analyse-top-bar {order:3!important;flex:1 1 100%!important;width:100%!important;justify-content:space-between!important;align-items:center!important;}
  body.exam-page.bankdrills-analyse-mode #mobile-palette-toggle {top:230px!important;}
  body.exam-page.bankdrills-analyse-mode #currentQues {height:max(130px,calc(100dvh - 440px))!important;min-height:130px!important;}
  body.exam-page #analyse-top-bar label {font-size:12px!important;}
  body.exam-page #btn-back-to-results {padding:8px!important;min-height:34px;}
  body.exam-page .profile-grouping-section {width:100%!important;min-width:0!important;box-sizing:border-box;}
  body.exam-page .profile-grouping-section #col1.Lft_Section.column {width:100%!important;min-width:0!important;}
  body.exam-page .profile-grouping-section #col2.Rght_Section.column {display:none!important;}
  body.exam-page .profile-grouping-section .profileDetailsCricle {width:100%!important;}
  body.exam-page #sectionbox2id {max-width:100%!important;overflow-x:auto!important;white-space:nowrap;}
  body.exam-page #sectionsField {width:100%!important;max-width:100%!important;overflow:hidden!important;}
  body.exam-page #sectionbox2id .sectionChangeExamLab {max-width:42vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
  body.exam-page #Questn_Area {width:100%!important;min-width:0!important;max-width:100%!important;box-sizing:border-box;}
  body.exam-page #currentQues {width:100%!important;min-width:0!important;max-width:100%!important;box-sizing:border-box;height:max(150px,calc(100dvh - 355px))!important;min-height:150px!important;}
  body.exam-page #currentQues .leftDiv {width:100%!important;box-sizing:border-box;float:none!important;overflow-y:auto!important;overscroll-behavior:contain;}
  body.exam-page #quesOuterDiv {width:100%!important;max-width:100%!important;box-sizing:border-box;}
  body.exam-page .has-passage #quesAnsContent.Ans_Area {flex-direction:column!important;overflow-y:auto!important;}
  body.exam-page .has-passage .groupInstructionsContextBlk,
  body.exam-page .has-passage .question-panel-split {width:100%!important;max-width:100%!important;min-width:0!important;flex:0 0 auto!important;}
  body.exam-page .bmt-column-resizer {display:none!important;}
  body.exam-page .textHighlighter,
  body.exam-page .labelForOptText,
  body.exam-page .opt-text-wrap {overflow-wrap:anywhere;word-break:normal;}
  body.exam-page .Ans_Area img,body.exam-page .textHighlighter img,body.exam-page .groupInstructionsContextBlk img {max-width:100%!important;height:auto!important;}
  body.exam-page .divHeader {height:auto!important;min-height:32px!important;line-height:1.3!important;padding:7px 8px!important;}
  body.exam-page .q-timer-badge {float:none!important;display:block!important;line-height:1.3!important;margin:3px 0!important;}

  /* Original right-hand palette as an off-canvas panel on phones. */
  body.exam-page #rightDivision {display:none!important;position:fixed!important;right:0!important;left:auto!important;top:0!important;bottom:0!important;width:min(88vw,340px)!important;height:100dvh!important;background:#e5f6fd!important;box-shadow:-8px 0 25px rgba(0,0,0,.28);z-index:10020!important;overflow:hidden!important;}
  body.exam-page.mobile-palette-open #rightDivision {display:block!important;}
  body.exam-page #rightDivision #col2.Rght_Section.column {position:relative!important;top:0!important;right:auto!important;bottom:auto!important;display:flex!important;width:100%!important;height:calc(100dvh - 54px)!important;max-height:none!important;overflow:hidden!important;}
  body.exam-page #rightDivision #col2 .collapsebel_panel {display:flex!important;flex-direction:column!important;min-height:0!important;height:100%!important;}
  body.exam-page #rightDivision #rightSectionDiv2 {flex:1 1 auto!important;min-height:0!important;overflow:hidden!important;}
  body.exam-page #rightDivision #question_area {flex:1 1 auto!important;overflow:hidden!important;min-height:0!important;height:auto!important;}
  body.exam-page #rightDivision #num_panel_box {overflow-y:auto!important;-webkit-overflow-scrolling:touch;}
  body.exam-page #rightDivision #numberpanelQues {padding-bottom:26px!important;}
  body.exam-page .collapse_icon,body.exam-page .expand_icon {display:none!important;}
  #mobile-palette-toggle {display:block;position:fixed;right:8px;top:195px;z-index:1000;background:#147eb3;color:#fff;border:1px solid #0e628b;border-radius:6px;padding:8px 10px;font:700 13px Arial,sans-serif;min-height:40px;box-shadow:0 2px 6px #0002;cursor:pointer;}
  #mobile-palette-close {display:block;width:100%;height:54px;border:0;border-bottom:1px solid #b7d4e1;background:#147eb3;color:#fff;font:700 16px Arial,sans-serif;text-align:left;padding:0 16px;cursor:pointer;}
  #mobile-palette-backdrop {display:none;position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:10015;}
  body.mobile-palette-open #mobile-palette-backdrop {display:block;}

  /* Two-row mobile footer; original functions and buttons stay in use. */
  body.exam-page #buttons-div-id {display:block!important;position:fixed!important;left:0!important;right:0!important;bottom:0!important;width:100%!important;height:115px!important;min-height:115px!important;padding:7px 7px max(7px,env(safe-area-inset-bottom))!important;box-sizing:border-box!important;z-index:1010!important;background:#e5f6fd!important;}
  body.exam-page #Bttn_Area2 {display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;grid-template-rows:44px 44px!important;gap:7px!important;width:100%!important;height:auto!important;float:none!important;}
  body.exam-page #Bttn_Area2 > .other_buttoncontainerGrp {display:none!important;}
  body.exam-page #Bttn_Area2 > .other_buttoncontainer,
  body.exam-page #Bttn_Area2 > .save_buttoncontainer,
  body.exam-page #Bttn_Area2 > .finalSubmit {display:contents!important;}
  body.exam-page #Bttn_Area2 > .typingSubmit {display:none!important;}
  body.exam-page:not(.bankdrills-analyse-mode) #underreview,
  body.exam-page:not(.bankdrills-analyse-mode) #clearResponse,
  body.exam-page:not(.bankdrills-analyse-mode) #previousBtn,
  body.exam-page:not(.bankdrills-analyse-mode) #savenext,
  body.exam-page:not(.bankdrills-analyse-mode) #finalSubmit,
  body.exam-page.bankdrills-analyse-mode #previousBtn,
  body.exam-page.bankdrills-analyse-mode #btnAnalyseNext,
  body.exam-page.bankdrills-analyse-mode #btnAnalyseBackResult {
    display:flex!important;align-items:center!important;justify-content:center!important;
    min-width:0!important;min-height:44px!important;height:44px!important;
    line-height:1.2!important;white-space:normal!important;margin:0!important;
    padding:6px 5px!important;font-size:12px!important;box-sizing:border-box!important;
    float:none!important;text-align:center!important;
  }
  body.exam-page:not(.bankdrills-analyse-mode) #underreview {grid-area:1/1/2/3;}
  body.exam-page:not(.bankdrills-analyse-mode) #clearResponse {grid-area:1/3/2/5;}
  body.exam-page:not(.bankdrills-analyse-mode) #previousBtn {grid-area:2/1/3/2;}
  body.exam-page:not(.bankdrills-analyse-mode) #savenext {grid-area:2/2/3/4;}
  body.exam-page:not(.bankdrills-analyse-mode) #finalSubmit {grid-area:2/4/3/5;}
  body.exam-page.bankdrills-analyse-mode #previousBtn {grid-area:1/1/2/3;}
  body.exam-page.bankdrills-analyse-mode #btnAnalyseNext {grid-area:1/3/2/5;}
  body.exam-page.bankdrills-analyse-mode #btnAnalyseBackResult {grid-area:2/1/3/5;}
  body.exam-page.bankdrills-analyse-mode #buttons-div-id {height:115px!important;}
  body.exam-page #footer,body.exam-page .exam-version-footer {display:none!important;}

  /* Overlays, instruction/declaration screen remain the original content. */
  .bmt-modal-overlay {padding:10px!important;box-sizing:border-box!important;align-items:center!important;}
  .bmt-modal-box {width:min(100%,600px)!important;max-width:100%!important;max-height:calc(100dvh - 24px)!important;overflow:hidden!important;box-sizing:border-box!important;}
  .bmt-modal-body {max-height:calc(100dvh - 170px)!important;overflow:auto!important;-webkit-overflow-scrolling:touch;}
  .bmt-modal-header h2 {font-size:20px!important;}
  #submit-summary {overflow-x:auto;-webkit-overflow-scrolling:touch;}
  #submit-summary table {min-width:560px;}
  .bmt-modal-footer {display:flex;gap:8px;flex-wrap:wrap;}
  .bmt-modal-footer button {min-height:44px;}
  .inst-header {height:50px!important;}
  .inst-header h1 {font-size:18px!important;}
  .inst-mainright {max-height:190px!important;}
  .inst-mainright .mockCandidateImg {max-height:80px;width:auto;}
  #instructions-body,#declaration-body {overflow-x:auto!important;}
  .drill-instruction-summary {min-width:440px;}
  #readylink {min-height:44px!important;}
  .inst-pagination button,.inst-pagination input {min-height:44px;}
}
@media (max-width:400px) {
  body:not(.exam-page) .stat-grid .stat .number {font-size:21px;}
  body.exam-page #sub-header .helpinstruction_div {gap:2px!important;}
  body.exam-page #sub-header #VI,body.exam-page #sub-header #viewQPButton {font-size:10px!important;padding:3px 4px!important;}
  body.exam-page #sub-header .test-header {font-size:11px!important;}
}
@media (min-width:768px) {
  #mobile-palette-toggle,#mobile-palette-close,#mobile-palette-backdrop {display:none!important;}
}
