:root{--navy:#071b2b;--blue:#4285f4;--green:#34a853;--yellow:#fbbc05;--red:#ea4335;color:var(--navy);background:#eef6fb;font:17px/1.45 system-ui,sans-serif}
*{box-sizing:border-box}
[hidden]{display:none!important}
main{max-width:760px;margin:24px auto;padding:0 14px}
header{display:flex;gap:12px;align-items:center;background:var(--navy);color:white;padding:14px 20px;border-radius:18px;font-size:1.2rem;font-weight:750}
.tiles{display:grid;grid-template-columns:repeat(2,9px);gap:3px}.tiles i{height:9px;border-radius:2px;background:var(--blue)}.tiles i:nth-child(2){background:var(--yellow)}.tiles i:nth-child(3){background:var(--green)}.tiles i:nth-child(4){background:var(--red)}
section{margin-top:14px;background:#fffdf8;border-radius:22px;padding:clamp(14px,4vw,28px);box-shadow:0 8px 24px #071b4314}
.hero{background:linear-gradient(125deg,#cceaff,#c5f4e1);padding:20px;border-radius:16px}
h1,p{margin:0 0 10px}.eyebrow{text-transform:uppercase;letter-spacing:.12em;font-size:.75rem;font-weight:800}
.fields{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,205px),1fr));gap:10px;margin:14px 0}
label{display:grid;gap:4px;font-weight:650}input,select,button{font:inherit;border-radius:10px;min-height:44px;padding:8px 12px}input,select{border:1px solid #647b8c;min-width:0;width:100%;background:white;color:inherit}fieldset{border:1px solid #acbccc;border-radius:12px;margin:0;padding:10px}fieldset>div{display:flex;align-items:end;gap:12px;flex-wrap:wrap;margin-bottom:8px}fieldset>div>label:first-child{flex:1;min-width:min(100%,200px)}
.check{display:flex;align-items:center;gap:8px;margin-bottom:10px}.check input{width:20px;accent-color:var(--blue)}
button{background:var(--navy);color:white;border:0;cursor:pointer;margin:4px 4px 4px 0}button:disabled{opacity:.55;cursor:wait}.secondary{background:#dceaff;color:var(--navy)}
:focus-visible{outline:3px solid #205ab8;outline-offset:3px}
.number{display:grid;place-items:center;min-height:clamp(160px,38vw,280px);font-size:clamp(128px,32vw,256px);font-weight:800;background:#e3efff;border-radius:18px;font-variant-numeric:tabular-nums}
#answer{font-size:2rem;margin:4px 0 10px}progress,meter{width:100%;accent-color:var(--green)}.robot{font-size:3rem}li{margin:6px 0;padding:8px;border-left:4px solid var(--yellow);background:white}li[data-status=Correct]{border-color:var(--green)}li[data-status=Incorrect]{border-color:var(--red)}#error{color:#9c241a;margin:10px 0}

main:has(#practice:not([hidden])) {
  display: flex;
  flex-direction: column;
  max-width: none;
  min-height: 100dvh;
  margin: 0;
  padding: clamp(8px, 2vw, 24px);
}

#practice:not([hidden]) {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#practice .number {
  flex: 1;
  min-height: 0;
  line-height: 1.1;
}

/* Keep four-character operands inside narrow practice panels. */
#practice .number[data-wide] {
  font-size: clamp(64px, 20vw, 256px);
}

main:has(#setup:not([hidden])) {
  display: flex;
  flex-direction: column;
  max-width: none;
  min-height: 100dvh;
  margin: 0;
  padding: clamp(8px, 2vw, 24px);
}

#setup { flex: 1; }
#setup .hero { padding: clamp(16px, 2.5vw, 32px); }
#setup h1 { font-size: clamp(1.8rem, 4vw, 3rem); }
#settings {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}
.setup-card {
  background: #f4f8fd;
  border: 1px solid #d4e3ef;
  border-radius: 16px;
  padding: clamp(12px, 1.6vw, 20px);
}
.setup-card h2 { margin: 0; font-size: 1.15rem; }
.timing-card { background: #eef9f3; border-color: #cfe7da; }
.timing-card .fields { grid-template-columns: minmax(0, 1fr); }
.setup-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
#start, .answer-actions button:first-child { background: #174d9f; font-weight: 750; }
#start { padding-inline: 24px; }
#start span { margin-left: 8px; }
#practice:has(#answer-form:not([hidden])) { background: linear-gradient(155deg, #fffdf8, #e3efff); }
#practice:has(#answer-form:not([hidden])) #instruction { text-align: center; margin-top: clamp(16px, 5vh, 48px); font-size: clamp(1.7rem, 4vw, 3rem); }
#answer-form {
  width: min(100%, 42rem);
  margin: 12px auto auto;
  padding: clamp(14px, 3vw, 32px);
  background: white;
  border: 1px solid #d4e3ef;
  border-radius: 20px;
  box-shadow: 0 8px 24px #071b4314;
  text-align: center;
}
#answer { text-align: center; font-size: clamp(2rem, 6vw, 4rem); font-weight: 750; }
#time:not(:empty) { font-weight: 650; color: #174d9f; }
.answer-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.answer-actions button { margin: 0; }
@media (max-width: 740px) {
  #settings { grid-template-columns: minmax(0, 1fr); }
  #start { width: 100%; }
}

#account-toggle { margin-left: auto; }
#account-panel h2, #account-panel h3 { margin: 0 0 8px; }
#display-name { max-width: 28rem; }

#create-class, .class-card form { max-width: 30rem; }
.class-card { margin-top: 12px; }
.class-card h4 { margin: 0 0 8px; }
.class-card ul { padding-left: 20px; }

#assignment-settings { grid-column: 1 / -1; }

#account-panel .hero { margin-bottom: 16px; }
#sign-in { max-width: 36rem; }
#account-panel > form, #account-panel > div:not(.hero) { margin-bottom: 16px; }
main:has(#account-panel:not([hidden])) { max-width: 1120px; }

/* Warm, spacious dashboard surfaces with the established navy brand. */
:root {
  background: #fff9ed;
  color: #071b2b;
  font-family: "Segoe UI", system-ui, sans-serif;
}
body {
  margin: 0;
  background:
    radial-gradient(circle at 97% 9%, #fbbc0524 0 85px, transparent 86px),
    radial-gradient(circle at 2% 65%, #ea433512 0 105px, transparent 106px),
    #fff9ed;
}
main { max-width: 1320px; padding: 0 24px; }
main:has(#account-panel:not([hidden])) { max-width: 1320px; }
header { border-radius: 20px; padding: 16px 22px; box-shadow: 0 5px 0 #fbbc05; }
section { background: #fffefb; border: 1px solid #eee4d0; box-shadow: 0 12px 36px #49331308; }
.hero { position: relative; isolation: isolate; overflow: hidden; background: #fff0be; padding: 30px; }
.hero::after {
  content: ""; position: absolute; z-index: -1; width: 130px; height: 130px;
  right: -30px; top: -45px; border-radius: 50%; background: #ff9363; opacity: .6;
}
body[data-role=teacher] #account-panel > .hero { background: #e2f2fc; }
body[data-role=student] #account-panel > .hero { background: #e1f4df; }
body[data-role=student] #account-panel > .hero::after { background: #fbbc05; }
h1 { font-size: clamp(1.9rem, 4vw, 3rem); line-height: 1.15; letter-spacing: -.03em; }
h2 { font-size: 1.45rem; letter-spacing: -.025em; }
h3 { font-size: 1.12rem; }
#dashboard-intro { max-width: 52rem; margin-bottom: 0; }
#account-status { margin: 16px 0; }
.dashboard-card, .setup-card {
  border: 1px solid #eadfcb; background: #fffdf6; border-radius: 20px; padding: 22px;
}
#account-panel > form, #teacher-classes, #student-assignments, #admin-directory, #leaderboard-panel {
  padding: 22px; border: 1px solid #eee4d0; border-radius: 20px; background: #fffefa; margin-top: 20px;
}
#sign-in { margin: 24px auto; padding: 28px; background: #fff; box-shadow: 0 6px 24px #071b2b09; }
input, select { border-color: #b6c1c7; background: white; min-height: 48px; }
button { min-height: 46px; padding: 10px 18px; font-weight: 650; border-radius: 12px; transition: transform .15s; }
button:hover:not(:disabled) { transform: translateY(-1px); }
.secondary { background: #edf3fa; }
#open-setup, #start { background: #ffc84b; color: #071b2b; box-shadow: 0 3px 0 #dd9f21; }
#account-panel > #sign-out { margin-left: 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 20px 0; }
.stat-card { display: flex; flex-direction: column; gap: 10px; padding: 22px; border-radius: 22px; background: #fff0bd; }
.stat-card:nth-child(2) { background: #ffddd0; }
.stat-card:nth-child(3) { background: #dceffc; }
.stat-card:nth-child(4) { background: #dff1d8; }
.stat-card:nth-child(5) { background: #eee5fa; }
.stat-card strong { font-size: 2.6rem; line-height: 1; }
.stat-card span { font-size: .9rem; font-weight: 650; }
.dashboard-columns { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin-bottom: 16px; }
.chart-row { padding: 8px 0; }
.chart-row span { display: block; margin-bottom: 5px; }
.chart-row meter { height: 22px; }
.chart-row[data-outcome=Incorrect] meter { accent-color: #ea4335; }
.chart-row[data-outcome=Unanswered] meter { accent-color: #fbbc05; }
details { border-top: 1px solid #e6dece; padding: 14px 0; }
summary { cursor: pointer; font-weight: 700; padding: 8px 0; }
#class-list, #assignment-list { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,340px),1fr)); gap: 18px; }
.class-card { margin-top: 16px; min-width: 0; }
li { overflow-wrap: anywhere; }
#account-list { padding-left: 20px; }
.section-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.badge { background: #fff0bd; padding: 5px 12px; border-radius: 20px; font-size: .8rem; font-weight: 700; }
.board-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 20px 0; }
.leaderboard { margin-bottom: 16px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
caption { text-align: left; font-size: .85rem; color: #516473; padding-bottom: 14px; }
th, td { padding: 13px 12px; border-bottom: 1px solid #e6e6dc; }
th { background: #f3f6ef; font-size: .85rem; }
.your-result { background: #fff0bd; font-weight: 700; }
#practice .number { background: #e3efff; border-radius: 24px; }
@media(max-width:700px) {
  main { padding: 0 10px; margin-top: 10px; }
  .hero { padding: 22px 18px; }
  .dashboard-columns { grid-template-columns: minmax(0,1fr); }
  #account-panel > form, #teacher-classes, #student-assignments, #admin-directory, #leaderboard-panel { padding: 16px; }
  .dashboard-card, .setup-card { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .stat-card { padding: 16px; }
  .stat-card strong { font-size: 2rem; }
}

:root { font-size: 15px; }
header { padding: 8px 16px; min-height: 66px; }
.brand-logo { display: block; width: 138px; height: 52px; object-fit: contain; background: white; border-radius: 9px; padding: 3px; }
h1, #setup h1 { font-size: clamp(1.6rem, 2.6vw, 2.15rem); }
h2 { font-size: 1.25rem; }
.hero { padding: 22px; }
#practice:has(#answer-form:not([hidden])) #instruction { font-size: clamp(1.5rem, 2.7vw, 2.25rem); margin-top: clamp(12px, 3vh, 28px); }
.number { font-weight: 400; }
#answer { font-weight: 400; font-size: clamp(2rem, 5vw, 3.3rem); }
#answer-form { max-width: 36rem; padding: 22px; }
.stat-card strong { font-size: 2.1rem; }
.stat-card { padding: 18px; }
.rocket-progress { position: relative; height: 48px; margin: 0 20px 12px 8px; --flight: 0%; }
.flight-track { position: absolute; top: 23px; left: 0; right: 0; height: 8px; border-radius: 12px; background: #dce9f5; overflow: hidden; }
#flight-fill { height: 100%; width: var(--flight); background: linear-gradient(90deg,#4285f4,#34a853,#fbbc05); border-radius: inherit; transition: width .6s ease; }
#rocket { position: absolute; left: var(--flight); top: 3px; font-size: 30px; transform: translateX(-40%) rotate(45deg); transition: left .6s ease; filter: drop-shadow(0 3px 2px #071b2b15); }
.destination { position: absolute; right: -18px; top: 8px; font-size: 24px; }
.journey-bars { display: flex; align-items: end; gap: 12px; min-height: 190px; overflow-x: auto; padding: 12px 4px; }
.journey-column { flex: 1; min-width: 36px; max-width: 95px; text-align: center; }
.journey-value { display: block; font-size: .8rem; font-weight: 650; margin-bottom: 6px; }
.journey-track { height: 130px; position: relative; background: #eef4fa; border-radius: 10px; overflow: hidden; }
.journey-fill { position: absolute; bottom: 0; width: 100%; background: #4285f4; border-radius: 10px 10px 0 0; }
.journey-column:nth-child(4n+2) .journey-fill { background: #34a853; }
.journey-column:nth-child(4n+3) .journey-fill { background: #fbbc05; }
.journey-column:nth-child(4n) .journey-fill { background: #ef8069; }
body[data-role=student] #personal-progress { background: linear-gradient(135deg,#fef0c8,#e4f5ff); margin-top: 20px; }
body[data-role=student] #student-assignments { background: #f0f9e9; }
@media(prefers-reduced-motion:reduce) { #rocket, #flight-fill { transition: none; } }
@media(max-width:700px) { .brand-logo { width: 114px; height: 46px; } header { padding: 8px 12px; } }

.nav-button { display: inline-block; background: #e3efff; color: #071b2b; text-decoration: none; padding: 12px 18px; border-radius: 12px; margin: 8px 8px 8px 0; font-weight: 650; }
#management-page { margin-top: 18px; }
#management-content > form, #management-content > label { margin: 20px 0; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,290px),1fr)); gap: 16px; margin-top: 20px; }
#management-status { margin: 14px 0; }
#management-content .dashboard-card { margin-bottom: 12px; }
#rod-note, #mix-note { font-size: .85rem; color: #4c6270; margin-top: 10px; }
#group-list { padding-left: 20px; }

/* Student quest dashboard, based on the supplied Math Quest reference. */
body[data-role=student] {
  background: #f5f6ff;
  font-family: ui-rounded, "Trebuchet MS", system-ui, sans-serif;
}
body[data-role=student] main:has(#account-panel:not([hidden])) { max-width: 1480px; padding: 0 20px; }
body[data-role=student] #account-panel {
  border: 0; box-shadow: none; background: transparent; padding: 0;
}
#student-shell { display: grid; grid-template-columns: 210px minmax(0,1fr); gap: 25px; align-items: start; margin-top: 22px; }
.quest-sidebar {
  background: white; border: 1px solid #ececff; padding: 22px 14px; border-radius: 22px;
  min-height: 640px; display: flex; flex-direction: column; gap: 24px;
}
.quest-profile { background: #f1edff; display: flex; gap: 10px; align-items: center; border-radius: 16px; padding: 12px; overflow-wrap: anywhere; }
.quest-profile strong { display: block; font-size: .9rem; }
.quest-profile small { color: #69728d; }
.mini-avatar { font-size: 28px; background: white; padding: 4px; border-radius: 12px; }
.quest-sidebar nav { display: grid; gap: 8px; }
.quest-sidebar nav a { color: #626c89; font-weight: 700; text-decoration: none; border-radius: 12px; padding: 12px; display: flex; gap: 10px; align-items: center; }
.quest-sidebar nav a.active, .quest-sidebar nav a:hover { background: #efebff; color: #6349d7; }
.quest-tip { margin-top: auto; padding: 14px; background: #fff7df; color: #746237; border-radius: 16px; font-size: .8rem; }
.quest-tip p { margin: 6px 0 0; }
.student-main { min-width: 0; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; align-items: start; }
#student-welcome, #student-hero, #student-stats, #student-badges { grid-column: 1 / -1; }
#student-welcome h1 { font-size: 1.8rem; letter-spacing: -.025em; }
#student-welcome p { color: #69728d; margin: 0; }
.quest-hero { background: linear-gradient(110deg,#7357e9,#8b75f5 60%,#48bdcf); color: white; border-radius: 24px; padding: 25px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 10px 26px #8067e525; }
.quest-hero h2 { font-size: 1.65rem; margin: 7px 0 10px; }
.quest-hero p { max-width: 36rem; }
.quest-hero .eyebrow { font-size: .75rem; }
.quest-hero-art { font-size: 74px; padding-left: 15px; filter: drop-shadow(0 7px 5px #30207833); }
.quest-cta { display: inline-block; color: #6349d7; background: white; padding: 10px 15px; text-decoration: none; font-weight: 750; border-radius: 12px; margin-top: 4px; }
#student-stats .stat-grid { grid-template-columns: repeat(4,minmax(0,1fr)); margin: 0; gap: 12px; }
#student-stats .stat-card { background: white; border-radius: 18px; box-shadow: 0 4px 14px #30345f06; border-top: 3px solid #ffc94a; }
#student-stats .stat-card:nth-child(2) { border-color: #38c8d9; }
#student-stats .stat-card:nth-child(3) { border-color: #36c98f; }
#student-stats .stat-card:nth-child(4) { border-color: #ff6fae; }
#student-stats .stat-card strong { font-size: 1.8rem; }
#student-stats .stat-card span { color: #69728d; font-size: .8rem; }
body[data-role=student] #personal-progress,
body[data-role=student] #student-assignments,
body[data-role=student] #leaderboard-panel,
#avatar-card, #student-badges {
  margin: 0; padding: 20px; background: white; border: 1px solid #ececff; border-radius: 20px; box-shadow: 0 5px 18px #30345f06; min-width: 0;
}
body[data-role=student] #personal-progress h2,
body[data-role=student] #leaderboard-panel h2,
body[data-role=student] #student-assignments h3,
#avatar-card h2, #student-badges h2 { font-size: 1.08rem; margin: 0 0 12px; }
body[data-role=student] #personal-progress > p,
body[data-role=student] #leaderboard-panel > p { font-size: .8rem; color: #69728d; }
body[data-role=student] #assignment-list { display: grid; grid-template-columns: minmax(0,1fr); gap: 10px; }
body[data-role=student] #assignment-list .class-card { background: #f8f7ff; border: 0; margin: 0; padding: 14px; border-radius: 15px; }
body[data-role=student] #assignment-list h4 { font-size: .9rem; }
body[data-role=student] button:not(.secondary) { background: #7357e9; color: white; }
body[data-role=student] #sign-out { width: 100%; background: #f1eff9; color: #6349d7; margin: 0; }
body[data-role=student] .badge { background: #f0edff; color: #6349d7; }
body[data-role=student] .leaderboard { padding: 0; border: 0; background: white; box-shadow: none; margin-top: 18px; }
body[data-role=student] .leaderboard h3 { font-size: .9rem; }
body[data-role=student] th { background: #f7f5ff; }
body[data-role=student] th, body[data-role=student] td { padding: 10px 8px; font-size: .8rem; }
body[data-role=student] .your-result { background: #f2edff; }
body[data-role=student] .journey-fill { background: #8066f4; }
.avatar-area { display: flex; gap: 15px; align-items: center; }
.big-avatar { display: grid; place-items: center; flex-shrink: 0; width: 82px; height: 82px; background: #f1edff; border-radius: 19px; font-size: 50px; }
.avatar-area p { color: #69728d; font-size: .8rem; margin: 5px 0; }
#avatar-form { margin-top: 18px; }
.avatar-choices { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; margin-top: 8px; }
.avatar-choice { position: relative; display: grid; place-items: center; cursor: pointer; }
.avatar-choice input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.avatar-choice span { width: 100%; text-align: center; padding: 8px; font-size: 28px; border: 2px solid #eee; border-radius: 12px; background: #fafaff; }
.avatar-choice input:checked + span { border-color: #7357e9; background: #f1edff; }
.avatar-choice input:focus-visible + span { outline: 3px solid #205ab8; outline-offset: 2px; }
#student-profile-settings { margin-top: 20px; }
#student-profile-settings input { font-size: .9rem; }
#student-profile-settings #display-name { margin-bottom: 10px; }
#earned-badges { display: grid; grid-template-columns: repeat(auto-fit,minmax(155px,1fr)); gap: 12px; }
.earned-badge { background: #fff8e6; border-radius: 15px; padding: 15px; display: grid; gap: 6px; }
.earned-badge > span { font-size: 30px; }
.earned-badge strong { font-size: .9rem; }
.earned-badge small { color: #776b51; }
@media(max-width:1050px) {
  #student-shell { grid-template-columns: 170px minmax(0,1fr); gap: 16px; }
  .student-main { grid-template-columns: minmax(0,1fr); }
  #student-stats .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .quest-sidebar { padding: 15px 10px; }
}
@media(max-width:650px) {
  body[data-role=student] main:has(#account-panel:not([hidden])) { padding: 0 10px; }
  #student-shell { grid-template-columns: minmax(0,1fr); gap: 16px; }
  .quest-sidebar { min-height: 0; padding: 12px; gap: 12px; }
  .quest-sidebar nav { display: flex; overflow-x: auto; gap: 5px; }
  .quest-sidebar nav a { flex-shrink: 0; padding: 8px; font-size: .8rem; gap: 5px; }
  .quest-tip { display: none; }
  #student-session { text-align: right; }
  body[data-role=student] #sign-out { width: auto; padding: 7px 12px; min-height: 38px; }
  #student-welcome h1 { font-size: 1.5rem; }
  .quest-hero { padding: 20px; }
  .quest-hero h2 { font-size: 1.35rem; }
  .quest-hero-art { font-size: 48px; padding-left: 4px; }
  #student-stats .stat-card { padding: 15px; }
}

.quest-chart svg { display: block; width: 100%; min-height: 180px; }
.quest-chart text { fill: #77809e; font-size: 10px; }
.quest-chart-axis { stroke: #eceef7; stroke-width: 1; }
.quest-chart-area { fill: #8066f418; }
.quest-chart-line { fill: none; stroke: #8066f4; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.quest-chart-dot { fill: white; stroke: #8066f4; stroke-width: 2.5; }

/* Shared quest design across every role and management page. */
:root { --quest-purple: #7357e9; --quest-cyan: #38c8d9; background: #f5f6ff; }
body { background: #f5f6ff; font-family: ui-rounded,"Trebuchet MS",system-ui,sans-serif; }
main, main:has(#account-panel:not([hidden])) { max-width: 1480px; }
section { border-color: #ececff; background: #fff; box-shadow: 0 5px 18px #30345f06; }
.hero, body[data-role=teacher] #account-panel > .hero {
  background: linear-gradient(110deg,#7357e9,#8b75f5 65%,#48bdcf);
  color: white; border-radius: 24px; padding: 25px; box-shadow: 0 10px 26px #8067e51a;
}
.hero::after { background: #ffffff21; }
#setup .hero { background: linear-gradient(110deg,#7357e9,#8b75f5 65%,#48bdcf); }
button:not(.secondary) { background: #7357e9; color: white; }
#start, #open-setup { background: #7357e9; color: white; box-shadow: none; }
.secondary, .nav-button { background: #f0edff; color: #6349d7; }
.dashboard-card, .setup-card { border-color: #ececff; background: #fff; box-shadow: 0 5px 18px #30345f06; border-radius: 20px; }
.timing-card { background: #f5f1ff; }
#assignment-settings { background: #f4fbff; border-color: #dcecf8; }
input, select { border-color: #d6dbea; border-radius: 11px; }
.stat-card { background: #fff !important; border-top: 3px solid #ffc94a; box-shadow: 0 4px 14px #30345f06; }
.stat-card:nth-child(2) { border-color: #38c8d9; }
.stat-card:nth-child(3) { border-color: #36c98f; }
.stat-card:nth-child(4) { border-color: #ff6fae; }
.stat-card:nth-child(5) { border-color: #8066f4; }
#management-page { background: #f5f6ff; border: 0; box-shadow: none; }
#management-content > form { background: white; }
th { background: #f7f5ff; }
.your-result { background: #f2edff; }
#staff-shell { display: grid; grid-template-columns: 210px minmax(0,1fr); gap: 25px; margin-top: 22px; align-items: start; }
body[data-role=admin] #account-panel, body[data-role=teacher] #account-panel { padding: 0; border: 0; box-shadow: none; background: transparent; }
#staff-main { min-width: 0; }
#staff-main > #dashboard-hero { margin-bottom: 20px; }
#staff-main > #open-setup { margin: 0 0 20px; }
#staff-main > #personal-progress,
#staff-main > #institute-insights,
#staff-main > #teacher-classes,
#staff-main > #leaderboard-panel { margin-bottom: 20px; padding: 22px; background: white; border: 1px solid #ececff; border-radius: 20px; }
#staff-main .dashboard-columns .dashboard-card { box-shadow: none; }
#staff-main #class-list .class-card { background: #faf9ff; }
#staff-session button { width: 100%; }
#sign-in { background: white; padding: 25px; margin: 24px auto; border-radius: 20px; }
body[data-role=student] #personal-progress,
body[data-role=student] #student-assignments,
body[data-role=student] #leaderboard-panel,
body[data-role=student] #avatar-card {
  height: 430px; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
body[data-role=student] #avatar-card { overflow-y: auto; }
#student-assignments #assignment-list {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 5px;
  align-content: start; scrollbar-width: thin;
}
#student-assignments #assignment-list .class-card { align-self: start; }
#personal-progress #progress-graph { overflow-y: auto; min-height: 0; }
#boards { overflow: auto; min-height: 0; flex: 1; scrollbar-width: thin; overscroll-behavior: contain; }
#boards table { table-layout: fixed; width: 100%; }
#boards th:nth-child(1) { width: 42%; }
#boards th:nth-child(2) { width: 17%; }
#boards th:nth-child(3) { width: 41%; }
#boards td { overflow-wrap: anywhere; vertical-align: middle; }
#boards thead { position: sticky; top: 0; z-index: 1; background: #f7f5ff; }
.leader-badge { display: inline-block; background: #fff7df; border-radius: 10px; font-size: .72rem; padding: 4px 7px; margin: 2px; }
.assignment-actions { display: flex; align-items: end; gap: 9px; }
.assignment-speed { flex: 0 0 112px; font-size: .72rem; line-height: 1.2; }
.assignment-speed input { width: 100%; min-height: 37px; height: 37px; padding: 6px 9px; font-size: .85rem; }
.assignment-actions button { min-height: 37px; padding: 8px 12px; margin: 0; font-size: .8rem; }
#assignment-list .class-card h4 { margin-bottom: 10px; }
.board-controls { display: flex; gap: 8px; margin: 12px 0; align-items: end; }
.board-controls label { flex: 1; min-width: 85px; font-size: .78rem; }
.board-controls select { width: 100%; min-height: 38px; padding: 7px 9px; font-size: .8rem; }
.board-controls button { min-height: 38px; margin: 0; padding: 8px 11px; font-size: .8rem; }
#board-status { font-size: .75rem; color: #69728d; }
#leaderboard-panel #board-status:empty { display: none; }
@media(max-width:1050px) {
  #staff-shell { grid-template-columns: 170px minmax(0,1fr); gap: 16px; }
}
@media(max-width:650px) {
  #staff-shell { grid-template-columns: minmax(0,1fr); }
  #staff-session button { width: auto; }
  .assignment-speed { flex-basis: 105px; }
  .board-controls { flex-wrap: wrap; }
}

#staff-main #boards { max-height: 360px; }

.sidebar-brand { display: flex; justify-content: center; align-items: center; padding: 9px; background: white; border: 1px solid #ececff; border-radius: 15px; }
.sidebar-brand img { display: block; width: 145px; max-width: 100%; height: 98px; object-fit: contain; }
#staff-shell { margin-top: 0; }
#staff-shell > .quest-sidebar { position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow-y: auto; min-height: min(760px,calc(100dvh - 32px)); }
#staff-main > section { margin-top: 0; }
#staff-main > #account-panel { padding: 0; background: transparent; border: 0; box-shadow: none; }
#staff-main > #account-panel > #dashboard-hero { margin-bottom: 20px; }
#staff-main > #account-panel > #personal-progress,
#staff-main > #account-panel > #institute-insights,
#staff-main > #account-panel > #leaderboard-panel { margin-bottom: 20px; padding: 22px; background: white; border: 1px solid #ececff; border-radius: 20px; }
#classes-page { background: transparent; border: 0; padding: 0; box-shadow: none; }
#classes-content { margin-top: 20px; }
#classes-content > #teacher-classes { padding: 22px; border: 1px solid #ececff; background: white; border-radius: 20px; margin-top: 16px; }
#classes-content > #open-setup { margin: 0 0 8px; }
#staff-main > #setup { padding: 20px; }
body[data-role=admin] main, body[data-role=teacher] main { max-width: 1480px; }
@media(max-width:650px) {
  #staff-shell > .quest-sidebar { position: static; max-height: none; min-height: 0; }
  .sidebar-brand { align-self: start; }
  .sidebar-brand img { width: 108px; height: 70px; }
  #classes-content > #teacher-classes { padding: 16px; }
}

/* Fluid layouts and compact navigation without an independently scrolling sidebar. */
body main, body main:has(#account-panel:not([hidden])) {
  max-width: none !important; width: 100%; margin: 0; padding: clamp(10px,1.5vw,22px);
}
#staff-shell, #student-shell { grid-template-columns: 205px minmax(0,1fr); gap: 22px; }
#staff-shell > .quest-sidebar, #student-shell > .quest-sidebar {
  min-height: 0; max-height: none; height: auto; overflow: visible;
  position: sticky; top: 14px; padding: 14px; gap: 15px;
}
.quest-sidebar .quest-tip { display: none; }
.sidebar-brand { padding: 5px; }
.sidebar-brand img { height: 72px; width: 124px; }
.quest-profile { padding: 10px; }
.quest-sidebar nav { gap: 4px; }
.quest-sidebar nav a { padding: 9px 10px; font-size: .85rem; }
#staff-session button, #student-session button { min-height: 38px; font-size: .85rem; }
#staff-main, .student-main, .setup-card, .dashboard-card { min-width: 0; }
.practice-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.practice-toolbar #question { margin: 0; }
.sound-options { display: flex; gap: 16px; flex-wrap: wrap; }
.sound-options .check { margin: 0; font-size: .85rem; }
.sound-options input { width: 18px; min-height: 18px; }
#practice #audio-status { font-size: .78rem; color: #53657c; margin: 8px 0 0; }
#pause-panel { width: min(100%,40rem); margin: 24px auto; }
dialog { color: #071b2b; border: 1px solid #ded7f4; border-radius: 20px; padding: 24px; max-width: min(94vw,500px); box-shadow: 0 20px 60px #071b2b30; }
dialog::backdrop { background: #071b2b77; }
#avatar-shortcut { height: 430px; display: flex; flex-direction: column; justify-content: center; background: linear-gradient(145deg,#f2edff,#e6f9ff); border: 1px solid #ececff; border-radius: 20px; }
#avatar-shortcut .quest-cta { align-self: start; }
.profile-page .student-main { grid-template-columns: minmax(0,1.4fr) minmax(0,1fr); }
.profile-page #student-welcome, .profile-page #student-stats { grid-column: 1 / -1; }
.profile-page #avatar-card, .profile-page #student-badges { height: auto; overflow: visible; min-height: 380px; grid-column: auto; padding: 28px; }
.profile-page .big-avatar { width: 120px; height: 120px; font-size: 78px; }
.profile-page #avatar-name { font-size: 1.35rem; }
.profile-page #student-stats .stat-card strong { font-size: 2.6rem; }
.profile-page #earned-badges { grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); }
.profile-page .earned-badge { padding: 22px; }
.profile-page .earned-badge > span { font-size: 44px; }
.profile-page .avatar-choices { grid-template-columns: repeat(auto-fill,minmax(64px,1fr)); max-height: none; overflow: visible; }
.profile-page .avatar-choice span { font-size: 34px; padding: 10px; }
#avatar-form fieldset > label { margin: 8px 0 14px; }
@media(min-width:1500px) {
  .student-main { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media(max-width:1050px) {
  #staff-shell, #student-shell { grid-template-columns: 175px minmax(0,1fr); gap: 16px; }
  .profile-page .student-main { grid-template-columns: minmax(0,1fr); }
}
@media(max-width:700px) {
  #staff-shell, #student-shell { grid-template-columns: minmax(0,1fr); gap: 14px; }
  #staff-shell > .quest-sidebar, #student-shell > .quest-sidebar { position: static; display: grid; grid-template-columns: auto minmax(0,1fr); padding: 12px; gap: 10px; }
  .quest-sidebar nav, #staff-navigation { grid-column: 1 / -1; display: flex; flex-wrap: wrap; overflow: visible; gap: 5px; }
  .quest-sidebar nav a { padding: 8px; font-size: .8rem; }
  .quest-sidebar .sidebar-brand img { height: 58px; width: 92px; }
  #staff-session, #student-session { grid-column: 1 / -1; }
  .practice-toolbar { align-items: start; }
  .practice-toolbar > div:last-child { display: flex; flex-wrap: wrap; }
  .profile-page #avatar-card, .profile-page #student-badges { padding: 20px; min-height: 0; }
  .profile-page .big-avatar { width: 90px; height: 90px; font-size: 60px; }
}

body[data-role=student] .profile-page #avatar-card,
body[data-role=student] .profile-page #student-badges { height: auto; overflow: visible; min-height: 380px; }
@media(max-width:700px) {
  body[data-role=student] .profile-page #avatar-card,
  body[data-role=student] .profile-page #student-badges { min-height: 0; }
}

#staff-page-heading .hero {
  margin: 0; padding: 14px 12px; border-radius: 14px;
  background: linear-gradient(135deg,#7357e9,#6a8fe9);
  box-shadow: none;
}
#staff-page-heading .hero .eyebrow { font-size: .6rem; letter-spacing: .06em; margin-bottom: 6px; }
#staff-page-heading .hero h1, #staff-page-heading #setup-heading h1 { font-size: 1rem; line-height: 1.25; margin-bottom: 7px; letter-spacing: 0; }
#staff-page-heading .hero p:last-child { font-size: .73rem; line-height: 1.4; margin: 0; }
#staff-page-heading .hero::after { display: none; }
#student-page-heading { background: #f0edff; padding: 12px; border-radius: 14px; }
#student-page-heading #student-welcome { margin: 0; }
#student-page-heading #student-greeting { font-size: 1rem; line-height: 1.25; margin-bottom: 5px; }
#student-page-heading #student-welcome p { font-size: .76rem; margin: 0; color: #6349d7; }
#avatar-shortcut { justify-content: start; gap: 12px; overflow: hidden; }
#dashboard-badges { display: grid; grid-template-columns: repeat(auto-fit,minmax(125px,1fr)); gap: 12px; flex: 1; min-height: 0; overflow-y: auto; align-content: start; }
#dashboard-badges .earned-badge { text-align: center; padding: 18px 10px; background: #fff6db; }
#dashboard-badges .earned-badge > span { font-size: 60px; line-height: 1.2; }
#dashboard-badges .earned-badge small { display: none; }
#dashboard-badges .earned-badge strong { font-size: .88rem; }
#avatar-shortcut .quest-cta { margin-top: auto; }
@media(max-width:700px) {
  #staff-page-heading, #student-page-heading { grid-column: 1 / -1; }
  #staff-page-heading .hero { padding: 10px 12px; }
}

#staff-feedback:has(#account-status:empty) { display: none; }
#staff-feedback #account-status { margin: 0; font-size: .76rem; overflow-wrap: anywhere; }

.student-main > #student-stats { order: 0; }
.student-main > #personal-progress { order: 1; }
.student-main > #student-assignments { order: 2; }
.student-main > #leaderboard-panel { order: 3; }
.student-main > #avatar-shortcut, .student-main > #avatar-card { order: 4; }
.student-main > #student-badges { order: 5; }

#student-practice-area { min-width: 0; grid-column: 2; }
#student-practice-area > #practice,
#student-practice-area > #results { margin-top: 0; }
#student-practice-area > #practice { min-height: calc(100dvh - 44px); }
#student-practice-area .number { min-height: 270px; }
@media(max-width:700px) {
  #student-practice-area { grid-column: 1; }
  #student-practice-area > #practice { min-height: 65dvh; }
  #student-practice-area .number { min-height: 220px; }
}

.assignment-audio-options { display: flex; gap: 14px; flex-wrap: wrap; margin: 0 0 10px; }
.assignment-audio-options .check { font-size: .78rem; margin: 0; }
.assignment-audio-options input { width: 16px; min-height: 16px; }

#class-toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}
#class-toolbar #create-class {
  display: flex;
  align-items: end;
  flex: 0 1 560px;
  gap: 10px;
  max-width: none;
}
#class-toolbar #create-class label { flex: 1; min-width: 0; }
#class-toolbar button { margin: 0; flex-shrink: 0; }
#class-toolbar #open-setup { align-self: end; }
@media(max-width:520px) {
  #class-toolbar #create-class { flex-basis: 100%; flex-wrap: wrap; }
  #class-toolbar #create-class label { flex-basis: 100%; }
}
