:root {
  --ink: #25170f;
  --muted: #6d5546;
  --paper: #fff8ea;
  --panel: rgba(255, 248, 234, 0.92);
  --cream: #ffe7b8;
  --cranberry: #a62d3f;
  --cranberry-dark: #751d2a;
  --pumpkin: #dc6e26;
  --gold: #f5b041;
  --corn: #f7d658;
  --sage: #5f7f4a;
  --green: #2f6f4f;
  --line: rgba(71, 41, 22, 0.18);
  --shadow: 0 18px 48px rgba(89, 48, 20, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(220, 110, 38, 0.18), transparent 28rem),
    radial-gradient(circle at top right, rgba(95, 127, 74, 0.18), transparent 26rem),
    linear-gradient(180deg, #fff4db, #fffaf0 58%, #e7c28f);
}

button,
input {
  font: inherit;
}

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

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

.brief {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

.teacher-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.teacher-shell {
  width: min(980px, 100%);
}

.teacher-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(rgba(255, 248, 234, 0.9), rgba(255, 248, 234, 0.95)),
    radial-gradient(circle at 76% 26%, rgba(220, 110, 38, 0.26), transparent 13rem),
    radial-gradient(circle at 20% 82%, rgba(47, 111, 79, 0.18), transparent 14rem),
    #fff8ea;
  box-shadow: var(--shadow);
  padding: clamp(28px, 6vw, 72px);
}

.teacher-card::after {
  content: "";
  position: absolute;
  right: clamp(20px, 8vw, 92px);
  bottom: -32px;
  width: clamp(160px, 24vw, 260px);
  aspect-ratio: 1.2;
  border-radius: 52% 48% 44% 56%;
  background:
    radial-gradient(circle at 50% 23%, #fff8ea 0 11%, transparent 12%),
    radial-gradient(circle at 50% 48%, var(--cranberry) 0 9%, transparent 10%),
    conic-gradient(from 210deg, #7b2d19, #dc6e26, #f5b041, #5f7f4a, #a62d3f, #7b2d19);
  opacity: 0.16;
}

.teacher-card h1,
.hero h1 {
  margin-bottom: 12px;
  font-size: clamp(3rem, 6vw, 6.8rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.teacher-links {
  display: grid;
  gap: 14px;
  max-width: 560px;
  margin-top: 30px;
}

.teacher-links a,
.lock-card button,
.win-card button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fffaf0;
  background: var(--cranberry);
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.teacher-links a:hover,
.lock-card button:hover,
.win-card button:hover {
  background: var(--cranberry-dark);
}

.teacher-links a {
  min-height: 52px;
  padding: 0 20px;
  justify-self: start;
}

.teacher-links p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.teacher-links span {
  font-weight: 900;
}

.app-shell {
  width: min(1460px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.hero {
  min-height: 210px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 24px;
  align-items: end;
  padding: 28px 0 18px;
}

.progress-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
  box-shadow: var(--shadow);
}

.progress-panel span:first-child {
  display: block;
  margin-bottom: 12px;
  font-weight: 900;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  background: #e7caa1;
  border: 1px solid rgba(71, 41, 22, 0.12);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--pumpkin), var(--cranberry));
  transition: width 220ms ease;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 22px;
  align-items: start;
}

.clue-area,
.locks-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.locks-panel {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.clue-toolbar,
.locks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.clue-toolbar h2,
.locks-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.locks-header {
  display: block;
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(255, 248, 234, 0.96);
}

.locks-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.ghost-button,
.icon-button {
  min-height: 40px;
  border: 1px solid rgba(71, 41, 22, 0.22);
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

.ghost-button:hover,
.icon-button:hover {
  border-color: var(--cranberry);
}

.explore-board {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.mission-card {
  margin: 0;
  border: 1px solid var(--line);
  background:
    linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.94)),
    radial-gradient(circle at 88% 16%, rgba(166, 45, 63, 0.16), transparent 10rem),
    radial-gradient(circle at 10% 86%, rgba(220, 110, 38, 0.2), transparent 12rem);
  padding: 22px;
}

.mission-card h2 {
  margin-bottom: 12px;
  font-size: clamp(1.5rem, 3vw, 2.35rem);
  line-height: 1.05;
}

.mission-card p {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.62;
}

.turkey-talk-puzzle {
  overflow: hidden;
  scroll-margin-top: 18px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 10% 10%, rgba(245, 176, 65, 0.16), transparent 12rem),
    radial-gradient(circle at 88% 92%, rgba(166, 45, 63, 0.12), transparent 12rem),
    #fff8ea;
}

.turkey-talk-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.turkey-talk-heading h2 {
  margin-bottom: 8px;
  font-size: clamp(1.6rem, 3vw, 2.55rem);
  line-height: 1;
}

.turkey-talk-heading p:last-child {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.48;
}

.turkey-talk-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.turkey-talk-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 22px;
  padding: 22px;
}

.turkey-talk-board {
  display: grid;
  gap: 16px;
  min-width: 0;
}

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

.turkey-picture-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid rgba(71, 41, 22, 0.16);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  padding: 10px;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(89, 48, 20, 0.08);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.turkey-picture-card:hover,
.turkey-picture-card:focus-visible {
  border-color: rgba(166, 45, 63, 0.5);
  box-shadow: 0 16px 30px rgba(89, 48, 20, 0.14);
  transform: translateY(-2px);
}

.turkey-picture-card:focus-visible {
  outline: 4px solid rgba(166, 45, 63, 0.18);
  outline-offset: 3px;
}

.turkey-picture-card.is-matched {
  background: #fffdf5;
  border-color: rgba(95, 127, 74, 0.38);
}

.turkey-image-frame {
  display: block;
  overflow: hidden;
  aspect-ratio: 0.82;
  border: 1px solid rgba(71, 41, 22, 0.16);
  border-radius: 8px;
  background: #f6dfb6;
}

.turkey-image-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.turkey-drop-zone {
  min-height: 64px;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 2px dashed rgba(123, 74, 47, 0.52);
  border-radius: 8px;
  color: #7b4a2f;
  background: rgba(255, 249, 237, 0.74);
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.18;
  text-align: center;
}

.turkey-drop-zone.filled {
  border-style: solid;
  border-color: rgba(95, 127, 74, 0.46);
  background: #f2f8ea;
}

.placed-term {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  min-width: min(100%, 112px);
  padding: 0 14px;
  border: 1px solid rgba(71, 41, 22, 0.22);
  border-radius: 8px;
  color: var(--ink);
  background: #fff1cc;
  box-shadow: 0 4px 0 rgba(123, 74, 47, 0.16);
  font-size: 1.08rem;
  font-weight: 900;
}

.turkey-name-tray {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(71, 41, 22, 0.16);
  border-radius: 8px;
  background: #8f332b;
  box-shadow: inset 0 0 0 2px rgba(255, 231, 184, 0.18);
}

.turkey-talk-status {
  min-height: 1.35em;
  margin: 0;
  color: #fff8ea;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
}

.turkey-name-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.turkey-name-card {
  min-height: 58px;
  border: 1px solid rgba(71, 41, 22, 0.22);
  border-radius: 8px;
  color: var(--ink);
  background: #fff4dc;
  box-shadow: 0 4px 0 rgba(37, 23, 15, 0.25);
  font-size: clamp(1rem, 2vw, 1.38rem);
  font-weight: 900;
  cursor: grab;
  transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.turkey-name-card:hover,
.turkey-name-card:focus-visible,
.turkey-name-card.selected {
  background: #ffe6ab;
  transform: translateY(-2px);
}

.turkey-name-card:focus-visible,
.turkey-name-card.selected {
  outline: 4px solid rgba(255, 244, 220, 0.42);
  outline-offset: 2px;
}

.turkey-name-card:active {
  cursor: grabbing;
}

.turkey-name-card.shake {
  animation: shake 300ms ease;
}

.turkey-reference {
  align-self: start;
  border: 1px solid rgba(71, 41, 22, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 249, 237, 0.9), rgba(255, 249, 237, 0.94)),
    repeating-linear-gradient(0deg, rgba(123, 74, 47, 0.08) 0 1px, transparent 1px 18px);
  padding: 18px;
}

.turkey-reference h3 {
  margin: 0 0 14px;
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 0 14px;
  color: #fffaf0;
  background: var(--sage);
  border-radius: 8px;
  font-size: 1rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.reference-item {
  position: relative;
  padding: 0 0 14px 28px;
  border-bottom: 2px dashed rgba(123, 74, 47, 0.28);
  margin-bottom: 14px;
}

.reference-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.reference-item::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 0;
  width: 16px;
  height: 34px;
  border-radius: 70% 8px 70% 8px;
  background: var(--accent, var(--pumpkin));
  transform: rotate(22deg);
}

.hen-ref {
  --accent: #a62d3f;
}

.tom-ref {
  --accent: #dc6e26;
}

.poult-ref {
  --accent: #5f7f4a;
}

.flock-ref {
  --accent: #7b4a2f;
}

.reference-item h4 {
  margin: 0 0 6px;
  color: var(--accent, var(--pumpkin));
  font-size: 1.18rem;
  line-height: 1;
  text-transform: uppercase;
}

.reference-item p {
  margin: 0;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.42;
}

.clue-scene {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 248, 234, 0.66), rgba(255, 248, 234, 0.9)),
    repeating-linear-gradient(90deg, rgba(95, 127, 74, 0.12) 0 18px, transparent 18px 36px),
    #fff8ea;
  padding: 14px;
}

.clue-card-button {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-width: 0;
  border: 1px solid rgba(71, 41, 22, 0.16);
  background: #fff;
  color: var(--ink);
  padding: 22px 16px 18px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(89, 48, 20, 0.08);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.clue-card-button:hover,
.clue-card-button:focus-visible {
  border-color: rgba(166, 45, 63, 0.52);
  box-shadow: 0 14px 30px rgba(89, 48, 20, 0.16);
  transform: translateY(-2px);
}

.clue-card-button:focus-visible {
  outline: 4px solid rgba(166, 45, 63, 0.18);
  outline-offset: 3px;
}

.clue-thumb-wrap {
  position: relative;
  display: block;
  width: min(100%, 178px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(71, 41, 22, 0.12);
  border-radius: 8px;
  background: #ffffff;
}

.clue-thumb {
  display: block;
  width: 100%;
  height: 100%;
  padding: 12px;
  object-fit: contain;
  background: #fff;
}

.clue-thumb-fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-content: center;
  justify-items: center;
  gap: 9px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.clue-thumb-fallback span {
  color: var(--cranberry);
  font-weight: 900;
  line-height: 1.12;
}

.clue-thumb-fallback small {
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
}

.is-missing-image .clue-thumb {
  display: none;
}

.is-missing-image .clue-thumb-fallback {
  display: grid;
}

.clue-card-title {
  min-height: 2.4em;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1.25;
}

.locks-list {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.lock-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(71, 41, 22, 0.14);
  background: #ffffff;
}

.lock-card.solved {
  background: #f2f8ea;
  border-color: rgba(95, 127, 74, 0.32);
}

.lock-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lock-title h3 {
  margin: 0;
  font-size: 1.06rem;
}

.lock-icon-svg {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.open-lock .lock-shackle {
  transform: translate(8px, -2px) rotate(18deg);
  transform-origin: 36px 28px;
}

.lock-card label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
}

.lock-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.lock-row input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid rgba(71, 41, 22, 0.2);
  padding: 0 12px;
  color: var(--ink);
  background: #fffaf2;
  font-weight: 800;
}

.lock-row input:focus {
  border-color: var(--cranberry);
  outline: 4px solid rgba(166, 45, 63, 0.14);
}

.lock-row button {
  min-height: 44px;
  border: 0;
  padding: 0 14px;
}

.lock-row button:disabled,
.lock-row input:disabled {
  cursor: default;
  opacity: 0.78;
}

.feedback {
  min-height: 1.35em;
  margin: 0;
  color: var(--cranberry);
  font-size: 0.9rem;
  font-weight: 800;
}

.clue-dialog,
.turkey-talk-dialog,
.win-dialog {
  width: min(720px, calc(100% - 28px));
  border: 0;
  padding: 0;
  color: var(--ink);
  background: #fffaf0;
  box-shadow: 0 24px 80px rgba(37, 23, 15, 0.34);
}

.turkey-talk-dialog {
  width: min(1420px, calc(100% - 18px));
  max-height: calc(100vh - 18px);
  overflow: auto;
  background: transparent;
}

.clue-dialog.wide-clue-dialog {
  width: min(1180px, calc(100% - 28px));
}

.clue-dialog::backdrop,
.turkey-talk-dialog::backdrop,
.win-dialog::backdrop {
  background: rgba(37, 23, 15, 0.46);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.8rem);
}

.icon-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
  font-weight: 900;
}

.clue-dialog-body {
  padding: 22px;
}

.clue-dialog-image {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
}

.wide-clue-dialog .clue-dialog-image {
  max-height: 82vh;
}

.image-fallback {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.62;
}

.win-card {
  padding: clamp(26px, 5vw, 46px);
  text-align: center;
}

.win-card h2 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
}

.win-card p {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.win-card button {
  min-height: 50px;
  margin-top: 12px;
  border: 0;
  padding: 0 20px;
}

.harvest-celebration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.fall-piece {
  position: absolute;
  top: -42px;
  left: var(--x);
  width: 28px;
  height: 28px;
  animation: fall var(--duration) linear var(--delay) forwards;
}

.leaf-piece {
  border-radius: 0 70% 0 70%;
  background: var(--pumpkin);
}

.corn-piece {
  border-radius: 48%;
  background:
    linear-gradient(90deg, transparent 45%, rgba(47, 111, 79, 0.7) 46% 54%, transparent 55%),
    radial-gradient(circle at 36% 32%, #fff2a6 0 14%, transparent 15%),
    var(--corn);
}

.pie-piece {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: #8c431f;
  border: 5px solid var(--gold);
}

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

  12% {
    opacity: 1;
  }

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

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-8px);
  }

  50% {
    transform: translateX(7px);
  }

  75% {
    transform: translateX(-4px);
  }
}

@media (max-width: 1020px) {
  .workspace,
  .hero {
    grid-template-columns: 1fr;
  }

  .locks-panel {
    position: static;
    max-height: none;
  }

  .turkey-talk-layout {
    grid-template-columns: 1fr;
  }

  .turkey-picture-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .hero {
    min-height: 0;
  }

  .teacher-card h1,
  .hero h1 {
    font-size: clamp(2.6rem, 16vw, 4rem);
  }

  .clue-scene {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .turkey-talk-heading {
    display: grid;
    align-items: start;
  }

  .turkey-talk-actions {
    justify-content: space-between;
  }

  .turkey-name-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 460px) {
  .clue-scene,
  .lock-row {
    grid-template-columns: 1fr;
  }

  .turkey-picture-grid {
    grid-template-columns: 1fr;
  }

  .clue-thumb-wrap {
    width: min(100%, 150px);
  }
}
