:root {
  --navy: #07111f;
  --navy-2: #0b1730;
  --navy-deep: #050b16;
  --purple: #a855f7;
  --blue: #38bdf8;
  --royal-blue: #6366f1;
  --pink: #fb7185;
  --green: #6ee7b7;
  --red: #fb7185;
  --white: #ffffff;
  --text: rgba(255, 255, 255, .94);
  --muted: rgba(255, 255, 255, .68);
  --border: rgba(255, 255, 255, .13);
  --glass: rgba(255, 255, 255, .065);
  --glass-strong: rgba(255, 255, 255, .095);
  --ea-gradient: linear-gradient(135deg, #38bdf8 0%, #6366f1 34%, #a855f7 70%, #fb7185 100%);
  --panel-gradient:
    radial-gradient(circle at 82% 10%, rgba(56, 189, 248, .145), transparent 34%),
    radial-gradient(circle at 8% 90%, rgba(251, 113, 133, .105), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, .092), rgba(255, 255, 255, .045));
  --shadow-soft: 0 28px 70px rgba(0, 0, 0, .26);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 4%, rgba(56, 189, 248, .15), transparent 28%),
    radial-gradient(circle at 82% 14%, rgba(56, 189, 248, .22), transparent 31%),
    radial-gradient(circle at 18% 72%, rgba(251, 113, 133, .16), transparent 34%),
    linear-gradient(135deg, #050b16, #07111f 48%, #101f3d);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  pointer-events: none;
  border-radius: 50%;
}

body::before {
  width: min(560px, 48vw);
  height: min(560px, 48vw);
  left: -210px;
  top: 110px;
  border: 1px solid rgba(255, 255, 255, .055);
  box-shadow: 0 0 0 58px rgba(56, 189, 248, .018), 0 0 0 116px rgba(139, 92, 246, .014);
}

body::after {
  width: 760px;
  height: 760px;
  right: -360px;
  bottom: -430px;
  border: 1px solid rgba(56, 189, 248, .14);
  box-shadow: 0 0 0 82px rgba(56, 189, 248, .045), 0 0 0 164px rgba(139, 92, 246, .035), 0 0 70px rgba(56, 189, 248, .08);
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
img { display: block; max-width: 100%; }
p, h1, h2 { margin-top: 0; }

.teacher-shell {
  position: relative;
  z-index: 1;
  width: min(1540px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px 0 18px;
}

.teacher-topbar {
  min-height: 82px;
  padding: 0 22px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .078), rgba(255, 255, 255, .030)), rgba(5, 13, 28, .78);
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 46px rgba(0, 0, 0, .18);
}

.brand,
.refined-logo,
.wordmark { display: inline-flex; align-items: center; }
.brand { gap: 14px; min-width: max-content; }
.brand-wave,
.refined-wave {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.wordmark { line-height: .92; letter-spacing: -.056em; font-size: clamp(1.75rem, 2.15vw, 2.35rem); font-weight: 860; }
.wordmark-echo { color: rgba(255, 255, 255, .96); }
.wordmark-aural {
  background: var(--ea-gradient);
  background-size: 170% 170%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: textGlow 6.4s ease-in-out infinite;
}

.refined-wave { width: 62px; height: 50px; gap: 3px; justify-content: center; }
.refined-wave span {
  display: block;
  width: 4px;
  border-radius: 999px;
  flex: 0 0 auto;
  transform-origin: 50% 50%;
  animation: waveRoll 1.45s ease-in-out infinite;
  box-shadow: 0 0 9px rgba(56, 189, 248, .28), 0 0 18px rgba(168, 85, 247, .14);
}
.refined-wave span:nth-child(1) { height: 12px; background: linear-gradient(180deg, #38bdf8, #4a90e2); animation-delay: 0s; }
.refined-wave span:nth-child(2) { height: 24px; background: linear-gradient(180deg, #38bdf8, #4a90e2); animation-delay: .09s; }
.refined-wave span:nth-child(3) { height: 36px; background: linear-gradient(180deg, #60a5fa, #4a90e2 48%, #8b5cf6); animation-delay: .18s; }
.refined-wave span:nth-child(4) { height: 46px; background: linear-gradient(180deg, #7dd3fc, #4a90e2 38%, #8b5cf6 76%, #a855f7); animation-delay: .27s; }
.refined-wave span:nth-child(5) { height: 34px; background: linear-gradient(180deg, #a78bfa, #8b5cf6 52%, #c084fc); animation-delay: .36s; }
.refined-wave span:nth-child(6) { height: 24px; background: linear-gradient(180deg, #c084fc, #a855f7 58%, #fb7185); animation-delay: .45s; }
.refined-wave span:nth-child(7) { height: 13px; background: linear-gradient(180deg, #d946ef, #fb7185); animation-delay: .54s; }

.teacher-title-lockup { text-align: center; }
.mode-pill,
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: rgba(125, 211, 252, .9);
  font-size: .72rem;
  font-weight: 860;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.teacher-title-lockup h1 { margin: 0; font-size: clamp(1.25rem, 2vw, 2.05rem); letter-spacing: -.045em; }
.ghost-link,
.primary-button,
.secondary-button,
.ghost-button,
.play-button {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, .28);
  color: rgba(255, 255, 255, .92);
  font-weight: 850;
  transition: transform .2s ease, border-color .2s ease, opacity .2s ease;
}
.ghost-link,
.secondary-button,
.ghost-button {
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(168, 85, 247, .18), rgba(74, 144, 226, .12));
}
.primary-button,
.play-button {
  padding: 0 18px;
  background: var(--ea-gradient);
  box-shadow: 0 16px 38px rgba(56, 189, 248, .18);
}
.play-button { min-width: 150px; }
.ghost-button { background: rgba(255, 255, 255, .055); }
button:not(:disabled):hover,
.ghost-link:hover { transform: translateY(-1px); border-color: rgba(56, 189, 248, .62); }

.teacher-grid {
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(520px, 1.4fr) minmax(340px, 1fr);
  grid-template-areas:
    "session controls students"
    "session leaderboard leaderboard";
  gap: 14px;
  margin-top: 14px;
}
.panel {
  position: relative;
  overflow: hidden;
  min-height: 240px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--panel-gradient);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
  padding: 22px;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, .065), rgba(255, 255, 255, 0));
}
.session-panel { grid-area: session; }
.control-panel { grid-area: controls; }
.students-panel { grid-area: students; }
.leaderboard-panel { grid-area: leaderboard; }
.panel-heading { margin-bottom: 16px; }
.panel-heading h2 { margin: 0; font-size: 1.4rem; letter-spacing: -.035em; }
.split-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

.session-card {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 24px;
  background: rgba(3, 9, 21, .46);
}
.session-card.is-muted { opacity: .78; }
.status-line { min-height: 22px; color: var(--muted); font-weight: 650; }
.room-code-wrap {
  display: grid;
  gap: 5px;
  margin: 14px 0;
  padding: 16px;
  border: 1px solid rgba(56, 189, 248, .22);
  border-radius: 20px;
  background: rgba(56, 189, 248, .075);
}
.room-code-wrap span,
.join-link-label { color: var(--muted); font-size: .78rem; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; }
.room-code-wrap strong { font-size: clamp(2.4rem, 7vw, 4.8rem); line-height: .95; letter-spacing: .08em; }
.join-instructions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  margin: 14px 0 10px;
  padding: 13px 14px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 18px;
  background: rgba(255, 255, 255, .055);
}
.join-instructions strong { display: block; color: white; font-size: .96rem; }
.join-instructions p { margin: 3px 0 0; color: var(--muted); line-height: 1.35; font-size: .86rem; }
.join-step-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(56, 189, 248, .95), rgba(168, 85, 247, .92));
  color: white;
  font-weight: 950;
  box-shadow: 0 10px 24px rgba(56, 189, 248, .18);
}
.code-step { margin-top: 16px; }
.join-link { width: 100%; min-height: 42px; margin: 8px 0 12px; padding: 0 12px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .12); color: white; background: rgba(255, 255, 255, .06); }
.join-link.short-link { font-size: 1.05rem; font-weight: 850; letter-spacing: .01em; }

.listen-counter,
.count-pill,
.average-pill,
.status-badge {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid rgba(56, 189, 248, .24);
  border-radius: 999px;
  background: rgba(56, 189, 248, .08);
  color: rgba(255, 255, 255, .86);
  font-size: .78rem;
  font-weight: 860;
}
.question-preview-card,
.notice,
.summary-grid > div,
.student-row,
.leaderboard-row {
  border: 1px solid rgba(255, 255, 255, .105);
  background: rgba(3, 9, 21, .42);
  border-radius: 20px;
}
.question-preview-card { padding: 18px; margin-bottom: 16px; }
.preview-meta p { margin: 0 0 8px; color: var(--muted); }
.preview-meta p:first-child { color: rgba(255, 255, 255, .9); font-weight: 780; }
.control-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.compact-row { margin-top: 2px; }
.notice { margin-top: 16px; padding: 14px 16px; color: var(--muted); font-weight: 650; }
.notice.good { border-color: rgba(110, 231, 183, .35); color: rgba(209, 250, 229, .94); background: rgba(16, 185, 129, .10); }
.notice.bad { border-color: rgba(251, 113, 133, .35); color: rgba(254, 205, 211, .94); background: rgba(251, 113, 133, .10); }

.student-list,
.leaderboard-list { display: grid; gap: 10px; }
.empty-state { min-height: 160px; display: grid; place-items: center; text-align: center; color: var(--muted); border: 1px dashed rgba(255, 255, 255, .15); border-radius: 22px; padding: 20px; }
.student-row,
.leaderboard-row {
  min-height: 58px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.student-row strong,
.leaderboard-row strong { display: block; margin-bottom: 2px; }
.student-row span,
.leaderboard-row span { color: var(--muted); font-size: .86rem; }
.status-badge { font-style: normal; }
.status-badge.is-submitted { border-color: rgba(110, 231, 183, .35); background: rgba(16, 185, 129, .12); }
.status-badge.is-waiting { border-color: rgba(251, 191, 36, .28); background: rgba(251, 191, 36, .10); }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.summary-grid > div { padding: 14px; }
.summary-grid span { display: block; color: var(--muted); font-size: .76rem; font-weight: 850; text-transform: uppercase; letter-spacing: .1em; }
.summary-grid strong { display: block; margin-top: 6px; font-size: 1.25rem; }
.leaderboard-row { display: grid; grid-template-columns: 42px 1fr auto; }
.rank { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--ea-gradient); color: white !important; font-weight: 950; }
.leaderboard-row em { font-style: normal; font-weight: 950; font-size: 1.2rem; }
.leaderboard-row.is-unsubmitted { opacity: .62; }

@keyframes waveRoll {
  0%, 100% { transform: scaleY(.72); }
  50% { transform: scaleY(1.08); }
}
@keyframes textGlow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@media (max-width: 1180px) {
  .teacher-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "session controls"
      "students leaderboard";
  }
}
@media (max-width: 820px) {
  .teacher-topbar { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 18px; }
  .teacher-grid { grid-template-columns: 1fr; grid-template-areas: "session" "controls" "students" "leaderboard"; }
  .summary-grid { grid-template-columns: 1fr; }
  .split-heading { flex-direction: column; }
}


/* Laptop Student Mode link additions */
.laptop-link-label {
  margin-top: 12px;
}
.laptop-copy-button {
  border-color: rgba(168, 85, 247, .30);
  background: rgba(168, 85, 247, .08);
}

/* Teacher controls simplification: settings → start quiz → play again → next question */
.teacher-primary-row {
  align-items: center;
}
.large-control-button {
  min-width: 190px;
  min-height: 50px;
  padding-inline: 24px;
  font-size: 1rem;
  letter-spacing: -.01em;
}
.danger-button {
  border-color: rgba(251, 113, 133, .30);
  background: rgba(251, 113, 133, .09);
}
.danger-button:not(:disabled):hover {
  border-color: rgba(251, 113, 133, .62);
}
.question-preview-card .preview-meta p#questionInstruction {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  padding: 8px 12px;
  border: 1px solid rgba(56, 189, 248, .24);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(56, 189, 248, .12), rgba(168, 85, 247, .10));
  color: rgba(255, 255, 255, .96);
  font-size: .95rem;
  font-weight: 900;
  letter-spacing: -.01em;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 8, 19, .72);
  backdrop-filter: blur(16px);
}
.modal-backdrop[hidden] { display: none !important; }
.settings-modal {
  position: relative;
  width: min(640px, calc(100vw - 36px));
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 32px;
  background:
    radial-gradient(circle at 86% 10%, rgba(56, 189, 248, .16), transparent 34%),
    radial-gradient(circle at 8% 92%, rgba(251, 113, 133, .13), transparent 38%),
    linear-gradient(180deg, rgba(15, 28, 55, .96), rgba(5, 11, 22, .96));
  box-shadow: 0 36px 100px rgba(0, 0, 0, .46);
  padding: 28px;
  color: var(--text);
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  color: rgba(255, 255, 255, .9);
  font-size: 1.55rem;
  line-height: 1;
}
.modal-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-right: 44px;
  margin-bottom: 22px;
}
.modal-brand h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -.045em;
}
.settings-section {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 24px;
  background: rgba(255, 255, 255, .055);
}
.settings-section h3 {
  margin: 0 0 6px;
  font-size: 1.04rem;
  letter-spacing: -.025em;
}
.settings-section p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}
.option-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.option-button {
  min-height: 50px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 18px;
  background: rgba(3, 9, 21, .42);
  color: rgba(255, 255, 255, .9);
  font-size: 1.1rem;
  font-weight: 950;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}
.option-button.is-selected {
  border-color: rgba(56, 189, 248, .66);
  background: linear-gradient(135deg, rgba(56, 189, 248, .28), rgba(168, 85, 247, .23));
  box-shadow: 0 14px 34px rgba(56, 189, 248, .14), inset 0 1px 0 rgba(255, 255, 255, .11);
}
.settings-summary {
  margin: 18px 0 14px;
  padding: 14px 16px;
  border: 1px solid rgba(110, 231, 183, .30);
  border-radius: 18px;
  background: rgba(16, 185, 129, .10);
  color: rgba(209, 250, 229, .96);
  font-weight: 850;
  text-align: center;
}
.modal-save-button {
  width: 100%;
  min-height: 52px;
}

@media (max-width: 620px) {
  .option-grid { grid-template-columns: repeat(2, 1fr); }
  .teacher-primary-row { flex-direction: column; align-items: stretch; }
  .large-control-button,
  .teacher-primary-row button { width: 100%; }
}

/* Refined teacher-control panel: locked student view, simplified teacher flow */
.teacher-control-heading {
  margin-bottom: 12px;
}
.teacher-control-heading h2 {
  max-width: 100%;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, .96);
  font-size: clamp(1.22rem, 1.65vw, 1.62rem);
  line-height: 1.08;
}
.teacher-task-line {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 8px 13px;
  border: 1px solid rgba(56, 189, 248, .25);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(56, 189, 248, .13), rgba(168, 85, 247, .11));
  color: rgba(255, 255, 255, .95);
  font-size: .93rem;
  font-weight: 920;
  letter-spacing: -.01em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.teacher-status-tile {
  margin: 0 0 16px;
  min-height: 74px;
  display: flex;
  align-items: center;
  padding: 18px 20px;
  border-radius: 22px;
  font-size: 1.08rem;
  line-height: 1.25;
}
.teacher-primary-row {
  margin-top: 2px;
  margin-bottom: 0;
}
.control-panel audio {
  display: none;
}


/* Teacher panel spacing refinement: remove task pill and give controls more air */
.control-panel {
  padding: 26px 26px 24px;
}
.teacher-control-heading {
  margin-bottom: 18px;
}
.teacher-control-heading .eyebrow {
  margin-bottom: 10px;
}
.teacher-control-heading h2 {
  margin-bottom: 0;
  line-height: 1.16;
}
.teacher-task-line {
  display: none !important;
}
.teacher-status-tile {
  margin: 0 0 22px;
  min-height: 92px;
  padding: 22px 24px;
  border-radius: 24px;
  font-size: 1.12rem;
  line-height: 1.34;
  justify-content: center;
}
.teacher-primary-row {
  gap: 14px;
  margin-top: 0;
  padding-top: 2px;
}
.teacher-primary-row button {
  min-height: 48px;
}
.large-control-button {
  min-width: 210px;
}

/* Fixed-position teacher control pane: no shifting between Settings / Play / Next states */
.control-panel {
  min-height: 390px;
  padding: 26px 26px 24px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 0;
}
.teacher-control-heading {
  grid-row: 1;
  align-self: start;
  margin: 0;
}
.teacher-control-heading .eyebrow {
  margin: 0;
}
.teacher-track-slot {
  grid-row: 2;
  align-self: end;
  min-height: 72px;
  margin: 0 0 18px;
  display: flex;
  align-items: flex-end;
  color: rgba(255, 255, 255, .96);
  font-size: clamp(1.18rem, 1.55vw, 1.52rem);
  line-height: 1.14;
  letter-spacing: -.035em;
}
.teacher-track-slot:empty {
  visibility: hidden;
}
.teacher-status-tile {
  grid-row: 3;
  width: 100%;
  min-height: 88px;
  margin: 0 0 24px;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 24px;
  font-size: 1.1rem;
  line-height: 1.32;
}
.teacher-primary-row {
  grid-row: 4;
  align-self: end;
  display: grid;
  grid-template-columns: minmax(170px, 1.15fr) minmax(170px, 1fr) minmax(130px, .78fr);
  gap: 14px;
  margin: 0;
  padding: 0;
}
.teacher-primary-row button,
.large-control-button {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding-inline: 16px;
  white-space: nowrap;
}
.control-panel audio {
  display: none;
}

@media (max-width: 620px) {
  .control-panel {
    min-height: 440px;
  }
  .teacher-primary-row {
    grid-template-columns: 1fr;
  }
}

/* Tiny teacher pane alignment patch: fixed controls, track info held in place, status tile below it. */
.control-panel {
  position: relative;
  display: block;
  min-height: 390px;
  padding: 26px 26px 24px;
}
.control-panel .teacher-control-heading {
  position: absolute;
  top: 26px;
  left: 26px;
  right: 26px;
  margin: 0;
}
.control-panel .teacher-track-slot {
  position: absolute;
  top: 82px;
  left: 26px;
  right: 26px;
  min-height: 48px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.control-panel .teacher-status-tile {
  position: absolute;
  top: 150px;
  left: 26px;
  right: 26px;
  bottom: auto;
  min-height: 88px;
  margin: 0;
}
.control-panel .teacher-primary-row {
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: 24px;
  margin: 0;
}

@media (max-width: 620px) {
  .control-panel {
    min-height: 500px;
  }
  .control-panel .teacher-track-slot {
    top: 86px;
  }
  .control-panel .teacher-status-tile {
    top: 164px;
  }
}

/* Teacher top-centre pane: keep the green status tile fixed at the exact centre. */
.control-panel .teacher-status-tile {
  position: absolute;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  width: calc(100% - 52px);
  min-height: 88px;
  margin: 0;
  transform: translate(-50%, -50%);
}

@media (max-width: 620px) {
  .control-panel .teacher-status-tile {
    top: 50%;
    left: 50%;
    right: auto;
    width: calc(100% - 52px);
    transform: translate(-50%, -50%);
  }
}

/* Requested micro-adjustment: move only the green status tile down in the top-centre teacher pane. */
.control-panel .teacher-status-tile {
  top: 62% !important;
}

@media (max-width: 620px) {
  .control-panel .teacher-status-tile {
    top: 62% !important;
  }
}

/* Green status tile locked just above the bottom teacher-control buttons. */
.control-panel .teacher-status-tile {
  position: absolute !important;
  left: 26px !important;
  right: 26px !important;
  top: auto !important;
  bottom: 162px !important;
  width: auto !important;
  min-height: 88px !important;
  margin: 0 !important;
  transform: none !important;
}

@media (max-width: 620px) {
  .control-panel .teacher-status-tile {
    left: 26px !important;
    right: 26px !important;
    top: auto !important;
    bottom: 232px !important;
    width: auto !important;
    transform: none !important;
  }
}

/* Final targeted adjustment: restore compact green status tile and lock it just above the bottom buttons. */
.control-panel .teacher-status-tile {
  position: absolute !important;
  left: 26px !important;
  right: 26px !important;
  top: auto !important;
  bottom: 92px !important;
  width: auto !important;
  height: 74px !important;
  min-height: 74px !important;
  padding: 14px 20px !important;
  margin: 0 !important;
  transform: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  line-height: 1.22 !important;
}

@media (max-width: 620px) {
  .control-panel .teacher-status-tile {
    bottom: 226px !important;
    height: 74px !important;
    min-height: 74px !important;
    padding: 14px 20px !important;
  }
}

/* Teacher layout refinement: leaderboard full-height right, joined players centre-bottom.
   Keep teacher controls untouched; constrain all class lists to one screen. */
html,
body {
  height: 100%;
  overflow: hidden;
}

.teacher-shell {
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.teacher-grid {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  grid-template-columns: minmax(310px, .9fr) minmax(520px, 1.35fr) minmax(360px, 1fr);
  grid-template-rows: minmax(330px, .58fr) minmax(210px, .42fr);
  grid-template-areas:
    "session controls leaderboard"
    "session students leaderboard";
  align-items: stretch;
}

.session-panel,
.control-panel,
.students-panel,
.leaderboard-panel {
  min-height: 0;
}

.students-panel,
.leaderboard-panel {
  display: flex;
  flex-direction: column;
}

/* Leaderboard now lives in the right full-height box. */
.leaderboard-panel {
  grid-area: leaderboard;
}

/* Joined players now live in the lower centre box. */
.students-panel {
  grid-area: students;
}

.students-panel .panel-heading,
.leaderboard-panel .panel-heading {
  flex: 0 0 auto;
  margin-bottom: 10px;
}

.leaderboard-panel .summary-grid {
  flex: 0 0 auto;
  gap: 8px;
  margin-bottom: 10px;
}

.leaderboard-panel .summary-grid > div {
  padding: 10px 11px;
  border-radius: 17px;
}

.leaderboard-panel .summary-grid span {
  font-size: .66rem;
}

.leaderboard-panel .summary-grid strong {
  margin-top: 4px;
  font-size: 1rem;
}

.student-list,
.leaderboard-list {
  min-height: 0;
}

.student-list:not(.empty-state),
.leaderboard-list:not(.empty-state) {
  flex: 1 1 auto;
  height: 100%;
  display: grid;
  align-content: stretch;
  overflow: hidden;
}

.student-list:not(.empty-state) {
  grid-template-rows: repeat(var(--student-count, 1), minmax(0, 1fr));
  gap: clamp(4px, .55vh, 9px);
}

.leaderboard-list:not(.empty-state) {
  grid-template-rows: repeat(var(--leaderboard-count, 1), minmax(0, 1fr));
  gap: clamp(4px, .52vh, 9px);
}

.student-row,
.leaderboard-row {
  min-height: 0;
  overflow: hidden;
  padding: clamp(6px, .85vh, 11px) clamp(9px, 1vw, 14px);
}

.student-row > div,
.leaderboard-row > div {
  min-width: 0;
  overflow: hidden;
}

.student-row strong,
.leaderboard-row strong,
.student-row span,
.leaderboard-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-row {
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 9px;
}

.rank {
  width: 30px;
  height: 30px;
  font-size: .82rem;
}

.leaderboard-row em {
  font-size: 1.05rem;
}

.student-list.is-dense,
.leaderboard-list.is-dense {
  gap: 5px;
}

.student-list.is-dense .student-row,
.leaderboard-list.is-dense .leaderboard-row {
  padding-block: 7px;
  border-radius: 16px;
}

.student-list.is-dense .student-row strong,
.leaderboard-list.is-dense .leaderboard-row strong {
  margin-bottom: 0;
  font-size: .92rem;
}

.student-list.is-dense .student-row span,
.leaderboard-list.is-dense .leaderboard-row span {
  font-size: .72rem;
}

.leaderboard-list.is-compact,
.student-list.is-compact {
  gap: 4px;
}

.leaderboard-list.is-compact .leaderboard-row,
.student-list.is-compact .student-row {
  padding: 5px 9px;
  border-radius: 14px;
}

.leaderboard-list.is-compact .leaderboard-row span,
.student-list.is-compact .student-row span {
  display: none;
}

.leaderboard-list.is-compact .rank {
  width: 25px;
  height: 25px;
  font-size: .72rem;
}

.leaderboard-list.is-compact .leaderboard-row {
  grid-template-columns: 30px minmax(0, 1fr) auto;
}

.leaderboard-list.is-compact .leaderboard-row em {
  font-size: .9rem;
}

.leaderboard-list.is-ultra,
.student-list.is-ultra {
  gap: 3px;
}

.leaderboard-list.is-ultra .leaderboard-row,
.student-list.is-ultra .student-row {
  padding: 3px 8px;
  border-radius: 12px;
}

.leaderboard-list.is-ultra .leaderboard-row strong,
.student-list.is-ultra .student-row strong {
  font-size: .78rem;
}

.leaderboard-list.is-ultra .rank {
  width: 22px;
  height: 22px;
  font-size: .66rem;
}

.leaderboard-list.is-ultra .leaderboard-row {
  grid-template-columns: 26px minmax(0, 1fr) auto;
}

.leaderboard-list.is-ultra .leaderboard-row em {
  font-size: .78rem;
}

.student-list.is-ultra .status-badge {
  padding: 4px 7px;
  font-size: .64rem;
}

@media (max-width: 1180px) {
  html,
  body {
    overflow: auto;
  }
  .teacher-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .teacher-grid {
    height: auto;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
    grid-template-areas:
      "session controls"
      "students leaderboard";
  }
}



/* Joined students panel: two-column compact layout only.
   Keep leaderboard and teacher controls unchanged. */
.students-panel .student-list:not(.empty-state) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(var(--student-rows, 1), minmax(0, 1fr));
  gap: clamp(4px, .55vh, 8px) clamp(8px, .75vw, 12px);
}

.students-panel .student-row {
  min-width: 0;
  width: 100%;
  padding-inline: clamp(8px, .8vw, 12px);
  gap: 8px;
}

.students-panel .student-row > div {
  flex: 1 1 auto;
}

.students-panel .student-row .status-badge {
  flex: 0 0 auto;
  padding-inline: clamp(7px, .7vw, 10px);
  max-width: 44%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.students-panel .student-list.is-compact .student-row,
.students-panel .student-list.is-ultra .student-row {
  padding-block: 4px;
}

.students-panel .student-list.is-compact .status-badge,
.students-panel .student-list.is-ultra .status-badge {
  font-size: .62rem;
  padding: 3px 6px;
  max-width: 48%;
}

/* =========================
   Teacher Mode final leaderboard pop-out
   Classroom-only. Main Melody Master app unaffected.
========================= */
.final-leaderboard-backdrop {
  z-index: 180;
  background:
    radial-gradient(circle at 50% 38%, rgba(56, 189, 248, .18), transparent 34%),
    rgba(2, 8, 19, .76);
}

.final-leaderboard-modal {
  position: relative;
  width: min(780px, calc(100vw - 42px));
  max-height: min(82vh, 760px);
  overflow: auto;
  border: 1px solid rgba(56, 189, 248, .22);
  border-radius: 32px;
  padding: clamp(22px, 2.6vw, 32px);
  color: var(--text);
  background:
    radial-gradient(circle at 88% 8%, rgba(56, 189, 248, .18), transparent 34%),
    radial-gradient(circle at 8% 92%, rgba(251, 113, 133, .14), transparent 38%),
    linear-gradient(145deg, rgba(15, 23, 42, .97), rgba(2, 6, 23, .94));
  box-shadow:
    0 36px 110px rgba(0, 0, 0, .58),
    0 0 0 1px rgba(56, 189, 248, .16),
    0 0 58px rgba(56, 189, 248, .15);
  animation: teacherFinalLeaderboardIn .38s cubic-bezier(.22, 1, .36, 1) both;
}

.final-leaderboard-brand {
  margin-bottom: 18px;
}

.final-leaderboard-close {
  z-index: 3;
  font-weight: 900;
}

.final-leaderboard-hero {
  display: grid;
  gap: 5px;
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid rgba(110, 231, 183, .28);
  border-radius: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(110, 231, 183, .14), transparent 34%),
    rgba(16, 185, 129, .09);
  text-align: center;
}

.final-leaderboard-hero span,
.final-leaderboard-row small,
.final-leaderboard-reset-note {
  color: var(--muted);
}

.final-leaderboard-hero span {
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.final-leaderboard-hero strong {
  font-size: clamp(2.4rem, 6vw, 4.3rem);
  line-height: .9;
  letter-spacing: -.06em;
}

.final-leaderboard-list {
  display: grid;
  gap: 10px;
  max-height: min(42vh, 430px);
  overflow: auto;
  padding-right: 4px;
}

.final-leaderboard-row {
  min-height: 64px;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 20px;
  background: rgba(3, 9, 21, .46);
}

.final-leaderboard-row strong {
  display: block;
  margin-bottom: 3px;
}

.final-leaderboard-row em {
  font-style: normal;
  font-weight: 950;
  font-size: 1.25rem;
}

.final-leaderboard-row.is-unsubmitted {
  opacity: .62;
}

.final-leaderboard-reset-note {
  margin: 16px 0 0;
  text-align: center;
  line-height: 1.35;
}

.final-empty-state {
  min-height: 110px;
}

@keyframes teacherFinalLeaderboardIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(.965);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
