:root {
  color-scheme: light;
  --ink: #242424;
  --muted: #62666f;
  --line: #d7d9df;
  --paper: #f7f1e6;
  --panel: #ffffff;
  --tile: #e4dfd3;
  --tile-selected: #f8f1d8;
  --tile-text: #202124;
  --tile-selected-text: #202124;
  --brand: #1f6f78;
  --brand-deep: #164d59;
  --berry: #6f91a8;
  --berry-deep: #4f7188;
  --berry-pop: #b23b62;
  --berry-pop-deep: #8f2e4c;
  --sun: #f5c84c;
  --button: var(--brand);
  --button-hover: var(--brand-deep);
  --shadow: 0 18px 45px rgba(39, 35, 25, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
select {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.tool-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 7px solid var(--berry);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.masthead-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.header-logo,
.student-brand img {
  display: block;
  width: 150px;
  max-width: 34vw;
  height: auto;
}

.student-brand {
  display: none;
  justify-content: center;
  margin-bottom: 18px;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--brand-deep);
  font-size: clamp(2.25rem, 7vw, 4.9rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid #b8d6da;
  border-radius: 999px;
  background: #e8f5f6;
  color: var(--brand-deep);
  padding: 8px 12px;
  font-size: 0.92rem;
  white-space: nowrap;
}

.chooser-row {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.chooser-row label {
  color: var(--muted);
  font-weight: 700;
}

.teacher-note {
  display: grid;
  gap: 12px;
  margin: 14px 0 0;
  border-left: 5px solid var(--berry);
  border-radius: 6px;
  background: #f1f7f8;
  color: var(--brand-deep);
  padding: 12px 14px;
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.45;
}

.teacher-note strong {
  display: block;
  margin-bottom: 5px;
  color: var(--brand-deep);
  font-size: 1.02rem;
}

.teacher-note p {
  margin: 0 0 4px;
}

.teacher-note p:last-child {
  margin-bottom: 0;
}

select {
  min-width: 0;
  width: 100%;
  min-height: 44px;
  border: 1px solid #b9bcc4;
  border-left: 5px solid var(--sun);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--button);
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  padding: 0 15px;
  transition:
    background 150ms ease,
    transform 150ms ease,
    opacity 150ms ease;
}

button:hover:not(:disabled) {
  background: var(--button-hover);
  transform: translateY(-1px);
}

#copy-link {
  background: var(--berry);
}

#copy-link:hover:not(:disabled) {
  background: var(--berry-deep);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.message {
  min-height: 24px;
  margin-top: 14px;
  color: var(--muted);
  font-weight: 700;
}

.message.error {
  color: #9b3328;
}

.game-area {
  margin-top: 22px;
}

.empty-state,
.game-board-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.empty-state {
  padding: clamp(28px, 7vw, 64px);
  text-align: center;
}

.empty-state h2 {
  margin-bottom: 8px;
  font-size: clamp(1.7rem, 5vw, 3rem);
  letter-spacing: 0;
}

.empty-state p {
  max-width: 620px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.5;
}

.game-board-wrap {
  padding: clamp(16px, 4vw, 28px);
  border-top: 7px solid var(--brand);
}

.game-topline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}


.game-title h2 {
  margin-bottom: 7px;
  color: var(--brand-deep);
  font-size: clamp(1.8rem, 5vw, 3.25rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.game-title p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

.mistakes {
  display: flex;
  align-items: center;
  gap: 7px;
  justify-content: flex-end;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--berry-pop);
  display: inline-block;
}

.dot.used {
  background: #d4d6dc;
}

.solved-list {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.solved-group {
  min-height: 74px;
  border-radius: 7px;
  padding: 13px;
  text-align: center;
  display: grid;
  place-items: center;
}

.solved-group strong,
.answer-group strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
}

.solved-group span,
.answer-group span {
  display: block;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
}

.group-color-0 {
  background: #f5df72;
}

.group-color-1 {
  background: #a7c957;
}

.group-color-2 {
  background: #83b5e1;
}

.group-color-3 {
  background: #b99ad6;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.tile {
  width: 100%;
  min-height: clamp(66px, 10vw, 86px);
  border-radius: 7px;
  background: var(--tile);
  color: var(--tile-text);
  display: grid;
  place-items: center;
  padding: 8px;
  text-align: center;
  line-height: 1.08;
  font-size: clamp(0.72rem, 2.1vw, 1rem);
  font-weight: 900;
  overflow-wrap: normal;
  word-break: normal;
}

.tile:hover:not(:disabled) {
  background: #f2ecdf;
  color: var(--tile-text);
}

.tile.selected {
  background: var(--tile-selected);
  color: var(--tile-selected-text);
  box-shadow: inset 0 0 0 3px #1f4f82;
}

.tile.selected:hover:not(:disabled) {
  background: var(--tile-selected);
  color: var(--tile-selected-text);
}

.controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.secondary {
  background: #f8fbfb;
  color: var(--brand-deep);
  border: 1px solid #8fc2c9;
}

.secondary:hover:not(:disabled) {
  background: #e8f5f6;
}

#submit-guess {
  background: var(--berry-pop);
}

#submit-guess:hover:not(:disabled) {
  background: var(--berry-pop-deep);
}

#reveal-answers {
  color: var(--berry-deep);
  border-color: #d99bb2;
  background: #fff4f7;
}

#reveal-answers:hover:not(:disabled) {
  background: #fde5ed;
}

.answer-panel {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.answer-panel h3 {
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.answer-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.answer-group {
  border-radius: 7px;
  padding: 13px;
  text-align: center;
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
}

.confetti span {
  position: absolute;
  left: var(--x);
  top: -18px;
  width: 10px;
  height: 16px;
  opacity: 0.95;
  animation: confetti-fall var(--duration) var(--delay) ease-out forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translate3d(0, -24px, 0) rotate(0deg);
  }

  100% {
    transform: translate3d(var(--drift), 110vh, 0) rotate(var(--spin));
  }
}

@media (prefers-reduced-motion: reduce) {
  .confetti {
    display: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 10px;
  }

  .tool-panel,
  .game-board-wrap {
    padding: 14px;
  }

  .masthead,
  .game-topline {
    grid-template-columns: 1fr;
    display: grid;
  }

  .masthead-actions {
    justify-items: start;
    justify-content: start;
  }

  .status-pill,
  .mistakes {
    justify-self: start;
  }

  .header-logo,
  .student-brand img {
    width: min(170px, 54vw);
    max-width: none;
  }

  .chooser-row {
    grid-template-columns: 1fr;
  }

  .tile-grid {
    gap: 6px;
  }

  .tile {
    min-height: 62px;
    padding: 6px;
    font-size: 0.68rem;
  }

  .answer-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 440px) {
  .tile {
    min-height: 62px;
    font-size: 0.6rem;
  }
}


html.teacher-auth-pending body > :not(#teacherGate) {
  display: none !important;
}

#teacherGate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--paper);
  color: var(--ink);
}

.teacher-gate-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-top: 7px solid var(--berry);
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: var(--panel);
}

.teacher-gate-eyebrow {
  margin: 0;
  color: var(--berry);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.teacher-gate-card h1 {
  margin: 0;
  color: var(--brand-deep);
  font-size: 2.2rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.teacher-gate-card label {
  color: var(--muted);
  font-weight: 800;
}

.teacher-gate-card input {
  width: 100%;
  min-height: 48px;
  border: 1px solid #b9bcc4;
  border-left: 5px solid var(--sun);
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
}

.teacher-gate-card input:focus {
  outline: 3px solid rgba(31, 111, 120, 0.2);
  border-color: var(--brand);
}

.teacher-gate-error {
  min-height: 1.2em;
  margin: 0;
  color: #9b3328;
  font-weight: 800;
}

.teacher-gate-card button {
  min-height: 48px;
}


body.student-mode .student-brand {
  display: flex;
}

body.student-mode .tool-panel {
  display: none;
}
