/* ============================================================
   BENCHMARK — bm_extras.css
   Styles for the new modules (calculator, NPCs, lecture, boss, mini-game).
   Matches the existing parchment + orange + teal aesthetic.
   ============================================================ */

/* ---------- collectibles HUD strip ---------- */
.bm-collectibles{
  display:flex;align-items:center;gap:14px;
  margin:0 12px;font-family:var(--ui);font-size:12px;
}
.bmc{
  display:flex;align-items:center;gap:4px;
  padding:4px 10px;border-radius:999px;
  background:rgba(20,32,26,.55);
  border:1px solid rgba(216,166,74,.4);
  color:var(--parch);
}
.bmc b{font-family:var(--mono);font-size:12px;color:var(--gold);}
.bmc-star{color:#ffe28a;}
.bmc-coin{color:#ffd24a;}
.bmc-book{color:#f0caa7;}
.bmc-chest{color:#e7b478;}

/* ---------- NPC overlay on canvas ---------- */
.bm-npc-layer{
  position:absolute;pointer-events:none;z-index:8;
  overflow:hidden;
}
.bm-npc{
  position:absolute;
  width:34px;height:34px;border-radius:50%;
  border:3px solid var(--ink);
  box-shadow:0 6px 14px rgba(0,0,0,.45);
  transform:translate(-50%,-50%);
  cursor:pointer;pointer-events:auto;
  display:flex;align-items:center;justify-content:center;
  overflow:hidden;
  transition:transform .12s ease,box-shadow .12s ease;
  background:#3b6e8c;
}
.bm-npc:hover{transform:translate(-50%,-58%);box-shadow:0 10px 18px rgba(0,0,0,.55);}
.bm-npc img{width:100%;height:100%;object-fit:cover;display:block;}
.bm-npc-initial{
  position:absolute;font-family:var(--serif);font-size:16px;color:var(--parch);
  text-shadow:0 1px 2px #000;pointer-events:none;
}
.bm-npc img + .bm-npc-initial{display:none;}
.bm-npc-label{
  position:absolute;bottom:-22px;left:50%;transform:translateX(-50%);
  background:rgba(20,32,26,.95);color:var(--parch);
  padding:2px 7px;border-radius:6px;font-size:10px;font-family:var(--ui);
  font-weight:600;white-space:nowrap;pointer-events:none;
  border:1px solid rgba(216,166,74,.4);
}
.bm-npc-lec{box-shadow:0 0 0 3px rgba(216,166,74,.5),0 6px 14px rgba(0,0,0,.5);}
.bm-npc-lec .bm-npc-label{color:var(--gold);}

/* ---------- bm-dialogue tweaks ---------- */
.bm-dialogue .dlg-portrait{width:64px;height:64px;}

/* ---------- bm-challenge (upgraded question card) ---------- */
.bm-challenge .ch-host{
  font-size:11px;letter-spacing:.08em;color:var(--gold);
  text-transform:uppercase;
}
.bm-challenge .ch-hint{
  margin-top:10px;padding:10px 12px;border-radius:8px;
  background:#eee6c8;border-left:4px solid var(--orange);
  font-size:13px;line-height:1.55;color:var(--ink);
}
.choices-bank{
  display:grid;grid-template-columns:1fr 1fr;gap:9px;
}
.choices-bank .choice{
  justify-content:center;font-weight:700;font-family:var(--serif);
}

/* ---------- boss + ultimate ---------- */
.bm-boss .ch-top,.bm-ultimate .ch-top{
  background:linear-gradient(180deg,#4a2a18,#2e1810);
}
.bm-boss .ch-tag{color:#ffd9a0;}
.bm-ultimate .ch-tag{color:#ffe28a;letter-spacing:.18em;}
.bm-boss .ch-body h2,.bm-ultimate .ch-body h2{
  font-family:var(--serif);font-size:26px;color:var(--ink);margin:6px 0 8px;
}

/* ---------- lecture cinematic ---------- */
.lecture-cine{
  display:grid;grid-template-columns:300px 1fr;gap:18px;
  padding:24px;border-radius:14px;
  border:1px solid rgba(216,166,74,.5);
  min-height:420px;color:var(--parch);
}
.lec-left{display:flex;flex-direction:column;gap:10px;align-items:center;}
.lec-port{
  width:240px;height:300px;border-radius:12px;overflow:hidden;
  border:3px solid var(--gold);background:#3a2f54;
  display:flex;align-items:center;justify-content:center;
  font-family:var(--serif);font-size:64px;color:var(--parch);
  box-shadow:0 12px 26px rgba(0,0,0,.55);
}
.lec-port img{width:100%;height:100%;object-fit:cover;}
.lec-port.fallback{background:radial-gradient(circle at 38% 34%,#6a5a8a,#3a2f54);}
.lec-name{
  font-family:var(--serif);font-size:24px;color:var(--parch);
  text-shadow:0 2px 0 #000,0 4px 10px rgba(0,0,0,.5);
}
.lec-title-badge{
  font-size:11px;letter-spacing:.18em;font-weight:700;color:var(--gold);
  border:1px solid rgba(216,166,74,.55);padding:5px 11px;border-radius:999px;
}
.lec-bio{
  font-family:var(--ui);font-size:12px;line-height:1.55;color:#d0d4cf;
  background:rgba(0,0,0,.32);border-left:3px solid var(--gold);
  padding:8px 10px;border-radius:0 8px 8px 0;
}
.lec-right{display:flex;flex-direction:column;gap:14px;justify-content:center;}
.lec-slide-tag{
  font-size:11px;letter-spacing:.22em;color:var(--gold);font-weight:700;
}
.lec-slide-text{
  font-family:var(--serif);font-size:20px;line-height:1.62;color:var(--parch);
  text-shadow:0 1px 4px rgba(0,0,0,.7);min-height:180px;
}
.lec-dots{display:flex;gap:5px;}
.lec-dot{width:8px;height:8px;border-radius:50%;background:rgba(255,255,255,.18);}
.lec-dot.on{background:var(--orange);transform:scale(1.4);}
.lec-dot.done{background:var(--good);}
.lec-foot{display:flex;gap:8px;margin-top:10px;}

.lecture-done{
  text-align:center;background:linear-gradient(180deg,var(--parch),var(--parch-2));
  border-radius:14px;padding:28px;
}
.lecture-done .seal{
  width:72px;height:72px;margin:0 auto 8px;border-radius:50%;
  background:radial-gradient(circle at 38% 34%,#f0a14e,var(--orange-d));
  border:3px solid var(--ink);
  display:flex;align-items:center;justify-content:center;font-size:34px;
}
.lecture-done h2{font-family:var(--serif);font-size:26px;color:var(--ink);}
.lecture-done p{color:var(--ink-soft);margin:8px 0 14px;}

/* ---------- mini-game card ---------- */
.minigame-card{
  background:linear-gradient(180deg,var(--parch),var(--parch-2));
  border-radius:14px;padding:18px 24px;text-align:center;
  border:1px solid var(--parch-edge);box-shadow:0 18px 50px rgba(0,0,0,.6);
}
.mg-title{font-family:var(--serif);font-size:22px;color:var(--ink);margin-bottom:4px;}
.mg-prompt{font-family:var(--ui);font-size:14px;color:var(--orange-d);margin-bottom:14px;font-weight:600;}
.mg-stage{display:flex;justify-content:center;}
.mg-stage canvas{
  background:#0e1410;border-radius:50%;
  border:2px solid var(--gold);box-shadow:0 8px 22px rgba(0,0,0,.5);
}
.mg-hint{margin:14px 0 8px;font-size:13px;color:var(--ink-soft);min-height:18px;}
.mg-foot{display:flex;gap:10px;justify-content:center;margin-top:6px;}

/* ---------- CALCULATOR ---------- */
.bm-calc-overlay{
  position:fixed;inset:0;z-index:80;
  display:flex;justify-content:flex-end;align-items:center;
  background:rgba(10,14,11,.4);
  padding:20px;
}
.bm-calc-overlay.hidden{display:none;}
.bm-calc{
  width:340px;background:linear-gradient(180deg,#1e2620,#141a15);
  border:2px solid var(--gold);border-radius:14px;
  box-shadow:0 16px 44px rgba(0,0,0,.6);
  padding:14px;position:relative;
  font-family:var(--ui);color:var(--parch);
}
.bm-calc-x{
  position:absolute;top:6px;right:8px;
  background:transparent;color:var(--parch);
  border:none;font-size:22px;cursor:pointer;line-height:1;
}
.bm-calc-head{
  display:flex;align-items:center;justify-content:space-between;
  margin-bottom:8px;
}
.bm-calc-title{font-family:var(--serif);font-size:14px;color:var(--gold);}
.bm-calc-status{display:flex;gap:10px;font-family:var(--mono);font-size:11px;}
.bm-calc-mem{color:#9fdac0;}
.bm-calc-mode{color:var(--gold);}
.bm-calc-display{
  width:100%;font-family:var(--mono);font-size:20px;
  padding:9px 10px;margin-bottom:8px;
  background:#0a0e0b;color:var(--parch);
  border:1px solid #2a3a30;border-radius:8px;
  text-align:right;
}
.bm-calc-display:focus{outline:1px solid var(--gold);}
.bm-calc-grid{
  display:grid;grid-template-columns:repeat(6, 1fr);
  gap:5px;
}
.bm-calc-btn{
  font-family:var(--ui);font-size:13px;font-weight:600;
  padding:9px 4px;border-radius:7px;cursor:pointer;
  background:#2a3a30;color:var(--parch);
  border:1px solid #3c4c40;border-bottom:2px solid #1a2620;
  transition:transform .05s ease, background .12s ease;
}
.bm-calc-btn:hover{background:#374a3e;}
.bm-calc-btn:active{transform:translateY(1px);border-bottom-width:1px;}
.bm-calc-btn.bm-calc-fn{background:#3b2a1f;color:#ffd9a0;border-color:#5a3e2a;}
.bm-calc-btn.bm-calc-fn:hover{background:#4e3826;}
.bm-calc-btn.bm-calc-sci{background:#2a2e3b;color:#cfd6ff;border-color:#3a3f4f;}
.bm-calc-btn.bm-calc-sci:hover{background:#363b50;}
.bm-calc-btn.bm-calc-eq{background:linear-gradient(180deg,#f0913f,var(--orange));color:#fff;border-color:var(--orange-d);}
.bm-calc-empty{visibility:hidden;}

/* ---------- responsive ---------- */
@media (max-width:780px){
  .bm-collectibles{gap:6px;margin:0 4px;}
  .bmc{padding:3px 7px;font-size:11px;}
  .lecture-cine{grid-template-columns:1fr;}
  .lec-port{width:160px;height:200px;}
  .lec-slide-text{font-size:16px;}
  .bm-calc{width:300px;}
}

/* ============================================================
   LESSON UI (BMLesson + BMDistrictQuiz)
   ============================================================ */
.bm-lesson{
  background:linear-gradient(180deg,#fff8e7 0%,#f1e1c1 100%);
  color:#2b2417;
  border:2px solid #6a5a3a;
  border-radius:14px;
  padding:22px 28px;
  width:min(1000px, 96vw);          /* wider — better use of 4K monitors */
  max-width:100%;                   /* never exceed parent (overlayBox) */
  max-height:calc(100vh - 32px);    /* fits in viewport even with overlay padding */
  overflow-y:auto;
  overflow-x:hidden;                /* prevent any child from poking past right edge */
  -webkit-overflow-scrolling:touch;
  box-shadow:0 10px 40px rgba(0,0,0,.5);
  font-family:var(--ui);
  box-sizing:border-box;
}
/* Make everything inside the lesson respect the card width */
.bm-lesson *{ max-width:100%; box-sizing:border-box; }
.bm-lesson .choices, .bm-lesson .bml-foot{ flex-wrap:wrap; }
/* Ensure buttons in the foot wrap and never go off-card */
.bml-foot{ row-gap:8px; }
.bml-tag{
  font-size:11px; letter-spacing:.18em; font-weight:800;
  color:#7a5a1a; margin-bottom:6px;
}
.bml-stage{
  font-size:18px; font-weight:700; color:#3a2a14;
  border-bottom:1px solid #c0a878; padding-bottom:8px; margin-bottom:14px;
}
.bml-intro-text{
  font-size:16px; line-height:1.55; color:#2b2417;
  white-space:pre-wrap; min-height:1.4em;
  font-family:Georgia,"Times New Roman",serif;
}
.bml-q-text{
  font-size:17px; line-height:1.5; font-weight:600;
  background:#f7eccd; border-left:4px solid #a17e2a; padding:12px 14px;
  border-radius:6px; margin-bottom:14px; min-height:1.4em;
  white-space:pre-wrap;
}
.bml-worked-q, .bml-worked-a, .bml-worked-steps{
  margin-bottom:12px;
}
.bml-label{
  font-size:11px; letter-spacing:.16em; font-weight:800;
  color:#7a5a1a; margin-bottom:4px;
}
.bml-a-text{
  font-size:17px; font-weight:700; color:#1a4a2a;
  background:#e6f1d9; padding:10px 14px; border-radius:6px;
  border-left:4px solid #3a8a3a;
}
.bml-worked-steps{
  background:#fff;
  border:1px solid #d4c69e; border-radius:8px;
  padding:10px 16px;
}
.bml-worked-steps.hidden{display:none;}
.bml-steps{ margin:6px 0 0 18px; padding:0; }
.bml-step{
  margin-bottom:6px; line-height:1.45; font-size:14px;
}
.bml-hint{
  background:#fff7d4; border:1px dashed #c39a2a;
  padding:10px 14px; border-radius:6px;
  margin-bottom:12px; font-size:14px; color:#5a3e10;
}
.bml-hint.hidden{display:none;}
.bml-helpmsg{
  margin-top:6px; font-style:italic; color:#7a4a1a; font-size:13px;
}
.bml-foot{
  display:flex; justify-content:flex-end; gap:8px;
  margin-top:16px; padding-top:12px; border-top:1px solid #c0a878;
  align-items:center;
}
.bml-result-big{
  font-size:42px; font-weight:800; text-align:center;
  margin:18px 0 6px; color:#3a2a14;
  font-family:Georgia,"Times New Roman",serif;
}
.bml-result-msg{
  text-align:center; font-size:15px; line-height:1.5;
  color:#3a2a14; margin-bottom:8px;
}

/* ---------- District-quiz review ---------- */
.bml-review-list{
  max-height:55vh; overflow-y:auto;
  background:#fffaef; border:1px solid #d4c69e; border-radius:8px;
  padding:10px 14px;
}
.bml-review-topic{ margin-bottom:14px; }
.bml-review-topic h3{
  margin:6px 0; color:#7a5a1a; font-size:15px;
  border-bottom:1px solid #d4c69e; padding-bottom:4px;
}
.bml-review-item{
  margin:8px 0; padding:6px 0; font-size:13px; line-height:1.45;
}
.bml-review-q{ font-weight:600; color:#3a2a14; }
.bml-review-e{ color:#5a4a2a; margin-top:3px; padding-left:8px; }

/* ---------- Lives HUD ---------- */
.bm-lives{
  display:inline-flex; gap:5px; padding:4px 9px;
  background:#1a1a14; border:1px solid #3a3a30;
  border-radius:20px; margin-left:6px;
  align-items:center;
  font-family:var(--ui); font-size:11px; letter-spacing:.12em; color:#aaa;
}
.bm-lives-label{ color:#9aa; margin-right:2px; }
.bm-life{
  display:inline-block; width:14px; height:14px;
  background:radial-gradient(circle at 35% 30%, #ff6a6a, #b02020);
  clip-path:path("M 7 12 C 1 8, 0 4, 3 2 C 5 1, 7 3, 7 4 C 7 3, 9 1, 11 2 C 14 4, 13 8, 7 12 Z");
  transition:opacity .25s ease;
}
.bm-life.lost{
  opacity:.18; filter:grayscale(.9);
}

/* ---------- Final-flag celebration ---------- */
.bm-final-unlock-pop{
  background:linear-gradient(180deg,#fff8e7,#f0d68a);
  color:#3a2a14;
  border:3px solid #c89a2a;
  border-radius:16px;
  padding:30px 36px;
  width:min(560px, 92vw);
  text-align:center;
  box-shadow:0 0 80px rgba(240,180,40,.65);
  font-family:var(--ui);
}
.bm-final-unlock-pop h2{
  margin:0 0 8px; font-size:30px;
  color:#7a4a1a;
  font-family:Georgia,"Times New Roman",serif;
}
.bm-final-unlock-pop .seal-big{
  font-size:60px; margin-bottom:6px;
}
.bm-final-unlock-pop p{
  font-size:15px; line-height:1.5; color:#3a2a14;
  margin-bottom:18px;
}

/* ---------- District reset toast ---------- */
.bm-district-reset{
  background:#3a1f1f;
  color:#ffd8c8;
  border:2px solid #8a2a2a;
  border-radius:14px;
  padding:24px 28px;
  width:min(500px, 92vw);
  text-align:center;
  font-family:var(--ui);
}
.bm-district-reset h2{
  margin:0 0 6px; font-size:24px; color:#ff6a6a;
}
.bm-district-reset p{ font-size:14px; line-height:1.5; margin-bottom:14px; }

/* ============================================================
   DONATION WIDGET
   ============================================================ */
.bm-support-btn{
  display:inline-flex;align-items:center;gap:5px;
  background:linear-gradient(180deg,#ffcf6b,#f0a13a);
  color:#3a2a14;font-weight:700;font-size:13px;
  padding:6px 12px;border-radius:999px;
  border:1px solid #b07820;cursor:pointer;
  box-shadow:0 2px 6px rgba(0,0,0,.3);
  transition:transform .08s ease;
  font-family:var(--ui);
}
.bm-support-btn:hover{transform:translateY(-1px);background:linear-gradient(180deg,#ffd87a,#f5ad4a);}
.bm-support-btn:active{transform:translateY(1px);}

.bm-donate-modal{
  /* Bulletproof solid background — no transparency, multiple fallbacks */
  background-color:#fff8e7 !important;
  background-image:linear-gradient(180deg,#fff8e7 0%,#f0e1c1 100%);
  color:#1a1208 !important;
  border:3px solid #5a3010;
  border-radius:14px;
  padding:22px 24px;
  width:min(440px, 94vw);
  max-height:calc(100vh - 32px);
  overflow-y:auto;
  font-family:var(--ui);
  /* Strong shadow + outer dark ring to make it pop against any backdrop */
  box-shadow:
    0 0 0 4px rgba(0,0,0,.4),
    0 14px 50px rgba(0,0,0,.7);
  position:relative;
  z-index:60;
  isolation:isolate;       /* new stacking context — avoids parent compositing bugs */
  opacity:1 !important;
}
/* Faux title bar at the top of the modal — makes it feel like a window */
.bm-donate-modal::before{
  content:"";
  display:block;
  margin:-22px -24px 14px;
  height:6px;
  background:linear-gradient(180deg,#c89a2a,#8a6618);
  border-radius:10px 10px 0 0;
}
.bm-donate-modal h2{
  font-family:Georgia,"Times New Roman",serif;
  font-size:24px; margin-bottom:8px; color:#3a1f08; text-align:center;
  font-weight:800;
  text-shadow:0 1px 0 rgba(255,255,255,.4);
}
.bm-donate-modal p{
  font-size:14px; line-height:1.55; color:#1a1208; margin-bottom:14px;
  text-align:center;
}
.bm-donate-grid{display:flex;flex-direction:column;gap:8px;margin:14px 0;}
.bm-donate-link{
  display:flex;align-items:center;justify-content:space-between;
  text-decoration:none;color:#2b2417;
  background:#fffaef;border:1px solid #c0a878;
  padding:11px 14px;border-radius:9px;
  font-size:14px;font-weight:600;
  transition:transform .08s ease, background .12s ease;
}
.bm-donate-link:hover{transform:translateY(-1px);background:#fff5d8;}
.bm-donate-link .bm-donate-icon{font-size:18px;margin-right:8px;}
.bm-donate-link .bm-donate-label{flex:1;}
.bm-donate-link .bm-donate-handle{font-size:12px;color:#7a5a1a;font-family:var(--mono);}
.bm-donate-foot{
  margin-top:14px;text-align:center;font-size:12px;color:#5b4f3e;
}
.bm-donate-close{margin-top:14px;width:100%;}

/* ============================================================
   MOBILE / RESPONSIVE
   ============================================================ */
@media (max-width:780px){
  /* HUD: stack into rows on narrow */
  #hud{
    gap:8px;padding:8px 10px;
    justify-content:center;
  }
  .hud-left,.hud-right{flex-wrap:wrap;}
  .hud-mid{flex:1;min-width:120px;}
  #hudTitle{font-size:16px;}
  .hud-rankwrap{min-width:auto;}
  .xpbar{width:90px;}
  .bm-collectibles{order:99;width:100%;justify-content:center;margin:4px 0 0;}
  .bm-lives{order:98;}

  /* Game canvas: use full width */
  #stage{padding:2px 4px 8px;}
  #game{
    width:100%;border-radius:8px;
    max-height:calc(100vh - 130px);
  }

  /* Lesson card: tighter padding + smaller fonts */
  .bm-lesson{padding:14px 16px;}
  .bml-stage{font-size:16px;padding-bottom:6px;margin-bottom:10px;}
  .bml-intro-text{font-size:14px;line-height:1.5;}
  .bml-q-text{font-size:15px;padding:10px 12px;}
  .bml-a-text{font-size:15px;}
  .bml-step{font-size:13px;}
  .bml-result-big{font-size:32px;margin:12px 0 4px;}
  .bml-foot{flex-wrap:wrap;gap:6px;}
  .bml-foot .btn{padding:8px 14px;font-size:13px;}

  /* Choices: tighter */
  .choices{gap:6px;}
  .choice{padding:10px 12px !important;font-size:13px !important;}

  /* Dialogue */
  .dialogue{padding:16px;}
  .dlg-name{font-size:15px;}
  .dlg-text{font-size:14px;line-height:1.5;}

  /* Donation modal */
  .bm-donate-modal{padding:18px 18px;}
  .bm-donate-modal h2{font-size:20px;}

  /* Show on-screen D-pad for touch movement */
  .bm-touchpad{display:flex !important;}
}

@media (max-width:420px){
  #hud{padding:6px 6px;}
  #hudTitle{font-size:14px;}
  .hud-area{font-size:10px;}
  .btn-sm{font-size:11px;padding:5px 9px;}
  .bm-support-btn{font-size:11px;padding:5px 9px;}
  .bm-life{width:11px;height:11px;}
}

/* ============================================================
   ON-SCREEN TOUCH D-PAD (mobile only)
   Visible on touch devices via the responsive query above.
   ============================================================ */
.bm-touchpad{
  display:none;                /* hidden on desktop; @media shows it on mobile */
  position:fixed;left:14px;bottom:14px;z-index:40;
  width:140px;height:140px;
  pointer-events:none;         /* container is transparent; buttons take events */
  user-select:none;
}
.bm-tp-btn{
  position:absolute;width:46px;height:46px;
  background:rgba(40,50,40,.78);color:#fff;
  border:1px solid rgba(255,255,255,.35);
  border-radius:10px;
  display:flex;align-items:center;justify-content:center;
  font-size:22px;font-weight:700;
  pointer-events:auto;
  -webkit-touch-callout:none;
  user-select:none;-webkit-user-select:none;
}
.bm-tp-btn:active{background:rgba(232,118,42,.85);}
.bm-tp-up    {top:0;   left:47px;}
.bm-tp-down  {bottom:0;left:47px;}
.bm-tp-left  {top:47px;left:0;}
.bm-tp-right {top:47px;right:0;}

.bm-action-btn{
  display:none;
  position:fixed;right:14px;bottom:14px;z-index:40;
  width:78px;height:78px;border-radius:50%;
  background:radial-gradient(circle at 35% 30%,#ff9a3a,#c75f1a);
  color:#fff;font-weight:800;font-size:22px;
  border:2px solid #6a3a10;
  box-shadow:0 4px 14px rgba(0,0,0,.5);
  align-items:center;justify-content:center;
  pointer-events:auto;
  -webkit-touch-callout:none;user-select:none;
}
.bm-action-btn:active{transform:scale(0.94);}
@media (max-width:780px){
  .bm-action-btn{display:flex;}
}
