:root {
  --bg-1: #f3f7ff;
  --bg-2: #eef9f4;
  --card: #ffffff;
  --card-strong: #f5f8ff;
  --primary: #5a67d8;
  --primary-dark: #4154c7;
  --secondary: #43b581;
  --accent: #ffb703;
  --text: #1c2440;
  --muted: #5d678d;
  --border: rgba(90, 103, 216, 0.15);
  --shadow: 0 18px 45px rgba(52, 64, 110, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', sans-serif;
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2));
  color: var(--text);
}

button,
input {
  font: inherit;
}

.page-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--primary);
}

h1, h2, h3 {
  margin: 0;
  font-family: 'Baloo 2', cursive;
}

h1 {
  font-size: clamp(2.3rem, 5vw, 4rem);
  line-height: 0.96;
}

.score-pill {
  min-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 18px;
  box-shadow: var(--shadow);
}

.score-pill span {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.score-pill strong {
  font-size: 2.2rem;
  line-height: 1;
}

.game-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 22px;
}

.game-menu {
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.menu-item {
  border: 1px solid transparent;
  background: var(--card-strong);
  border-radius: 16px;
  padding: 14px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: 0.2s ease;
}

.menu-item:hover,
.menu-item.active {
  background: linear-gradient(135deg, #ecedff, #e9faf1);
  border-color: rgba(90, 103, 216, 0.22);
  transform: translateY(-1px);
}

.icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: rgba(90, 103, 216, 0.1);
  border-radius: 12px;
  font-size: 1.3rem;
}

.game-panel {
  display: none;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 24px 22px 26px;
  box-shadow: var(--shadow);
}

.game-panel.active {
  display: block;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.panel-header h2 {
  font-size: clamp(1.8rem, 2.8vw, 2.5rem);
}

.status-badge {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(67, 181, 129, 0.12);
  color: #1c7a59;
  font-size: 0.8rem;
  font-weight: 700;
}

.question-box {
  background: linear-gradient(135deg, rgba(90, 103, 216, 0.06), rgba(67, 181, 129, 0.08));
  border: 1px solid rgba(90, 103, 216, 0.1);
  border-radius: 18px;
  padding: 22px 18px;
  margin-bottom: 18px;
}

.prompt-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.question-box h3 {
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: 0.03em;
}

.answer-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.answer-form input,
.answer-form select,
.word-list-editor input {
  flex: 1 1 250px;
  min-height: 52px;
  border: 1px solid rgba(90, 103, 216, 0.22);
  background: #fff;
  border-radius: 14px;
  padding: 0 16px;
  font-size: 1.1rem;
  color: var(--text);
}

.class-picker-label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 700;
}

.concept-selector {
  margin-bottom: 18px;
}

.concept-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.concept-button {
  border: 1px solid rgba(90, 103, 216, 0.18);
  background: rgba(90, 103, 216, 0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

.concept-button.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-color: transparent;
}

.answer-form button,
.option-button,
.small-button,
.secondary-button,
.spell-letter,
.memory-card {
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.answer-form button {
  min-width: 130px;
  min-height: 52px;
  padding: 0 20px;
  box-shadow: 0 12px 25px rgba(90, 103, 216, 0.24);
}

.answer-form button:hover,
.option-button:hover,
.small-button:hover,
.secondary-button:hover,
.spell-letter:hover,
.memory-card:hover {
  transform: translateY(-1px);
}

.feedback {
  margin-top: 18px;
  color: var(--muted);
  font-size: 1.03rem;
  font-weight: 600;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 8px;
}

.option-button {
  min-height: 62px;
  padding: 12px 14px;
  text-align: left;
  box-shadow: 0 10px 18px rgba(90, 103, 216, 0.12);
}

.spellbuilder-box {
  display: grid;
  gap: 18px;
}

.spellbound-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.spell-letter {
  min-width: 52px;
  height: 52px;
  padding: 0 12px;
  font-size: 1.3rem;
  font-family: 'Baloo 2', cursive;
  box-shadow: 0 8px 18px rgba(90, 103, 216, 0.15);
}

.built-word-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: 1px dashed rgba(90, 103, 216, 0.26);
  border-radius: 14px;
  background: rgba(90, 103, 216, 0.04);
}

.built-word-row span {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

.built-word-row strong {
  font-size: 1.35rem;
  letter-spacing: 0.14em;
}

.mini-action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.small-button,
.secondary-button {
  min-height: 46px;
  padding: 0 18px;
}

.secondary-button {
  background: linear-gradient(135deg, #f2f7ff, #eafaf1);
  color: var(--text);
  border: 1px solid rgba(90, 103, 216, 0.12);
}

.word-list-panel {
  margin-top: 22px;
  padding: 16px;
  border: 1px solid rgba(90, 103, 216, 0.12);
  border-radius: 18px;
  background: rgba(90, 103, 216, 0.03);
}

.word-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.word-list-header p {
  margin: 0;
}

.word-list-editor {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.word-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-list li {
  padding: 6px 10px;
  background: rgba(67, 181, 129, 0.14);
  color: #1c7a59;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 6px;
}

.memory-card {
  min-height: 92px;
  font-size: 2rem;
  background: linear-gradient(135deg, #7b86e9, #5a67d8);
  box-shadow: 0 10px 20px rgba(90, 103, 216, 0.16);
}

.memory-card.matched {
  background: linear-gradient(135deg, #43b581, #2d9d6b);
}

[hidden] {
  display: none !important;
}

.header-actions,
.student-session,
.dashboard-toolbar,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.teacher-link {
  color: var(--primary-dark);
  font-weight: 800;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.student-session {
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
  font-weight: 700;
}

.student-gate,
.teacher-login {
  max-width: 720px;
  margin: 34px auto;
  padding: 26px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.student-gate h2,
.teacher-login h2,
.section-heading h2 {
  font-size: 1.8rem;
}

.student-gate > p:not(.feedback) {
  color: var(--muted);
}

.teacher-page .page-shell {
  max-width: 1120px;
}

.teacher-dashboard {
  display: grid;
  gap: 20px;
}

.dashboard-toolbar {
  justify-content: flex-end;
  min-height: 44px;
}

.dashboard-toolbar .feedback {
  flex: 1;
  margin: 0;
}

.teacher-section {
  padding: 24px 0;
  border-top: 1px solid var(--border);
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading .prompt-label {
  margin-bottom: 2px;
}

.teacher-inline-form {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.teacher-inline-form label {
  display: grid;
  gap: 6px;
  min-width: 190px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.teacher-inline-form input {
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(90, 103, 216, 0.22);
  border-radius: 10px;
  color: var(--text);
  background: #fff;
}

.teacher-note {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.concept-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.concept-check input {
  width: 17px;
  height: 17px;
  accent-color: var(--secondary);
}

.teacher-page h3 {
  margin: 22px 0 10px;
  font-size: 1.3rem;
}

.table-scroll {
  overflow-x: auto;
}

.teacher-page table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.teacher-page th,
.teacher-page td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.teacher-page th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.teacher-word-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px 18px;
  padding: 0;
  margin: 16px 0 0;
  list-style: none;
}

.teacher-word-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.teacher-word-list li span {
  font-weight: 800;
}

.teacher-word-list li small {
  color: var(--muted);
}

.teacher-word-list .table-action {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.table-action {
  border: 0;
  padding: 6px 8px;
  color: #9a3d34;
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

@media print {
  body {
    background: #fff;
  }

  .teacher-page .page-shell {
    max-width: none;
    padding: 0;
  }

  .teacher-page .topbar a,
  .teacher-page .teacher-login,
  .teacher-page .dashboard-toolbar,
  .teacher-page form,
  .teacher-page button,
  .teacher-page .teacher-section:not(#report-section) {
    display: none !important;
  }

  .teacher-page #report-section {
    display: block;
    border: 0;
  }

  .teacher-page .table-scroll {
    overflow: visible;
  }

  .teacher-page table {
    font-size: 9pt;
  }
}

.legacy-import {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px;
  border-left: 3px solid var(--secondary);
  background: rgba(67, 181, 129, 0.08);
}

.legacy-import .teacher-note {
  margin: 0;
}

@media (max-width: 760px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .student-gate,
  .teacher-login {
    padding: 20px 16px;
  }

  .teacher-inline-form label {
    flex: 1 1 100%;
  }

  .score-pill {
    align-self: stretch;
  }

  .options-grid,
  .memory-grid {
    grid-template-columns: 1fr;
  }
}
