/* MABNI v45 UX hardening: wrapping, readable dashboard, responsive controls */
:root{
  --ux-focus:#00b7d8;
  --ux-card-min:240px;
  --ux-tap:44px;
}
*,*::before,*::after{box-sizing:border-box}
html{scroll-behavior:smooth;-webkit-text-size-adjust:100%;text-size-adjust:100%}
body{max-width:100%;overflow-x:hidden}
img,svg,canvas,video{max-width:100%;height:auto}
button,a,input,select,textarea,summary{min-height:var(--ux-tap)}
button,a,label,summary{min-width:0}
input,select,textarea{max-width:100%;min-width:0}
button,.btn,.btn-small,.secondary,.primary,.home-btn,.lesson-chooser,.toplink{
  white-space:normal;
  line-height:1.15;
  text-align:center;
  overflow-wrap:anywhere;
}
:where(h1,h2,h3,h4,p,span,strong,small,li,td,th,label,summary,pre,code,div){
  overflow-wrap:anywhere;
  word-break:normal;
}
:where(.mono,pre,code,.class-code,.device-key,.student-chip,.badge,.pill){
  overflow-wrap:anywhere;
  word-break:break-word;
}
:focus-visible{outline:3px solid var(--ux-focus)!important;outline-offset:3px!important}
[hidden]{display:none!important}

/* App/student UX safety */
#app,.game-shell,.left-panel,.right-panel,.mission-bar,.run-dock,.workspace-head,.feedback,.run-feedback-details,.learning-focus-card,.dialog-card{min-width:0;max-width:100%}
.topbar{min-width:0;overflow:visible}
.lesson-level-cluster,.user-area,.mission-goals,.workspace-meta{min-width:0;max-width:100%}
.user-area,.status-row,.tools,.toolbar,.dialog-actions,.customize-top-tools{display:flex;flex-wrap:wrap;align-items:center;gap:.55rem}
.level-strip{min-width:0;max-width:100%;overflow-x:auto;overflow-y:visible;scrollbar-width:thin;padding-bottom:.15rem}
.level-chip,.mission-chip,.lesson-chooser strong,.lesson-chooser span,.feedback-message,.workspace-note,#capacityBubble{min-width:0;max-width:100%;overflow-wrap:anywhere;white-space:normal!important}
.feedback{display:flex;flex-wrap:wrap;gap:.45rem;align-items:flex-start;line-height:1.4}
.feedback-label{flex:0 0 auto}.feedback-message{flex:1 1 220px}
.run-dock{align-items:stretch}.run-dock button{min-width:0;min-height:48px;padding-inline:.75rem}
.big-run span{display:inline!important;font-weight:1000}.big-run{min-height:54px!important}
.custom-preview{grid-template-columns:minmax(72px,92px) minmax(0,1fr)!important;align-items:center}.custom-preview>*{min-width:0}.customize-top-tools{grid-column:1 / -1;justify-content:flex-start}
.dialog-card{max-height:min(88vh,860px);overflow:auto;overscroll-behavior:contain}
.dialog-head{min-width:0}.dialog-head>*{min-width:0}
.choice-grid{grid-template-columns:repeat(auto-fit,minmax(48px,1fr))!important}
.choice{min-width:0}
.saved-user{min-width:0}.saved-user>*{min-width:0}.saved-user strong{overflow-wrap:anywhere}
.visualization{min-width:0}

/* Generic dashboard-like areas */
.grid{min-width:0}.grid>*{min-width:0}.stats{grid-template-columns:repeat(auto-fit,minmax(var(--ux-card-min),1fr))!important}.stat strong{overflow-wrap:anywhere;word-break:break-word}.panel,.card{min-width:0;max-width:100%}.panel-head{min-width:0;flex-wrap:wrap}.panel-head>*{min-width:0}.toolbar{align-items:stretch}.searchbar{min-width:min(100%,260px)!important;max-width:100%}.searchbar input{min-width:0}.form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:12px}.form-grid label{min-width:0}.split{grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr))!important;gap:16px}.empty{overflow-wrap:anywhere;line-height:1.5}

/* Teacher dashboard hardening */
.layout{min-width:0}.side,.main{min-width:0}.side{overscroll-behavior:contain}.brand{min-width:0}.brand strong,.brand span{overflow-wrap:anywhere}.side-actions{min-width:0}.side-actions form{min-width:0}.side-actions .btn{width:100%}.mode-card,.mode-top,.switch,.nav{min-width:0}.switch{grid-template-columns:repeat(2,minmax(0,1fr))!important}.switch button{min-width:0}.nav button{min-width:0;white-space:normal;text-align:left;line-height:1.2}.topbar{align-items:flex-start}.title{min-width:0}.title h1{font-size:clamp(1.6rem,4vw,2rem);line-height:1.05}.title p{line-height:1.45;max-width:72ch}.status-row{justify-content:flex-end}.pill{max-width:100%;white-space:normal;line-height:1.25}.class-card{min-width:0;overflow:hidden}.class-card-head{display:flex;flex-wrap:wrap;gap:12px;align-items:flex-start}.class-code{font-size:clamp(1.2rem,3vw,1.8rem);line-height:1;max-width:100%;padding:.45rem .65rem;border-radius:14px}.student-chips{display:flex;flex-wrap:wrap;gap:.45rem}.student-chip{display:inline-flex;max-width:100%;align-items:center;gap:.35rem;line-height:1.2}.icon-picker{display:flex;flex-wrap:wrap;gap:.45rem}.icon-picker button{min-width:44px;min-height:44px}.rules-box pre,.mono{max-width:100%;overflow:auto;white-space:pre-wrap;line-height:1.45}.toast{max-width:min(560px,calc(100vw - 24px));left:50%;transform:translateX(-50%);right:auto;bottom:16px;white-space:normal;line-height:1.35}.notice,.err{overflow-wrap:anywhere;line-height:1.45}
.tablewrap{max-width:100%;overflow:auto;-webkit-overflow-scrolling:touch;scrollbar-width:thin}.tablewrap table{table-layout:auto}.tablewrap th,.tablewrap td{max-width:260px;white-space:normal;overflow-wrap:anywhere;word-break:break-word;line-height:1.35}.tablewrap th{white-space:normal}.tablewrap details{max-width:100%}.tablewrap summary{cursor:pointer}.tablewrap select,.tablewrap input{width:auto;max-width:100%}.tablewrap .tools{align-items:center}.tablewrap .tools select{max-width:180px}.tablewrap .tools input[type="number"]{max-width:82px}

@media (max-width:1100px){
  .layout{grid-template-columns:1fr!important}.side{position:relative!important;height:auto!important;display:block}.main{padding:18px!important}.status-row{justify-content:flex-start}.topbar{flex-direction:column;align-items:stretch}.title p{max-width:none}.stats{grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr))!important}.side-actions{grid-template-columns:repeat(auto-fit,minmax(180px,1fr));display:grid}.side-actions .btn{width:100%}
  .game-shell{gap:12px}.left-panel,.right-panel{min-width:0}.run-dock{grid-template-columns:repeat(auto-fit,minmax(130px,1fr))!important}.custom-grid{grid-template-columns:1fr!important}
}
@media (max-width:720px){
  :root{--ux-card-min:160px}.main{padding:14px!important}.panel{padding:14px!important;border-radius:18px!important}.card,.panel{border-radius:18px!important}.toolbar,.panel-head,.status-row,.tools{flex-direction:column;align-items:stretch}.tools .btn-small,.toolbar .btn-small,.status-row .btn-small,.status-row .pill{width:100%}.searchbar{width:100%}.title h1{font-size:1.55rem}.stat strong{font-size:1.65rem!important}.class-card-head{flex-direction:column}.class-code{width:100%;text-align:center}.modal,.dialog-card{width:min(96vw,640px)!important;padding:16px!important;border-radius:20px!important}.dialog-actions{justify-content:stretch}.dialog-actions button{flex:1 1 140px}.custom-preview{grid-template-columns:1fr!important}.preview-tile{width:90px}.game-shell{padding-inline:10px}.workspace-head{flex-wrap:wrap;gap:.45rem}.workspace-meta{width:100%;justify-content:flex-start}.mission-bar{gap:.45rem}.mission-goals{width:100%}.feedback-label{width:100%}
  .tablewrap{border:none;background:transparent;overflow:visible}.tablewrap table{min-width:0!important;width:100%;display:block}.tablewrap thead{display:none}.tablewrap tbody,.tablewrap tr,.tablewrap td{display:block;width:100%}.tablewrap tr{background:#fff;border:1px solid var(--line,#dfe5ef);border-radius:18px;margin:0 0 12px;padding:10px;box-shadow:0 10px 28px rgba(16,24,40,.08)}.tablewrap td{border:0!important;max-width:none!important;padding:9px 8px}.tablewrap td::before{content:attr(data-label);display:block;font-size:.74rem;text-transform:uppercase;letter-spacing:.04em;color:#667085;font-weight:900;margin-bottom:.25rem}.tablewrap td:empty{display:none}.tablewrap .tools{flex-direction:column;align-items:stretch}.tablewrap .tools>*{width:100%!important;max-width:100%!important}.tablewrap .mono{max-height:180px;overflow:auto}
}
@media (max-width:460px){
  button,.btn,.btn-small,.secondary,.primary{width:100%;justify-content:center}.nav button{width:100%}.run-dock{grid-template-columns:1fr!important}.level-row{gap:.25rem}.toplink{width:auto}.brand img{max-width:88px}.side{padding:14px!important}.switch{grid-template-columns:1fr!important}.status-row{gap:.45rem}.toast{bottom:8px}.choice-grid{grid-template-columns:repeat(auto-fit,minmax(44px,1fr))!important}
}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-duration:.01ms!important}}
