html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5faf8;
}

#layout,
#stage,
.v3d-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.v3d-container canvas {
  touch-action: none;
}

.ui-hidden #lesson-ui {
  display: none;
}

.lesson-ui {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  color: #17324a;
}

.topbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.title-block,
.progress-pill,
.formula-strip,
.op-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(35, 64, 88, 0.12);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 22px rgba(40, 70, 90, 0.08);
}

.title-block {
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 228px;
}

.lesson-title {
  font-size: 22px;
  line-height: 1.2;
  font-weight: 900;
}

.step-text {
  margin-top: 3px;
  font-size: 16px;
  line-height: 1.35;
  color: #52687a;
}

.progress-pill {
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 20px;
  font-weight: 900;
  color: #14633e;
}

.formula-strip {
  position: absolute;
  left: 50%;
  top: 92px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
}

.formula-strip .arrow {
  color: #78909f;
}

#formula-result {
  padding-left: 8px;
  color: #c14953;
  opacity: 0.55;
}

.formula-strip.is-done #formula-result {
  opacity: 1;
}

.op-panel {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(860px, calc(100% - 28px));
  border-radius: 8px;
  padding: 10px;
  box-sizing: border-box;
  pointer-events: auto;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn,
.number-wrap input {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(23, 50, 74, 0.16);
  background: #fff;
  color: #17324a;
  font-size: 17px;
  font-weight: 850;
  padding: 0 18px;
  cursor: pointer;
  box-sizing: border-box;
}

.btn.primary {
  background: #e9f8ef;
  border-color: rgba(35, 153, 88, 0.32);
  color: #14633e;
}

.btn:disabled,
.number-wrap input:disabled {
  cursor: default;
  opacity: 0.55;
}

.number-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 16px;
  font-weight: 800;
  color: #52687a;
}

.number-wrap input {
  width: 84px;
  padding: 0 10px;
  text-align: center;
}

.hint-text {
  min-height: 24px;
  margin-top: 8px;
  text-align: center;
  font-size: 17px;
  line-height: 1.45;
  color: #385268;
}

.fullscreen-button {
  z-index: 10;
}

@media (max-width: 760px), (max-height: 620px) {
  .topbar {
    top: 8px;
    left: 8px;
    right: 52px;
  }

  .title-block {
    min-width: 0;
    padding: 8px 10px;
  }

  .lesson-title {
    font-size: 19px;
  }

  .step-text {
    font-size: 14px;
  }

  .progress-pill {
    padding: 8px 12px;
    font-size: 17px;
  }

  .formula-strip {
    top: 74px;
    max-width: calc(100% - 16px);
    overflow: hidden;
    gap: 7px;
    padding: 8px 10px;
    font-size: 15px;
  }

  .op-panel {
    bottom: 8px;
    width: calc(100% - 16px);
    padding: 8px;
  }

  .btn,
  .number-wrap input {
    min-height: 40px;
    font-size: 15px;
    padding: 0 10px;
  }

  .hint-text {
    font-size: 15px;
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: stretch;
    gap: 6px;
  }

  .lesson-title {
    font-size: 17px;
  }

  .step-text {
    font-size: 13px;
  }

  .progress-pill {
    display: flex;
    align-items: center;
    padding: 6px 9px;
    font-size: 15px;
  }

  .formula-strip {
    top: 68px;
    white-space: normal;
    flex-wrap: wrap;
    justify-content: center;
    line-height: 1.2;
    font-size: 13px;
  }

  .control-row {
    gap: 6px;
  }

  .btn,
  .number-wrap input {
    min-height: 36px;
    font-size: 14px;
    padding: 0 8px;
  }

  .number-wrap {
    min-height: 36px;
    font-size: 13px;
    gap: 5px;
  }

  .number-wrap input {
    width: 68px;
  }

  .hint-text {
    margin-top: 6px;
    font-size: 13px;
  }
}
