:root {
  color-scheme: light;
  --ink: #1d1812;
  --paper: #f7f5ee;
  --plastic: #e9ead6;
  --plastic-warm: #d7d4b7;
  --recess: #f5f4df;
  --groove: #c8c8a9;
  --line: #19150f;
  --red: #de2f22;
  --yellow: #e9b91f;
  --blue: #1287b7;
  --green: #3fa51b;
  --orange: #ff6b12;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(36, 30, 20, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(36, 30, 20, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 36px 36px;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button {
  font: inherit;
  touch-action: manipulation;
}

.machine-shell {
  align-items: center;
  display: grid;
  gap: 14px;
  justify-items: center;
  min-height: 100vh;
  padding: 18px;
}

.clamshell {
  display: grid;
  justify-items: center;
  max-width: 1100px;
  perspective: 1600px;
  width: min(100%, 1100px);
}

.screen-lid {
  display: grid;
  justify-items: center;
  margin-bottom: -0.4%;
  position: relative;
  width: min(84%, 900px);
  z-index: 3;
}

.screen-bezel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), transparent 20%),
    linear-gradient(180deg, #e7e7d2 0%, #d1cfad 100%);
  border: clamp(3px, 0.46vw, 6px) solid rgba(53, 50, 35, 0.44);
  border-radius: 5.8% 5.8% 2.5% 2.5% / 9% 9% 3% 3%;
  box-shadow:
    inset 0 0.9vw 1.3vw rgba(255, 255, 255, 0.82),
    inset 0 -0.85vw 1vw rgba(70, 62, 36, 0.16),
    0 0.75vw 1.7vw rgba(37, 29, 14, 0.22);
  padding: clamp(10px, 1.6vw, 22px);
  transform: rotateX(-4deg);
  transform-origin: bottom center;
  width: 100%;
}

.screen-video-frame {
  aspect-ratio: 16 / 9;
  background: #111;
  border: clamp(5px, 0.8vw, 12px) solid #211915;
  border-radius: 2.6% / 4%;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.08),
    0 0.35vw 0 rgba(55, 44, 25, 0.18);
  overflow: hidden;
  position: relative;
  width: 100%;
}

.hinge {
  align-items: center;
  display: grid;
  gap: 2%;
  grid-template-columns: 18% 56% 18%;
  height: clamp(10px, 1.4vw, 18px);
  justify-content: center;
  margin-top: -1px;
  width: 74%;
}

.hinge span {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 45%),
    #b9b187;
  border: 2px solid rgba(60, 54, 34, 0.36);
  border-radius: 999px;
  box-shadow: 0 0.25vw 0 rgba(57, 45, 22, 0.18);
  display: block;
  height: 100%;
}

.console {
  aspect-ratio: 870 / 500;
  background:
    radial-gradient(circle at 50% 6%, rgba(255, 255, 255, 0.96), transparent 13%),
    linear-gradient(180deg, #f7f7e7 0%, var(--plastic) 54%, #dadac0 100%);
  border: clamp(3px, 0.5vw, 5px) solid rgba(46, 43, 31, 0.42);
  border-radius: 13% 13% 7% 7% / 20% 20% 10% 10%;
  box-shadow:
    inset 0 1.5vw 1.6vw rgba(255, 255, 255, 0.78),
    inset 0 -1.5vw 1.5vw rgba(74, 68, 44, 0.16),
    0 1vw 0 #bdb482,
    0 1.7vw 2.5vw rgba(36, 27, 13, 0.26);
  max-width: none;
  overflow: hidden;
  position: relative;
  transform: rotateX(2deg);
  transform-origin: top center;
  width: 100%;
  z-index: 2;
}

.console::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  content: "";
  height: 12%;
  left: 14%;
  opacity: 0.55;
  position: absolute;
  top: 3%;
  width: 72%;
}

.console-well {
  background:
    linear-gradient(180deg, rgba(210, 210, 181, 0.55), transparent 18%),
    var(--recess);
  border-radius: 7% / 13%;
  box-shadow:
    inset 0 1vw 1vw rgba(62, 57, 37, 0.2),
    inset 0 -0.4vw 0 rgba(255, 255, 255, 0.56);
  height: 82%;
  left: 7%;
  position: absolute;
  top: 8%;
  width: 86%;
}

.lesson-video {
  background: #111;
  cursor: pointer;
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.video-toggle {
  align-items: center;
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.14), transparent 28%),
    rgba(21, 164, 59, 0.86);
  border: 0;
  color: #fff;
  cursor: pointer;
  display: flex;
  font-size: clamp(1rem, 4.6vw, 3.4rem);
  font-weight: 950;
  inset: 0;
  justify-content: center;
  letter-spacing: 0;
  line-height: 1;
  position: absolute;
  text-transform: uppercase;
  text-shadow: 0 0.18vw 0 rgba(0, 0, 0, 0.18);
}

.video-toggle.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.worm {
  align-items: center;
  display: flex;
  height: 15.2%;
  position: absolute;
  top: 14.6%;
  z-index: 4;
}

.worm-green {
  left: 13.7%;
  width: 20.6%;
}

.worm-red {
  justify-content: flex-end;
  right: 13.8%;
  width: 20.6%;
}

.worm-face,
.worm-segment,
.worm-dot {
  border: clamp(2px, 0.4vw, 4px) solid var(--line);
  border-radius: 50%;
  display: block;
  flex: 0 0 auto;
  position: relative;
  transition:
    background 160ms ease,
    filter 160ms ease,
    box-shadow 160ms ease;
}

.worm-face {
  height: 100%;
  width: 41%;
  z-index: 3;
}

.segment-large {
  height: 76%;
  width: 32%;
}

.segment-mid {
  height: 61%;
  width: 25%;
}

.segment-small {
  height: 42%;
  width: 18%;
}

.worm-dot {
  height: 18%;
  width: 8%;
}

.worm-green .worm-face,
.worm-green .worm-segment,
.worm-green .worm-dot {
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.28), transparent 18%),
    #4fbd38;
}

.worm-red .worm-face,
.worm-red .worm-segment,
.worm-red .worm-dot {
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.28), transparent 18%),
    #e8493d;
}

.worm-green .worm-segment,
.worm-green .worm-dot {
  margin-left: -7%;
}

.worm-red .worm-segment,
.worm-red .worm-dot {
  margin-right: -7%;
}

.worm-eye {
  background: #f8f8e7;
  border: clamp(1px, 0.28vw, 3px) solid var(--line);
  border-radius: 50%;
  height: 35%;
  position: absolute;
  top: 27%;
  width: 28%;
}

.worm-eye::after {
  background: var(--line);
  border-radius: 50%;
  content: "";
  height: 34%;
  left: 43%;
  position: absolute;
  top: 43%;
  width: 34%;
}

.eye-left {
  left: 22%;
}

.eye-right {
  right: 18%;
}

.worm-mouth {
  border: clamp(2px, 0.42vw, 4px) solid transparent;
  border-bottom-color: var(--line);
  border-radius: 50%;
  height: 29%;
  left: 29%;
  position: absolute;
  width: 42%;
}

.smile {
  top: 48%;
}

.frown {
  bottom: 7%;
  transform: rotate(180deg);
}

body.feedback-correct .worm-green .worm-face,
body.feedback-correct .worm-green .worm-segment,
body.feedback-correct .worm-green .worm-dot {
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.62), transparent 20%),
    #24ff4d;
  box-shadow: 0 0 1.2vw rgba(36, 255, 77, 0.92);
  filter: saturate(1.5) brightness(1.25);
}

body.feedback-wrong .worm-red .worm-face,
body.feedback-wrong .worm-red .worm-segment,
body.feedback-wrong .worm-red .worm-dot {
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.58), transparent 20%),
    #ff2c22;
  box-shadow: 0 0 1.2vw rgba(255, 44, 34, 0.94);
  filter: saturate(1.5) brightness(1.25);
}

.speaker {
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 8%,
      var(--groove) 8%,
      var(--groove) 11%,
      rgba(255, 255, 255, 0.74) 12%,
      transparent 14%
    );
  border-radius: 4% / 9%;
  height: 43%;
  position: absolute;
  top: 36.5%;
  width: 20.2%;
}

.speaker::before,
.speaker::after {
  background: #d5d5bb;
  border-radius: 999px;
  box-shadow: inset 0 0.2vw 0.15vw rgba(54, 50, 33, 0.16);
  content: "";
  height: 3.2%;
  left: 0;
  position: absolute;
  width: 100%;
}

.speaker::before {
  top: 0;
}

.speaker::after {
  bottom: 0;
}

.speaker-left {
  left: 12.8%;
}

.speaker-right {
  right: 12.8%;
}

.button-pad {
  display: grid;
  gap: 5.6%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  height: 49.5%;
  left: 34.9%;
  position: absolute;
  top: 33.7%;
  width: 30.1%;
  z-index: 5;
}

.answer-button {
  border: clamp(2px, 0.42vw, 5px) solid rgba(43, 29, 16, 0.5);
  border-radius: 9%;
  box-shadow:
    inset 0 0.55vw 0.5vw rgba(255, 255, 255, 0.2),
    inset 0 -0.8vw 0.45vw rgba(29, 19, 9, 0.24),
    0 0.55vw 0 rgba(55, 38, 23, 0.34),
    0 0.75vw 0.8vw rgba(35, 22, 12, 0.17);
  color: rgba(32, 21, 12, 0.42);
  cursor: pointer;
  display: grid;
  grid-template-rows: 43% 57%;
  min-width: 0;
  padding: 0;
  text-transform: uppercase;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    filter 120ms ease;
}

.answer-button:active,
.answer-button.pressed {
  box-shadow:
    inset 0 0.3vw 0.55vw rgba(31, 20, 10, 0.28),
    0 0.14vw 0 rgba(55, 38, 23, 0.52);
  transform: translateY(0.42vw);
}

.answer-button:focus-visible,
.power-switch:focus-visible,
.video-toggle:focus-visible,
.small-actions button:focus-visible {
  outline: clamp(2px, 0.42vw, 4px) solid #fff;
  outline-offset: 0.25vw;
}

.button-top {
  border-bottom: clamp(1px, 0.24vw, 3px) solid rgba(33, 24, 14, 0.18);
  display: grid;
  font-size: clamp(1rem, 2.5vw, 2rem);
  font-weight: 950;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  line-height: 1;
  text-shadow:
    0 0.11vw 0 rgba(255, 255, 255, 0.14),
    0 -0.08vw 0 rgba(31, 20, 11, 0.18);
}

.button-top span {
  align-items: center;
  display: flex;
  justify-content: center;
}

.button-top span:first-child {
  border-right: clamp(1px, 0.24vw, 3px) solid rgba(33, 24, 14, 0.18);
}

.answer-button strong {
  align-items: center;
  display: flex;
  font-size: clamp(1rem, 2.25vw, 1.85rem);
  font-weight: 950;
  justify-content: center;
  letter-spacing: 0;
  line-height: 1;
  overflow-wrap: anywhere;
  text-shadow:
    0 0.12vw 0 rgba(255, 255, 255, 0.13),
    0 -0.08vw 0 rgba(31, 20, 11, 0.18);
}

.yellow {
  background: var(--yellow);
}

.blue {
  background: var(--blue);
  color: rgba(1, 54, 79, 0.58);
}

.green {
  background: var(--green);
  color: rgba(20, 53, 6, 0.58);
}

.red {
  background: var(--red);
  color: rgba(72, 13, 9, 0.58);
}

.power-switch {
  background: var(--orange);
  border: clamp(2px, 0.38vw, 4px) solid rgba(69, 44, 23, 0.42);
  border-radius: 7%;
  box-shadow:
    inset 0 0.45vw 0.25vw rgba(255, 255, 255, 0.27),
    inset 0 -0.55vw 0.25vw rgba(108, 42, 5, 0.23),
    0 0.45vw 0 rgba(73, 46, 25, 0.28);
  color: rgba(104, 40, 5, 0.72);
  cursor: pointer;
  font-size: clamp(0.7rem, 1.45vw, 1.15rem);
  font-weight: 950;
  height: 10.5%;
  left: 66.1%;
  line-height: 1;
  padding: 0;
  position: absolute;
  text-transform: uppercase;
  top: 50.8%;
  width: 6%;
  z-index: 6;
}

body.is-off .power-switch {
  box-shadow:
    inset 0 0.3vw 0.32vw rgba(74, 31, 8, 0.22),
    0 0.12vw 0 rgba(73, 46, 25, 0.38);
  filter: saturate(0.72) brightness(0.82);
  transform: translateY(0.35vw);
}

body.is-off .answer-button,
body.is-off .lesson-video,
body.is-off .worm {
  filter: grayscale(0.55) brightness(0.74);
}

.brand-badge {
  align-items: center;
  background: #df322b;
  border-radius: 11%;
  bottom: 12%;
  box-shadow:
    inset 0 0.2vw 0 rgba(255, 255, 255, 0.2),
    0 0.15vw 0 rgba(55, 35, 22, 0.28);
  color: #fff7e9;
  display: flex;
  font-size: clamp(0.75rem, 1.55vw, 1.3rem);
  font-weight: 950;
  height: 7.6%;
  justify-content: center;
  left: 8.8%;
  letter-spacing: 0;
  position: absolute;
  width: 7.2%;
}

.console-tools {
  align-items: center;
  background: rgba(255, 249, 232, 0.92);
  border: 3px solid rgba(60, 43, 28, 0.34);
  border-radius: 10px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  max-width: 900px;
  padding: 10px 12px;
  width: min(100%, 900px);
}

#prompt-text,
#voice-line {
  margin: 0;
}

#prompt-text {
  font-size: 1rem;
  font-weight: 950;
}

#voice-line {
  color: #6d4a2e;
  font-size: 0.9rem;
  font-weight: 800;
  margin-top: 2px;
}

.status-row,
.small-actions {
  display: flex;
  gap: 8px;
}

.status-row span,
.small-actions button {
  background: #efe3bf;
  border: 2px solid rgba(62, 43, 26, 0.36);
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 950;
  min-height: 38px;
  padding: 8px 10px;
}

.small-actions button {
  cursor: pointer;
}

@media (max-width: 760px) {
  .machine-shell {
    align-content: start;
    gap: 10px;
    padding: 10px;
  }

  .clamshell {
    width: 100%;
  }

  .screen-lid {
    width: 96%;
  }

  .screen-bezel,
  .console {
    transform: none;
  }

  .hinge {
    width: 86%;
  }

  .console-tools {
    grid-template-columns: 1fr;
  }

  .status-row,
  .small-actions {
    justify-content: stretch;
  }

  .status-row span,
  .small-actions button {
    flex: 1;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .machine-shell {
    gap: 8px;
    padding: 6px;
  }

  .screen-lid {
    width: 100%;
  }

  .screen-bezel {
    padding: 8px;
  }

  .hinge {
    height: 10px;
  }

  .button-top {
    font-size: clamp(0.75rem, 4.2vw, 1rem);
  }

  .answer-button strong {
    font-size: clamp(0.74rem, 4vw, 1rem);
  }
}
