:root {
  --background: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #f1f5fb;
  --brand-cream: #fffde1;
  --brand-yellow: #fff1a8;
  --brand-purple: #6e56cf;
  --brand-purple-dark: #5842b8;
  --text: #23262b;
  --muted: #5f6b7a;
  --primary: #0b3a8a;
  --primary-light: #245cb1;
  --border: #d5deeb;
  --board: #174c3a;
  --board-frame: #8b623c;
  --wall: #e8e1d2;
  --floor-light: #d8c8a7;
  --floor-dark: #b9a27b;
  --tile-active: #ffd166;
  --tile-visited: #b9e3f4;
  --tile-zero: #d8f3dc;
  --shadow: 0 16px 36px rgba(11, 58, 138, 0.1);
  --brand-shadow: 0 7px 0 var(--primary);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  display: flow-root;
  margin: 0;
  min-height: 100vh;
  font-family:
    "Noto Sans Hebrew",
    "Montserrat",
    Arial,
    sans-serif;
  color: var(--text);
  background: var(--background);
  line-height: 1.6;
}

html[lang="en"] body {
  font-family:
    "Montserrat",
    "Manrope",
    Arial,
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
.fundamatics-home-link {
  font-family:
    "Manrope",
    "Noto Sans Hebrew",
    Arial,
    sans-serif;
}

#app {
  width: min(1200px, calc(100% - 32px));
  margin: 22px auto 36px;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
  padding: 16px 18px;
  border: 2px solid var(--primary);
  border-radius: 22px;
  background: var(--brand-cream);
  color: var(--text);
  box-shadow:
    var(--brand-shadow),
    var(--shadow);
}

.brand-product-lockup {
  display: flex;
  flex: 1 1 560px;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.fundamatics-brand {
  display: flex;
  width: min(230px, 42vw);
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 18px 7px;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  text-decoration: none;
}

.fundamatics-brand img {
  display: block;
  width: 100%;
  height: auto;
}

.brand-tagline {
  color: var(--brand-yellow);
  font-family: cursive;
  font-size: 0.92rem;
  font-style: italic;
  line-height: 1.15;
}

.brand-divider {
  color: var(--primary);
  font-family: "Montserrat", Arial, sans-serif;
  font-size: 2rem;
  font-weight: 600;
}

.product-identity {
  min-width: 0;
}

.app-header h1 {
  margin: 0 0 2px;
  color: var(--primary);
  font-family: "Montserrat", Arial, sans-serif;
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 800;
  line-height: 1.2;
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.language-option {
  width: auto;
  min-width: 0;
  min-height: 0;
  padding: 7px 11px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 0.88rem;
}

.language-option:hover:not(:disabled) {
  background: var(--surface-soft);
  color: var(--primary);
  transform: none;
}

.language-option.is-active,
.language-option.is-active:hover:not(:disabled) {
  background: var(--primary);
  color: white;
}

.fundamatics-home-link {
  flex: 0 0 auto;
  padding: 10px 18px;
  border: 2px solid var(--brand-purple);
  border-radius: 999px;
  color: var(--brand-purple-dark);
  font-weight: 700;
  text-decoration: none;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.fundamatics-home-link:hover {
  background: var(--brand-purple);
  color: white;
  transform: translateY(-2px);
}

.fundamatics-brand:focus-visible,
.fundamatics-home-link:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(110, 86, 207, 0.35);
  outline-offset: 3px;
}

main {
  width: 100%;
}

.controls {
  display: grid;
  grid-template-columns:
    minmax(96px, 1fr)
    minmax(70px, 0.55fr)
    minmax(96px, 1fr)
    minmax(118px, auto)
    minmax(76px, auto);
  grid-template-areas: "first operator second start reset";
  align-items: end;
  gap: 8px;
  padding: 0;
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  max-width: none;
}

.field-operator {
  grid-area: operator;
}

.field-first {
  grid-area: first;
}

.field-second {
  grid-area: second;
}

label {
  color: var(--primary);
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid #aebed2;
  border-radius: 14px;
  background: white;
  color: var(--text);
  font-size: 1.05rem;
}

input {
  direction: ltr;
  text-align: center;
}

select {
  text-align: center;
}

input:focus,
select:focus {
  border-color: var(--brand-purple);
}

button {
  min-height: 48px;
  padding: 10px 20px;
  border: 0;
  border-radius: 14px;
  background: var(--brand-purple);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--brand-purple-dark);
  transform: translateY(-2px);
}

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

.reset-button {
  background: #667085;
}

.reset-button:hover:not(:disabled) {
  background: #4b5565;
}

#startButton {
  grid-area: start;
}

#resetButton {
  grid-area: reset;
}

.message {
  text-align: center;
}

.board-controls label {
  overflow: hidden;
  color: #ffffff;
  font-size: clamp(0.8rem, 0.9vw, 0.92rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.42);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-controls input,
.board-controls select {
  min-height: 38px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  font-size: 1rem;
}

.board-controls button {
  min-height: 38px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.86rem;
  white-space: nowrap;
}

.board-message {
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 5px 10px;
  border: 1px dashed rgba(255, 255, 255, 0.42);
  border-radius: 7px;
  color: #f7fbf8;
  background: rgba(0, 0, 0, 0.12);
  font-size: clamp(0.78rem, 1.5vw, 0.95rem);
  font-weight: 600;
  line-height: 1.25;
}

.playback-controls {
  display: grid;
  grid-template-columns: auto repeat(4, 34px) minmax(120px, 1fr) auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  direction: ltr;
}

.playback-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  direction: rtl;
}

.playback-mode-option {
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 5px;
  background: transparent;
  color: #f7fbf8;
  font-size: 0.68rem;
  line-height: 1.1;
  white-space: nowrap;
}

.playback-mode-option:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  transform: none;
}

.playback-mode-option.is-active,
.playback-mode-option.is-active:hover:not(:disabled) {
  background: var(--brand-purple);
  color: white;
}

.playback-button {
  width: 34px;
  min-height: 30px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  font-size: 0.86rem;
  line-height: 1;
}

.playback-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.27);
}

.playback-primary {
  background: var(--brand-purple);
}

.playback-progress {
  width: 100%;
  min-height: 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  accent-color: #ffe89a;
  cursor: pointer;
}

.playback-counter {
  min-width: 42px;
  color: #f7fbf8;
  font-family: "Manrope", Arial, sans-serif;
  font-size: 0.72rem;
  direction: ltr;
}

.classroom {
  position: relative;
  display: grid;
  grid-template-rows: 285px minmax(260px, 1fr) 300px;
  min-height: 845px;
  overflow: hidden;
  border: 8px solid #786048;
  border-radius: 22px;
  background: var(--wall);
  box-shadow:
    inset 0 0 20px rgba(0, 0, 0, 0.18),
    var(--shadow);
}

.front-wall {
  position: relative;
  height: 285px;
  border-bottom: 8px solid #9f8c6e;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.15), transparent),
    var(--wall);
}

.board {
  position: absolute;
  top: 14px;
  left: 50%;
  width: min(900px, 74%);
  height: 260px;
  display: grid;
  grid-template-rows: auto auto auto minmax(32px, auto) auto;
  gap: 6px;
  padding: 9px 16px 10px;
  transform: translateX(-50%);
  border: 8px solid var(--board-frame);
  border-radius: 5px;
  color: white;
  background:
    radial-gradient(
      circle at 20% 30%,
      rgba(255, 255, 255, 0.04),
      transparent 35%
    ),
    var(--board);
  box-shadow: 0 7px 14px rgba(0, 0, 0, 0.28);
  text-align: center;
}

.board-title {
  font-size: 0.72rem;
  line-height: 1;
  opacity: 0.85;
}

.board-display {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.board-exercise {
  font-size: clamp(1.55rem, 3.2vw, 2.25rem);
  font-weight: 700;
  line-height: 1;
  direction: ltr;
}

.board-result {
  min-height: 24px;
  padding-inline-start: 12px;
  border-inline-start: 2px solid rgba(255, 232, 154, 0.55);
  color: #ffe89a;
  font-size: clamp(1rem, 2vw, 1.3rem);
  font-weight: 700;
  line-height: 1.2;
  direction: ltr;
}

.board-result:empty {
  display: none;
}

.window {
  position: absolute;
  top: 28px;
  inset-inline-end: 22px;
  width: 84px;
  height: 88px;
  border: 6px solid white;
  background:
    linear-gradient(
      90deg,
      transparent 46%,
      white 47%,
      white 53%,
      transparent 54%
    ),
    linear-gradient(
      transparent 46%,
      white 47%,
      white 53%,
      transparent 54%
    ),
    #a9d8ee;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.18);
}

.clock {
  position: absolute;
  top: 28px;
  inset-inline-start: 28px;
  width: 50px;
  height: 50px;
  border: 5px solid #344955;
  border-radius: 50%;
  background: white;
}

.clock::before,
.clock::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 3px;
  border-radius: 3px;
  background: #344955;
  transform-origin: bottom center;
}

.clock::before {
  height: 15px;
  transform: translateX(-50%) rotate(25deg);
}

.clock::after {
  height: 11px;
  transform: translateX(-50%) rotate(120deg);
}

.front-people {
  position: absolute;
  left: 50%;
  bottom: -100px;
  display: flex;
  align-items: flex-end;
  gap: 45px;
  transform: translateX(-50%);
  transform-style: preserve-3d;
  z-index: 20;
}

.person {
  position: relative;
  width: 58px;
  height: 112px;
}

.head {
  position: relative;
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border: 2px solid #263842;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #ffd3ae 0 22%, transparent 23%),
    linear-gradient(100deg, #d99b72 0%, #efbd94 48%, #ffd1aa 72%, #c88762 100%);
  box-shadow:
    inset -4px -2px 5px rgba(91, 50, 30, 0.24),
    1px 2px 2px rgba(38, 56, 66, 0.24);
}

.hair {
  position: absolute;
  top: -3px;
  left: 3px;
  width: 26px;
  height: 13px;
  border-radius: 16px 16px 4px 4px;
  background: #3f3028;
}

.body {
  position: relative;
  width: 42px;
  height: 53px;
  margin: -1px auto 0;
  border: 2px solid #263842;
  border-radius: 10px 10px 4px 4px;
  box-shadow:
    inset -5px 0 6px rgba(0, 0, 0, 0.2),
    inset 4px 0 4px rgba(255, 255, 255, 0.12),
    2px 3px 3px rgba(38, 56, 66, 0.24);
}

.teacher .body {
  background: linear-gradient(100deg, #34464e 0%, #526c78 48%, #607d8b 68%, #34464e 100%);
}

.active-student .body,
.moving-student .body {
  background: linear-gradient(100deg, #0e4f87 0%, #1976b9 48%, #2f91d1 68%, #0d477a 100%);
}

.legs {
  position: relative;
  width: 34px;
  height: 25px;
  margin: 0 auto;
}

.legs::before,
.legs::after {
  content: "";
  position: absolute;
  top: 0;
  width: 8px;
  height: 25px;
  border-radius: 0 0 5px 5px;
  background: #263842;
}

.legs::before {
  left: 5px;
}

.legs::after {
  right: 5px;
}

.person-label {
  position: absolute;
  left: 50%;
  bottom: -23px;
  width: 110px;
  transform: translateX(-50%);
  color: var(--text);
  text-align: center;
  font-size: 0.875rem;
  font-weight: 700;
}

.front-people .person {
  width: 41px;
  height: 78px;
}

.front-people .head {
  width: 24px;
  height: 24px;
}

.front-people .hair {
  top: -2px;
  left: 2px;
  width: 18px;
  height: 9px;
}

.front-people .body {
  width: 29px;
  height: 37px;
  border-radius: 7px 7px 3px 3px;
}

.front-people .legs {
  width: 24px;
  height: 18px;
}

.front-people .legs::before,
.front-people .legs::after {
  width: 6px;
  height: 18px;
}

.front-people .legs::before {
  left: 3px;
}

.front-people .legs::after {
  right: 3px;
}

.front-people .person-label {
  bottom: -18px;
  width: 90px;
  font-size: 0.75rem;
}

.speech-bubble {
  padding: 10px;
  border: 2px solid #344955;
  border-radius: 14px;
  background: white;
  color: var(--text);
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
}

.teacher-speech-bubble {
  position: absolute;
  right: auto;
  left: calc(100% + 15px);
  bottom: 16px;
  width: 235px;
  z-index: 40;
}

.teacher-speech-bubble::after {
  content: "";
  position: absolute;
  right: auto;
  left: -10px;
  top: 56%;
  width: 18px;
  height: 18px;
  border-left: 2px solid #344955;
  border-bottom: 2px solid #344955;
  background: white;
  transform: translateY(-50%) rotate(45deg);
}

.teacher-speech-bubble.is-flipped {
  right: calc(100% + 15px);
  left: auto;
}

.teacher-speech-bubble.is-flipped::after {
  right: -10px;
  left: auto;
  border-right: 2px solid #344955;
  border-left: 0;
  transform: translateY(-50%) rotate(-45deg);
}

.teacher-speech-bubble:empty {
  display: none;
}

.student-speech-bubble {
  position: absolute;
  top: 0;
  left: 0;
  width: min(250px, 30vw);
  z-index: 60;
  transform: translate(18px, -100%);
  transition:
    left 0.62s cubic-bezier(0.35, 0.05, 0.2, 1),
    top 0.62s cubic-bezier(0.35, 0.05, 0.2, 1),
    opacity 0.2s ease;
}

.student-speech-bubble[hidden] {
  display: none;
}

.student-speech-bubble::after {
  content: "";
  position: absolute;
  left: -10px;
  bottom: 13px;
  width: 18px;
  height: 18px;
  border-left: 2px solid #344955;
  border-bottom: 2px solid #344955;
  background: white;
  transform: rotate(45deg);
}

.student-speech-bubble[data-side="left"] {
  transform: translate(calc(-100% - 18px), -100%);
}

.student-speech-bubble[data-side="left"]::after {
  right: -10px;
  left: auto;
  border-right: 2px solid #344955;
  border-left: 0;
  transform: rotate(-45deg);
}

.floor {
  position: relative;
  min-height: 320px;
  padding-top: 14px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.17), rgba(255, 255, 255, 0.17)),
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 74px,
      rgba(90, 70, 40, 0.28) 75px,
      rgba(90, 70, 40, 0.28) 77px
    ),
    repeating-linear-gradient(
      90deg,
      var(--floor-light) 0,
      var(--floor-light) 88px,
      var(--floor-dark) 89px,
      var(--floor-dark) 92px
    );
}

.student-desks {
  position: absolute;
  top: auto;
  bottom: 16px;
  right: 25px;
  left: 25px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 20px;
  z-index: 3;
}

.desk-unit {
  position: relative;
  height: 74px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.seated-student {
  position: absolute;
  top: 0;
  width: 32px;
  height: 46px;
}

.seated-student .head {
  width: 19px;
  height: 19px;
}

.seated-student .hair {
  top: -2px;
  left: 2px;
  width: 18px;
  height: 9px;
}

.seated-student .body {
  width: 24px;
  height: 25px;
  background: #6c8ebf;
}

.desk {
  position: absolute;
  bottom: 2px;
  width: 70px;
  height: 29px;
  border: 2px solid #67482d;
  border-radius: 4px;
  background: #b47c49;
  box-shadow: 0 4px 0 #67482d;
}

.desk::before,
.desk::after {
  content: "";
  position: absolute;
  bottom: -15px;
  width: 5px;
  height: 15px;
  background: #67482d;
}

.desk::before {
  left: 8px;
}

.desk::after {
  right: 8px;
}

.number-line-area {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 18px;
  border-top: 4px solid #9f8c6e;
  border-bottom: 4px solid #9f8c6e;
  background:
    linear-gradient(rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.1)),
    var(--floor-light);
  z-index: 10;
  direction: ltr;
  scrollbar-width: none;
}

.number-line-area::-webkit-scrollbar {
  display: none;
}

.number-line {
  position: relative;
  display: flex;
  width: max-content;
  min-width: 100%;
  justify-content: center;
  padding-top: 92px;
  direction: ltr;
}

.tile {
  position: relative;
  flex: 1 0 36px;
  max-width: 54px;
  height: 54px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid #77664e;
  background: rgba(255, 255, 255, 0.9);
  font-size: 1rem;
  font-weight: 700;
  transition:
    background 0.3s ease,
    transform 0.3s ease;
}

.tile.zero {
  background: var(--tile-zero);
}

.tile.visited {
  background: var(--tile-visited);
}

.tile.active {
  background: var(--tile-active);
  transform: translateY(-5px);
}

.moving-student {
  position: absolute;
  bottom: 42px;
  left: 50%;
  width: 50px;
  height: 92px;
  opacity: 0;
  transform: translateX(-50%);
  transition:
    left 0.62s cubic-bezier(0.35, 0.05, 0.2, 1),
    opacity 0.4s ease;
  z-index: 20;
}

.student-pose {
  position: relative;
  width: 50px;
  height: 86px;
  transform-origin: center 82%;
  transition: transform 0.72s cubic-bezier(0.2, 0.8, 0.2, 1);
  animation: student-breathe 2.4s ease-in-out infinite;
}

.moving-student .head {
  width: 29px;
  height: 29px;
  transition: transform 0.25s ease;
}

.active-student .hair,
.moving-student .hair {
  z-index: 5;
}

.student-face {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.student-eye {
  position: absolute;
  top: 42%;
  width: 3px;
  height: 4px;
  border-radius: 50%;
  background: #15232b;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.student-eye-left {
  left: 25%;
}

.student-eye-right {
  right: 25%;
}

.student-nose {
  position: absolute;
  top: 49%;
  left: 50%;
  width: 4px;
  height: 6px;
  border-right: 1px solid #9c6044;
  border-bottom: 1px solid #9c6044;
  border-radius: 0 0 4px 0;
  transform: translateX(-50%);
}

.student-mouth {
  position: absolute;
  bottom: 16%;
  left: 50%;
  width: 8px;
  height: 4px;
  border-bottom: 2px solid #7d342f;
  border-radius: 0 0 8px 8px;
  transform: translateX(-50%);
}

.student-ear {
  position: absolute;
  top: 42%;
  width: 5px;
  height: 8px;
  border: 1px solid #9c6044;
  border-radius: 50%;
  background: #efbd94;
  z-index: 1;
}

.student-ear-left {
  left: -4px;
}

.student-ear-right {
  right: -4px;
}

.moving-student[data-facing="right"] .student-eye-left,
.moving-student[data-facing="right"] .student-ear-left,
.moving-student[data-facing="left"] .student-eye-right,
.moving-student[data-facing="left"] .student-ear-right {
  opacity: 0;
}

.moving-student[data-facing="right"] .student-face {
  transform: translateX(3px);
}

.moving-student[data-facing="right"] .student-eye-right {
  right: 10%;
}

.moving-student[data-facing="right"] .student-nose {
  top: 48%;
  right: -5px;
  left: auto;
  width: 7px;
  height: 6px;
  border: 1px solid #9c6044;
  border-left: 0;
  border-radius: 0 6px 6px 0;
  background: #efbd94;
  transform: none;
}

.moving-student[data-facing="right"] .student-mouth {
  right: 0;
  left: auto;
  width: 6px;
  transform: rotate(8deg);
}

.moving-student[data-facing="left"] .student-face {
  transform: translateX(-3px);
}

.moving-student[data-facing="left"] .student-eye-left {
  left: 10%;
}

.moving-student[data-facing="left"] .student-nose {
  top: 48%;
  left: -5px;
  width: 7px;
  height: 6px;
  border: 1px solid #9c6044;
  border-right: 0;
  border-radius: 6px 0 0 6px;
  background: #efbd94;
  transform: none;
}

.moving-student[data-facing="left"] .student-mouth {
  right: auto;
  left: 0;
  width: 6px;
  transform: rotate(-8deg);
}

.moving-student .hair {
  top: -2px;
  left: 2px;
  width: 23px;
  height: 11px;
}

.moving-student .body {
  width: 35px;
  height: 42px;
  overflow: visible;
  border-radius: 8px 8px 4px 4px;
}

.moving-student .body::before,
.moving-student .body::after {
  content: "";
  position: absolute;
  top: 5px;
  width: 7px;
  height: 31px;
  border: 2px solid #263842;
  border-radius: 7px;
  background: #efbd94;
  transform-origin: top center;
}

.moving-student .body::before {
  left: -8px;
}

.moving-student .body::after {
  right: -8px;
}

.moving-student .legs {
  width: 30px;
  height: 23px;
}

.moving-student .legs::before,
.moving-student .legs::after {
  width: 7px;
  height: 23px;
  transform-origin: top center;
}

.moving-student .legs::before {
  left: 4px;
}

.moving-student .legs::after {
  right: 4px;
}

.moving-student[data-facing="right"] .student-pose {
  transform: perspective(170px) rotateY(-52deg) scaleX(0.96);
  filter: drop-shadow(4px 3px 2px rgba(38, 56, 66, 0.28));
}

.moving-student[data-facing="left"] .student-pose {
  transform: perspective(170px) rotateY(52deg) scaleX(0.96);
  filter: drop-shadow(-4px 3px 2px rgba(38, 56, 66, 0.28));
}

.moving-student.is-turning .student-pose {
  animation: student-turn 0.72s ease-in-out;
}

.moving-student.is-arriving .student-pose {
  animation: student-arrive 0.75s ease-out;
}

.moving-student.is-walking .student-pose {
  animation: student-step 0.42s ease-in-out infinite;
}

.moving-student.is-walking .head {
  animation: head-step 0.42s ease-in-out infinite;
}

.moving-student.is-walking .legs::before {
  animation: leg-forward 0.42s ease-in-out infinite alternate;
}

.moving-student.is-walking .legs::after {
  animation: leg-back 0.42s ease-in-out infinite alternate;
}

.moving-student.is-walking .body::before {
  animation: arm-back 0.42s ease-in-out infinite alternate;
}

.moving-student.is-walking .body::after {
  animation: arm-forward 0.42s ease-in-out infinite alternate;
}

.moving-student.is-walking-backward .student-pose {
  filter: saturate(0.8) brightness(0.96);
}

.moving-student[data-facing="right"].is-walking-backward .student-pose {
  animation-name: student-step-backward-right;
  filter:
    saturate(0.8)
    brightness(0.96)
    drop-shadow(4px 3px 2px rgba(38, 56, 66, 0.28));
}

.moving-student[data-facing="left"].is-walking-backward .student-pose {
  animation-name: student-step-backward-left;
  filter:
    saturate(0.8)
    brightness(0.96)
    drop-shadow(-4px 3px 2px rgba(38, 56, 66, 0.28));
}

.moving-student.is-walking-backward .legs::before {
  animation-name: leg-back;
}

.moving-student.is-walking-backward .legs::after {
  animation-name: leg-forward;
}

.moving-student.is-walking-backward .body::before {
  animation-name: arm-forward;
}

.moving-student.is-walking-backward .body::after {
  animation-name: arm-back;
}

.moving-student.is-paused .student-pose,
.moving-student.is-paused .head,
.moving-student.is-paused .legs::before,
.moving-student.is-paused .legs::after,
.moving-student.is-paused .body::before,
.moving-student.is-paused .body::after {
  animation-play-state: paused;
}

@keyframes student-breathe {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -1px;
  }
}

@keyframes student-turn {
  0% {
    scale: 1 1;
  }
  45% {
    scale: 0.72 1.04;
  }
  70% {
    scale: 1.04 0.98;
  }
  100% {
    scale: 1 1;
  }
}

@keyframes student-arrive {
  0% {
    translate: 0 -12px;
    scale: 0.88;
    opacity: 0;
  }
  65% {
    translate: 0 2px;
    scale: 1.04;
    opacity: 1;
  }
  100% {
    translate: 0 0;
    scale: 1;
    opacity: 1;
  }
}

@keyframes student-step {
  0%,
  100% {
    translate: 0 0;
    rotate: -1deg;
  }
  50% {
    translate: 0 -6px;
    rotate: 1deg;
  }
}

@keyframes student-step-backward-right {
  0%,
  100% {
    translate: 0 0;
    rotate: 4deg;
  }
  50% {
    translate: 0 -3px;
    rotate: 7deg;
  }
}

@keyframes student-step-backward-left {
  0%,
  100% {
    translate: 0 0;
    rotate: -4deg;
  }
  50% {
    translate: 0 -3px;
    rotate: -7deg;
  }
}

@keyframes head-step {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(2px);
  }
}

@keyframes leg-forward {
  from {
    transform: rotate(18deg);
  }
  to {
    transform: rotate(-20deg);
  }
}

@keyframes leg-back {
  from {
    transform: rotate(-20deg);
  }
  to {
    transform: rotate(18deg);
  }
}

@keyframes arm-forward {
  from {
    transform: rotate(-16deg);
  }
  to {
    transform: rotate(18deg);
  }
}

@keyframes arm-back {
  from {
    transform: rotate(18deg);
  }
  to {
    transform: rotate(-16deg);
  }
}

@media (min-width: 901px) and (min-height: 700px) {
  #app {
    display: grid;
    min-height: 0;
    height: auto;
    margin: 10px auto;
    grid-template-rows: auto auto;
    gap: 12px;
  }

  .app-header {
    margin-bottom: 0;
    padding: 8px 12px;
    gap: 12px;
  }

  .brand-product-lockup {
    flex: 1 1 0;
    gap: 10px;
  }

  .fundamatics-brand {
    width: min(175px, 24vw);
    padding: 7px 14px 5px;
  }

  .product-identity {
    flex: 1 1 auto;
  }

  .app-header h1 {
    overflow: visible;
    font-size: clamp(0.95rem, 1.25vw, 1.25rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    text-overflow: clip;
    white-space: nowrap;
  }

  .app-header p {
    font-size: 0.82rem;
    line-height: 1.25;
    white-space: nowrap;
  }

  .header-actions {
    gap: 8px;
  }

  .language-option {
    padding: 6px 9px;
    font-size: 0.8rem;
  }

  .fundamatics-home-link {
    padding: 7px 12px;
    font-size: 0.82rem;
  }

  main {
    min-height: 0;
    height: auto;
    display: block;
  }

  .controls {
    display: grid;
    grid-template-columns:
      minmax(96px, 1fr)
      minmax(70px, 0.55fr)
      minmax(96px, 1fr)
      minmax(118px, auto)
      minmax(76px, auto);
    grid-template-rows: auto;
    grid-template-areas: "first operator second start reset";
    gap: 8px;
    margin: 0;
    padding: 0;
  }

  .field {
    width: 100%;
    max-width: none;
    min-width: 0;
    gap: 3px;
  }

  .field-first {
    grid-area: first;
  }

  .field-operator {
    grid-area: operator;
  }

  .field-second {
    grid-area: second;
  }

  .controls input,
  .controls select,
  .controls button {
    min-height: 38px;
  }

  #startButton {
    grid-area: start;
    padding-inline: 10px;
  }

  #resetButton {
    grid-area: reset;
    padding-inline: 10px;
  }

  .classroom {
    width: 100%;
    height: auto;
    min-height: 750px;
    grid-template-rows: 285px minmax(235px, 1fr) 230px;
  }

  .front-wall {
    height: auto;
    min-height: 0;
  }

  .floor {
    height: auto;
    min-height: 0;
  }

  .board {
    width: min(900px, 74%);
    height: 260px;
  }

  .board-exercise {
    margin-top: 0;
  }

  .front-people {
    gap: 34px;
  }

  .teacher-speech-bubble {
    bottom: 16px;
    width: 220px;
    padding: 8px;
    font-size: 0.85rem;
    line-height: 1.35;
  }

  .student-desks {
    top: auto;
    bottom: 8px;
    gap: 4px 18px;
  }

  .desk-unit {
    height: 70px;
  }

  .number-line-area {
    padding-block: 0;
  }

}

@media (min-width: 901px) and (max-width: 1120px) {
  .window {
    display: none;
  }

  .board {
    width: min(720px, 76%);
  }

}

@media (max-width: 900px) {
  .app-header {
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .classroom {
    min-height: 880px;
  }

  .board {
    width: min(760px, 86%);
  }

  .student-desks {
    grid-template-columns: repeat(3, 1fr);
  }

  .window {
    display: none;
  }
}

@media (max-width: 650px) {
  #app {
    width: min(100% - 20px, 1200px);
    margin-top: 12px;
  }

  .app-header {
    gap: 16px;
    padding: 15px;
    border-radius: 18px;
  }

  .brand-product-lockup {
    flex-basis: 100%;
    flex-wrap: wrap;
    gap: 10px;
  }

  .fundamatics-brand {
    width: min(210px, 70vw);
  }

  .brand-divider {
    display: none;
  }

  .product-identity {
    flex-basis: 100%;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .language-switcher {
    order: 1;
  }

  .fundamatics-home-link {
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  .classroom {
    grid-template-rows: 370px minmax(320px, 1fr) 510px;
    min-height: 1200px;
  }

  .front-wall {
    height: 370px;
  }

  .board {
    top: 14px;
    width: calc(100% - 24px);
    height: 330px;
    padding-inline: 10px;
  }

  .board-controls {
    grid-template-columns: minmax(80px, 1fr) 70px minmax(80px, 1fr);
    grid-template-rows: auto auto;
    grid-template-areas:
      "first operator second"
      "start start reset";
    gap: 6px;
  }

  .board-controls button {
    min-height: 34px;
  }

  .board-display {
    min-height: 36px;
  }

  .board-message {
    font-size: 0.75rem;
  }

  .playback-controls {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto auto auto;
  }

  .playback-mode-switch {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .playback-button {
    width: 100%;
  }

  .playback-progress {
    grid-column: 1 / 4;
  }

  .playback-counter {
    grid-column: 4;
  }

  .front-people {
    gap: 22px;
  }

  .teacher-speech-bubble {
    right: auto;
    left: calc(100% + 10px);
    bottom: 12px;
    width: 170px;
    font-size: 0.82rem;
  }

  .student-speech-bubble {
    width: min(210px, calc(100vw - 46px));
    font-size: 0.82rem;
  }

  .student-desks {
    grid-template-columns: repeat(2, 1fr);
  }

  .number-line-area {
    padding-block: 0;
  }
}

@media (max-width: 390px) {
  .header-actions {
    align-items: stretch;
  }

  .language-switcher,
  .fundamatics-home-link {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .language-option {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  button,
  .fundamatics-home-link,
  .tile,
  .moving-student,
  .student-pose {
    transition: none;
  }

  .moving-student,
  .moving-student .student-pose,
  .moving-student .head,
  .moving-student .legs::before,
  .moving-student .legs::after,
  .moving-student .body::before,
  .moving-student .body::after {
    animation: none;
  }

  button:hover:not(:disabled),
  .fundamatics-home-link:hover {
    transform: none;
  }
}
