:root {
  color-scheme: only light;
  --ink: #173b3f;
  --teal: #0d7f83;
  --deep-teal: #07535a;
  --orange: #e67a28;
  --gold: #f7ba3b;
  --cream: #fff8df;
  --wood: #9b4f24;
  --root: #14a6a2;
  --prefix: #ef8d32;
  --suffix: #7765cf;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body {
  min-width: 1100px;
  background: #102f33;
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
}

button { font: inherit; }

button:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 7px #0f747c;
}

.lesson-shell { width: 100%; height: 100%; }

.workshop {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 700px;
  isolation: isolate;
  overflow: hidden;
  background: #744522 url("art/workshop-backdrop-01.webp") center / cover no-repeat;
}

.workshop-scrim {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 52% 44%, transparent 5%, rgba(10, 43, 43, .05) 55%, rgba(8, 28, 29, .4) 100%),
    linear-gradient(180deg, rgba(3, 38, 42, .23), transparent 25%, rgba(16, 48, 43, .16));
}

.workshop-hud {
  position: absolute;
  top: 24px;
  left: 28px;
  right: 28px;
  z-index: 8;
  display: grid;
  grid-template-columns: 250px 1fr 292px;
  align-items: start;
  gap: 20px;
  pointer-events: none;
}

.brand-plate, .score-plate, .difficulty-meter {
  border: 2px solid rgba(255,255,255,.42);
  background: rgba(10, 62, 65, .91);
  color: white;
  box-shadow: 0 10px 24px rgba(16, 30, 22, .25), inset 0 1px rgba(255,255,255,.2);
  backdrop-filter: blur(8px);
}

.brand-plate {
  width: max-content;
  min-width: 240px;
  padding: 12px 18px 13px;
  border-radius: 15px 15px 15px 5px;
}

.brand-plate span, .score-plate span, .difficulty-meter span {
  display: block;
  color: #aee6df;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.brand-plate strong { display: block; margin-top: 3px; font-size: 18px; }

.score-plate {
  justify-self: end;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 292px;
  padding: 11px 10px;
  border-radius: 15px 15px 5px 15px;
}

.score-plate div { padding: 0 13px; border-right: 1px solid rgba(255,255,255,.2); }
.score-plate div:last-child { border-right: 0; }
.score-plate strong { display: block; margin-top: 1px; color: #ffd46c; font-size: 25px; line-height: 1.05; }

.difficulty-meter {
  justify-self: center;
  width: 320px;
  padding: 10px 15px;
  border-radius: 15px;
}

.difficulty-meter > div { display: flex; align-items: baseline; justify-content: space-between; }
.difficulty-meter > div strong { color: #ffd46c; font-size: 20px; }
.difficulty-meter > i { display: block; height: 7px; margin: 6px 0 4px; overflow: hidden; border-radius: 99px; background: rgba(0,0,0,.3); }
.difficulty-meter > i b { display: block; width: 20%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #45d4bd, #ffd255, #ff8b3d); transition: width 350ms ease-out; }
.difficulty-meter small { color: #d4f1ed; font-weight: 700; }

.mascot-bay {
  position: absolute;
  z-index: 3;
  left: 16px;
  bottom: -26px;
  width: 310px;
  height: 650px;
  pointer-events: none;
}

.mascot {
  position: absolute;
  z-index: 2;
  left: -22px;
  bottom: 18px;
  width: 330px;
  filter: drop-shadow(0 18px 16px rgba(19, 29, 21, .4));
  transform-origin: 50% 80%;
  transition: transform 180ms ease-out, filter 180ms ease-out;
}

.block-cart {
  position: absolute;
  z-index: 1;
  left: 105px;
  bottom: -44px;
  width: 235px;
  filter: drop-shadow(0 12px 12px rgba(19, 29, 21, .34));
}

.speech-bubble {
  position: absolute;
  z-index: 4;
  top: 36px;
  left: 68px;
  width: 230px;
  padding: 14px 17px;
  border: 3px solid #1a4e50;
  border-radius: 18px 18px 18px 5px;
  background: #fff9e7;
  box-shadow: 0 9px 20px rgba(36, 26, 14, .22);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: 27px;
  bottom: -15px;
  width: 20px;
  height: 20px;
  border-right: 3px solid #1a4e50;
  border-bottom: 3px solid #1a4e50;
  background: #fff9e7;
  transform: rotate(45deg);
}

.mission-panel {
  position: absolute;
  z-index: 4;
  top: 105px;
  bottom: 34px;
  left: clamp(320px, 24vw, 380px);
  right: 42px;
  display: grid;
  grid-template-rows: auto auto minmax(210px, 1fr) auto auto auto;
  gap: 11px;
  min-width: 730px;
  padding: 24px 28px 22px;
  border: 3px solid rgba(255,255,255,.68);
  border-radius: 28px 28px 28px 9px;
  background: rgba(255, 249, 225, .94);
  box-shadow: 0 22px 55px rgba(32, 28, 18, .35), inset 0 0 0 6px rgba(167, 91, 33, .11);
  backdrop-filter: blur(12px);
}

.mission-copy { padding-right: 250px; }
.kicker { color: #a64e20; font-size: 12px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.mission-copy h1 { margin: 4px 0 3px; color: #133f42; font-size: clamp(25px, 2.45vw, 39px); line-height: 1.04; letter-spacing: -.035em; }
.mission-copy p { margin: 0; color: #527174; font-size: 15px; font-weight: 650; }

.blueprint {
  position: absolute;
  top: 23px;
  right: 27px;
  width: 230px;
  padding: 12px 15px;
  border: 2px dashed #2b7f80;
  border-radius: 8px;
  background: #e4f4e9;
  box-shadow: 4px 5px 0 rgba(22, 75, 73, .12);
  transform: rotate(1deg);
}

.blueprint span { display: block; color: #3f7472; font-size: 10px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.blueprint strong { display: block; margin-top: 3px; font-family: "American Typewriter", Rockwell, serif; font-size: 17px; line-height: 1.15; }

.machine {
  position: relative;
  min-height: 210px;
  padding: 51px 28px 54px;
  overflow: hidden;
  border: 3px solid #315859;
  border-radius: 23px 23px 13px 13px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.18), transparent 18%, transparent 82%, rgba(0,0,0,.13)),
    linear-gradient(180deg, #4ea8a1, #19747a 62%, #12575c);
  box-shadow: inset 0 4px rgba(255,255,255,.24), inset 0 -8px rgba(0,0,0,.13), 0 8px 0 #7d4727, 0 12px 20px rgba(65, 42, 21, .2);
}

.machine::before, .machine::after {
  content: "";
  position: absolute;
  top: 18px;
  width: 42px;
  height: 25px;
  border: 4px solid #173f43;
  border-radius: 6px;
  background: #ef9d33;
  box-shadow: inset 0 3px #ffd87a;
}
.machine::before { left: 22px; }
.machine::after { right: 22px; }

.machine-lights { position: absolute; top: 19px; left: 50%; display: flex; gap: 10px; transform: translateX(-50%); }
.machine-lights i { width: 11px; height: 11px; border: 2px solid #123c40; border-radius: 50%; background: #c7eee6; box-shadow: 0 0 0 3px rgba(255,255,255,.12); }
.machine-lights i:nth-child(2) { background: #ffd456; }
.machine-lights i:nth-child(3) { background: #f48a44; }

.socket-row {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(150px, .8fr) minmax(210px, 1.2fr) minmax(150px, .8fr);
  align-items: stretch;
  gap: 14px;
  max-width: 820px;
  margin: 0 auto;
}

.socket {
  position: relative;
  display: flex;
  min-height: 96px;
  align-items: center;
  justify-content: center;
  padding: 25px 14px 9px;
  border: 5px solid #173f43;
  border-radius: 14px;
  background: rgba(10, 52, 55, .53);
  box-shadow: inset 0 5px 9px rgba(0,0,0,.35), 0 3px rgba(255,255,255,.18);
}

.socket > span {
  position: absolute;
  top: 6px;
  left: 10px;
  color: rgba(255,255,255,.77);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.word-block {
  position: relative;
  display: flex;
  min-width: 92px;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border: 3px solid rgba(56, 32, 18, .48);
  border-radius: 9px;
  color: white;
  text-shadow: 0 2px rgba(0,0,0,.2);
  box-shadow: inset 0 4px rgba(255,255,255,.3), inset 0 -6px rgba(0,0,0,.1), 0 6px 0 rgba(43, 30, 20, .34);
  font-family: "American Typewriter", Rockwell, serif;
  font-size: clamp(20px, 2vw, 30px);
  font-weight: 900;
  letter-spacing: .01em;
  animation: block-snap 220ms cubic-bezier(.2, 1.35, .4, 1);
}

.word-block::before, .word-block::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 10px;
  height: 20px;
  border-radius: 4px;
  background: inherit;
  transform: translateY(-50%);
}
.word-block::before { left: -8px; }
.word-block::after { right: -8px; }
.word-block.prefix { background: var(--prefix); }
.word-block.root { background: var(--root); }
.word-block.suffix { background: var(--suffix); }
.word-block.empty { min-width: 110px; border-style: dashed; color: #dbefec; background: #376c70; font-family: inherit; font-size: 14px; text-shadow: none; }

.stamp-arm { position: absolute; z-index: 2; top: -1px; left: 50%; width: 110px; height: 44px; border: 4px solid #3d2a20; border-top: 0; border-radius: 0 0 13px 13px; background: #e6962b; transform: translateX(-50%) translateY(-34px); transition: transform 170ms ease-in; }
.stamp-arm i { position: absolute; left: 46px; bottom: -30px; width: 18px; height: 32px; background: #5e3926; }
.machine.is-stamping .stamp-arm { transform: translateX(-50%) translateY(37px); }

.conveyor { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; height: 34px; border-top: 5px solid #292f2d; background: #4d4b3f; }
.conveyor i { width: 25px; height: 25px; margin-top: 2px; border: 4px solid #292f2d; border-radius: 50%; background: #d08b33; }
.machine.is-stamping .conveyor i { animation: wheel .3s linear 2; }

.result-card {
  position: absolute;
  z-index: 8;
  top: 160px;
  left: 50%;
  width: min(560px, 65%);
  padding: 17px 25px 19px;
  border: 4px solid #21575a;
  border-radius: 17px;
  background: #fffdf2;
  box-shadow: 0 16px 38px rgba(10, 35, 32, .34), 0 0 0 6px rgba(255,255,255,.55);
  text-align: center;
  transform: translateX(-50%) rotate(-1deg);
  animation: result-pop 300ms cubic-bezier(.16, 1.25, .3, 1);
}
.result-card span { color: #b15d25; font-size: 10px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.result-card strong { display: block; margin: 1px 0 2px; color: #0e7479; font-family: "American Typewriter", Rockwell, serif; font-size: 36px; line-height: 1; }
.result-card p { margin: 0; color: #48686a; font-size: 14px; font-weight: 700; }
.result-card p b { color: #0a7f83; }

.choice-bench { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 10px; min-height: 54px; }
.choice-group { display: flex; align-items: center; gap: 7px; padding: 5px 7px; border: 2px solid #d7c6a4; border-radius: 13px; background: #f4ead2; }
.choice-group > span { width: 56px; color: #7c684d; font-size: 9px; font-weight: 900; letter-spacing: .1em; text-align: center; text-transform: uppercase; }
.block-choice, .meaning-choice {
  min-height: 46px;
  border: 2px solid rgba(73, 48, 27, .26);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  box-shadow: 0 4px 0 #c5aa7a;
  cursor: pointer;
  font-weight: 850;
  transition: transform 130ms ease-out, box-shadow 130ms ease-out, background 130ms ease-out;
}
.block-choice { min-width: 70px; padding: 8px 13px; font-family: "American Typewriter", Rockwell, serif; font-size: 17px; }
.block-choice.prefix { color: #a94b13; }
.block-choice.root { color: #08716e; }
.block-choice.suffix { color: #5846a2; }
.block-choice.is-selected { color: white; background: #173f43; box-shadow: 0 2px 0 #0a282b; transform: translateY(2px); }
.block-choice:hover, .meaning-choice:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #b89252; }
.meaning-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.meaning-choice { display: flex; min-height: 57px; align-items: center; justify-content: center; padding: 10px 16px; font-size: 14px; line-height: 1.2; }

.feedback { min-height: 22px; color: #3b696a; font-size: 14px; font-weight: 800; text-align: center; }
.feedback.is-error { color: #a63b2e; }

.main-action { display: flex; min-height: 49px; align-items: center; justify-content: center; }
.primary-action {
  position: relative;
  min-width: 240px;
  min-height: 50px;
  padding: 10px 24px;
  border: 2px solid #154b4c;
  border-radius: 13px;
  background: linear-gradient(#24a39d, #0c7b7e);
  color: white;
  box-shadow: 0 6px 0 #0d4d51, 0 9px 15px rgba(18, 47, 43, .2), inset 0 2px rgba(255,255,255,.25);
  cursor: pointer;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: .01em;
  transition: transform 130ms ease-out, box-shadow 130ms ease-out;
}
.primary-action.is-gold { border-color: #84421d; background: linear-gradient(#f4ad33, #db7025); box-shadow: 0 6px 0 #88451f, 0 9px 15px rgba(65, 38, 18, .2), inset 0 2px rgba(255,255,255,.32); }
.primary-action:hover { transform: translateY(-2px); }
.primary-action:active { transform: translateY(4px); box-shadow: 0 2px 0 #0d4d51; }
.primary-action:disabled { opacity: .52; cursor: not-allowed; filter: grayscale(.35); }

.toast {
  position: absolute;
  z-index: 20;
  left: 50%;
  bottom: 28px;
  max-width: 480px;
  padding: 11px 18px;
  border-radius: 999px;
  background: #153f42;
  color: white;
  box-shadow: 0 9px 25px rgba(0,0,0,.25);
  font-weight: 800;
  opacity: 0;
  transform: translate(-50%, 15px);
  transition: opacity 160ms, transform 160ms ease-out;
  pointer-events: none;
}
.toast.is-showing { opacity: 1; transform: translate(-50%, 0); }

.miss-flash { position: absolute; inset: 0; z-index: 30; border: 0 solid rgba(203, 57, 42, 0); pointer-events: none; }
.workshop.is-miss .miss-flash { animation: miss-flash 420ms ease-out; }
.workshop.is-miss .mission-panel { animation: gentle-shake 360ms ease-out; }
.workshop.is-miss .mascot { transform: rotate(-5deg) translateY(8px); filter: drop-shadow(0 18px 16px rgba(19, 29, 21, .4)) saturate(.75); }

.celebration { position: absolute; inset: 0; z-index: 24; overflow: hidden; opacity: 0; pointer-events: none; }
.celebration img { position: absolute; top: 46%; left: 60%; width: 210px; filter: drop-shadow(0 14px 20px rgba(39, 30, 10, .35)); transform: translate(-50%, -50%) scale(.2) rotate(-20deg); }
.celebration i { position: absolute; top: 42%; left: 60%; width: 14px; height: 25px; border-radius: 4px; background: #ffd34d; }
.celebration i:nth-of-type(2n) { background: #25b9aa; }
.celebration i:nth-of-type(3n) { background: #ed6c36; }
.workshop.is-celebrating .celebration { opacity: 1; animation: celebration-fade 900ms ease-out forwards; }
.workshop.is-celebrating .celebration img { animation: badge-pop 740ms cubic-bezier(.12, 1.35, .28, 1) forwards; }
.workshop.is-celebrating .celebration i:nth-of-type(1) { animation: confetti-one 800ms ease-out forwards; }
.workshop.is-celebrating .celebration i:nth-of-type(2) { animation: confetti-two 850ms ease-out forwards; }
.workshop.is-celebrating .celebration i:nth-of-type(3) { animation: confetti-three 800ms ease-out forwards; }
.workshop.is-celebrating .celebration i:nth-of-type(4) { animation: confetti-four 850ms ease-out forwards; }
.workshop.is-celebrating .celebration i:nth-of-type(5) { animation: confetti-one 850ms ease-out reverse forwards; }
.workshop.is-celebrating .celebration i:nth-of-type(6) { animation: confetti-two 800ms ease-out reverse forwards; }
.workshop.is-celebrating .celebration i:nth-of-type(7) { animation: confetti-three 850ms ease-out reverse forwards; }
.workshop.is-celebrating .celebration i:nth-of-type(8) { animation: confetti-four 800ms ease-out reverse forwards; }
.workshop.is-celebrating .mascot { animation: mascot-cheer 720ms cubic-bezier(.2, 1.2, .3, 1); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@keyframes block-snap { from { opacity: .2; transform: translateY(-18px) scale(.88); } to { opacity: 1; transform: none; } }
@keyframes result-pop { from { opacity: 0; transform: translateX(-50%) translateY(24px) scale(.85) rotate(2deg); } }
@keyframes wheel { to { transform: rotate(360deg); } }
@keyframes gentle-shake { 20% { transform: translateX(-7px); } 45% { transform: translateX(6px); } 70% { transform: translateX(-3px); } }
@keyframes miss-flash { 25% { border-width: 8px; border-color: rgba(203,57,42,.5); } 100% { border-width: 18px; border-color: transparent; } }
@keyframes mascot-cheer { 30% { transform: translateY(-26px) rotate(3deg); } 58% { transform: translateY(-7px) rotate(-2deg); } }
@keyframes celebration-fade { 0%, 72% { opacity: 1; } 100% { opacity: 0; } }
@keyframes badge-pop { 0% { transform: translate(-50%, -50%) scale(.2) rotate(-20deg); } 65% { transform: translate(-50%, -50%) scale(1.08) rotate(3deg); } 100% { transform: translate(-50%, -50%) scale(1) rotate(0); } }
@keyframes confetti-one { to { transform: translate(-190px, -180px) rotate(300deg); opacity: 0; } }
@keyframes confetti-two { to { transform: translate(180px, -170px) rotate(-300deg); opacity: 0; } }
@keyframes confetti-three { to { transform: translate(-210px, 140px) rotate(-260deg); opacity: 0; } }
@keyframes confetti-four { to { transform: translate(210px, 150px) rotate(280deg); opacity: 0; } }

@media (max-height: 780px) {
  .mission-panel { top: 88px; bottom: 20px; padding-top: 18px; }
  .mission-copy h1 { font-size: 27px; }
  .machine { min-height: 184px; padding-top: 42px; }
  .socket { min-height: 82px; }
  .mascot-bay { transform: scale(.88); transform-origin: left bottom; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
